Enable focus events through configuration by using focus (option) and on-ui-enter/on-ui-exit events.

This commit is contained in:
Christian Zangl committed 2023-09-21 21:39:05 +02:00
1 parent c8163439f5
commit 77f113639f
6 files changed
+93 -9

No files matched your search

+21 -6
View File
@@ -1449,17 +1449,32 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
return nil
}
func readCmdEvent(ev tcell.Event) expr {
func (ui *ui) readCmdEvent(ev tcell.Event) expr {
switch tev := ev.(type) {
case *tcell.EventKey:
if tev.Key() == tcell.KeyRune {
if tev.Modifiers() == tcell.ModMask(tcell.ModAlt) {
val := string([]rune{'<', 'a', '-', tev.Rune(), '>'})
if expr, ok := gOpts.cmdkeys[val]; ok {
return expr
// support multi-key bindings but only for ESC[ at the moment
if tev.Rune() == '[' {
ui.keyAcc = append(ui.keyAcc, '<', 'a', '-', tev.Rune(), '>')
} else {
val := string([]rune{'<', 'a', '-', tev.Rune(), '>'})
if expr, ok := gOpts.cmdkeys[val]; ok {
return expr
}
}
} else {
return &callExpr{"cmd-insert", []string{string(tev.Rune())}, 1}
// multi-key bindings
if ui.keyAcc != nil {
ui.keyAcc = append(ui.keyAcc, tev.Rune())
val := string(ui.keyAcc)
ui.keyAcc = nil
if expr, ok := gOpts.cmdkeys[val]; ok {
return expr
}
} else {
return &callExpr{"cmd-insert", []string{string(tev.Rune())}, 1}
}
}
} else {
val := gKeyVal[tev.Key()]
@@ -1478,7 +1493,7 @@ func (ui *ui) readEvent(ev tcell.Event, nav *nav) expr {
}
if _, ok := ev.(*tcell.EventKey); ok && ui.cmdPrefix != "" {
return readCmdEvent(ev)
return ui.readCmdEvent(ev)
}
return ui.readNormalEvent(ev, nav)