From 87d147cf9269435afebed54933d5204c6f89863e Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Sat, 28 May 2016 13:58:42 -0400 Subject: [PATCH] Indicate correct help binding in status line --- cmd/micro/bindings.go | 9 ++++++++- cmd/micro/statusline.go | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmd/micro/bindings.go b/cmd/micro/bindings.go index be2f97da..ed866420 100644 --- a/cmd/micro/bindings.go +++ b/cmd/micro/bindings.go @@ -14,6 +14,7 @@ import ( ) var bindings map[Key]func(*View) bool +var helpBinding string // The Key struct holds the data for a keypress (keycode + modifiers) type Key struct { @@ -251,14 +252,20 @@ func InitBindings() { } else { bindings[keys[k]] = actions[v] } + if v == "ToggleHelp" { + helpBinding = k + } } for k, v := range parsed { if strings.Contains(k, "Alt-") { - key := Key{tcell.KeyRune, tcell.ModAlt, rune(k[len(k)])} + key := Key{tcell.KeyRune, tcell.ModAlt, rune(k[len(k)-1])} bindings[key] = actions[v] } else { bindings[keys[k]] = actions[v] } + if v == "ToggleHelp" { + helpBinding = k + } } } diff --git a/cmd/micro/statusline.go b/cmd/micro/statusline.go index c08c147a..32f1d230 100644 --- a/cmd/micro/statusline.go +++ b/cmd/micro/statusline.go @@ -40,9 +40,9 @@ func (sline *Statusline) Display() { // Add the filetype file += " " + sline.view.Buf.FileType - rightText := "Ctrl-g for help " + rightText := helpBinding + " for help " if sline.view.helpOpen { - rightText = "Ctrl-g to close help " + rightText = helpBinding + " to close help " } statusLineStyle := defStyle.Reverse(true)