From 0453b712f5d20ebec52903a297093ef6d514a59c Mon Sep 17 00:00:00 2001 From: Edouard Paris Date: Mon, 29 Apr 2019 13:33:06 +0200 Subject: [PATCH] controller: add keybindings --- ui/controller.go | 10 ++++++++++ ui/views/help.go | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ui/controller.go b/ui/controller.go index ee6776d..519de62 100644 --- a/ui/controller.go +++ b/ui/controller.go @@ -214,6 +214,11 @@ func (c *controller) setKeyBinding(g *gocui.Gui) error { return err } + err = g.SetKeybinding("", 'q', gocui.ModNone, quit) + if err != nil { + return err + } + err = g.SetKeybinding("", gocui.KeyArrowUp, gocui.ModNone, c.cursorUp) if err != nil { return err @@ -244,6 +249,11 @@ func (c *controller) setKeyBinding(g *gocui.Gui) error { return err } + err = g.SetKeybinding("", 'h', gocui.ModNone, c.Help) + if err != nil { + return err + } + return nil } diff --git a/ui/views/help.go b/ui/views/help.go index 3a3a9d9..9f0f36c 100644 --- a/ui/views/help.go +++ b/ui/views/help.go @@ -54,8 +54,10 @@ func (h Help) Set(g *gocui.Gui, x0, y0, x1, y1 int) error { fmt.Fprintln(h.view, fmt.Sprintf("lntop %s - (C) 2019 Edouard Paris", version)) fmt.Fprintln(h.view, "Released under the MIT License") fmt.Fprintln(h.view, "") - fmt.Fprintln(h.view, fmt.Sprintf("%5s %s", - color.Cyan("F1 h:"), "show this help screen")) + fmt.Fprintln(h.view, fmt.Sprintf("%6s %s", + color.Cyan("F1 h:"), "show/close this help screen")) + fmt.Fprintln(h.view, fmt.Sprintf("%6s %s", + color.Cyan("F10 q:"), "quit")) _, err = g.SetCurrentView(HELP) return err }