From 661e3ec2a4dd97d4a8a8eab4f281b088770a6af2 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 26 Feb 2018 22:41:54 -0500 Subject: Implement basic ex line input TODO: - scrolling - commit/cancel - command history (via an external command history provider) - tab completion (via an external tab completion provider) --- ui/ui.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ui/ui.go') diff --git a/ui/ui.go b/ui/ui.go index d1d2ca3..9ea037c 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -11,6 +11,8 @@ type UI struct { Content Drawable ctx *Context + interactive []Interactive + tbEvents chan tb.Event invalidations chan interface{} } @@ -58,6 +60,11 @@ 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) + } + } case <-state.invalidations: state.Content.Draw(state.ctx) tb.Flush() @@ -66,3 +73,7 @@ func (state *UI) Tick() bool { } return true } + +func (state *UI) AddInteractive(i Interactive) { + state.interactive = append(state.interactive, i) +} -- cgit 1.4.1-2-gfad0