diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2025-01-06 02:10:44 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2025-01-06 02:10:44 +0900 |
| commit | 5ae60e2e806adba1652bec64a62caa473004d7ed (patch) | |
| tree | 5aa2c889a85d656ccc5a0f77d149534a7637a76e /src | |
| parent | 0e0b86834294e1befb9e1ce16239230aa40d1add (diff) | |
| download | fzf-5ae60e2e806adba1652bec64a62caa473004d7ed.tar.gz | |
Add style presets: --style=[default|minimal|full]
Close #4160
Diffstat (limited to 'src')
| -rw-r--r-- | src/options.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/options.go b/src/options.go index 7db7418b..2b1425fc 100644 --- a/src/options.go +++ b/src/options.go @@ -67,6 +67,7 @@ Usage: fzf [options] --jump-labels=CHARS Label characters for jump mode Layout + --style=PRESET Apply a style preset [default|minimal|full] --height=[~]HEIGHT[%] Display fzf window below the cursor with the given height instead of using fullscreen. A negative value is calculated as the terminal height @@ -2646,6 +2647,14 @@ func parseOptions(index *int, opts *Options, allArgs []string) error { if err := parseLabelPosition(&opts.PreviewLabel, pos); err != nil { return err } + case "--style": + preset, err := nextString(allArgs, &i, "preset name required: [default|minimal|full]") + if err != nil { + return err + } + if err := applyPreset(opts, preset); err != nil { + return err + } case "--no-unicode": opts.Unicode = false case "--unicode": @@ -2742,6 +2751,10 @@ func parseOptions(index *int, opts *Options, allArgs []string) error { if opts.Tmux, err = parseTmuxOptions(value, index); err != nil { return err } + } else if match, value := optString(arg, "--style="); match { + if err := applyPreset(opts, value); err != nil { + return err + } } else if match, value := optString(arg, "--scheme="); match { opts.Scheme = strings.ToLower(value) } else if match, value := optString(arg, "-q", "--query="); match { @@ -2990,6 +3003,48 @@ func parseOptions(index *int, opts *Options, allArgs []string) error { return err } +func applyPreset(opts *Options, preset string) error { + switch strings.ToLower(preset) { + case "default": + opts.ListBorderShape = tui.BorderUndefined + opts.InputBorderShape = tui.BorderUndefined + opts.HeaderBorderShape = tui.BorderUndefined + opts.Preview.border = tui.DefaultBorderShape + opts.Preview.info = true + opts.InfoStyle = infoDefault + opts.Theme.Gutter = tui.NewColorAttr() + opts.Separator = nil + opts.Scrollbar = nil + opts.CursorLine = false + case "minimal": + opts.ListBorderShape = tui.BorderUndefined + opts.InputBorderShape = tui.BorderUndefined + opts.HeaderBorderShape = tui.BorderUndefined + opts.Preview.border = tui.BorderLine + opts.Preview.info = false + opts.InfoStyle = infoDefault + opts.Theme.Gutter = tui.ColorAttr{Color: -1, Attr: 0} + empty := "" + opts.Separator = &empty + opts.Scrollbar = &empty + opts.CursorLine = false + case "full": + opts.ListBorderShape = tui.DefaultBorderShape + opts.InputBorderShape = tui.DefaultBorderShape + opts.HeaderBorderShape = tui.DefaultBorderShape + opts.Preview.border = tui.DefaultBorderShape + opts.Preview.info = true + opts.InfoStyle = infoInlineRight + opts.Theme.Gutter = tui.NewColorAttr() + opts.Separator = nil + opts.Scrollbar = nil + opts.CursorLine = true + default: + return errors.New("unsupported style preset: " + preset) + } + return nil +} + func validateSign(sign string, signOptName string) error { if uniseg.StringWidth(sign) > 2 { return fmt.Errorf("%v display width should be up to 2", signOptName) |
