mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-02-08 23:18:32 +00:00
Allow setting border styles at once with --style full:STYLE
This commit is contained in:
parent
1313510890
commit
0d5aebb806
@ -17,7 +17,7 @@ Also, fzf now offers "style presets" for quick customization, which can be activ
|
|||||||
| `minimal` | <img src="https://raw.githubusercontent.com/junegunn/i/master/fzf-style-minimal.png"/> |
|
| `minimal` | <img src="https://raw.githubusercontent.com/junegunn/i/master/fzf-style-minimal.png"/> |
|
||||||
|
|
||||||
- Style presets (#4160)
|
- Style presets (#4160)
|
||||||
- `--style=full`
|
- `--style=full[:BORDER_STYLE]`
|
||||||
- `--style=default`
|
- `--style=default`
|
||||||
- `--style=minimal`
|
- `--style=minimal`
|
||||||
- Border and label for the list section (#4148)
|
- Border and label for the list section (#4148)
|
||||||
|
@ -189,7 +189,7 @@ e.g. \fB# Avoid rendering both fzf instances at the same time
|
|||||||
.SS GLOBAL STYLE
|
.SS GLOBAL STYLE
|
||||||
.TP
|
.TP
|
||||||
.BI "\-\-style=" "PRESET"
|
.BI "\-\-style=" "PRESET"
|
||||||
Apply a style preset [default|minimal|full]
|
Apply a style preset [default|minimal|full[:BORDER_STYLE]]
|
||||||
.TP
|
.TP
|
||||||
.BI "\-\-color=" "[BASE_SCHEME][,COLOR_NAME[:ANSI_COLOR][:ANSI_ATTRIBUTES]]..."
|
.BI "\-\-color=" "[BASE_SCHEME][,COLOR_NAME[:ANSI_COLOR][:ANSI_ATTRIBUTES]]..."
|
||||||
Color configuration. The name of the base color scheme is followed by custom
|
Color configuration. The name of the base color scheme is followed by custom
|
||||||
|
@ -56,7 +56,7 @@ Usage: fzf [options]
|
|||||||
--sync Synchronous search for multi-staged filtering
|
--sync Synchronous search for multi-staged filtering
|
||||||
|
|
||||||
GLOBAL STYLE
|
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
|
--color=COLSPEC Base scheme (dark|light|16|bw) and/or custom colors
|
||||||
--no-color Disable colors
|
--no-color Disable colors
|
||||||
--no-bold Do not use bold text
|
--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 = " < "
|
const defaultInfoPrefix = " < "
|
||||||
|
|
||||||
// Case denotes case-sensitivity of search
|
// Case denotes case-sensitivity of search
|
||||||
@ -628,7 +631,7 @@ func filterNonEmpty(input []string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func defaultPreviewOpts(command string) previewOpts {
|
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 {
|
func defaultOptions() *Options {
|
||||||
@ -842,7 +845,7 @@ func parseBorder(str string, optional bool, allowLine bool) (tui.BorderShape, er
|
|||||||
return tui.BorderNone, nil
|
return tui.BorderNone, nil
|
||||||
}
|
}
|
||||||
if optional && str == "" {
|
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)")
|
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
|
return err
|
||||||
}
|
}
|
||||||
case "--style":
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -2882,12 +2885,15 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func applyPreset(opts *Options, preset string) error {
|
func applyPreset(opts *Options, preset string) error {
|
||||||
|
// Reset to the platform default
|
||||||
|
defaultBorderShape = tui.DefaultBorderShape
|
||||||
|
|
||||||
switch strings.ToLower(preset) {
|
switch strings.ToLower(preset) {
|
||||||
case "default":
|
case "default":
|
||||||
opts.ListBorderShape = tui.BorderUndefined
|
opts.ListBorderShape = tui.BorderUndefined
|
||||||
opts.InputBorderShape = tui.BorderUndefined
|
opts.InputBorderShape = tui.BorderUndefined
|
||||||
opts.HeaderBorderShape = tui.BorderUndefined
|
opts.HeaderBorderShape = tui.BorderUndefined
|
||||||
opts.Preview.border = tui.DefaultBorderShape
|
opts.Preview.border = defaultBorderShape
|
||||||
opts.Preview.info = true
|
opts.Preview.info = true
|
||||||
opts.InfoStyle = infoDefault
|
opts.InfoStyle = infoDefault
|
||||||
opts.Theme.Gutter = tui.NewColorAttr()
|
opts.Theme.Gutter = tui.NewColorAttr()
|
||||||
@ -2906,19 +2912,29 @@ func applyPreset(opts *Options, preset string) error {
|
|||||||
opts.Separator = &empty
|
opts.Separator = &empty
|
||||||
opts.Scrollbar = &empty
|
opts.Scrollbar = &empty
|
||||||
opts.CursorLine = false
|
opts.CursorLine = false
|
||||||
case "full":
|
default:
|
||||||
opts.ListBorderShape = tui.DefaultBorderShape
|
tokens := strings.SplitN(preset, ":", 2)
|
||||||
opts.InputBorderShape = tui.DefaultBorderShape
|
if tokens[0] != "full" {
|
||||||
opts.HeaderBorderShape = tui.DefaultBorderShape
|
return errors.New("unsupported style preset: " + preset)
|
||||||
opts.Preview.border = tui.DefaultBorderShape
|
}
|
||||||
|
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.Preview.info = true
|
||||||
opts.InfoStyle = infoInlineRight
|
opts.InfoStyle = infoInlineRight
|
||||||
opts.Theme.Gutter = tui.NewColorAttr()
|
opts.Theme.Gutter = tui.NewColorAttr()
|
||||||
opts.Separator = nil
|
opts.Separator = nil
|
||||||
opts.Scrollbar = nil
|
opts.Scrollbar = nil
|
||||||
opts.CursorLine = true
|
opts.CursorLine = true
|
||||||
default:
|
|
||||||
return errors.New("unsupported style preset: " + preset)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,9 @@ func runTmux(args []string, opts *Options) (int, error) {
|
|||||||
fzf, rest := args[0], args[1:]
|
fzf, rest := args[0], args[1:]
|
||||||
args = []string{"--bind=ctrl-z:ignore"}
|
args = []string{"--bind=ctrl-z:ignore"}
|
||||||
if !opts.Tmux.border && opts.BorderShape == tui.BorderUndefined {
|
if !opts.Tmux.border && opts.BorderShape == tui.BorderUndefined {
|
||||||
args = append(args, "--border")
|
// We append --border option at the end, because `--style=full:STYLE`
|
||||||
|
// may have changed the default border style.
|
||||||
|
rest = append(rest, "--border")
|
||||||
}
|
}
|
||||||
if opts.Tmux.border && opts.Margin == defaultMargin() {
|
if opts.Tmux.border && opts.Margin == defaultMargin() {
|
||||||
args = append(args, "--margin=0,1")
|
args = append(args, "--margin=0,1")
|
||||||
|
@ -3719,6 +3719,24 @@ class TestGoFZF < TestBase
|
|||||||
tmux.until { assert_block(block, _1) }
|
tmux.until { assert_block(block, _1) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_style_full_adaptive_height_double
|
||||||
|
tmux.send_keys %(seq 1| #{FZF} --style=full:double --border --height=~100% --header-lines=1 --info=default), :Enter
|
||||||
|
block = <<~BLOCK
|
||||||
|
╔══════════
|
||||||
|
║ ╔════════
|
||||||
|
║ ╚════════
|
||||||
|
║ ╔════════
|
||||||
|
║ ║ 1
|
||||||
|
║ ╚════════
|
||||||
|
║ ╔════════
|
||||||
|
║ ║ 0/0
|
||||||
|
║ ║ >
|
||||||
|
║ ╚════════
|
||||||
|
╚══════════
|
||||||
|
BLOCK
|
||||||
|
tmux.until { assert_block(block, _1) }
|
||||||
|
end
|
||||||
|
|
||||||
def test_change_nth
|
def test_change_nth
|
||||||
input = [
|
input = [
|
||||||
*[''] * 1000,
|
*[''] * 1000,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user