mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-06 15:12:05 -07:00
Allow setting border styles at once with --style full:STYLE
This commit is contained in:
@@ -56,7 +56,7 @@ Usage: fzf [options]
|
||||
--sync Synchronous search for multi-staged filtering
|
||||
|
||||
GLOBAL STYLE
|
||||
--style=PRESET Apply a style preset [default|minimal|full]
|
||||
--style=PRESET Apply a style preset [default|minimal|full[:BORDER_STYLE]
|
||||
--color=COLSPEC Base scheme (dark|light|16|bw) and/or custom colors
|
||||
--no-color Disable colors
|
||||
--no-bold Do not use bold text
|
||||
@@ -214,6 +214,9 @@ Usage: fzf [options]
|
||||
|
||||
`
|
||||
|
||||
// Can be changed by --style
|
||||
var defaultBorderShape tui.BorderShape = tui.DefaultBorderShape
|
||||
|
||||
const defaultInfoPrefix = " < "
|
||||
|
||||
// Case denotes case-sensitivity of search
|
||||
@@ -628,7 +631,7 @@ func filterNonEmpty(input []string) []string {
|
||||
}
|
||||
|
||||
func defaultPreviewOpts(command string) previewOpts {
|
||||
return previewOpts{command, posRight, sizeSpec{50, true}, "", false, false, false, false, true, tui.DefaultBorderShape, 0, 0, nil}
|
||||
return previewOpts{command, posRight, sizeSpec{50, true}, "", false, false, false, false, true, defaultBorderShape, 0, 0, nil}
|
||||
}
|
||||
|
||||
func defaultOptions() *Options {
|
||||
@@ -842,7 +845,7 @@ func parseBorder(str string, optional bool, allowLine bool) (tui.BorderShape, er
|
||||
return tui.BorderNone, nil
|
||||
}
|
||||
if optional && str == "" {
|
||||
return tui.DefaultBorderShape, nil
|
||||
return defaultBorderShape, nil
|
||||
}
|
||||
return tui.BorderNone, errors.New("invalid border style (expected: rounded|sharp|bold|block|thinblock|double|horizontal|vertical|top|bottom|left|right|none)")
|
||||
}
|
||||
@@ -2729,7 +2732,7 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
|
||||
return err
|
||||
}
|
||||
case "--style":
|
||||
preset, err := nextString("preset name required: [default|minimal|full]")
|
||||
preset, err := nextString("preset name required: [default|minimal|full[:BORDER_STYLE]]")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -2882,12 +2885,15 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
|
||||
}
|
||||
|
||||
func applyPreset(opts *Options, preset string) error {
|
||||
// Reset to the platform default
|
||||
defaultBorderShape = tui.DefaultBorderShape
|
||||
|
||||
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.border = defaultBorderShape
|
||||
opts.Preview.info = true
|
||||
opts.InfoStyle = infoDefault
|
||||
opts.Theme.Gutter = tui.NewColorAttr()
|
||||
@@ -2906,19 +2912,29 @@ func applyPreset(opts *Options, preset string) error {
|
||||
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
|
||||
default:
|
||||
tokens := strings.SplitN(preset, ":", 2)
|
||||
if tokens[0] != "full" {
|
||||
return errors.New("unsupported style preset: " + preset)
|
||||
}
|
||||
if len(tokens) == 2 && len(tokens[1]) > 0 {
|
||||
var err error
|
||||
defaultBorderShape, err = parseBorder(tokens[1], false, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
opts.ListBorderShape = defaultBorderShape
|
||||
opts.InputBorderShape = defaultBorderShape
|
||||
opts.HeaderBorderShape = defaultBorderShape
|
||||
opts.Preview.border = 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
|
||||
}
|
||||
|
Reference in New Issue
Block a user