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>
This commit is contained in:
parent
150aa0f498
commit
1c2dd4c9f1
2 changed files with 10 additions and 2 deletions
|
@ -819,7 +819,7 @@ each binding context:
|
|||
This can be set to a keystroke which will bring up the command input in this
|
||||
context.
|
||||
|
||||
Default: <semicolon>
|
||||
Default: ':'
|
||||
|
||||
In addition to letters, special keys may be specified in <angle brackets>. The
|
||||
following special keys are supported:
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue