From a4db8bd7b550c010b99f26337d841395e319890a Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 20 Jan 2025 00:49:08 +0900 Subject: 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 --- src/tui/tui.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/tui/tui.go') 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) -- cgit v1.2.3