m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-16 23:33:39 -05:00

Set foreground color without affecting background

Close #712
This commit is contained in:
Junegunn Choi
2016-10-21 19:35:59 +09:00
parent cfdb00b971
commit 0a8d2996dc
6 changed files with 73 additions and 76 deletions

View File

@@ -92,13 +92,13 @@ func minRank() rank {
return rank{index: 0, points: [4]uint16{math.MaxUint16, 0, 0, 0}}
}
func (result *Result) colorOffsets(matchOffsets []Offset, color int, attr curses.Attr, current bool) []colorOffset {
func (result *Result) colorOffsets(matchOffsets []Offset, theme *curses.ColorTheme, color int, attr curses.Attr, current bool) []colorOffset {
itemColors := result.item.Colors()
// No ANSI code, or --color=no
if len(itemColors) == 0 {
var offsets []colorOffset
for _, off := range matchOffsets {
offsets = append(offsets, colorOffset{offset: [2]int32{off[0], off[1]}, color: color, attr: attr})
}
return offsets
@@ -149,17 +149,17 @@ func (result *Result) colorOffsets(matchOffsets []Offset, color int, attr curses
fg := ansi.color.fg
if fg == -1 {
if current {
fg = curses.CurrentFG
fg = int(theme.Current)
} else {
fg = curses.FG
fg = int(theme.Fg)
}
}
bg := ansi.color.bg
if bg == -1 {
if current {
bg = curses.DarkBG
bg = int(theme.DarkBg)
} else {
bg = curses.BG
bg = int(theme.Bg)
}
}
colors = append(colors, colorOffset{