aboutsummaryrefslogtreecommitdiffstats
path: root/ui/render.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-01-10 22:03:56 -0500
committerDrew DeVault <sir@cmpwn.com>2018-01-10 22:03:56 -0500
commitdb1b2cd53f5dc7bfbfb6ee54ad0bb0882ea2cc03 (patch)
tree97c17d675dc2b38cf2acb6473f545de2c0d42979 /ui/render.go
parenta0be5e80256b98237241b2f3d7825484e7a9c964 (diff)
downloadaerc-db1b2cd53f5dc7bfbfb6ee54ad0bb0882ea2cc03.tar.gz
Renderer scaffolding
Diffstat (limited to 'ui/render.go')
-rw-r--r--ui/render.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/ui/render.go b/ui/render.go
new file mode 100644
index 00000000..bca0cf60
--- /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
+}