summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cmd/aerc/main.go12
-rw-r--r--ui/render.go45
-rw-r--r--ui/types.go47
-rw-r--r--worker/imap/worker.go2
4 files changed, 100 insertions, 6 deletions
diff --git a/cmd/aerc/main.go b/cmd/aerc/main.go
index 9188dce..4adf11e 100644
--- a/cmd/aerc/main.go
+++ b/cmd/aerc/main.go
@@ -1,10 +1,10 @@
 package main
 
 import (
-	"fmt"
 	"time"
 
 	"git.sr.ht/~sircmpwn/aerc2/config"
+	"git.sr.ht/~sircmpwn/aerc2/ui"
 	"git.sr.ht/~sircmpwn/aerc2/worker"
 	"git.sr.ht/~sircmpwn/aerc2/worker/types"
 )
@@ -20,19 +20,23 @@ func main() {
 		if err != nil {
 			panic(err)
 		}
-		fmt.Printf("Initializing worker %s\n", account.Name)
 		go work.Run()
 		work.PostAction(types.Configure{Config: account})
 		workers = append(workers, work)
 	}
-	for {
+	_ui, err := ui.Initialize(conf)
+	if err != nil {
+		panic(err)
+	}
+	defer _ui.Close()
+	for !_ui.Exit {
 		activity := false
 		for _, worker := range workers {
 			if msg := worker.GetMessage(); msg != nil {
 				activity = true
-				fmt.Printf("<- %T\n", msg)
 			}
 		}
+		activity = _ui.Tick() || activity
 		if !activity {
 			time.Sleep(100 * time.Millisecond)
 		}
diff --git a/ui/render.go b/ui/render.go
new file mode 100644
index 0000000..bca0cf6
--- /dev/null
+++ b/ui/render.go
@@ -0,0 +1,45 @@
+package ui
+
+import (
+	tb "github.com/nsf/termbox-go"
+
+	"git.sr.ht/~sircmpwn/aerc2/config"
+)
+
+func Initialize(conf *config.AercConfig) (*UIState, error) {
+	state := UIState{
+		InvalidPanes: InvalidateAll,
+		Tabs:         make([]AercTab, len(conf.Accounts)),
+	}
+	// TODO: Initialize each tab to a mailbox tab
+	if err := tb.Init(); err != nil {
+		return nil, err
+	}
+	tb.SetInputMode(tb.InputEsc | tb.InputMouse)
+	tb.SetOutputMode(tb.Output256)
+	return &state, nil
+}
+
+func (state *UIState) Close() {
+	tb.Close()
+}
+
+func (state *UIState) Invalidate(what uint) {
+	state.InvalidPanes |= what
+}
+
+func (state *UIState) Tick() bool {
+	switch e := tb.PollEvent(); e.Type {
+	case tb.EventKey:
+		if e.Key == tb.KeyEsc {
+			state.Exit = true
+		}
+	case tb.EventResize:
+		state.Invalidate(InvalidateAll)
+	}
+	if state.InvalidPanes != 0 {
+		// TODO: re-render
+		state.InvalidPanes = 0
+	}
+	return true
+}
diff --git a/ui/types.go b/ui/types.go
new file mode 100644
index 0000000..a7918b5
--- /dev/null
+++ b/ui/types.go
@@ -0,0 +1,47 @@
+package ui
+
+const (
+	Valid          = 0
+	InvalidateTabs = 1 << iota
+	InvalidateSidebar
+	InvalidateStatusBar
+)
+
+const (
+	InvalidateAll = InvalidateTabs | InvalidateSidebar | InvalidateStatusBar
+)
+
+type Geometry struct {
+	row    int
+	col    int
+	width  int
+	height int
+}
+
+type AercTab interface {
+	Name() string
+	Invalid() bool
+	Render(at Geometry)
+}
+
+type UIState struct {
+	Exit         bool
+	InvalidPanes uint
+
+	Panes struct {
+		TabList   Geometry
+		TabView   Geometry
+		Sidebar   Geometry
+		StatusBar Geometry
+	}
+
+	Tabs        []AercTab
+	SelectedTab int
+
+	Prompt struct {
+		Prompt *string
+		Text   *string
+		Index  int
+		Scroll int
+	}
+}
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index 6ffdf3a..14e4004 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -1,7 +1,6 @@
 package imap
 
 import (
-	"fmt"
 	"time"
 
 	"git.sr.ht/~sircmpwn/aerc2/worker/types"
@@ -50,7 +49,6 @@ func (w *IMAPWorker) Run() {
 	for {
 		select {
 		case msg := <-w.actions:
-			fmt.Printf("<= %T\n", msg)
 			w.handleMessage(msg)
 		default:
 			time.Sleep(100 * time.Millisecond)
/akspecs/aerc/blame/commands/msg/reply.go?h=0.5.1&id=c6b776adbfb11ba34756a1d4f770b15c2fb3cb46'>^
2a09617 ^
475b697 ^

6838c23 ^
3ba69ed ^
8be59ca ^


f5a4d93 ^
3ba69ed ^
475b697 ^
8be59ca ^


3ba69ed ^
8be59ca ^






3ba69ed ^

8be59ca ^

475b697 ^
753adb9 ^

3ba69ed ^
753adb9 ^


ce0d0e8 ^

753adb9 ^
8bb115d ^


217e85a ^



475b697 ^




c610c3c ^
475b697 ^
38e7165 ^


475b697 ^
38e7165 ^
475b697 ^
38e7165 ^
c610c3c ^
38e7165 ^
c610c3c ^
38e7165 ^
c610c3c ^
38e7165 ^
475b697 ^
8f2e505 ^







38e7165 ^

8f2e505 ^



c610c3c ^
38e7165 ^

c610c3c ^
bcab8de ^
38e7165 ^

c610c3c ^
ce0d0e8 ^
ce0d0e8 ^
475b697 ^

7f97e0b ^
282dc44 ^
217e885 ^
7f97e0b ^
217e885 ^
7f97e0b ^
475b697 ^
67fb093 ^





bf28e23 ^
67fb093 ^
3ba69ed ^

bf28e23 ^
8f1c6c4 ^
3ba69ed ^
38e7165 ^
7f03327 ^
bf28e23 ^
3ba69ed ^
caad1b2 ^
3ba69ed ^





475b697 ^
8be59ca ^
67fb093 ^
8be59ca ^






3ba69ed ^
b1eb7ad ^



3ba69ed ^
8be59ca ^
475b697 ^
217e885 ^
3ba69ed ^

217e885 ^

c574a83 ^
cff4476 ^
c574a83 ^



cff4476 ^

3ba69ed ^
9096049 ^
bf28e23 ^
d238272 ^










8be59ca ^

3ba69ed ^
8be59ca ^
3ba69ed ^
8be59ca ^
475b697 ^
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201