summary refs log tree commit diff stats
path: root/lib/ui/ui.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-02-27 21:17:26 -0500
committerDrew DeVault <sir@cmpwn.com>2018-02-27 21:17:26 -0500
commitcab3771e17286788913255a6abe858b476166837 (patch)
tree85c626c779e380bb6a9d7ddd6cba69ef33cf919d /lib/ui/ui.go
parenta073d7613fac7c79b7909d93a0dd7bfea05d5c9d (diff)
downloadaerc-cab3771e17286788913255a6abe858b476166837.tar.gz
Pull main aerc UI into widget
Diffstat (limited to 'lib/ui/ui.go')
-rw-r--r--lib/ui/ui.go19
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/ui/ui.go b/lib/ui/ui.go
index 9ea037c..e9b4e9b 100644
--- a/lib/ui/ui.go
+++ b/lib/ui/ui.go
@@ -8,16 +8,16 @@ import (
 
 type UI struct {
 	Exit    bool
-	Content Drawable
+	Content DrawableInteractive
 	ctx     *Context
 
-	interactive []Interactive
-
 	tbEvents      chan tb.Event
 	invalidations chan interface{}
 }
 
-func Initialize(conf *config.AercConfig, content Drawable) (*UI, error) {
+func Initialize(conf *config.AercConfig,
+	content DrawableInteractive) (*UI, error) {
+
 	if err := tb.Init(); err != nil {
 		return nil, err
 	}
@@ -52,6 +52,7 @@ func (state *UI) Tick() bool {
 	case event := <-state.tbEvents:
 		switch event.Type {
 		case tb.EventKey:
+			// TODO: temporary
 			if event.Key == tb.KeyEsc {
 				state.Exit = true
 			}
@@ -60,11 +61,7 @@ func (state *UI) Tick() bool {
 			state.ctx = NewContext(event.Width, event.Height)
 			state.Content.Invalidate()
 		}
-		if state.interactive != nil {
-			for _, i := range state.interactive {
-				i.Event(event)
-			}
-		}
+		state.Content.Event(event)
 	case <-state.invalidations:
 		state.Content.Draw(state.ctx)
 		tb.Flush()
@@ -73,7 +70,3 @@ func (state *UI) Tick() bool {
 	}
 	return true
 }
-
-func (state *UI) AddInteractive(i Interactive) {
-	state.interactive = append(state.interactive, i)
-}