use Key if it's a rune, otherwise KeyReadable

This commit is contained in:
Dawid Dziurla 2018-09-01 13:06:53 +02:00
parent 7ec5b6cc30
commit 265d7e121a
No known key found for this signature in database
GPG key ID: 7B6D8368172E9B0B

View file

@ -54,8 +54,17 @@ func (gui *Gui) handleHelp(g *gocui.Gui, v *gocui.View) error {
bindings := gui.getKeybindings()
for _, binding := range bindings {
if binding.ViewName == v.Name() && binding.Description != "" && binding.KeyReadable != "" {
content += fmt.Sprintf(" %s - %s\n", binding.KeyReadable, binding.Description)
r, ok := binding.Key.(rune)
key := ""
if ok {
key = string(r)
} else if binding.KeyReadable != "" {
key = binding.KeyReadable
}
if key != "" && binding.ViewName == v.Name() && binding.Description != "" {
content += fmt.Sprintf(" %s - %s\n", key, binding.Description)
keys = append(keys, binding)
}
}