m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-13 22:03:47 -05:00

Make --color attributes mergeable

So you can override the colors and still have the text attributes

    # Default colors and attributes
    fzf

    export FZF_DEFAULT_OPTS='--color hl👎underline,hl+👎underline:reverse'

    # Default colors with underline+reverse attributes
    fzf

    # Different colors with underline+reverse attributes
    fzf --color hl:176,hl+:177

Related: https://github.com/junegunn/fzf.vim/issues/1197#issuecomment-739804363
This commit is contained in:
Junegunn Choi
2020-12-07 19:07:17 +09:00
parent 00a3610331
commit e0a22e76f8

View File

@@ -644,7 +644,7 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) *tui.ColorTheme {
fail() fail()
} }
cattr := tui.NewColorAttr() mergeAttr := func(cattr *tui.ColorAttr) {
for _, component := range components[1:] { for _, component := range components[1:] {
switch component { switch component {
case "regular": case "regular":
@@ -674,41 +674,42 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) *tui.ColorTheme {
} }
} }
} }
}
switch components[0] { switch components[0] {
case "input": case "input":
theme.Input = cattr mergeAttr(&theme.Input)
case "fg": case "fg":
theme.Fg = cattr mergeAttr(&theme.Fg)
case "bg": case "bg":
theme.Bg = cattr mergeAttr(&theme.Bg)
case "preview-fg": case "preview-fg":
theme.PreviewFg = cattr mergeAttr(&theme.PreviewFg)
case "preview-bg": case "preview-bg":
theme.PreviewBg = cattr mergeAttr(&theme.PreviewBg)
case "fg+": case "fg+":
theme.Current = cattr mergeAttr(&theme.Current)
case "bg+": case "bg+":
theme.DarkBg = cattr mergeAttr(&theme.DarkBg)
case "gutter": case "gutter":
theme.Gutter = cattr mergeAttr(&theme.Gutter)
case "hl": case "hl":
theme.Match = cattr mergeAttr(&theme.Match)
case "hl+": case "hl+":
theme.CurrentMatch = cattr mergeAttr(&theme.CurrentMatch)
case "border": case "border":
theme.Border = cattr mergeAttr(&theme.Border)
case "prompt": case "prompt":
theme.Prompt = cattr mergeAttr(&theme.Prompt)
case "spinner": case "spinner":
theme.Spinner = cattr mergeAttr(&theme.Spinner)
case "info": case "info":
theme.Info = cattr mergeAttr(&theme.Info)
case "pointer": case "pointer":
theme.Cursor = cattr mergeAttr(&theme.Cursor)
case "marker": case "marker":
theme.Selected = cattr mergeAttr(&theme.Selected)
case "header": case "header":
theme.Header = cattr mergeAttr(&theme.Header)
default: default:
fail() fail()
} }