diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2024-05-19 11:26:32 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2024-05-19 15:51:32 +0900 |
| commit | 5b204c54f9d16accdf66bb24477e9eff4fc3a21a (patch) | |
| tree | cef3aa9b6fd733c407c2e77ea5a0eb486627982e /src | |
| parent | 04dfb14e3215f578d44cdc117d9f19920af21faa (diff) | |
| download | fzf-5b204c54f9d16accdf66bb24477e9eff4fc3a21a.tar.gz | |
Change default pointer and marker character
* Pointer: '▌'
* Marker: '▏'
They will still be set to '>' if `--no-unicode` is given.
Reasons:
* They look okay
* They work better with multi-line items (WIP)
Diffstat (limited to 'src')
| -rw-r--r-- | src/options.go | 44 | ||||
| -rw-r--r-- | src/terminal.go | 4 |
2 files changed, 34 insertions, 14 deletions
diff --git a/src/options.go b/src/options.go index ded8a92d..efeb75a9 100644 --- a/src/options.go +++ b/src/options.go @@ -83,8 +83,8 @@ const Usage = `usage: fzf [options] --scrollbar[=C1[C2]] Scrollbar character(s) (each for main and preview window) --no-scrollbar Hide scrollbar --prompt=STR Input prompt (default: '> ') - --pointer=STR Pointer to the current line (default: '>') - --marker=STR Multi-select marker (default: '>') + --pointer=STR Pointer to the current line (default: '▌' or '>') + --marker=STR Multi-select marker (default: '▏' or '>') --header=STR String to print as header --header-lines=N The first N lines of the input are treated as header --header-first Print header before the prompt line @@ -420,8 +420,8 @@ type Options struct { Separator *string JumpLabels string Prompt string - Pointer string - Marker string + Pointer *string + Marker *string Query string Select1 bool Exit0 bool @@ -515,8 +515,8 @@ func defaultOptions() *Options { Separator: nil, JumpLabels: defaultJumpLabels, Prompt: "> ", - Pointer: ">", - Marker: ">", + Pointer: nil, + Marker: nil, Query: "", Select1: false, Exit0: false, @@ -2153,13 +2153,15 @@ func parseOptions(opts *Options, allArgs []string) error { if err != nil { return err } - opts.Pointer = firstLine(str) + str = firstLine(str) + opts.Pointer = &str case "--marker": str, err := nextString(allArgs, &i, "selected sign string required") if err != nil { return err } - opts.Marker = firstLine(str) + str = firstLine(str) + opts.Marker = &str case "--sync": opts.Sync = true case "--no-sync", "--async": @@ -2395,9 +2397,11 @@ func parseOptions(opts *Options, allArgs []string) error { } else if match, value := optString(arg, "--prompt="); match { opts.Prompt = value } else if match, value := optString(arg, "--pointer="); match { - opts.Pointer = firstLine(value) + str := firstLine(value) + opts.Pointer = &str } else if match, value := optString(arg, "--marker="); match { - opts.Marker = firstLine(value) + str := firstLine(value) + opts.Marker = &str } else if match, value := optString(arg, "-n", "--nth="); match { if opts.Nth, err = splitNth(value); err != nil { return err @@ -2586,11 +2590,27 @@ func postProcessOptions(opts *Options) error { opts.BorderShape = tui.BorderNone } - if err := validateSign(opts.Pointer, "pointer"); err != nil { + if opts.Pointer == nil { + defaultPointer := "▌" + if !opts.Unicode { + defaultPointer = ">" + } + opts.Pointer = &defaultPointer + } + + if opts.Marker == nil { + defaultMarker := "▏" + if !opts.Unicode { + defaultMarker = ">" + } + opts.Marker = &defaultMarker + } + + if err := validateSign(*opts.Pointer, "pointer"); err != nil { return err } - if err := validateSign(opts.Marker, "marker"); err != nil { + if err := validateSign(*opts.Marker, "marker"); err != nil { return err } diff --git a/src/terminal.go b/src/terminal.go index 530c9eb6..01960552 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -811,8 +811,8 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor lastAction: actStart, lastFocus: minItem.Index()} t.prompt, t.promptLen = t.parsePrompt(opts.Prompt) - t.pointer, t.pointerLen = t.processTabs([]rune(opts.Pointer), 0) - t.marker, t.markerLen = t.processTabs([]rune(opts.Marker), 0) + t.pointer, t.pointerLen = t.processTabs([]rune(*opts.Pointer), 0) + t.marker, t.markerLen = t.processTabs([]rune(*opts.Marker), 0) // Pre-calculated empty pointer and marker signs t.pointerEmpty = strings.Repeat(" ", t.pointerLen) t.markerEmpty = strings.Repeat(" ", t.markerLen) |
