move ui.Init() into main, allow any key to exit help dialog

This commit is contained in:
Bradley Cicenas 2017-01-01 22:48:35 +00:00
parent 6e87539b9d
commit e09bcd0272
3 changed files with 7 additions and 7 deletions

View File

@ -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()

View File

@ -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
}
}
}

View File

@ -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()