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

+19
View File
@@ -1157,6 +1157,22 @@ func onSelect(app *app) {
}
}
func onUiEnter(app *app) {
if cmd, ok := gOpts.cmds["on-ui-enter"]; ok {
ecmd := cmd.(*execExpr)
ecmd.prefix = "^"
ecmd.eval(app, nil)
}
}
func onUiExit(app *app) {
if cmd, ok := gOpts.cmds["on-ui-exit"]; ok {
ecmd := cmd.(*execExpr)
ecmd.prefix = "^"
ecmd.eval(app, nil)
}
}
func splitKeys(s string) (keys []string) {
for i := 0; i < len(s); {
r, w := utf8.DecodeRuneInString(s[i:])
@@ -2764,6 +2780,9 @@ func (e *execExpr) eval(app *app, args []string) {
case "&":
log.Printf("shell-async: %s -- %s", e, args)
app.runShell(e.value, args, e.prefix)
case "^":
log.Printf("shell-sync-evt: %s -- %s", e, args)
app.runShell(e.value, args, e.prefix)
default:
log.Printf("evaluating unknown execution prefix: %q", e.prefix)
}