diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2024-01-07 17:44:49 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2024-01-07 17:46:21 +0900 |
commit | 250496c953f8e36cb70ca99d58034bd79a1d0670 (patch) | |
tree | f4cb2223052921cbb78c01f6fe4f645d0c8e9c21 /src | |
parent | e47dc758c90fc151ef86dc5f189fdea19383d962 (diff) |
Add 'result' event that is triggered when the result list is ready
Close #3560
Diffstat (limited to 'src')
-rw-r--r-- | src/options.go | 2 | ||||
-rw-r--r-- | src/terminal.go | 10 | ||||
-rw-r--r-- | src/tui/tui.go | 1 |
3 files changed, 11 insertions, 2 deletions
diff --git a/src/options.go b/src/options.go index e18bdd1b..2962f4bb 100644 --- a/src/options.go +++ b/src/options.go @@ -650,6 +650,8 @@ func parseKeyChordsImpl(str string, message string, exit func(string)) map[tui.E add(tui.Load) case "focus": add(tui.Focus) + case "result": + add(tui.Result) case "one": add(tui.One) case "zero": diff --git a/src/terminal.go b/src/terminal.go index 295886dd..67f5cedf 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -251,6 +251,7 @@ type Terminal struct { borderWidth int count int progress int + hasResultActions bool hasFocusActions bool hasLoadActions bool triggerLoad bool @@ -731,6 +732,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal { ellipsis: opts.Ellipsis, ansi: opts.Ansi, tabstop: opts.Tabstop, + hasResultActions: false, hasFocusActions: false, hasLoadActions: false, triggerLoad: false, @@ -759,7 +761,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal { killChan: make(chan int), serverInputChan: make(chan []*action, 10), serverOutputChan: make(chan string), - eventChan: make(chan tui.Event, 4), // (load + zero|one) | (focus) | (GetChar) + eventChan: make(chan tui.Event, 5), // (load + result + zero|one) | (focus) | (GetChar) tui: renderer, initFunc: func() { renderer.Init() }, executing: util.NewAtomicBool(false), @@ -803,6 +805,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal { } } + _, t.hasResultActions = t.keymap[tui.Result.AsEvent()] _, t.hasFocusActions = t.keymap[tui.Focus.AsEvent()] _, t.hasLoadActions = t.keymap[tui.Load.AsEvent()] @@ -1076,6 +1079,9 @@ func (t *Terminal) UpdateList(merger *Merger) { t.eventChan <- one } } + if t.hasResultActions { + t.eventChan <- tui.Result.AsEvent() + } } t.mutex.Unlock() t.reqBox.Set(reqInfo, nil) @@ -3189,7 +3195,7 @@ func (t *Terminal) Loop() { } select { case event = <-t.eventChan: - needBarrier = !event.Is(tui.Load, tui.Focus, tui.One, tui.Zero) + needBarrier = !event.Is(tui.Load, tui.Result, tui.Focus, tui.One, tui.Zero) case serverActions := <-t.serverInputChan: event = tui.Invalid.AsEvent() if t.listenAddr == nil || t.listenAddr.IsLocal() || t.listenUnsafe { diff --git a/src/tui/tui.go b/src/tui/tui.go index 5a5e18d6..74129c16 100644 --- a/src/tui/tui.go +++ b/src/tui/tui.go @@ -105,6 +105,7 @@ const ( Focus One Zero + Result AltBS |