diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2025-01-20 00:49:08 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2025-01-20 01:02:58 +0900 |
| commit | a4db8bd7b550c010b99f26337d841395e319890a (patch) | |
| tree | 89f4ca038fa6c5a8d599133413852e9581e5ea02 /src/tui/tui.go | |
| parent | f1c1b02d77a9d36cc5195a11ec2e162d829ddb9d (diff) | |
| download | fzf-a4db8bd7b550c010b99f26337d841395e319890a.tar.gz | |
Make 'current-fg' inherit from 'fg' to simplify configuration
If you do not want 'current-fg' to inherit attributes of 'fg', prefix it
with 'regular:' to reset them.
# italic and underline
fzf --color fg:italic,current-fg:underline
# only underline
fzf --color fg:italic,current-fg:regular:underline
Diffstat (limited to 'src/tui/tui.go')
| -rw-r--r-- | src/tui/tui.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/tui/tui.go b/src/tui/tui.go index 212a1bed..58c1bec5 100644 --- a/src/tui/tui.go +++ b/src/tui/tui.go @@ -213,6 +213,16 @@ func NewColorAttr() ColorAttr { return ColorAttr{Color: colUndefined, Attr: AttrUndefined} } +func (a ColorAttr) Merge(other ColorAttr) ColorAttr { + if other.Color != colUndefined { + a.Color = other.Color + } + if other.Attr != AttrUndefined { + a.Attr = a.Attr.Merge(other.Attr) + } + return a +} + const ( colUndefined Color = -2 colDefault Color = -1 @@ -904,7 +914,9 @@ func InitTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool, hasInp theme.DarkBg = o(baseTheme.DarkBg, theme.DarkBg) theme.Prompt = o(baseTheme.Prompt, theme.Prompt) theme.Match = o(baseTheme.Match, theme.Match) - theme.Current = o(baseTheme.Current, theme.Current) + // Inherit from 'fg', so that we don't have to write 'current-fg:dim' + // e.g. fzf --delimiter / --nth -1 --color fg:dim,nth:regular + theme.Current = theme.Fg.Merge(o(baseTheme.Current, theme.Current)) theme.CurrentMatch = o(baseTheme.CurrentMatch, theme.CurrentMatch) theme.Spinner = o(baseTheme.Spinner, theme.Spinner) theme.Info = o(baseTheme.Info, theme.Info) |
