summary refs log tree commit diff stats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/account.go10
-rw-r--r--widgets/aerc.go14
-rw-r--r--widgets/directories.go37
3 files changed, 54 insertions, 7 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 3848bbf..dc339cb 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -75,7 +75,7 @@ func NewAccountView(conf *config.AccountConfig,
 		for {
 			msg := <-worker.Messages
 			msg = worker.ProcessMessage(msg)
-			// TODO: dispatch to appropriate handlers
+			acct.onMessage(msg)
 		}
 	}()
 
@@ -164,3 +164,11 @@ func (acct *AccountView) connected(msg types.WorkerMessage) {
 			Color(tcell.ColorRed, tcell.ColorDefault)
 	}
 }
+
+func (acct *AccountView) Directories() *DirectoryList {
+	return acct.dirlist
+}
+
+func (acct *AccountView) onMessage(msg types.WorkerMessage) {
+	// TODO
+}
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 26dc5f2..bf545f9 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -1,7 +1,6 @@
 package widgets
 
 import (
-	"fmt"
 	"log"
 
 	"github.com/gdamore/tcell"
@@ -13,11 +12,14 @@ import (
 
 type Aerc struct {
 	accounts map[string]*AccountView
+	cmd      func(cmd string) error
 	grid     *libui.Grid
 	tabs     *libui.Tabs
 }
 
-func NewAerc(conf *config.AercConfig, logger *log.Logger) *Aerc {
+func NewAerc(conf *config.AercConfig, logger *log.Logger,
+	cmd func(cmd string) error) *Aerc {
+
 	tabs := libui.NewTabs()
 
 	mainGrid := libui.NewGrid().Rows([]libui.GridSpec{
@@ -37,12 +39,13 @@ func NewAerc(conf *config.AercConfig, logger *log.Logger) *Aerc {
 
 	aerc := &Aerc{
 		accounts: make(map[string]*AccountView),
+		cmd:      cmd,
 		grid:     mainGrid,
 		tabs:     tabs,
 	}
 
 	for _, acct := range conf.Accounts {
-		view := NewAccountView(&acct, logger, aerc.RunCommand)
+		view := NewAccountView(&acct, logger, cmd)
 		aerc.accounts[acct.Name] = view
 		tabs.Add(view, acct.Name)
 	}
@@ -73,7 +76,6 @@ func (aerc *Aerc) Event(event tcell.Event) bool {
 	return acct.Event(event)
 }
 
-func (aerc *Aerc) RunCommand(cmd string) error {
-	// TODO
-	return fmt.Errorf("TODO: execute '%s'", cmd)
+func (aerc *Aerc) SelectedAccount() *AccountView {
+	return aerc.accounts[aerc.tabs.Tabs[aerc.tabs.Selected].Name]
 }
diff --git a/widgets/directories.go b/widgets/directories.go
index 11fe2d6..ae31d29 100644
--- a/widgets/directories.go
+++ b/widgets/directories.go
@@ -103,3 +103,40 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
 		row++
 	}
 }
+
+func (dirlist *DirectoryList) nextPrev(delta int) {
+	for i, dir := range dirlist.dirs {
+		if dir == dirlist.selected {
+			var j int
+			ndirs := len(dirlist.dirs)
+			for j = i + delta; j != i; j += delta {
+				if j < 0 {
+					j = ndirs - 1
+				}
+				if j >= ndirs {
+					j = 0
+				}
+				name := dirlist.dirs[j]
+				if len(dirlist.conf.Folders) > 1 && name != dirlist.selected {
+					idx := sort.SearchStrings(dirlist.conf.Folders, name)
+					if idx == len(dirlist.conf.Folders) ||
+						dirlist.conf.Folders[idx] != name {
+
+						continue
+					}
+				}
+				break
+			}
+			dirlist.Select(dirlist.dirs[j])
+			break
+		}
+	}
+}
+
+func (dirlist *DirectoryList) Next() {
+	dirlist.nextPrev(1)
+}
+
+func (dirlist *DirectoryList) Prev() {
+	dirlist.nextPrev(-1)
+}
html?h=hlt&id=c5ffb6e1cc9c5ff880d037c53b8ebc8562be0008'>c5ffb6e1 ^
c842d90b ^
76755b28 ^
c842d90b ^
76755b28 ^

c5ffb6e1 ^
c842d90b ^
c5ffb6e1 ^
83fcebf3 ^
c5ffb6e1 ^







76755b28 ^

4690ce81 ^
76755b28 ^

c5ffb6e1 ^
4690ce81 ^
c5ffb6e1 ^


beea7ce2 ^



c5ffb6e1 ^


a654e4ec ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69



                                                                                          
                                

                                                
                                  

                                                                                         

                       
                                                                                                 
                                                                                            

                                      
                            
                              
                               
                                                                           

        





                               

       
                         
                                                                                      
                                           
                                                                                 
                                                                                                                                                                                                                    
                                                                                
                                                                              

                                                                       
                                                                                         
                                                                              
                                                                                             
                                                                                      







                                                                                                                                                                                                                            

                                                                                                                                                                                                                                                      
                                                                                               

                                                                       
                                                                                         
                                                                                               


                                                                                                                                               



                                                                                                     


       
                                     
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - 067random.cc</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="cpp">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="minimal">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; }
body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; }
* { font-size: 12pt; font-size: 1em; }
.Constant { color: #00a0a0; }
.Comment { color: #9090ff; }
.Delimiter { color: #800080; }
.Identifier { color: #c0a020; }
.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
REAL_RANDOM<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;real-random&quot;</span><span class="Delimiter">,</span> REAL_RANDOM<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> REAL_RANDOM: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> REAL_RANDOM: <span class="Delimiter">{</span>
  <span class="Comment">// todo: limited range of numbers, might be imperfectly random</span>
  <span class="Comment">// todo: thread state in extra ingredients and products</span>
  products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span>
  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>rand<span class="Delimiter">());</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
MAKE_RANDOM_NONDETERMINISTIC<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;make-random-nondeterministic&quot;</span><span class="Delimiter">,</span> MAKE_RANDOM_NONDETERMINISTIC<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> MAKE_RANDOM_NONDETERMINISTIC: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> MAKE_RANDOM_NONDETERMINISTIC: <span class="Delimiter">{</span>
  srand<span class="Delimiter">(</span>time<span class="Delimiter">(</span><span class="Constant">NULL</span><span class="Delimiter">));</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Comment">// undo non-determinism in later tests</span>
<span class="Delimiter">:(before &quot;End Setup&quot;)</span>
srand<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->