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
\fBfg+ \fRText (current line)
\fBbg+ \fRBackground (current line)
\fBgutter \fRGutter on the left (default to \fBbg+\fR)
\fBhl+ \fRHighlighted substrings (current line)
\fBinfo \fRInfo
\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
case "bg+":
theme.DarkBg = ansi
case "gutter":
theme.Gutter = ansi
case "hl":
theme.Match = ansi
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.window.CPrint(tui.ColCursor, t.strong, label)
if current {
t.window.CPrint(tui.ColCurrentCursor, t.strong, label)
if selected {
t.window.CPrint(tui.ColSelected, t.strong, ">")
t.window.CPrint(tui.ColCurrentSelected, t.strong, ">")
} 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)
} else {
t.window.CPrint(tui.ColCursor, t.strong, label)
if selected {
t.window.CPrint(tui.ColSelected, t.strong, ">")
} else {

View File

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