From 6c0ca4a64a4e2f8697dfa830dcae56c1d7ddca51 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 30 Jan 2025 00:50:46 +0900 Subject: 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}' --- src/options.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/options.go') diff --git a/src/options.go b/src/options.go index cc627ee1..fec9596c 100644 --- a/src/options.go +++ b/src/options.go @@ -127,6 +127,7 @@ Usage: fzf [options] (default: 0 or center) INPUT SECTION + --no-input Disable and hide the input section --prompt=STR Input prompt (default: '> ') --info=STYLE Finder info style [default|right|hidden|inline[-right][:PREFIX]] @@ -538,6 +539,7 @@ type Options struct { Scheme string Extended bool Phony bool + Inputless bool Case Case Normalize bool Nth []Range @@ -659,6 +661,7 @@ func defaultOptions() *Options { Scheme: "", // Unknown Extended: true, Phony: false, + Inputless: false, Case: CaseSmart, Normalize: true, Nth: make([]Range, 0), @@ -2315,6 +2318,8 @@ func parseOptions(index *int, opts *Options, allArgs []string) error { opts.Phony = false case "--disabled", "--phony": opts.Phony = true + case "--no-input": + opts.Inputless = true case "--tiebreak": str, err := nextString("sort criterion required") if err != nil { @@ -3064,6 +3069,9 @@ func noSeparatorLine(style infoStyle, separator bool) bool { } func (opts *Options) noSeparatorLine() bool { + if opts.Inputless { + return true + } sep := opts.Separator == nil && !opts.InputBorderShape.Visible() || opts.Separator != nil && len(*opts.Separator) > 0 return noSeparatorLine(opts.InfoStyle, sep) } @@ -3235,7 +3243,13 @@ func postProcessOptions(opts *Options) error { // Sets --min-height automatically if opts.Height.size > 0 && opts.Height.percent && opts.MinHeight < 0 { - opts.MinHeight = -opts.MinHeight + 1 + borderLines(opts.BorderShape) + borderLines(opts.ListBorderShape) + borderLines(opts.InputBorderShape) + opts.MinHeight = -opts.MinHeight + borderLines(opts.BorderShape) + borderLines(opts.ListBorderShape) + if !opts.Inputless { + opts.MinHeight += 1 + borderLines(opts.InputBorderShape) + if !opts.noSeparatorLine() { + opts.MinHeight++ + } + } if len(opts.Header) > 0 { opts.MinHeight += borderLines(opts.HeaderBorderShape) + len(opts.Header) } @@ -3246,9 +3260,6 @@ func postProcessOptions(opts *Options) error { } opts.MinHeight += borderLines(borderShape) + opts.HeaderLines } - if !opts.noSeparatorLine() { - opts.MinHeight++ - } if len(opts.Preview.command) > 0 && (opts.Preview.position == posUp || opts.Preview.position == posDown) && opts.Preview.Visible() && opts.Preview.position == posUp { borderShape := opts.Preview.border if opts.Preview.border == tui.BorderLine { -- cgit v1.2.3