Skip to content
Myr

Change how hl:-1 or hl+:-1 is applied to text with background color

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

authored by Junegunn Choi · committed by Junegunn Choi · parent 052d17e · Browse files · 2 files+22 added−1 removed
This commit

State

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

Diff stats

2 files+22 added−1 removed

  • other:+22 added−1 removed

2 files+22 added−1 removed

modified:src/tui/tui.go+9 added
122 unmodified lines
123)124125type Color int32126127func (c Color) IsDefault() bool {128 return c == colDefault129}130131func (c Color) is24() bool {132 return c > 0 && (c&(1<<24)) > 0133}134
58 unmodified lines
193func (p ColorPair) Attr() Attr {194 return p.attr195}196197func (p ColorPair) HasBg() bool {198 return p.attr&Reverse == 0 && p.bg != colDefault ||199 p.attr&Reverse > 0 && p.fg != colDefault200}201202func (p ColorPair) merge(other ColorPair, except Color) ColorPair {203 dup := p204 dup.attr = dup.attr.Merge(other.attr)205 if other.fg != except {
393 unmodified lines
modified:src/result.go+13 added-1 removed
158 unmodified lines
159 if curr < 0 {160 color := colMatch161 if curr < -1 && theme.Colored {162 origColor := ansiToColorPair(itemColors[-curr-2], colMatch)163 // hl or hl+ only sets the foreground color, so colMatch is the164 // combination of either [hl and bg] or [hl+ and bg+].165 //166 // If the original text already has background color, and the167 // forground color of colMatch is -1, we shouldn't only apply the168 // background color of colMatch.169 // e.g. echo -e "\x1b[32;7mfoo\x1b[mbar" | fzf --ansi --color bg+:1,hl+:-1:underline170 // echo -e "\x1b[42mfoo\x1b[mbar" | fzf --ansi --color bg+:1,hl+:-1:underline171 if color.Fg().IsDefault() && origColor.HasBg() {172 color = origColor173 } else {163 color = origColor.MergeNonDefault(color)174 color = origColor.MergeNonDefault(color)175 }176 }177 colors = append(colors, colorOffset{178 offset: [2]int32{int32(start), int32(idx)}, color: color})179 } else {
64 unmodified lines