Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow setting tcell prompt color #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fuzzyfinder.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (f *finder) _draw() {

for _, r := range f.opt.promptString {
style := tcell.StyleDefault.
Foreground(tcell.ColorBlue).
Foreground(f.opt.promptColor).
Background(tcell.ColorDefault)

f.term.SetContent(promptLinePad, maxHeight-1, r, nil, style)
Expand Down
11 changes: 11 additions & 0 deletions option.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package fuzzyfinder
import (
"context"
"sync"

"github.com/gdamore/tcell/v2"
)

type opt struct {
Expand All @@ -12,6 +14,7 @@ type opt struct {
hotReload bool
hotReloadLock sync.Locker
promptString string
promptColor tcell.Color
header string
beginAtTop bool
context context.Context
Expand All @@ -34,6 +37,7 @@ const (

var defaultOption = opt{
promptString: "> ",
promptColor: tcell.ColorBlue,
hotReloadLock: &sync.Mutex{}, // this won't resolve the race condition but avoid nil panic
}

Expand Down Expand Up @@ -109,6 +113,13 @@ func WithPromptString(s string) Option {
}
}

// WithPromptColor changes the prompt color. The default color is blue.
func WithPromptColor(c tcell.Color) Option {
return func(o *opt) {
o.promptColor = c
}
}

// withMulti enables to select multiple items by tab key.
func withMulti() Option {
return func(o *opt) {
Expand Down