diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2022-10-30 16:28:58 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2022-11-01 13:27:11 +0900 |
| commit | b9ca1fe830d4f25ca0169f76a7faea10b5fa3de4 (patch) | |
| tree | 1501e81b0e4d5e48878d1a94eef3b21774358156 /src/options.go | |
| parent | e61585f2f37c6b1ead971f448af8db26dff1502c (diff) | |
| download | fzf-b9ca1fe830d4f25ca0169f76a7faea10b5fa3de4.tar.gz | |
Add horizontal separator after info panel (counter)
Close #3029
Diffstat (limited to 'src/options.go')
| -rw-r--r-- | src/options.go | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/src/options.go b/src/options.go index 80ca3e11..36fd2055 100644 --- a/src/options.go +++ b/src/options.go @@ -69,7 +69,7 @@ const usage = `usage: fzf [options] NEGATIVE_INTEGER: columns from right] (default: 0) --margin=MARGIN Screen margin (TRBL | TB,RL | T,RL,B | T,R,B,L) --padding=PADDING Padding inside border (TRBL | TB,RL | T,RL,B | T,R,B,L) - --info=STYLE Finder info style [default|inline|hidden] + --info=STYLE Finder info style [default|inline|hidden[:nosep]] --prompt=STR Input prompt (default: '> ') --pointer=STR Pointer to the current line (default: '>') --marker=STR Multi-select marker (default: '>') @@ -169,10 +169,14 @@ const ( layoutReverseList ) -type infoStyle int +type infoLayout int +type infoStyle struct { + layout infoLayout + separator bool +} const ( - infoDefault infoStyle = iota + infoDefault infoLayout = iota infoInline infoHidden ) @@ -310,7 +314,7 @@ func defaultOptions() *Options { HscrollOff: 10, ScrollOff: 0, FileWord: false, - InfoStyle: infoDefault, + InfoStyle: infoStyle{layout: infoDefault, separator: true}, JumpLabels: defaultJumpLabels, Prompt: "> ", Pointer: ">", @@ -813,6 +817,8 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) *tui.ColorTheme { mergeAttr(&theme.CurrentMatch) case "border": mergeAttr(&theme.Border) + case "separator": + mergeAttr(&theme.Separator) case "label": mergeAttr(&theme.BorderLabel) case "prompt": @@ -1214,17 +1220,26 @@ func parseLayout(str string) layoutType { } func parseInfoStyle(str string) infoStyle { - switch str { - case "default": - return infoDefault - case "inline": - return infoInline - case "hidden": - return infoHidden - default: - errorExit("invalid info style (expected: default / inline / hidden)") + layout := infoDefault + separator := true + + for _, token := range regexp.MustCompile("[,:]").Split(strings.ToLower(str), -1) { + switch token { + case "default": + layout = infoDefault + case "inline": + layout = infoInline + case "hidden": + layout = infoHidden + case "nosep": + separator = false + case "sep": + separator = true + default: + errorExit("invalid info style (expected: default|inline|hidden[:nosep])") + } } - return infoDefault + return infoStyle{layout: layout, separator: separator} } func parsePreviewWindow(opts *previewOpts, input string) { @@ -1486,11 +1501,11 @@ func parseOptions(opts *Options, allArgs []string) { opts.InfoStyle = parseInfoStyle( nextString(allArgs, &i, "info style required")) case "--no-info": - opts.InfoStyle = infoHidden + opts.InfoStyle.layout = infoHidden case "--inline-info": - opts.InfoStyle = infoInline + opts.InfoStyle.layout = infoInline case "--no-inline-info": - opts.InfoStyle = infoDefault + opts.InfoStyle.layout = infoDefault case "--jump-labels": opts.JumpLabels = nextString(allArgs, &i, "label characters required") validateJumpLabels = true |
