mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-18 00:03:39 -05:00
Add --ghost=TEXT to display a ghost text when the input is empty
This commit is contained in:
@@ -136,6 +136,7 @@ Usage: fzf [options]
|
||||
--separator=STR Draw horizontal separator on info line using the string
|
||||
(default: '─' or '-')
|
||||
--no-separator Hide info line separator
|
||||
--ghost=TEXT Ghost text to display when the input is empty
|
||||
--filepath-word Make word-wise movements respect path separators
|
||||
--input-border[=STYLE] Draw border around the input section
|
||||
[rounded|sharp|bold|block|thinblock|double|horizontal|vertical|
|
||||
@@ -574,6 +575,7 @@ type Options struct {
|
||||
InfoStyle infoStyle
|
||||
InfoPrefix string
|
||||
InfoCommand string
|
||||
Ghost string
|
||||
Separator *string
|
||||
JumpLabels string
|
||||
Prompt string
|
||||
@@ -689,6 +691,7 @@ func defaultOptions() *Options {
|
||||
ScrollOff: 3,
|
||||
FileWord: false,
|
||||
InfoStyle: infoDefault,
|
||||
Ghost: "",
|
||||
Separator: nil,
|
||||
JumpLabels: defaultJumpLabels,
|
||||
Prompt: "> ",
|
||||
@@ -2597,6 +2600,10 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
|
||||
case "--no-separator":
|
||||
nosep := ""
|
||||
opts.Separator = &nosep
|
||||
case "--ghost":
|
||||
if opts.Ghost, err = nextString("ghost text required"); err != nil {
|
||||
return err
|
||||
}
|
||||
case "--scrollbar":
|
||||
given, bar := optionalNextString()
|
||||
if given {
|
||||
|
||||
@@ -234,6 +234,7 @@ type Terminal struct {
|
||||
wrap bool
|
||||
wrapSign string
|
||||
wrapSignWidth int
|
||||
ghost string
|
||||
separator labelPrinter
|
||||
separatorLen int
|
||||
spinner []string
|
||||
@@ -847,6 +848,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
|
||||
infoCommand: opts.InfoCommand,
|
||||
infoStyle: opts.InfoStyle,
|
||||
infoPrefix: opts.InfoPrefix,
|
||||
ghost: opts.Ghost,
|
||||
separator: nil,
|
||||
spinner: makeSpinner(opts.Unicode),
|
||||
promptString: opts.Prompt,
|
||||
@@ -2359,6 +2361,11 @@ func (t *Terminal) printPrompt() {
|
||||
t.prompt()
|
||||
|
||||
before, after := t.updatePromptOffset()
|
||||
if len(before) == 0 && len(after) == 0 && len(t.ghost) > 0 {
|
||||
w.CPrint(tui.ColInput.WithAttr(tui.Dim), t.ghost)
|
||||
return
|
||||
}
|
||||
|
||||
color := tui.ColInput
|
||||
if t.paused {
|
||||
color = tui.ColDisabled
|
||||
|
||||
Reference in New Issue
Block a user