diff options
| author | Andreas Auernhammer <github@aead.dev> | 2025-01-04 10:30:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-04 18:30:32 +0900 |
| commit | 120cd7f25a8209297f15b0a79b36c44b30e641fb (patch) | |
| tree | 60e91ffcaeca4fcae11a2b2dc76b1533659493b2 /src | |
| parent | fb3bf6c9841d849ec459fc6b251b4aa0f16d8038 (diff) | |
| download | fzf-120cd7f25a8209297f15b0a79b36c44b30e641fb.tar.gz | |
Add `border-native` option to `--tmux` flag (#4157)
This commit adds the `border-native` resulting in the following:
```
--tmux[=[center|top|bottom|left|right][,SIZE[%]][,SIZE[%]][,border-native]]
```
By default, when not specified, the `-B` flag is passed to the
`tmux popup-window` command such that no border is drawn around
the tmux popup window.
When the `border-native` option is present, the `-B` flag is omitted
and the popup window is drawn using the border style configured in
the tmux config file.
Fixes #4156
Signed-off-by: Andreas Auernhammer <github@aead.dev>
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/options.go | 15 | ||||
| -rw-r--r-- | src/tmux.go | 16 |
2 files changed, 23 insertions, 8 deletions
diff --git a/src/options.go b/src/options.go index 0b6250f3..a3096d11 100644 --- a/src/options.go +++ b/src/options.go @@ -77,7 +77,7 @@ Usage: fzf [options] (default: 10) --tmux[=OPTS] Start fzf in a tmux popup (requires tmux 3.3+) [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]] - (default: center,50%) + [,border-native] (default: center,50%) --layout=LAYOUT Choose layout: [default|reverse|reverse-list] --border[=STYLE] Draw border around the finder [rounded|sharp|bold|block|thinblock|double|horizontal|vertical| @@ -254,6 +254,7 @@ type tmuxOptions struct { height sizeSpec position windowPosition index int + border bool } type layoutType int @@ -316,11 +317,19 @@ func parseTmuxOptions(arg string, index int) (*tmuxOptions, error) { var err error opts := defaultTmuxOptions(index) tokens := splitRegexp.Split(arg, -1) - errorToReturn := errors.New("invalid tmux option: " + arg + " (expected: [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]])") - if len(tokens) == 0 || len(tokens) > 3 { + errorToReturn := errors.New("invalid tmux option: " + arg + " (expected: [center|top|bottom|left|right][,SIZE[%]][,SIZE[%][,border-native]])") + if len(tokens) == 0 || len(tokens) > 4 { return nil, errorToReturn } + for i, token := range tokens { + if token == "border-native" { + tokens = append(tokens[:i], tokens[i+1:]...) // cut the 'border-native' option + opts.border = true + break + } + } + // Defaults to 'center' switch tokens[0] { case "top", "up": diff --git a/src/tmux.go b/src/tmux.go index b2315dcd..e459000a 100644 --- a/src/tmux.go +++ b/src/tmux.go @@ -9,13 +9,16 @@ import ( func runTmux(args []string, opts *Options) (int, error) { // Prepare arguments - fzf := args[0] - args = append([]string{"--bind=ctrl-z:ignore"}, args[1:]...) - if opts.BorderShape == tui.BorderUndefined { + fzf, rest := args[0], args[1:] + args = []string{"--bind=ctrl-z:ignore"} + if !opts.Tmux.border && opts.BorderShape == tui.BorderUndefined { args = append(args, "--border") } + if opts.Tmux.border && opts.Margin == defaultMargin() { + args = append(args, "--margin=0,1") + } argStr := escapeSingleQuote(fzf) - for _, arg := range args { + for _, arg := range append(args, rest...) { argStr += " " + escapeSingleQuote(arg) } argStr += ` --no-tmux --no-height` @@ -33,7 +36,10 @@ func runTmux(args []string, opts *Options) (int, error) { // M Both The mouse position // W Both The window position on the status line // S -y The line above or below the status line - tmuxArgs := []string{"display-popup", "-E", "-B", "-d", dir} + tmuxArgs := []string{"display-popup", "-E", "-d", dir} + if !opts.Tmux.border { + tmuxArgs = append(tmuxArgs, "-B") + } switch opts.Tmux.position { case posUp: tmuxArgs = append(tmuxArgs, "-xC", "-y0") |
