From e09bcd027259f6c222a3c715230a54a6e27ecda7 Mon Sep 17 00:00:00 2001 From: Bradley Cicenas Date: Sun, 1 Jan 2017 22:48:35 +0000 Subject: [PATCH] move ui.Init() into main, allow any key to exit help dialog --- grid.go | 4 ---- main.go | 8 ++++++-- views/help.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/grid.go b/grid.go index f547b45..c14d77b 100644 --- a/grid.go +++ b/grid.go @@ -91,10 +91,6 @@ func OpenView(v View) { func Display(g *Grid) bool { var newView View - if err := ui.Init(); err != nil { - panic(err) - } - defer ui.Close() // calculate layout ui.Body.Align() g.Cursor() diff --git a/main.go b/main.go index 82f59f5..5311264 100644 --- a/main.go +++ b/main.go @@ -1,15 +1,19 @@ package main import ( - "os" + ui "github.com/gizak/termui" ) func main() { + if err := ui.Init(); err != nil { + panic(err) + } + defer ui.Close() g := NewGrid() for { exit := Display(g) if exit { - os.Exit(0) + return } } } diff --git a/views/help.go b/views/help.go index d56df9a..233c592 100644 --- a/views/help.go +++ b/views/help.go @@ -19,7 +19,7 @@ func Help() { p.BorderLabel = "Help" p.BorderFg = ui.ColorCyan ui.Render(p) - ui.Handle("/sys/kbd/q", func(ui.Event) { + ui.Handle("/sys/kbd/", func(ui.Event) { ui.StopLoop() }) ui.Loop()