diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2024-09-12 18:22:07 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2024-09-12 18:31:14 +0900 |
| commit | 952276dc2dcdd5401be804b4417d0cb392e2eda8 (patch) | |
| tree | 6ed067738c9d4c78213a7548a4d282315e6785e1 | |
| parent | 2286edb3296a5d50f048bf950163ef4c3a0651fa (diff) | |
| download | fzf-952276dc2dcdd5401be804b4417d0cb392e2eda8.tar.gz | |
Add 'noinfo' option to hide scroll offset information in preview window
fzf --preview 'seq 1000' --preview-window noinfo
Close #2525
| -rw-r--r-- | man/man1/fzf.1 | 7 | ||||
| -rw-r--r-- | src/options.go | 11 | ||||
| -rw-r--r-- | src/terminal.go | 2 | ||||
| -rwxr-xr-x | test/test_go.rb | 9 |
4 files changed, 23 insertions, 6 deletions
diff --git a/man/man1/fzf.1 b/man/man1/fzf.1 index b605b59b..321327ab 100644 --- a/man/man1/fzf.1 +++ b/man/man1/fzf.1 @@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. .. -.TH fzf 1 "Aug 2024" "fzf 0.55.0" "fzf - a command-line fuzzy finder" +.TH fzf 1 "Sep 2024" "fzf 0.56.0" "fzf - a command-line fuzzy finder" .SH NAME fzf - a command-line fuzzy finder @@ -756,7 +756,7 @@ default value 0 (or \fBcenter\fR) will put the label at the center of the border line. .TP -.BI "\-\-preview\-window=" "[POSITION][,SIZE[%]][,border\-BORDER_OPT][,[no]wrap][,[no]follow][,[no]cycle][,[no]hidden][,+SCROLL[OFFSETS][/DENOM]][,~HEADER_LINES][,default][,<SIZE_THRESHOLD(ALTERNATIVE_LAYOUT)]" +.BI "\-\-preview\-window=" "[POSITION][,SIZE[%]][,border\-BORDER_OPT][,[no]wrap][,[no]follow][,[no]cycle][,[no]info][,[no]hidden][,+SCROLL[OFFSETS][/DENOM]][,~HEADER_LINES][,default][,<SIZE_THRESHOLD(ALTERNATIVE_LAYOUT)]" .RS .B POSITION: (default: right) @@ -790,6 +790,9 @@ e.g. * Cyclic scrolling is enabled with \fBcycle\fR flag. +* To hide the scroll offset information on the top right corner, specify +\fBnoinfo\fR. + * To change the style of the border of the preview window, specify one of the options for \fB\-\-border\fR with \fBborder\-\fR prefix. e.g. \fBborder\-rounded\fR (border with rounded edges, default), diff --git a/src/options.go b/src/options.go index 55030bd2..67e70a70 100644 --- a/src/options.go +++ b/src/options.go @@ -120,8 +120,8 @@ Usage: fzf [options] --preview=COMMAND Command to preview highlighted line ({}) --preview-window=OPT Preview window layout (default: right:50%) [up|down|left|right][,SIZE[%]] - [,[no]wrap][,[no]cycle][,[no]follow][,[no]hidden] - [,border-BORDER_OPT] + [,[no]wrap][,[no]cycle][,[no]follow][,[no]info] + [,[no]hidden][,border-BORDER_OPT] [,+SCROLL[OFFSETS][/DENOM]][,~HEADER_LINES] [,default][,<SIZE_THRESHOLD(ALTERNATIVE_LAYOUT)] --preview-label=LABEL @@ -271,6 +271,7 @@ type previewOpts struct { wrap bool cycle bool follow bool + info bool border tui.BorderShape headerLines int threshold int @@ -508,7 +509,7 @@ func filterNonEmpty(input []string) []string { } func defaultPreviewOpts(command string) previewOpts { - return previewOpts{command, posRight, sizeSpec{50, true}, "", false, false, false, false, tui.DefaultBorderShape, 0, 0, nil} + return previewOpts{command, posRight, sizeSpec{50, true}, "", false, false, false, false, true, tui.DefaultBorderShape, 0, 0, nil} } func defaultOptions() *Options { @@ -1789,6 +1790,10 @@ func parsePreviewWindowImpl(opts *previewOpts, input string) error { opts.follow = true case "nofollow": opts.follow = false + case "info": + opts.info = true + case "noinfo": + opts.info = false default: if headerRegex.MatchString(token) { if opts.headerLines, err = atoi(token[1:]); err != nil { diff --git a/src/terminal.go b/src/terminal.go index 1158de7a..535f5e3a 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -2507,7 +2507,7 @@ func (t *Terminal) renderPreviewSpinner() { spin := t.previewer.spinner if len(spin) > 0 || t.previewer.scrollable { maxWidth := t.pwindow.Width() - if !t.previewer.scrollable { + if !t.previewer.scrollable || !t.previewOpts.info { if maxWidth > 0 { t.pwindow.Move(0, maxWidth-1) t.pwindow.CPrint(tui.ColPreviewSpinner, spin) diff --git a/test/test_go.rb b/test/test_go.rb index ac294d62..1860ac1a 100755 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -3378,6 +3378,15 @@ class TestGoFZF < TestBase assert_equal expected, result end end + + def test_preview_window_noinfo + # │ 1 ││ + tmux.send_keys %(#{FZF} --preview 'seq 1000' --preview-window top,noinfo --scrollbar), :Enter + tmux.until do |lines| + assert lines[1]&.start_with?('│ 1') + assert lines[1]&.end_with?(' ││') + end + end end module TestShell |
