Indicate correct help binding in status line

This commit is contained in:
Zachary Yedidia
2016-05-28 13:58:42 -04:00
parent a08f457cd0
commit 87d147cf92
2 changed files with 10 additions and 3 deletions

View File

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

View File

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