From 1b76ab85316b5f09fd953ced51b63a0ca16375e4 Mon Sep 17 00:00:00 2001 From: abyxcos Date: Tue, 8 Sep 2020 23:24:23 -0400 Subject: [PATCH] Use a multi-line string for the help message. --- hatemail.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/hatemail.go b/hatemail.go index 9bc2683..5de388e 100644 --- a/hatemail.go +++ b/hatemail.go @@ -18,6 +18,24 @@ var ( emailBody *tview.TextView ) +func helpMessage() string { + return `Keys: + Global: + q - quit + ? - this help message + + Lists: + j/k - up/down one message + g/G - top/bottom of list + h/l - change panes + o - open an email + + Email: + esc - close an email +` + +} + func eventHandler(ev *tcell.EventKey) *tcell.EventKey { // Some global keys that function in every context // Just stop if we find a CtrlC @@ -65,7 +83,7 @@ func eventHandler(ev *tcell.EventKey) *tcell.EventKey { } case "help": switch { - case ev.Key() == tcell.KeyEsc: + case ev.Key() == tcell.KeyEsc || ev.Rune() == '?' || ev.Rune() == 'q': pages.HidePage("help") } } @@ -125,7 +143,7 @@ func main() { SetColumns(0). SetBorders(true) helpText := tview.NewTextView(). - SetText("q - quit\nj/k - up and down list\nh/l - change active list\no - open message\nesc - close message\n? - this help page") + SetText(helpMessage()) help.AddItem(helpText, 0, 0, 1, 1, 0, 0, true) // Piece the app together -- 2.45.2