diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2025-01-30 00:50:46 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-30 00:50:46 +0900 |
| commit | 6c0ca4a64a4e2f8697dfa830dcae56c1d7ddca51 (patch) | |
| tree | b3cb6eefec8009c815d0ce0a4bea3032f8bc0cf8 /src/tui | |
| parent | 6b5d4614114f1a7a34a50c21ed2952f94a5ee81e (diff) | |
| download | fzf-6c0ca4a64a4e2f8697dfa830dcae56c1d7ddca51.tar.gz | |
Add --no-input to hide the input section (#4210)
Close #2890
Close #1396
You can't type in queries in this mode, and the only way to trigger an
fzf search is to use `search(...)` action.
# Click header to trigger search
fzf --header '[src] [test]' --no-input --layout reverse \
--header-border bottom --input-border \
--bind 'click-header:transform-search:echo ${FZF_CLICK_HEADER_WORD:1:-1}'
Diffstat (limited to 'src/tui')
| -rw-r--r-- | src/tui/dummy.go | 1 | ||||
| -rw-r--r-- | src/tui/light.go | 19 | ||||
| -rw-r--r-- | src/tui/tcell.go | 15 | ||||
| -rw-r--r-- | src/tui/tui.go | 5 |
4 files changed, 35 insertions, 5 deletions
diff --git a/src/tui/dummy.go b/src/tui/dummy.go index 1cfb292e..8dd58457 100644 --- a/src/tui/dummy.go +++ b/src/tui/dummy.go @@ -45,6 +45,7 @@ func (r *FullscreenRenderer) Clear() {} func (r *FullscreenRenderer) NeedScrollbarRedraw() bool { return false } func (r *FullscreenRenderer) ShouldEmitResizeEvent() bool { return false } func (r *FullscreenRenderer) Bell() {} +func (r *FullscreenRenderer) HideCursor() {} func (r *FullscreenRenderer) Refresh() {} func (r *FullscreenRenderer) Close() {} func (r *FullscreenRenderer) Size() TermSize { return TermSize{} } diff --git a/src/tui/light.go b/src/tui/light.go index 54c38c18..7b40efbb 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -77,7 +77,13 @@ func (r *LightRenderer) csi(code string) string { func (r *LightRenderer) flush() { if r.queued.Len() > 0 { - r.flushRaw("\x1b[?7l\x1b[?25l" + r.queued.String() + "\x1b[?25h\x1b[?7h") + raw := "\x1b[?7l\x1b[?25l" + r.queued.String() + if r.showCursor { + raw += "\x1b[?25h\x1b[?7h" + } else { + raw += "\x1b[?7h" + } + r.flushRaw(raw) r.queued.Reset() } } @@ -110,6 +116,7 @@ type LightRenderer struct { y int x int maxHeightFunc func(int) int + showCursor bool // Windows only ttyinChannel chan byte @@ -152,7 +159,8 @@ func NewLightRenderer(ttyin *os.File, theme *ColorTheme, forceBlack bool, mouse tabstop: tabstop, fullscreen: fullscreen, upOneLine: false, - maxHeightFunc: maxHeightFunc} + maxHeightFunc: maxHeightFunc, + showCursor: true} return &r, nil } @@ -759,6 +767,9 @@ func (r *LightRenderer) Close() { } else if !r.fullscreen { r.csi("u") } + if !r.showCursor { + r.csi("?25h") + } r.disableMouse() r.flush() r.closePlatform() @@ -1214,3 +1225,7 @@ func (w *LightWindow) Erase() { func (w *LightWindow) EraseMaybe() bool { return false } + +func (r *LightRenderer) HideCursor() { + r.showCursor = false +} diff --git a/src/tui/tcell.go b/src/tui/tcell.go index 3738214a..9d6fde80 100644 --- a/src/tui/tcell.go +++ b/src/tui/tcell.go @@ -52,6 +52,7 @@ type TcellWindow struct { borderStyle BorderStyle uri *string params *string + showCursor bool } func (w *TcellWindow) Top() int { @@ -72,7 +73,9 @@ func (w *TcellWindow) Height() int { func (w *TcellWindow) Refresh() { if w.moveCursor { - _screen.ShowCursor(w.left+w.lastX, w.top+w.lastY) + if w.showCursor { + _screen.ShowCursor(w.left+w.lastX, w.top+w.lastY) + } w.moveCursor = false } w.lastX = 0 @@ -104,6 +107,10 @@ func (r *FullscreenRenderer) Bell() { _screen.Beep() } +func (r *FullscreenRenderer) HideCursor() { + r.showCursor = false +} + func (r *FullscreenRenderer) PassThrough(str string) { // No-op // https://github.com/gdamore/tcell/pull/650#issuecomment-1806442846 @@ -168,6 +175,9 @@ func (r *FullscreenRenderer) getScreen() (tcell.Screen, error) { if e != nil { return nil, e } + if !r.showCursor { + s.HideCursor() + } _screen = s } return _screen, nil @@ -590,7 +600,8 @@ func (r *FullscreenRenderer) NewWindow(top int, left int, width int, height int, width: width, height: height, normal: normal, - borderStyle: borderStyle} + borderStyle: borderStyle, + showCursor: r.showCursor} w.Erase() return w } diff --git a/src/tui/tui.go b/src/tui/tui.go index fe8fc243..0c778ad6 100644 --- a/src/tui/tui.go +++ b/src/tui/tui.go @@ -615,6 +615,7 @@ type Renderer interface { NeedScrollbarRedraw() bool ShouldEmitResizeEvent() bool Bell() + HideCursor() GetChar() Event @@ -662,6 +663,7 @@ type FullscreenRenderer struct { forceBlack bool prevDownTime time.Time clicks [][2]int + showCursor bool } func NewFullscreenRenderer(theme *ColorTheme, forceBlack bool, mouse bool) Renderer { @@ -670,7 +672,8 @@ func NewFullscreenRenderer(theme *ColorTheme, forceBlack bool, mouse bool) Rende mouse: mouse, forceBlack: forceBlack, prevDownTime: time.Unix(0, 0), - clicks: [][2]int{}} + clicks: [][2]int{}, + showCursor: true} return r } |
