summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/options.go2
-rw-r--r--src/terminal.go16
-rw-r--r--src/tui/tui.go1
3 files changed, 17 insertions, 2 deletions
diff --git a/src/options.go b/src/options.go
index fa238d7e..393f5804 100644
--- a/src/options.go
+++ b/src/options.go
@@ -609,6 +609,8 @@ func parseKeyChordsImpl(str string, message string, exit func(string)) map[tui.E
add(tui.Start)
case "load":
add(tui.Load)
+ case "focus":
+ add(tui.Focus)
case "alt-enter", "alt-return":
chords[tui.CtrlAltKey('m')] = key
case "alt-space":
diff --git a/src/terminal.go b/src/terminal.go
index a9565c86..62e80431 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -1265,7 +1265,7 @@ func (t *Terminal) resizeWindows(forcePreview bool) {
}
func (t *Terminal) printLabel(window tui.Window, render labelPrinter, opts labelOpts, length int, borderShape tui.BorderShape, redrawBorder bool) {
- if window == nil || render == nil {
+ if window == nil {
return
}
@@ -1274,6 +1274,9 @@ func (t *Terminal) printLabel(window tui.Window, render labelPrinter, opts label
if redrawBorder {
window.DrawHBorder()
}
+ if render == nil {
+ return
+ }
var col int
if opts.column == 0 {
col = util.Max(0, (window.Width()-length)/2)
@@ -2616,6 +2619,11 @@ func (t *Terminal) Loop() {
}
}
+ var onFocus []*action
+ if actions, prs := t.keymap[tui.Focus.AsEvent()]; prs {
+ onFocus = actions
+ }
+
go func() {
var focusedIndex int32 = minItem.Index()
var version int64 = -1
@@ -2651,7 +2659,11 @@ func (t *Terminal) Loop() {
if currentItem != nil {
currentIndex = currentItem.Index()
}
- if focusedIndex != currentIndex || version != t.version {
+ focusChanged := focusedIndex != currentIndex
+ if onFocus != nil && focusChanged {
+ t.serverChan <- onFocus
+ }
+ if focusChanged || version != t.version {
version = t.version
focusedIndex = currentIndex
refreshPreview(t.previewOpts.command)
diff --git a/src/tui/tui.go b/src/tui/tui.go
index 203da76c..a51627fd 100644
--- a/src/tui/tui.go
+++ b/src/tui/tui.go
@@ -92,6 +92,7 @@ const (
BackwardEOF
Start
Load
+ Focus
AltBS