Skip to content
Myr

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

8 files+138 added−29 removed

modified:src/tui/tui.go+3 added-1 removed
774 unmodified lines
775 ColGhost ColorPair776 ColMatch ColorPair777 ColCursor ColorPair778 ColCursorEmpty ColorPair779 ColCursorEmptyChar ColorPair780 ColMarker ColorPair781 ColSelected ColorPair782 ColSelectedMatch ColorPair783 ColCurrent ColorPair
384 unmodified lines
1168 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 lines
modified:src/options_test.go+1 added-1 removed
460 unmodified lines
461 {">>>", false},462 }463464 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 lines
modified:src/options.go+20 added-5 removed
588 unmodified lines
589 Ghost string590 Separator *string591 JumpLabels string592 Prompt string593 Gutter *string594 Pointer *string595 Marker *string596 MarkerMulti *[3]string597 Query string
112 unmodified lines
710 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 lines
2858 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 err
490 unmodified lines
3363 }3364 return nil3365}33663358func 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)3367func 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}33733374func 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 }33803381 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 }33863387 if opts.Gutter != nil {3388 if err := validateSign(*opts.Gutter, "gutter", 1); err != nil {3389 return err3390 }3391 }33923393 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 lines
modified:src/terminal.go+34 added-4 removed
270 unmodified lines
271 headerLabelOpts labelOpts272 footerLabel labelPrinter273 footerLabelLen int274 footerLabelOpts labelOpts275 gutterReverse bool276 pointer string277 pointerLen int278 pointerEmpty string279 marker string
814 unmodified lines
10941095 // This should be called before accessing tui.Color*1096 tui.InitTheme(opts.Theme, renderer.DefaultTheme(), opts.Black, opts.InputBorderShape.Visible(), opts.HeaderBorderShape.Visible())10971098 // 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 }11081109 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)11171118 // 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 lines
3113 t.markEmptyLine(line)3114 t.renderBar(line, barRange)3115}31163117func (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}31283129func (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.markerLen31343135 width := t.window.Width() - x - 1
155 unmodified lines
3291 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 lines
3313 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 lines
modified:test/lib/common.rb+1 added-1 removed
22 unmodified lines
2324FILE = File.expand_path(__FILE__)25BASE = File.expand_path('../..', __dir__)26Dir.chdir(BASE)27FZF = "FZF_DEFAULT_OPTS=\"--no-scrollbar --pointer \\> --marker \\>\" FZF_DEFAULT_COMMAND= #{BASE}/bin/fzf".freeze27FZF = %[FZF_DEFAULT_OPTS="--no-scrollbar --gutter ' ' --pointer '>' --marker '>'" FZF_DEFAULT_COMMAND= #{BASE}/bin/fzf].freeze2829def wait(timeout = DEFAULT_TIMEOUT)30 since = Time.now31 begin
209 unmodified lines
modified:test/test_exec.rb+1 added-1 removed
401 unmodified lines
402 tmux.until { |lines| assert_includes lines[-3], 'bar' }403 end404405 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 :Enter
7 unmodified lines
modified:test/test_layout.rb+52 added-16 removed
176 unmodified lines
177 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 OUTPUT
9 unmodified lines
196 │ │197 │ │198 │ │199 │ ╰────────200 │ 3201 │ 2200 │ ▌ 3201 │ ▌ 2202 │ > 1203 │ > < 3/3204 ╰──────────205 OUTPUT
40 unmodified lines
246 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 OUTPUT
19 unmodified lines
274275 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 lines
311 ╭───────────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 lines
1155 BLOCK1156 tmux.until { assert_block(block, it) }1157 end11581159 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 end11701171 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 end11821183 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 end11941195 def test_combinations1196 skip unless ENV['LONGTEST']11971198 base = [
71 unmodified lines
modified:CHANGELOG.md+26 added
1CHANGELOG2=========340.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 '▐'1314 # Even thinner gutter15 fzf --gutter '▎'1617 # Checker18 fzf --gutter '▚'1920 # Dotted21 fzf --gutter '▖'2223 # Full-width24 fzf --gutter '█'2526 # No gutter27 fzf --gutter ' '28 ```29300.65.231------32- Bug fixes and improvements33 - Fix incorrect truncation of `--info-command` with `--info=inline-right` (#4479)
2791 unmodified lines