Enable focus events through configuration by using focus (option) and on-ui-enter/on-ui-exit events.
This commit is contained in:
6 files changed
+93
-9
No files matched your search
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user