aboutsummaryrefslogtreecommitdiffstats
path: root/app/aerc.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2024-01-28 00:52:22 +0100
committerRobin Jarry <robin@jarry.cc>2024-02-11 21:24:04 +0100
commitc618ac9a02fc207f72a8f004785c622c72ac5e9a (patch)
tree061e2cce4643575bdef1fb3c87b07ad59e019a6c /app/aerc.go
parent64502d9e8b0458456f255e65f392950463d68bac (diff)
downloadaerc-c618ac9a02fc207f72a8f004785c622c72ac5e9a.tar.gz
app: add keybinds annotation when printing bindings
Add annotations in square brackets in app.HumanReadableBindings() which translates the keyinds to strings for the ':help keys' command. Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Reviewed-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'app/aerc.go')
-rw-r--r--app/aerc.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/app/aerc.go b/app/aerc.go
index ee383f86..261e1af7 100644
--- a/app/aerc.go
+++ b/app/aerc.go
@@ -204,11 +204,18 @@ func (aerc *Aerc) HumanReadableBindings() []string {
format := func(s string) string {
return strings.ReplaceAll(s, "%", "%%")
}
- fmtStr := "%10s %s"
+ annotate := func(b *config.Binding) string {
+ if b.Annotation == "" {
+ return ""
+ }
+ return "[" + b.Annotation + "]"
+ }
+ fmtStr := "%10s %s %s"
for _, bind := range binds.Bindings {
result = append(result, fmt.Sprintf(fmtStr,
format(config.FormatKeyStrokes(bind.Input)),
format(config.FormatKeyStrokes(bind.Output)),
+ annotate(bind),
))
}
if binds.Globals && config.Binds.Global != nil {
@@ -216,16 +223,17 @@ func (aerc *Aerc) HumanReadableBindings() []string {
result = append(result, fmt.Sprintf(fmtStr+" (Globals)",
format(config.FormatKeyStrokes(bind.Input)),
format(config.FormatKeyStrokes(bind.Output)),
+ annotate(bind),
))
}
}
result = append(result, fmt.Sprintf(fmtStr,
"$ex",
- fmt.Sprintf("'%c'", binds.ExKey.Rune),
+ fmt.Sprintf("'%c'", binds.ExKey.Rune), "",
))
result = append(result, fmt.Sprintf(fmtStr,
"Globals",
- fmt.Sprintf("%v", binds.Globals),
+ fmt.Sprintf("%v", binds.Globals), "",
))
sort.Strings(result)
return result