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
Provenance
- Commit
0d5aebb- Tree
1320a53- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
1313510
5 files changed+51 added−15 removed
modified:man/man1/fzf.1+1 added-1 removed
187 unmodified lines188 .RE189 .SS GLOBAL STYLE190 .TP191 .BI "\-\-style=" "PRESET"192-Apply a style preset [default|minimal|full]192+Apply a style preset [default|minimal|full[:BORDER_STYLE]]193 .TP194 .BI "\-\-color=" "[BASE_SCHEME][,COLOR_NAME[:ANSI_COLOR][:ANSI_ATTRIBUTES]]..."195 Color configuration. The name of the base color scheme is followed by custom196 color mappings.1604 unmodified linesmodified:src/options.go+28 added-12 removed
54 unmodified lines55 --ansi Enable processing of ANSI color codes56 --sync Synchronous search for multi-staged filtering57 58 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 lines213 FZF_API_KEY X-API-Key header for HTTP server (--listen)214 215 `216 217+// Can be changed by --style218+var defaultBorderShape tui.BorderShape = tui.DefaultBorderShape219+220 const defaultInfoPrefix = " < "221 222 // Case denotes case-sensitivity of search223 type Case int406 unmodified lines630 return output631 }632 633 func 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 }636 637 func defaultOptions() *Options {638 var theme *tui.ColorTheme205 unmodified lines844 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 lines2731 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 lines2884 return err2885 }2886 2887 func applyPreset(opts *Options, preset string) error {2888+ // Reset to the platform default2889+ defaultBorderShape = tui.DefaultBorderShape2890+2891 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 = nil10 unmodified lines2911 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.DefaultBorderShape2927+2928+ 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 linesmodified:src/tmux.go+3 added-1 removed
10 unmodified lines11 // 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 linesmodified:test/test_go.rb+18 added
3717 unmodified lines3718 BLOCK3719 tmux.until { assert_block(block, _1) }3720 end3721 3722+ 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+ end3739+3740 def test_change_nth3741 input = [3742 *[''] * 1000,3743 'foo bar bar bar bar',580 unmodified linesmodified:CHANGELOG.md+1 added-1 removed
15 unmodified lines16 | `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"/> |18 19 - 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 - Options2410 unmodified lines