Skip to content
Myr

Make --color attributes mergeable

Before adoption: this commit came in with the history the project adopted, so no landing records it.

So you can override the colors and still have the text attributes # Default colors and attributes fzf export FZF_DEFAULT_OPTS='--color hl:-1:underline,hl+:-1:underline:reverse' # Default colors with underline+reverse attributes fzf # Different colors with underline+reverse attributes fzf --color hl:176,hl+:177

authored by Junegunn Choi · committed by Junegunn Choi · parent 00a3610 · Browse files · 1 file+44 added−43 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Related: https://github.com/junegunn/fzf.vim/issues/1197#issuecomment-739804363

Diff stats

1 file+44 added−43 removed

  • other:+44 added−43 removed

1 file+44 added−43 removed

modified:src/options.go+44 added-43 removed
642 unmodified lines
643 if len(components) < 2 {644 fail()645 }646647 cattr := tui.NewColorAttr()648 for _, component := range components[1:] {649 switch component {650 case "regular":651 cattr.Attr = tui.AttrRegular652 case "bold", "strong":653 cattr.Attr |= tui.Bold654 case "dim":655 cattr.Attr |= tui.Dim656 case "italic":657 cattr.Attr |= tui.Italic658 case "underline":659 cattr.Attr |= tui.Underline660 case "blink":661 cattr.Attr |= tui.Blink662 case "reverse":663 cattr.Attr |= tui.Reverse664 case "":665 default:666 if rrggbb.MatchString(component) {667 cattr.Color = tui.HexToColor(component)668 } else {669 ansi32, err := strconv.Atoi(component)670 if err != nil || ansi32 < -1 || ansi32 > 255 {671 fail()647 mergeAttr := func(cattr *tui.ColorAttr) {648 for _, component := range components[1:] {649 switch component {650 case "regular":651 cattr.Attr = tui.AttrRegular652 case "bold", "strong":653 cattr.Attr |= tui.Bold654 case "dim":655 cattr.Attr |= tui.Dim656 case "italic":657 cattr.Attr |= tui.Italic658 case "underline":659 cattr.Attr |= tui.Underline660 case "blink":661 cattr.Attr |= tui.Blink662 case "reverse":663 cattr.Attr |= tui.Reverse664 case "":665 default:666 if rrggbb.MatchString(component) {667 cattr.Color = tui.HexToColor(component)668 } else {669 ansi32, err := strconv.Atoi(component)670 if err != nil || ansi32 < -1 || ansi32 > 255 {671 fail()672 }673 cattr.Color = tui.Color(ansi32)674 }673 cattr.Color = tui.Color(ansi32)675 }676 }677 }678 switch components[0] {679 case "input":679 theme.Input = cattr680 mergeAttr(&theme.Input)681 case "fg":681 theme.Fg = cattr682 mergeAttr(&theme.Fg)683 case "bg":683 theme.Bg = cattr684 mergeAttr(&theme.Bg)685 case "preview-fg":685 theme.PreviewFg = cattr686 mergeAttr(&theme.PreviewFg)687 case "preview-bg":687 theme.PreviewBg = cattr688 mergeAttr(&theme.PreviewBg)689 case "fg+":689 theme.Current = cattr690 mergeAttr(&theme.Current)691 case "bg+":691 theme.DarkBg = cattr692 mergeAttr(&theme.DarkBg)693 case "gutter":693 theme.Gutter = cattr694 mergeAttr(&theme.Gutter)695 case "hl":695 theme.Match = cattr696 mergeAttr(&theme.Match)697 case "hl+":697 theme.CurrentMatch = cattr698 mergeAttr(&theme.CurrentMatch)699 case "border":699 theme.Border = cattr700 mergeAttr(&theme.Border)701 case "prompt":701 theme.Prompt = cattr702 mergeAttr(&theme.Prompt)703 case "spinner":703 theme.Spinner = cattr704 mergeAttr(&theme.Spinner)705 case "info":705 theme.Info = cattr706 mergeAttr(&theme.Info)707 case "pointer":707 theme.Cursor = cattr708 mergeAttr(&theme.Cursor)709 case "marker":709 theme.Selected = cattr710 mergeAttr(&theme.Selected)711 case "header":711 theme.Header = cattr712 mergeAttr(&theme.Header)713 default:714 fail()715 }716 }
863 unmodified lines