mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 11:29:01 +00: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:
parent
00a3610331
commit
e0a22e76f8
@ -644,71 +644,72 @@ 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":
|
||||||
cattr.Attr = tui.AttrRegular
|
cattr.Attr = tui.AttrRegular
|
||||||
case "bold", "strong":
|
case "bold", "strong":
|
||||||
cattr.Attr |= tui.Bold
|
cattr.Attr |= tui.Bold
|
||||||
case "dim":
|
case "dim":
|
||||||
cattr.Attr |= tui.Dim
|
cattr.Attr |= tui.Dim
|
||||||
case "italic":
|
case "italic":
|
||||||
cattr.Attr |= tui.Italic
|
cattr.Attr |= tui.Italic
|
||||||
case "underline":
|
case "underline":
|
||||||
cattr.Attr |= tui.Underline
|
cattr.Attr |= tui.Underline
|
||||||
case "blink":
|
case "blink":
|
||||||
cattr.Attr |= tui.Blink
|
cattr.Attr |= tui.Blink
|
||||||
case "reverse":
|
case "reverse":
|
||||||
cattr.Attr |= tui.Reverse
|
cattr.Attr |= tui.Reverse
|
||||||
case "":
|
case "":
|
||||||
default:
|
default:
|
||||||
if rrggbb.MatchString(component) {
|
if rrggbb.MatchString(component) {
|
||||||
cattr.Color = tui.HexToColor(component)
|
cattr.Color = tui.HexToColor(component)
|
||||||
} else {
|
} else {
|
||||||
ansi32, err := strconv.Atoi(component)
|
ansi32, err := strconv.Atoi(component)
|
||||||
if err != nil || ansi32 < -1 || ansi32 > 255 {
|
if err != nil || ansi32 < -1 || ansi32 > 255 {
|
||||||
fail()
|
fail()
|
||||||
|
}
|
||||||
|
cattr.Color = tui.Color(ansi32)
|
||||||
}
|
}
|
||||||
cattr.Color = tui.Color(ansi32)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user