diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-10-03 12:49:53 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-10-03 21:08:23 +0200 |
commit | 1c2dd4c9f15ddc9cba0849c4077525bd6d64cd6a (patch) | |
tree | cadb2323193b517b5d9ff21c332d572a21ee87f0 /widgets/aerc.go | |
parent | 150aa0f498b9780a40fdab815552c4c4230b5178 (diff) | |
download | aerc-1c2dd4c9f15ddc9cba0849c4077525bd6d64cd6a.tar.gz |
bindings: properly check for exKey keystrokes
When checking for an exKey, aerc inspects the key and the rune of the
event vs the exkey binding. Runes should only be inspected if the key is
a tcell.KeyRune. Some Ctrl-[:alpha:] keys report a rune in tcell, but
aerc does not have these bound to the keystroke definition. Only <C-x>
has a rune bound, and is one of the very few <C-> keys that can actually
be bound to exKey
Only compare the Rune field if the key is of type KeyRune. Otherwise,
compare the Key. Also compare any modifiers with the keystroke/key
event. These changes allow for any control or alt key combination to be
bound to the exkey.
Update documentaiton to reflect that the default keybind is ':', and not
<semicolon>
Fixes: https://todo.sr.ht/~rjarry/aerc/67
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/aerc.go')
-rw-r--r-- | widgets/aerc.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go index 7209b2d8..bdd18dd5 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -339,7 +339,7 @@ func (aerc *Aerc) Event(event tcell.Event) bool { // Keybindings still use : even if you change the ex key exKey = aerc.conf.Bindings.Global.ExKey } - if event.Key() == exKey.Key && event.Rune() == exKey.Rune { + if aerc.isExKey(event, exKey) { aerc.BeginExCommand("") return true } @@ -850,3 +850,11 @@ func errorScreen(s string, conf config.UIConfig) ui.Drawable { grid.AddChild(ui.NewFill(' ', tcell.StyleDefault)).At(2, 0) return grid } + +func (aerc *Aerc) isExKey(event *tcell.EventKey, exKey config.KeyStroke) bool { + if event.Key() == tcell.KeyRune { + // Compare runes if it's a KeyRune + return event.Modifiers() == exKey.Modifiers && event.Rune() == exKey.Rune + } + return event.Modifiers() == exKey.Modifiers && event.Key() == exKey.Key +} |