Add color option for gutter

fzf --color gutter:-1

Close #1529
Close #1468
This commit is contained in:
Junegunn Choi 2019-03-17 15:37:23 +09:00
parent 309bae423c
commit 2157f4f193
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
4 changed files with 38 additions and 22 deletions

View File

@ -250,6 +250,7 @@ e.g. \fBfzf --color=bg+:24\fR
\fBhl \fRHighlighted substrings \fBhl \fRHighlighted substrings
\fBfg+ \fRText (current line) \fBfg+ \fRText (current line)
\fBbg+ \fRBackground (current line) \fBbg+ \fRBackground (current line)
\fBgutter \fRGutter on the left (default to \fBbg+\fR)
\fBhl+ \fRHighlighted substrings (current line) \fBhl+ \fRHighlighted substrings (current line)
\fBinfo \fRInfo \fBinfo \fRInfo
\fBborder \fRBorder of the preview window and horizontal separators (\fB--border\fR) \fBborder \fRBorder of the preview window and horizontal separators (\fB--border\fR)

View File

@ -576,6 +576,8 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) *tui.ColorTheme {
theme.Current = ansi theme.Current = ansi
case "bg+": case "bg+":
theme.DarkBg = ansi theme.DarkBg = ansi
case "gutter":
theme.Gutter = ansi
case "hl": case "hl":
theme.Match = ansi theme.Match = ansi
case "hl+": case "hl+":

View File

@ -834,15 +834,16 @@ func (t *Terminal) printItem(result Result, line int, i int, current bool) {
} }
t.move(line, 0, false) t.move(line, 0, false)
t.window.CPrint(tui.ColCursor, t.strong, label)
if current { if current {
t.window.CPrint(tui.ColCurrentCursor, t.strong, label)
if selected { if selected {
t.window.CPrint(tui.ColSelected, t.strong, ">") t.window.CPrint(tui.ColCurrentSelected, t.strong, ">")
} else { } else {
t.window.CPrint(tui.ColCurrent, t.strong, " ") t.window.CPrint(tui.ColCurrentSelected, t.strong, " ")
} }
newLine.width = t.printHighlighted(result, t.strong, tui.ColCurrent, tui.ColCurrentMatch, true, true) newLine.width = t.printHighlighted(result, t.strong, tui.ColCurrent, tui.ColCurrentMatch, true, true)
} else { } else {
t.window.CPrint(tui.ColCursor, t.strong, label)
if selected { if selected {
t.window.CPrint(tui.ColSelected, t.strong, ">") t.window.CPrint(tui.ColSelected, t.strong, ">")
} else { } else {

View File

@ -172,6 +172,7 @@ type ColorTheme struct {
Fg Color Fg Color
Bg Color Bg Color
DarkBg Color DarkBg Color
Gutter Color
Prompt Color Prompt Color
Match Color Match Color
Current Color Current Color
@ -272,17 +273,19 @@ var (
Dark256 *ColorTheme Dark256 *ColorTheme
Light256 *ColorTheme Light256 *ColorTheme
ColNormal ColorPair ColPrompt ColorPair
ColPrompt ColorPair ColNormal ColorPair
ColMatch ColorPair ColMatch ColorPair
ColCurrent ColorPair ColCursor ColorPair
ColCurrentMatch ColorPair ColSelected ColorPair
ColSpinner ColorPair ColCurrent ColorPair
ColInfo ColorPair ColCurrentMatch ColorPair
ColCursor ColorPair ColCurrentCursor ColorPair
ColSelected ColorPair ColCurrentSelected ColorPair
ColHeader ColorPair ColSpinner ColorPair
ColBorder ColorPair ColInfo ColorPair
ColHeader ColorPair
ColBorder ColorPair
) )
func EmptyTheme() *ColorTheme { func EmptyTheme() *ColorTheme {
@ -290,6 +293,7 @@ func EmptyTheme() *ColorTheme {
Fg: colUndefined, Fg: colUndefined,
Bg: colUndefined, Bg: colUndefined,
DarkBg: colUndefined, DarkBg: colUndefined,
Gutter: colUndefined,
Prompt: colUndefined, Prompt: colUndefined,
Match: colUndefined, Match: colUndefined,
Current: colUndefined, Current: colUndefined,
@ -312,6 +316,7 @@ func init() {
Fg: colDefault, Fg: colDefault,
Bg: colDefault, Bg: colDefault,
DarkBg: colBlack, DarkBg: colBlack,
Gutter: colBlack,
Prompt: colBlue, Prompt: colBlue,
Match: colGreen, Match: colGreen,
Current: colYellow, Current: colYellow,
@ -326,6 +331,7 @@ func init() {
Fg: colDefault, Fg: colDefault,
Bg: colDefault, Bg: colDefault,
DarkBg: 236, DarkBg: 236,
Gutter: colUndefined,
Prompt: 110, Prompt: 110,
Match: 108, Match: 108,
Current: 254, Current: 254,
@ -340,6 +346,7 @@ func init() {
Fg: colDefault, Fg: colDefault,
Bg: colDefault, Bg: colDefault,
DarkBg: 251, DarkBg: 251,
Gutter: colUndefined,
Prompt: 25, Prompt: 25,
Match: 66, Match: 66,
Current: 237, Current: 237,
@ -371,6 +378,7 @@ func initTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool) {
theme.Fg = o(baseTheme.Fg, theme.Fg) theme.Fg = o(baseTheme.Fg, theme.Fg)
theme.Bg = o(baseTheme.Bg, theme.Bg) theme.Bg = o(baseTheme.Bg, theme.Bg)
theme.DarkBg = o(baseTheme.DarkBg, theme.DarkBg) theme.DarkBg = o(baseTheme.DarkBg, theme.DarkBg)
theme.Gutter = o(theme.DarkBg, o(baseTheme.Gutter, theme.Gutter))
theme.Prompt = o(baseTheme.Prompt, theme.Prompt) theme.Prompt = o(baseTheme.Prompt, theme.Prompt)
theme.Match = o(baseTheme.Match, theme.Match) theme.Match = o(baseTheme.Match, theme.Match)
theme.Current = o(baseTheme.Current, theme.Current) theme.Current = o(baseTheme.Current, theme.Current)
@ -392,27 +400,31 @@ func initPalette(theme *ColorTheme) {
return ColorPair{fg, bg, idx} return ColorPair{fg, bg, idx}
} }
if theme != nil { if theme != nil {
ColNormal = pair(theme.Fg, theme.Bg)
ColPrompt = pair(theme.Prompt, theme.Bg) ColPrompt = pair(theme.Prompt, theme.Bg)
ColNormal = pair(theme.Fg, theme.Bg)
ColMatch = pair(theme.Match, theme.Bg) ColMatch = pair(theme.Match, theme.Bg)
ColCursor = pair(theme.Cursor, theme.Gutter)
ColSelected = pair(theme.Selected, theme.Gutter)
ColCurrent = pair(theme.Current, theme.DarkBg) ColCurrent = pair(theme.Current, theme.DarkBg)
ColCurrentMatch = pair(theme.CurrentMatch, theme.DarkBg) ColCurrentMatch = pair(theme.CurrentMatch, theme.DarkBg)
ColCurrentCursor = pair(theme.Cursor, theme.DarkBg)
ColCurrentSelected = pair(theme.Selected, theme.DarkBg)
ColSpinner = pair(theme.Spinner, theme.Bg) ColSpinner = pair(theme.Spinner, theme.Bg)
ColInfo = pair(theme.Info, theme.Bg) ColInfo = pair(theme.Info, theme.Bg)
ColCursor = pair(theme.Cursor, theme.DarkBg)
ColSelected = pair(theme.Selected, theme.DarkBg)
ColHeader = pair(theme.Header, theme.Bg) ColHeader = pair(theme.Header, theme.Bg)
ColBorder = pair(theme.Border, theme.Bg) ColBorder = pair(theme.Border, theme.Bg)
} else { } else {
ColNormal = pair(colDefault, colDefault)
ColPrompt = pair(colDefault, colDefault) ColPrompt = pair(colDefault, colDefault)
ColNormal = pair(colDefault, colDefault)
ColMatch = pair(colDefault, colDefault) ColMatch = pair(colDefault, colDefault)
ColCurrent = pair(colDefault, colDefault)
ColCurrentMatch = pair(colDefault, colDefault)
ColSpinner = pair(colDefault, colDefault)
ColInfo = pair(colDefault, colDefault)
ColCursor = pair(colDefault, colDefault) ColCursor = pair(colDefault, colDefault)
ColSelected = pair(colDefault, colDefault) ColSelected = pair(colDefault, colDefault)
ColCurrent = pair(colDefault, colDefault)
ColCurrentMatch = pair(colDefault, colDefault)
ColCurrentCursor = pair(colDefault, colDefault)
ColCurrentSelected = pair(colDefault, colDefault)
ColSpinner = pair(colDefault, colDefault)
ColInfo = pair(colDefault, colDefault)
ColHeader = pair(colDefault, colDefault) ColHeader = pair(colDefault, colDefault)
ColBorder = pair(colDefault, colDefault) ColBorder = pair(colDefault, colDefault)
} }