blob: bca0cf60febdcebda376b4df2676535265ccfc51 (
plain) (
blame)
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
|
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
}
|