Add style presets: --style=[default|minimal|full]
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Close #4160
authored by Junegunn Choi · committed by Junegunn Choi · parent 0e0b868 · Browse files · 2 files·+67 added−3 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+67 added−3 removed
- other:+67 added−3 removed
Provenance
- Commit
5ae60e2- Tree
5aa2c88- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
0e0b868
2 files changed+67 added−3 removed
modified:src/options.go+55 added
65 unmodified lines66 --filepath-word Make word-wise movements respect path separators67 --jump-labels=CHARS Label characters for jump mode68 69 Layout70+ --style=PRESET Apply a style preset [default|minimal|full]71 --height=[~]HEIGHT[%] Display fzf window below the cursor with the given72 height instead of using fullscreen.73 A negative value is calculated as the terminal height74 minus the given value.2571 unmodified lines2646 }2647 if err := parseLabelPosition(&opts.PreviewLabel, pos); err != nil {2648 return err2649 }2650+ case "--style":2651+ preset, err := nextString(allArgs, &i, "preset name required: [default|minimal|full]")2652+ if err != nil {2653+ return err2654+ }2655+ if err := applyPreset(opts, preset); err != nil {2656+ return err2657+ }2658 case "--no-unicode":2659 opts.Unicode = false2660 case "--unicode":2661 opts.Unicode = true88 unmodified lines2750 } else if match, value := optString(arg, "--tmux="); match {2751 if opts.Tmux, err = parseTmuxOptions(value, index); err != nil {2752 return err2753 }2754+ } else if match, value := optString(arg, "--style="); match {2755+ if err := applyPreset(opts, value); err != nil {2756+ return err2757+ }2758 } else if match, value := optString(arg, "--scheme="); match {2759 opts.Scheme = strings.ToLower(value)2760 } else if match, value := optString(arg, "-q", "--query="); match {2761 opts.Query = value240 unmodified lines3002 }3003 return err3004 }3005 3006+func applyPreset(opts *Options, preset string) error {3007+ switch strings.ToLower(preset) {3008+ case "default":3009+ opts.ListBorderShape = tui.BorderUndefined3010+ opts.InputBorderShape = tui.BorderUndefined3011+ opts.HeaderBorderShape = tui.BorderUndefined3012+ opts.Preview.border = tui.DefaultBorderShape3013+ opts.Preview.info = true3014+ opts.InfoStyle = infoDefault3015+ opts.Theme.Gutter = tui.NewColorAttr()3016+ opts.Separator = nil3017+ opts.Scrollbar = nil3018+ opts.CursorLine = false3019+ case "minimal":3020+ opts.ListBorderShape = tui.BorderUndefined3021+ opts.InputBorderShape = tui.BorderUndefined3022+ opts.HeaderBorderShape = tui.BorderUndefined3023+ opts.Preview.border = tui.BorderLine3024+ opts.Preview.info = false3025+ opts.InfoStyle = infoDefault3026+ opts.Theme.Gutter = tui.ColorAttr{Color: -1, Attr: 0}3027+ empty := ""3028+ opts.Separator = &empty3029+ opts.Scrollbar = &empty3030+ opts.CursorLine = false3031+ case "full":3032+ opts.ListBorderShape = tui.DefaultBorderShape3033+ opts.InputBorderShape = tui.DefaultBorderShape3034+ opts.HeaderBorderShape = tui.DefaultBorderShape3035+ opts.Preview.border = tui.DefaultBorderShape3036+ opts.Preview.info = true3037+ opts.InfoStyle = infoInlineRight3038+ opts.Theme.Gutter = tui.NewColorAttr()3039+ opts.Separator = nil3040+ opts.Scrollbar = nil3041+ opts.CursorLine = true3042+ default:3043+ return errors.New("unsupported style preset: " + preset)3044+ }3045+ return nil3046+}3047+3048 func validateSign(sign string, signOptName string) error {3049 if uniseg.StringWidth(sign) > 2 {3050 return fmt.Errorf("%v display width should be up to 2", signOptName)3051 }272 unmodified linesmodified:CHANGELOG.md+12 added-3 removed
1 unmodified line2 =========3 4 0.58.05 ------6+7+This version introduces three new border types, `--list-border`, `--input-border`, and `--header-border`, offering much greater flexibility for customizing the user interface.8+9+Also, fzf now offers three "style presets" for easier customization, which can be activated using the `--style=[default|minimal|full]` option.10+11+- Style presets (#4160)12+ - `--style=full`13+ - `--style=default`14+ - `--style=minimal`6-- Border and label for the list section15+- Border and label for the list section (#4148)16 - Options17 - `--list-border[=STYLE]`18 - `--list-label=LABEL`19 - `--list-label-pos=COL[:bottom]`4 unmodified lines24 - `list-label`25 - Actions26 - `change-list-label`27 - `transform-list-label`19-- Border and label for the input section (prompt line and info line)28+- Border and label for the input section (prompt line and info line) (#4154)29 - Options30 - `--input-border[=STYLE]`31 - `--input-label=LABEL`32 - `--input-label-pos=COL[:bottom]`4 unmodified lines37 - `input-label`38 - Actions39 - `change-input-label`40 - `transform-input-label`32-- Border and label for the header section41+- Border and label for the header section (#4159)42 - Options43 - `--header-border[=STYLE]`44 - `--header-label=LABEL`45 - `--header-label-pos=COL[:bottom]`2346 unmodified lines