diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2023-01-01 14:48:14 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2023-01-01 14:48:14 +0900 |
commit | 5cd6f1d06427f1e023573be084e384227fae3cdf (patch) | |
tree | 912b9359e1767e4de768df65206547eedfac729f /src/options.go | |
parent | ec20dfe312fb31dca2ebf7aa0caa05cd582cf131 (diff) |
Add scrollbar
Close #3096
Diffstat (limited to 'src/options.go')
-rw-r--r-- | src/options.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/options.go b/src/options.go index 0ee7db33..e4a6aa39 100644 --- a/src/options.go +++ b/src/options.go @@ -73,6 +73,8 @@ const usage = `usage: fzf [options] --info=STYLE Finder info style [default|inline|hidden] --separator=STR String to form horizontal separator on info line --no-separator Hide info line separator + --scrollbar[=CHAR] Scrollbar character + --no-scrollbar Hide scrollbar --prompt=STR Input prompt (default: '> ') --pointer=STR Pointer to the current line (default: '>') --marker=STR Multi-select marker (default: '>') @@ -290,6 +292,7 @@ type Options struct { HeaderLines int HeaderFirst bool Ellipsis string + Scrollbar *string Margin [4]sizeSpec Padding [4]sizeSpec BorderShape tui.BorderShape @@ -359,6 +362,7 @@ func defaultOptions() *Options { HeaderLines: 0, HeaderFirst: false, Ellipsis: "..", + Scrollbar: nil, Margin: defaultMargin(), Padding: defaultMargin(), Unicode: true, @@ -847,6 +851,8 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) *tui.ColorTheme { mergeAttr(&theme.Border) case "separator": mergeAttr(&theme.Separator) + case "scrollbar": + mergeAttr(&theme.Scrollbar) case "label": mergeAttr(&theme.BorderLabel) case "preview-label": @@ -1570,6 +1576,16 @@ func parseOptions(opts *Options, allArgs []string) { case "--no-separator": nosep := "" opts.Separator = &nosep + case "--scrollbar": + given, bar := optionalNextString(allArgs, &i) + if given { + opts.Scrollbar = &bar + } else { + opts.Scrollbar = nil + } + case "--no-scrollbar": + noBar := "" + opts.Scrollbar = &noBar case "--jump-labels": opts.JumpLabels = nextString(allArgs, &i, "label characters required") validateJumpLabels = true @@ -1739,6 +1755,8 @@ func parseOptions(opts *Options, allArgs []string) { opts.InfoStyle = parseInfoStyle(value) } else if match, value := optString(arg, "--separator="); match { opts.Separator = &value + } else if match, value := optString(arg, "--scrollbar="); match { + opts.Scrollbar = &value } else if match, value := optString(arg, "--toggle-sort="); match { parseToggleSort(opts.Keymap, value) } else if match, value := optString(arg, "--expect="); match { @@ -1845,6 +1863,11 @@ func postProcessOptions(opts *Options) { if !opts.Version && !tui.IsLightRendererSupported() && opts.Height.size > 0 { errorExit("--height option is currently not supported on this platform") } + + if opts.Scrollbar != nil && runewidth.StringWidth(*opts.Scrollbar) > 1 { + errorExit("scrollbar display width should be 1") + } + // Default actions for CTRL-N / CTRL-P when --history is set if opts.History != nil { if _, prs := opts.Keymap[tui.CtrlP.AsEvent()]; !prs { |