Style change: thinner gutter column (#4521)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by GitHub · parent c5cabe1 · Browse files · 8 files·+138 added−29 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+138 added−29 removed
- tests:+54 added−18 removed
- other:+84 added−11 removed
Provenance
- Commit
a67aa85- Tree
05f9f81- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
c5cabe1
8 files changed+138 added−29 removed
modified:src/tui/tui.go+3 added-1 removed
774 unmodified lines775 ColGhost ColorPair776 ColMatch ColorPair777 ColCursor ColorPair778 ColCursorEmpty ColorPair779+ ColCursorEmptyChar ColorPair780 ColMarker ColorPair781 ColSelected ColorPair782 ColSelectedMatch ColorPair783 ColCurrent ColorPair384 unmodified lines1168 ColMatch = pair(theme.Match, theme.ListBg)1169 ColSelectedMatch = pair(theme.SelectedMatch, theme.SelectedBg)1170 ColCursor = pair(theme.Cursor, theme.Gutter)1171 ColCursorEmpty = pair(blank, theme.Gutter)1172+ ColCursorEmptyChar = pair(theme.Gutter, theme.ListBg)1173 if theme.SelectedBg.Color != theme.ListBg.Color {1174 ColMarker = pair(theme.Marker, theme.SelectedBg)1175 } else {1174- ColMarker = pair(theme.Marker, theme.Gutter)1176+ ColMarker = pair(theme.Marker, theme.ListBg)1177 }1178 ColCurrent = pair(theme.Current, theme.DarkBg)1179 ColCurrentMatch = pair(theme.CurrentMatch, theme.DarkBg)1180 ColCurrentCursor = pair(theme.Cursor, theme.DarkBg)30 unmodified linesmodified:src/options_test.go+1 added-1 removed
460 unmodified lines461 {">>>", false},462 }463 464 for _, testCase := range testCases {465- err := validateSign(testCase.inputSign, "")465+ err := validateSign(testCase.inputSign, "", 2)466 if testCase.isValid && err != nil {467 t.Errorf("Input sign `%s` caused error", testCase.inputSign)468 }469 37 unmodified linesmodified:src/options.go+20 added-5 removed
588 unmodified lines589 Ghost string590 Separator *string591 JumpLabels string592 Prompt string593+ Gutter *string594 Pointer *string595 Marker *string596 MarkerMulti *[3]string597 Query string112 unmodified lines710 Ghost: "",711 Separator: nil,712 JumpLabels: defaultJumpLabels,713 Prompt: "> ",714+ Gutter: nil,715 Pointer: nil,716 Marker: nil,717 MarkerMulti: nil,718 Query: "",2139 unmodified lines2858 opts.Prompt, err = nextString("prompt string required")2859 if err != nil {2860 return err2861 }2862+ case "--gutter":2863+ str, err := nextString("gutter character required")2864+ if err != nil {2865+ return err2866+ }2867+ str = firstLine(str)2868+ opts.Gutter = &str2869 case "--pointer":2870 str, err := nextString("pointer sign required")2871 if err != nil {2872 return err490 unmodified lines3363 }3364 return nil3365 }3366 3358-func validateSign(sign string, signOptName string) error {3359- if uniseg.StringWidth(sign) > 2 {3360- return fmt.Errorf("%v display width should be up to 2", signOptName)3367+func validateSign(sign string, signOptName string, maxWidth int) error {3368+ if uniseg.StringWidth(sign) > maxWidth {3369+ return fmt.Errorf("%v display width should be up to %d", signOptName, maxWidth)3370 }3371 return nil3372 }3373 3374 func validateOptions(opts *Options) error {3375 if opts.Pointer != nil {3367- if err := validateSign(*opts.Pointer, "pointer"); err != nil {3376+ if err := validateSign(*opts.Pointer, "pointer", 2); err != nil {3377 return err3378 }3379 }3380 3381 if opts.Marker != nil {3373- if err := validateSign(*opts.Marker, "marker"); err != nil {3382+ if err := validateSign(*opts.Marker, "marker", 2); err != nil {3383 return err3384 }3385 }3386 3387+ if opts.Gutter != nil {3388+ if err := validateSign(*opts.Gutter, "gutter", 1); err != nil {3389+ return err3390+ }3391+ }3392+3393 if opts.Scrollbar != nil {3394 runes := []rune(*opts.Scrollbar)3395 if len(runes) > 2 {3396 return errors.New("--scrollbar should be given one or two characters")359 unmodified linesmodified:src/terminal.go+34 added-4 removed
270 unmodified lines271 headerLabelOpts labelOpts272 footerLabel labelPrinter273 footerLabelLen int274 footerLabelOpts labelOpts275+ gutterReverse bool276 pointer string277 pointerLen int278 pointerEmpty string279 marker string814 unmodified lines1094 1095 // This should be called before accessing tui.Color*1096 tui.InitTheme(opts.Theme, renderer.DefaultTheme(), opts.Black, opts.InputBorderShape.Visible(), opts.HeaderBorderShape.Visible())1097 1098+ // Gutter character1099+ var gutterChar string1100+ if opts.Gutter != nil {1101+ gutterChar = *opts.Gutter1102+ } else if t.unicode && !t.theme.Gutter.Color.IsDefault() {1103+ gutterChar = "▌"1104+ } else {1105+ gutterChar = " "1106+ t.gutterReverse = true1107+ }1108+1109 t.prompt, t.promptLen = t.parsePrompt(opts.Prompt)1110 // Pre-calculated empty pointer and marker signs1099- t.pointerEmpty = strings.Repeat(" ", t.pointerLen)1111+ if t.pointerLen == 0 {1112+ t.pointerEmpty = ""1113+ } else {1114+ t.pointerEmpty = gutterChar + strings.Repeat(" ", util.Max(0, t.pointerLen-1))1115+ }1116 t.markerEmpty = strings.Repeat(" ", t.markerLen)1117+1118+ // Labels1119 t.listLabel, t.listLabelLen = t.ansiLabelPrinter(opts.ListLabel.label, &tui.ColListLabel, false)1120 t.borderLabel, t.borderLabelLen = t.ansiLabelPrinter(opts.BorderLabel.label, &tui.ColBorderLabel, false)1121 t.previewLabel, t.previewLabelLen = t.ansiLabelPrinter(opts.PreviewLabel.label, &tui.ColPreviewLabel, false)1122 t.inputLabel, t.inputLabelLen = t.ansiLabelPrinter(opts.InputLabel.label, &tui.ColInputLabel, false)1990 unmodified lines3113 t.markEmptyLine(line)3114 t.renderBar(line, barRange)3115 }3116 3117+func (t *Terminal) gutter(current bool) {3118+ var color tui.ColorPair3119+ if current {3120+ color = tui.ColCurrentCursorEmpty3121+ } else if t.gutterReverse {3122+ color = tui.ColCursorEmpty3123+ } else {3124+ color = tui.ColCursorEmptyChar3125+ }3126+ t.window.CPrint(color, t.pointerEmpty)3127+}3128+3129 func (t *Terminal) renderGapLine(line int, barRange [2]int, drawLine bool) {3130 t.move(line, 0, false)3101- t.window.CPrint(tui.ColCursorEmpty, t.pointerEmpty)3131+ t.gutter(false)3132 t.window.Print(t.markerEmpty)3133 x := t.pointerLen + t.markerLen3134 3135 width := t.window.Width() - x - 1155 unmodified lines3291 if w < 0 {3292 return indentSize3293 }3294 if len(label) == 0 {3265- t.window.CPrint(tui.ColCurrentCursorEmpty, t.pointerEmpty)3295+ t.gutter(true)3296 } else {3297 t.window.CPrint(tui.ColCurrentCursor, label)3298 }3299 if w-t.markerLen < 0 {13 unmodified lines3313 if w < 0 {3314 return indentSize3315 }3316 if len(label) == 0 {3287- t.window.CPrint(tui.ColCursorEmpty, t.pointerEmpty)3317+ t.gutter(false)3318 } else {3319 t.window.CPrint(tui.ColCursor, label)3320 }3321 if w-t.markerLen < 0 {3749 unmodified linesmodified:test/lib/common.rb+1 added-1 removed
22 unmodified lines23 24 FILE = File.expand_path(__FILE__)25 BASE = File.expand_path('../..', __dir__)26 Dir.chdir(BASE)27-FZF = "FZF_DEFAULT_OPTS=\"--no-scrollbar --pointer \\> --marker \\>\" FZF_DEFAULT_COMMAND= #{BASE}/bin/fzf".freeze27+FZF = %[FZF_DEFAULT_OPTS="--no-scrollbar --gutter ' ' --pointer '>' --marker '>'" FZF_DEFAULT_COMMAND= #{BASE}/bin/fzf].freeze28 29 def wait(timeout = DEFAULT_TIMEOUT)30 since = Time.now31 begin209 unmodified linesmodified:test/test_exec.rb+1 added-1 removed
401 unmodified lines402 tmux.until { |lines| assert_includes lines[-3], 'bar' }403 end404 405 def test_become406- tmux.send_keys "seq 100 | #{FZF} --bind 'enter:become:seq {} | #{FZF}'", :Enter406+ tmux.send_keys "seq 100 | fzf --bind 'enter:become:seq {} | fzf'", :Enter407 tmux.until { |lines| assert_equal 100, lines.match_count }408 tmux.send_keys 999409 tmux.until { |lines| assert_equal 0, lines.match_count }410 tmux.send_keys :Enter7 unmodified linesmodified:test/test_layout.rb+52 added-16 removed
176 unmodified lines177 def test_height_range_fit178 tmux.send_keys 'seq 3 | fzf --height ~100% --info=inline --border rounded', :Enter179 expected = <<~OUTPUT180 ╭──────────181- │ 3182- │ 2181+ │ ▌ 3182+ │ ▌ 2183 │ > 1184 │ > < 3/3185 ╰──────────186 OUTPUT9 unmodified lines196 │ │197 │ │198 │ │199 │ ╰────────200- │ 3201- │ 2200+ │ ▌ 3201+ │ ▌ 2202 │ > 1203 │ > < 3/3204 ╰──────────205 OUTPUT40 unmodified lines246 def test_height_range_overflow247 tmux.send_keys 'seq 100 | fzf --height ~5 --info=inline --border rounded', :Enter248 expected = <<~OUTPUT249 ╭──────────────250- │ 2250+ │ ▌ 2251 │ > 1252 │ > < 100/100253 ╰──────────────254 OUTPUT19 unmodified lines274 275 def test_fzf_multi_line276 tmux.send_keys %[(echo -en '0\\0'; echo -en '1\\n2\\0'; seq 1000) | fzf --read0 --multi --bind load:select-all --border rounded], :Enter277 block = <<~BLOCK278- │ ┃998279- │ ┃999280- │ ┃1000281- │ ╹282- │ ╻1283- │ ╹2278+ │ ▌┃998279+ │ ▌┃999280+ │ ▌┃1000281+ │ ▌╹282+ │ ▌╻1283+ │ ▌╹2284 │ >>0285 │ 3/3 (3)286 │ >287 ╰───────────23 unmodified lines311 ╭───────────312 │ >313 │ 3/3 (3)314 │ >>0315- │ ╻1316- │ ╹2317- │ ╻1318- │ ┃2319- │ ┃3315+ │ ▌╻1316+ │ ▌╹2317+ │ ▌╻1318+ │ ▌┃2319+ │ ▌┃3320 BLOCK321 tmux.until { assert_block(block, it) }322 end323 831 unmodified lines1155 BLOCK1156 tmux.until { assert_block(block, it) }1157 end1158 1159+ def test_gutter_default1160+ tmux.send_keys %(seq 10 | fzf), :Enter1161+ block = <<~BLOCK1162+ ▌ 31163+ ▌ 21164+ > 11165+ 10/101166+ >1167+ BLOCK1168+ tmux.until { assert_block(block, it) }1169+ end1170+1171+ def test_gutter_default_no_unicode1172+ tmux.send_keys %(seq 10 | fzf --no-unicode), :Enter1173+ block = <<~BLOCK1174+ 31175+ 21176+ > 11177+ 10/101178+ >1179+ BLOCK1180+ tmux.until { assert_block(block, it) }1181+ end1182+1183+ def test_gutter_custom1184+ tmux.send_keys %(seq 10 | fzf --gutter x), :Enter1185+ block = <<~BLOCK1186+ x 31187+ x 21188+ > 11189+ 10/101190+ >1191+ BLOCK1192+ tmux.until { assert_block(block, it) }1193+ end1194+1195 def test_combinations1196 skip unless ENV['LONGTEST']1197 1198 base = [71 unmodified linesmodified:CHANGELOG.md+26 added
1 CHANGELOG2 =========3 4+0.66.05+------6+- Style changes7+ - Narrowed the gutter column by using the left-half block character (`▌`).8+ - Removed background colors from markers.9+- Added `--gutter CHAR` option for customizing the gutter column. Some examples using [box-drawing characters](https://en.wikipedia.org/wiki/Box-drawing_characters):10+ ```sh11+ # Right-aligned gutter12+ fzf --gutter '▐'13+14+ # Even thinner gutter15+ fzf --gutter '▎'16+17+ # Checker18+ fzf --gutter '▚'19+20+ # Dotted21+ fzf --gutter '▖'22+23+ # Full-width24+ fzf --gutter '█'25+26+ # No gutter27+ fzf --gutter ' '28+ ```29+30 0.65.231 ------32 - Bug fixes and improvements33 - Fix incorrect truncation of `--info-command` with `--info=inline-right` (#4479)2791 unmodified lines