mirror of
https://github.com/junegunn/fzf.git
synced 2026-07-23 00:20:38 +08:00
Set --border-label as the title of the tmux floating pane (#4853)
The pane sets the options itself before running fzf, so that they are
in place no matter how quickly the command exits, targeted at
$TMUX_PANE; the default target would resolve to the active pane of
the session's current window.
- pane-border-format is set to '#{pane_title}' so that the label is
displayed on the border when pane-border-status is enabled;
pane-border-status itself is a window option in released tmux
versions and is left alone
- When a border style is explicitly specified with --border, a popup
is used instead of a floating pane so that the fzf-drawn border is
the only border shown; give 'border-native' to force a floating pane
- 'none' and 'line' are treated as no border; fzf draws no box for
either, so the label is displayed on the native border
- Remove 'border-fzf' which is now redundant; it was never released
- The title is escaped for select-pane -T which expands format
expressions; a lone ';' is escaped as tmux would treat it as a
command separator
- The label is skipped when ANSI stripping leaves an empty string
- --border-label-pos is ignored
- Fix remain-on-exit set on the original pane instead of the floating
pane
This commit is contained in:
+6
-18
@@ -77,7 +77,7 @@ Usage: fzf [options]
|
||||
according to the other layout options (default: 10+).
|
||||
--popup[=OPTS] Start fzf in a floating pane (requires tmux 3.3+ or Zellij 0.44+)
|
||||
[center|top|bottom|left|right][,SIZE[%]][,SIZE[%]]
|
||||
[,border-native|border-fzf] (default: center,50%)
|
||||
[,border-native] (default: center,50%)
|
||||
--tmux[=OPTS] Alias for --popup
|
||||
|
||||
LAYOUT
|
||||
@@ -335,20 +335,12 @@ const (
|
||||
posNext // adjacent to the input section, on the list side
|
||||
)
|
||||
|
||||
type tmuxBorder int
|
||||
|
||||
const (
|
||||
tmuxBorderAuto tmuxBorder = iota
|
||||
tmuxBorderNative
|
||||
tmuxBorderFzf
|
||||
)
|
||||
|
||||
type tmuxOptions struct {
|
||||
width sizeSpec
|
||||
height sizeSpec
|
||||
position windowPosition
|
||||
index int
|
||||
border tmuxBorder
|
||||
border bool
|
||||
}
|
||||
|
||||
type layoutType int
|
||||
@@ -435,19 +427,15 @@ func parseTmuxOptions(arg string, index int) (*tmuxOptions, error) {
|
||||
var err error
|
||||
opts := defaultTmuxOptions(index)
|
||||
tokens := splitRegexp.Split(arg, -1)
|
||||
errorToReturn := errors.New("invalid popup option: " + arg + " (expected: [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]][,border-native|border-fzf])")
|
||||
errorToReturn := errors.New("invalid popup 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" || token == "border-fzf" {
|
||||
tokens = append(tokens[:i], tokens[i+1:]...) // cut the border option
|
||||
if token == "border-native" {
|
||||
opts.border = tmuxBorderNative
|
||||
} else {
|
||||
opts.border = tmuxBorderFzf
|
||||
}
|
||||
if token == "border-native" {
|
||||
tokens = append(tokens[:i], tokens[i+1:]...) // cut the 'border-native' option
|
||||
opts.border = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user