mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-01 20:52:06 -07:00
Change default pointer and marker character
* Pointer: '▌' * Marker: '▏' They will still be set to '>' if `--no-unicode` is given. Reasons: * They look okay * They work better with multi-line items (WIP)
This commit is contained in:
@@ -438,10 +438,10 @@ Do not display scrollbar. A synonym for \fB--scrollbar=''\fB
|
|||||||
Input prompt (default: '> ')
|
Input prompt (default: '> ')
|
||||||
.TP
|
.TP
|
||||||
.BI "--pointer=" "STR"
|
.BI "--pointer=" "STR"
|
||||||
Pointer to the current line (default: '>')
|
Pointer to the current line (default: '▌' or '>' depending on \fB--no-unicode\fR)
|
||||||
.TP
|
.TP
|
||||||
.BI "--marker=" "STR"
|
.BI "--marker=" "STR"
|
||||||
Multi-select marker (default: '>')
|
Multi-select marker (default: '▏' or '>' depending on \fB--no-unicode\fR)
|
||||||
.TP
|
.TP
|
||||||
.BI "--header=" "STR"
|
.BI "--header=" "STR"
|
||||||
The given string will be printed as the sticky header. The lines are displayed
|
The given string will be printed as the sticky header. The lines are displayed
|
||||||
|
@@ -83,8 +83,8 @@ const Usage = `usage: fzf [options]
|
|||||||
--scrollbar[=C1[C2]] Scrollbar character(s) (each for main and preview window)
|
--scrollbar[=C1[C2]] Scrollbar character(s) (each for main and preview window)
|
||||||
--no-scrollbar Hide scrollbar
|
--no-scrollbar Hide scrollbar
|
||||||
--prompt=STR Input prompt (default: '> ')
|
--prompt=STR Input prompt (default: '> ')
|
||||||
--pointer=STR Pointer to the current line (default: '>')
|
--pointer=STR Pointer to the current line (default: '▌' or '>')
|
||||||
--marker=STR Multi-select marker (default: '>')
|
--marker=STR Multi-select marker (default: '▏' or '>')
|
||||||
--header=STR String to print as header
|
--header=STR String to print as header
|
||||||
--header-lines=N The first N lines of the input are treated as header
|
--header-lines=N The first N lines of the input are treated as header
|
||||||
--header-first Print header before the prompt line
|
--header-first Print header before the prompt line
|
||||||
@@ -420,8 +420,8 @@ type Options struct {
|
|||||||
Separator *string
|
Separator *string
|
||||||
JumpLabels string
|
JumpLabels string
|
||||||
Prompt string
|
Prompt string
|
||||||
Pointer string
|
Pointer *string
|
||||||
Marker string
|
Marker *string
|
||||||
Query string
|
Query string
|
||||||
Select1 bool
|
Select1 bool
|
||||||
Exit0 bool
|
Exit0 bool
|
||||||
@@ -515,8 +515,8 @@ func defaultOptions() *Options {
|
|||||||
Separator: nil,
|
Separator: nil,
|
||||||
JumpLabels: defaultJumpLabels,
|
JumpLabels: defaultJumpLabels,
|
||||||
Prompt: "> ",
|
Prompt: "> ",
|
||||||
Pointer: ">",
|
Pointer: nil,
|
||||||
Marker: ">",
|
Marker: nil,
|
||||||
Query: "",
|
Query: "",
|
||||||
Select1: false,
|
Select1: false,
|
||||||
Exit0: false,
|
Exit0: false,
|
||||||
@@ -2153,13 +2153,15 @@ func parseOptions(opts *Options, allArgs []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
opts.Pointer = firstLine(str)
|
str = firstLine(str)
|
||||||
|
opts.Pointer = &str
|
||||||
case "--marker":
|
case "--marker":
|
||||||
str, err := nextString(allArgs, &i, "selected sign string required")
|
str, err := nextString(allArgs, &i, "selected sign string required")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
opts.Marker = firstLine(str)
|
str = firstLine(str)
|
||||||
|
opts.Marker = &str
|
||||||
case "--sync":
|
case "--sync":
|
||||||
opts.Sync = true
|
opts.Sync = true
|
||||||
case "--no-sync", "--async":
|
case "--no-sync", "--async":
|
||||||
@@ -2395,9 +2397,11 @@ func parseOptions(opts *Options, allArgs []string) error {
|
|||||||
} else if match, value := optString(arg, "--prompt="); match {
|
} else if match, value := optString(arg, "--prompt="); match {
|
||||||
opts.Prompt = value
|
opts.Prompt = value
|
||||||
} else if match, value := optString(arg, "--pointer="); match {
|
} else if match, value := optString(arg, "--pointer="); match {
|
||||||
opts.Pointer = firstLine(value)
|
str := firstLine(value)
|
||||||
|
opts.Pointer = &str
|
||||||
} else if match, value := optString(arg, "--marker="); match {
|
} else if match, value := optString(arg, "--marker="); match {
|
||||||
opts.Marker = firstLine(value)
|
str := firstLine(value)
|
||||||
|
opts.Marker = &str
|
||||||
} else if match, value := optString(arg, "-n", "--nth="); match {
|
} else if match, value := optString(arg, "-n", "--nth="); match {
|
||||||
if opts.Nth, err = splitNth(value); err != nil {
|
if opts.Nth, err = splitNth(value); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -2586,11 +2590,27 @@ func postProcessOptions(opts *Options) error {
|
|||||||
opts.BorderShape = tui.BorderNone
|
opts.BorderShape = tui.BorderNone
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateSign(opts.Pointer, "pointer"); err != nil {
|
if opts.Pointer == nil {
|
||||||
|
defaultPointer := "▌"
|
||||||
|
if !opts.Unicode {
|
||||||
|
defaultPointer = ">"
|
||||||
|
}
|
||||||
|
opts.Pointer = &defaultPointer
|
||||||
|
}
|
||||||
|
|
||||||
|
if opts.Marker == nil {
|
||||||
|
defaultMarker := "▏"
|
||||||
|
if !opts.Unicode {
|
||||||
|
defaultMarker = ">"
|
||||||
|
}
|
||||||
|
opts.Marker = &defaultMarker
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := validateSign(*opts.Pointer, "pointer"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateSign(opts.Marker, "marker"); err != nil {
|
if err := validateSign(*opts.Marker, "marker"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -811,8 +811,8 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
|
|||||||
lastAction: actStart,
|
lastAction: actStart,
|
||||||
lastFocus: minItem.Index()}
|
lastFocus: minItem.Index()}
|
||||||
t.prompt, t.promptLen = t.parsePrompt(opts.Prompt)
|
t.prompt, t.promptLen = t.parsePrompt(opts.Prompt)
|
||||||
t.pointer, t.pointerLen = t.processTabs([]rune(opts.Pointer), 0)
|
t.pointer, t.pointerLen = t.processTabs([]rune(*opts.Pointer), 0)
|
||||||
t.marker, t.markerLen = t.processTabs([]rune(opts.Marker), 0)
|
t.marker, t.markerLen = t.processTabs([]rune(*opts.Marker), 0)
|
||||||
// Pre-calculated empty pointer and marker signs
|
// Pre-calculated empty pointer and marker signs
|
||||||
t.pointerEmpty = strings.Repeat(" ", t.pointerLen)
|
t.pointerEmpty = strings.Repeat(" ", t.pointerLen)
|
||||||
t.markerEmpty = strings.Repeat(" ", t.markerLen)
|
t.markerEmpty = strings.Repeat(" ", t.markerLen)
|
||||||
|
@@ -24,7 +24,7 @@ DEFAULT_TIMEOUT = 10
|
|||||||
FILE = File.expand_path(__FILE__)
|
FILE = File.expand_path(__FILE__)
|
||||||
BASE = File.expand_path('..', __dir__)
|
BASE = File.expand_path('..', __dir__)
|
||||||
Dir.chdir(BASE)
|
Dir.chdir(BASE)
|
||||||
FZF = "FZF_DEFAULT_OPTS=--no-scrollbar FZF_DEFAULT_COMMAND= #{BASE}/bin/fzf"
|
FZF = "FZF_DEFAULT_OPTS=\"--no-scrollbar --pointer \\> --marker \\>\" FZF_DEFAULT_COMMAND= #{BASE}/bin/fzf"
|
||||||
|
|
||||||
def wait
|
def wait
|
||||||
since = Time.now
|
since = Time.now
|
||||||
@@ -66,7 +66,7 @@ class Shell
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fish
|
def fish
|
||||||
"unset #{UNSETS.join(' ')}; FZF_DEFAULT_OPTS=--no-scrollbar fish_history= fish"
|
"unset #{UNSETS.join(' ')}; FZF_DEFAULT_OPTS=\"--no-scrollbar --pointer '>' --marker '>'\" fish_history= fish"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -3397,12 +3397,16 @@ module TestShell
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_ctrl_r_multiline
|
def test_ctrl_r_multiline
|
||||||
|
# NOTE: Current bash implementation shows an extra new line if there's
|
||||||
|
# only enty in the history
|
||||||
|
tmux.send_keys ':', :Enter
|
||||||
tmux.send_keys 'echo "foo', :Enter, 'bar"', :Enter
|
tmux.send_keys 'echo "foo', :Enter, 'bar"', :Enter
|
||||||
tmux.until { |lines| assert_equal %w[foo bar], lines[-2..] }
|
tmux.until { |lines| assert_equal %w[foo bar], lines[-2..] }
|
||||||
tmux.prepare
|
tmux.prepare
|
||||||
tmux.send_keys 'C-r'
|
tmux.send_keys 'C-r'
|
||||||
tmux.until { |lines| assert_equal '>', lines[-1] }
|
tmux.until { |lines| assert_equal '>', lines[-1] }
|
||||||
tmux.send_keys 'foo bar'
|
tmux.send_keys 'foo bar'
|
||||||
|
tmux.until { |lines| assert lines[-4]&.match?(/"foo/) } unless shell == :zsh
|
||||||
tmux.until { |lines| assert lines[-3]&.match?(/bar"␊?/) }
|
tmux.until { |lines| assert lines[-3]&.match?(/bar"␊?/) }
|
||||||
tmux.send_keys :Enter
|
tmux.send_keys :Enter
|
||||||
tmux.until { |lines| assert lines[-1]&.match?(/bar"␊?/) }
|
tmux.until { |lines| assert lines[-1]&.match?(/bar"␊?/) }
|
||||||
@@ -3742,7 +3746,7 @@ unset <%= UNSETS.join(' ') %>
|
|||||||
unset $(env | sed -n /^_fzf_orig/s/=.*//p)
|
unset $(env | sed -n /^_fzf_orig/s/=.*//p)
|
||||||
unset $(declare -F | sed -n "/_fzf/s/.*-f //p")
|
unset $(declare -F | sed -n "/_fzf/s/.*-f //p")
|
||||||
|
|
||||||
export FZF_DEFAULT_OPTS=--no-scrollbar
|
export FZF_DEFAULT_OPTS="--no-scrollbar --pointer '>' --marker '>'"
|
||||||
|
|
||||||
# Setup fzf
|
# Setup fzf
|
||||||
# ---------
|
# ---------
|
||||||
|
Reference in New Issue
Block a user