Skip to content
Myr

Allow setting border styles at once with --style full:STYLE

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 1313510 · Browse files · 5 files+51 added−15 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+51 added−15 removed

  • tests:+18 added−0 removed
  • other:+33 added−15 removed

5 files+51 added−15 removed

modified:man/man1/fzf.1+1 added-1 removed
187 unmodified lines
188.RE189.SS GLOBAL STYLE190.TP191.BI "\-\-style=" "PRESET"192Apply a style preset [default|minimal|full]192Apply a style preset [default|minimal|full[:BORDER_STYLE]]193.TP194.BI "\-\-color=" "[BASE_SCHEME][,COLOR_NAME[:ANSI_COLOR][:ANSI_ATTRIBUTES]]..."195Color configuration. The name of the base color scheme is followed by custom196color mappings.
1604 unmodified lines
modified:src/options.go+28 added-12 removed
54 unmodified lines
55 --ansi Enable processing of ANSI color codes56 --sync Synchronous search for multi-staged filtering5758 GLOBAL STYLE59 --style=PRESET Apply a style preset [default|minimal|full]59 --style=PRESET Apply a style preset [default|minimal|full[:BORDER_STYLE]60 --color=COLSPEC Base scheme (dark|light|16|bw) and/or custom colors61 --no-color Disable colors62 --no-bold Do not use bold text63
149 unmodified lines
213 FZF_API_KEY X-API-Key header for HTTP server (--listen)214215`216217// Can be changed by --style218var defaultBorderShape tui.BorderShape = tui.DefaultBorderShape219220const defaultInfoPrefix = " < "221222// Case denotes case-sensitivity of search223type Case int
406 unmodified lines
630 return output631}632633func defaultPreviewOpts(command string) previewOpts {631 return previewOpts{command, posRight, sizeSpec{50, true}, "", false, false, false, false, true, tui.DefaultBorderShape, 0, 0, nil}634 return previewOpts{command, posRight, sizeSpec{50, true}, "", false, false, false, false, true, defaultBorderShape, 0, 0, nil}635}636637func defaultOptions() *Options {638 var theme *tui.ColorTheme
205 unmodified lines
844 case "none":845 return tui.BorderNone, nil846 }847 if optional && str == "" {845 return tui.DefaultBorderShape, nil848 return defaultBorderShape, nil849 }850 return tui.BorderNone, errors.New("invalid border style (expected: rounded|sharp|bold|block|thinblock|double|horizontal|vertical|top|bottom|left|right|none)")851}852
1878 unmodified lines
2731 if err := parseLabelPosition(&opts.PreviewLabel, pos); err != nil {2732 return err2733 }2734 case "--style":2732 preset, err := nextString("preset name required: [default|minimal|full]")2735 preset, err := nextString("preset name required: [default|minimal|full[:BORDER_STYLE]]")2736 if err != nil {2737 return err2738 }2739 if err := applyPreset(opts, preset); err != nil {
144 unmodified lines
2884 return err2885}28862887func applyPreset(opts *Options, preset string) error {2888 // Reset to the platform default2889 defaultBorderShape = tui.DefaultBorderShape28902891 switch strings.ToLower(preset) {2892 case "default":2893 opts.ListBorderShape = tui.BorderUndefined2894 opts.InputBorderShape = tui.BorderUndefined2895 opts.HeaderBorderShape = tui.BorderUndefined2890 opts.Preview.border = tui.DefaultBorderShape2896 opts.Preview.border = defaultBorderShape2897 opts.Preview.info = true2898 opts.InfoStyle = infoDefault2899 opts.Theme.Gutter = tui.NewColorAttr()2900 opts.Separator = nil
10 unmodified lines
2911 empty := ""2912 opts.Separator = &empty2913 opts.Scrollbar = &empty2914 opts.CursorLine = false2915 default:2916 tokens := strings.SplitN(preset, ":", 2)2917 if tokens[0] != "full" {2918 return errors.New("unsupported style preset: " + preset)2919 }2920 if len(tokens) == 2 && len(tokens[1]) > 0 {2921 var err error2922 defaultBorderShape, err = parseBorder(tokens[1], false, false)2923 if err != nil {2924 return err2925 }2926 }2909 case "full":2910 opts.ListBorderShape = tui.DefaultBorderShape2911 opts.InputBorderShape = tui.DefaultBorderShape2912 opts.HeaderBorderShape = tui.DefaultBorderShape2913 opts.Preview.border = tui.DefaultBorderShape29272928 opts.ListBorderShape = defaultBorderShape2929 opts.InputBorderShape = defaultBorderShape2930 opts.HeaderBorderShape = defaultBorderShape2931 opts.Preview.border = defaultBorderShape2932 opts.Preview.info = true2933 opts.InfoStyle = infoInlineRight2934 opts.Theme.Gutter = tui.NewColorAttr()2935 opts.Separator = nil2936 opts.Scrollbar = nil2937 opts.CursorLine = true2920 default:2921 return errors.New("unsupported style preset: " + preset)2938 }2939 return nil2940}2941
288 unmodified lines
modified:src/tmux.go+3 added-1 removed
10 unmodified lines
11 // Prepare arguments12 fzf, rest := args[0], args[1:]13 args = []string{"--bind=ctrl-z:ignore"}14 if !opts.Tmux.border && opts.BorderShape == tui.BorderUndefined {15 args = append(args, "--border")15 // We append --border option at the end, because `--style=full:STYLE`16 // may have changed the default border style.17 rest = append(rest, "--border")18 }19 if opts.Tmux.border && opts.Margin == defaultMargin() {20 args = append(args, "--margin=0,1")21 }
47 unmodified lines
modified:test/test_go.rb+18 added
3717 unmodified lines
3718 BLOCK3719 tmux.until { assert_block(block, _1) }3720 end37213722 def test_style_full_adaptive_height_double3723 tmux.send_keys %(seq 1| #{FZF} --style=full:double --border --height=~100% --header-lines=1 --info=default), :Enter3724 block = <<~BLOCK3725 ╔══════════3726 ║ ╔════════3727 ║ ╚════════3728 ║ ╔════════3729 ║ ║ 13730 ║ ╚════════3731 ║ ╔════════3732 ║ ║ 0/03733 ║ ║ >3734 ║ ╚════════3735 ╚══════════3736 BLOCK3737 tmux.until { assert_block(block, _1) }3738 end37393740 def test_change_nth3741 input = [3742 *[''] * 1000,3743 'foo bar bar bar bar',
580 unmodified lines
modified:CHANGELOG.md+1 added-1 removed
15 unmodified lines
16| `full` | <img src="https://raw.githubusercontent.com/junegunn/i/master/fzf-style-full.png"/> |17| `minimal` | <img src="https://raw.githubusercontent.com/junegunn/i/master/fzf-style-minimal.png"/> |1819- Style presets (#4160)20 - `--style=full`20 - `--style=full[:BORDER_STYLE]`21 - `--style=default`22 - `--style=minimal`23- Border and label for the list section (#4148)24 - Options
2410 unmodified lines