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

+15 -3
View File
@@ -300,6 +300,8 @@ func (app *app) loop() {
}()
}
onUiEnter(app)
for {
select {
case <-app.quitChan:
@@ -322,6 +324,7 @@ func (app *app) loop() {
cmd.eval(app, nil)
}
onUiExit(app)
app.quit()
app.nav.previewChan <- ""
@@ -461,12 +464,14 @@ func (app *app) loop() {
app.ui.draw(app.nav)
}
}
}
func (app *app) runCmdSync(cmd *exec.Cmd, pause_after bool) {
app.nav.previewChan <- ""
app.nav.dirPreviewChan <- nil
onUiExit(app)
if err := app.ui.suspend(); err != nil {
log.Printf("suspend: %s", err)
}
@@ -475,6 +480,7 @@ func (app *app) runCmdSync(cmd *exec.Cmd, pause_after bool) {
app.quit()
os.Exit(3)
}
onUiEnter(app)
}()
if err := cmd.Run(); err != nil {
@@ -495,6 +501,7 @@ func (app *app) runCmdSync(cmd *exec.Cmd, pause_after bool) {
// % No No Yes Yes Yes Statline for input/output
// ! Yes No Yes Yes Yes Pause and then resume
// & No Yes No No No Do nothing
// ^ No No Yes Yes Yes (internal for events)
func (app *app) runShell(s string, args []string, prefix string) {
app.nav.exportFiles()
app.ui.exportSizes()
@@ -513,12 +520,17 @@ func (app *app) runShell(s string, args []string, prefix string) {
var out io.Reader
var err error
switch prefix {
case "$", "!":
case "$", "!", "^":
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stderr
cmd.Stderr = os.Stderr
app.runCmdSync(cmd, prefix == "!")
if prefix != "^" {
app.runCmdSync(cmd, prefix == "!")
} else {
if err := cmd.Run(); err != nil {
app.ui.echoerrf("running ^shell: %s", err)
}
}
return
}