Skip to content

Commit

Permalink
Make ctrl+h configurable as a string
Browse files Browse the repository at this point in the history
The actual key input ctrl+h can be set with the string "ctrl+h".
Fix for noborus/ov#410.
  • Loading branch information
noborus committed Sep 7, 2023
1 parent 91bcd66 commit d58db6e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,17 @@ func (c *Configuration) Capture(ev *tcell.EventKey) *tcell.EventKey {
return nil
}

key := ev.Key()
mod := ev.Modifiers()

var keyName string
if ev.Key() != tcell.KeyRune {
keyName = fmt.Sprintf("%d-%d", ev.Modifiers(), ev.Key())
if key == tcell.KeyRune {
keyName = fmt.Sprintf("%d:%d", mod, ev.Rune())
} else {
keyName = fmt.Sprintf("%d:%d", ev.Modifiers(), ev.Rune())
if key == tcell.KeyBackspace || key == tcell.KeyTab || key == tcell.KeyEnter {
mod ^= tcell.ModCtrl
}
keyName = fmt.Sprintf("%d-%d", mod, key)
}

handler := c.handlers[keyName]
Expand Down

0 comments on commit d58db6e

Please sign in to comment.