mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-01-11 02:36:12 +00:00
Allow customizing the color of preview scrollbar via 'preview-scrollbar'
This commit is contained in:
parent
94999101e3
commit
5a39102405
@ -446,8 +446,10 @@ color mappings.
|
|||||||
\fBdisabled \fRQuery string when search is disabled (\fB--disabled\fR)
|
\fBdisabled \fRQuery string when search is disabled (\fB--disabled\fR)
|
||||||
\fBinfo \fRInfo line (match counters)
|
\fBinfo \fRInfo line (match counters)
|
||||||
\fBborder \fRBorder around the window (\fB--border\fR and \fB--preview\fR)
|
\fBborder \fRBorder around the window (\fB--border\fR and \fB--preview\fR)
|
||||||
\fBseparator \fRHorizontal separator on info line
|
|
||||||
\fBscrollbar \fRScrollbar
|
\fBscrollbar \fRScrollbar
|
||||||
|
\fBpreview-border \fRBorder around the preview window (\fB--preview\fR)
|
||||||
|
\fBpreview-scrollbar \fRScrollbar
|
||||||
|
\fBseparator \fRHorizontal separator on info line
|
||||||
\fBlabel \fRBorder label (\fB--border-label\fR and \fB--preview-label\fR)
|
\fBlabel \fRBorder label (\fB--border-label\fR and \fB--preview-label\fR)
|
||||||
\fBpreview-label \fRBorder label of the preview window (\fB--preview-label\fR)
|
\fBpreview-label \fRBorder label of the preview window (\fB--preview-label\fR)
|
||||||
\fBprompt \fRPrompt
|
\fBprompt \fRPrompt
|
||||||
|
@ -888,10 +888,14 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) *tui.ColorTheme {
|
|||||||
mergeAttr(&theme.CurrentMatch)
|
mergeAttr(&theme.CurrentMatch)
|
||||||
case "border":
|
case "border":
|
||||||
mergeAttr(&theme.Border)
|
mergeAttr(&theme.Border)
|
||||||
|
case "preview-border":
|
||||||
|
mergeAttr(&theme.PreviewBorder)
|
||||||
case "separator":
|
case "separator":
|
||||||
mergeAttr(&theme.Separator)
|
mergeAttr(&theme.Separator)
|
||||||
case "scrollbar":
|
case "scrollbar":
|
||||||
mergeAttr(&theme.Scrollbar)
|
mergeAttr(&theme.Scrollbar)
|
||||||
|
case "preview-scrollbar":
|
||||||
|
mergeAttr(&theme.PreviewScrollbar)
|
||||||
case "label":
|
case "label":
|
||||||
mergeAttr(&theme.BorderLabel)
|
mergeAttr(&theme.BorderLabel)
|
||||||
case "preview-label":
|
case "preview-label":
|
||||||
|
@ -1930,7 +1930,9 @@ func (t *Terminal) renderPreviewText(height int, lines []string, lineNo int, unc
|
|||||||
func (t *Terminal) renderPreviewScrollbar(yoff int, barLength int, barStart int) {
|
func (t *Terminal) renderPreviewScrollbar(yoff int, barLength int, barStart int) {
|
||||||
height := t.pwindow.Height()
|
height := t.pwindow.Height()
|
||||||
w := t.pborder.Width()
|
w := t.pborder.Width()
|
||||||
|
redraw := false
|
||||||
if len(t.previewer.bar) != height {
|
if len(t.previewer.bar) != height {
|
||||||
|
redraw = true
|
||||||
t.previewer.bar = make([]bool, height)
|
t.previewer.bar = make([]bool, height)
|
||||||
}
|
}
|
||||||
xshift := -1 - t.borderWidth
|
xshift := -1 - t.borderWidth
|
||||||
@ -1947,7 +1949,7 @@ func (t *Terminal) renderPreviewScrollbar(yoff int, barLength int, barStart int)
|
|||||||
|
|
||||||
// Avoid unnecessary redraws
|
// Avoid unnecessary redraws
|
||||||
bar := i >= yoff+barStart && i < yoff+barStart+barLength
|
bar := i >= yoff+barStart && i < yoff+barStart+barLength
|
||||||
if bar == t.previewer.bar[i] && !t.tui.NeedScrollbarRedraw() {
|
if !redraw && bar == t.previewer.bar[i] && !t.tui.NeedScrollbarRedraw() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1956,7 +1958,7 @@ func (t *Terminal) renderPreviewScrollbar(yoff int, barLength int, barStart int)
|
|||||||
if i >= yoff+barStart && i < yoff+barStart+barLength {
|
if i >= yoff+barStart && i < yoff+barStart+barLength {
|
||||||
t.pborder.CPrint(tui.ColPreviewScrollbar, t.scrollbar)
|
t.pborder.CPrint(tui.ColPreviewScrollbar, t.scrollbar)
|
||||||
} else {
|
} else {
|
||||||
t.pborder.Print(" ")
|
t.pborder.CPrint(tui.ColPreviewScrollbar, " ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,6 +274,8 @@ type ColorTheme struct {
|
|||||||
Separator ColorAttr
|
Separator ColorAttr
|
||||||
Scrollbar ColorAttr
|
Scrollbar ColorAttr
|
||||||
Border ColorAttr
|
Border ColorAttr
|
||||||
|
PreviewBorder ColorAttr
|
||||||
|
PreviewScrollbar ColorAttr
|
||||||
BorderLabel ColorAttr
|
BorderLabel ColorAttr
|
||||||
PreviewLabel ColorAttr
|
PreviewLabel ColorAttr
|
||||||
}
|
}
|
||||||
@ -528,6 +530,8 @@ func EmptyTheme() *ColorTheme {
|
|||||||
PreviewFg: ColorAttr{colUndefined, AttrUndefined},
|
PreviewFg: ColorAttr{colUndefined, AttrUndefined},
|
||||||
PreviewBg: ColorAttr{colUndefined, AttrUndefined},
|
PreviewBg: ColorAttr{colUndefined, AttrUndefined},
|
||||||
Gutter: ColorAttr{colUndefined, AttrUndefined},
|
Gutter: ColorAttr{colUndefined, AttrUndefined},
|
||||||
|
PreviewBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||||
|
PreviewScrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||||
PreviewLabel: ColorAttr{colUndefined, AttrUndefined},
|
PreviewLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||||
Separator: ColorAttr{colUndefined, AttrUndefined},
|
Separator: ColorAttr{colUndefined, AttrUndefined},
|
||||||
Scrollbar: ColorAttr{colUndefined, AttrUndefined},
|
Scrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||||
@ -556,6 +560,8 @@ func NoColorTheme() *ColorTheme {
|
|||||||
PreviewFg: ColorAttr{colDefault, AttrUndefined},
|
PreviewFg: ColorAttr{colDefault, AttrUndefined},
|
||||||
PreviewBg: ColorAttr{colDefault, AttrUndefined},
|
PreviewBg: ColorAttr{colDefault, AttrUndefined},
|
||||||
Gutter: ColorAttr{colDefault, AttrUndefined},
|
Gutter: ColorAttr{colDefault, AttrUndefined},
|
||||||
|
PreviewBorder: ColorAttr{colDefault, AttrUndefined},
|
||||||
|
PreviewScrollbar: ColorAttr{colDefault, AttrUndefined},
|
||||||
PreviewLabel: ColorAttr{colDefault, AttrUndefined},
|
PreviewLabel: ColorAttr{colDefault, AttrUndefined},
|
||||||
Separator: ColorAttr{colDefault, AttrUndefined},
|
Separator: ColorAttr{colDefault, AttrUndefined},
|
||||||
Scrollbar: ColorAttr{colDefault, AttrUndefined},
|
Scrollbar: ColorAttr{colDefault, AttrUndefined},
|
||||||
@ -589,6 +595,8 @@ func init() {
|
|||||||
PreviewFg: ColorAttr{colUndefined, AttrUndefined},
|
PreviewFg: ColorAttr{colUndefined, AttrUndefined},
|
||||||
PreviewBg: ColorAttr{colUndefined, AttrUndefined},
|
PreviewBg: ColorAttr{colUndefined, AttrUndefined},
|
||||||
Gutter: ColorAttr{colUndefined, AttrUndefined},
|
Gutter: ColorAttr{colUndefined, AttrUndefined},
|
||||||
|
PreviewBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||||
|
PreviewScrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||||
PreviewLabel: ColorAttr{colUndefined, AttrUndefined},
|
PreviewLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||||
Separator: ColorAttr{colUndefined, AttrUndefined},
|
Separator: ColorAttr{colUndefined, AttrUndefined},
|
||||||
Scrollbar: ColorAttr{colUndefined, AttrUndefined},
|
Scrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||||
@ -614,6 +622,8 @@ func init() {
|
|||||||
PreviewFg: ColorAttr{colUndefined, AttrUndefined},
|
PreviewFg: ColorAttr{colUndefined, AttrUndefined},
|
||||||
PreviewBg: ColorAttr{colUndefined, AttrUndefined},
|
PreviewBg: ColorAttr{colUndefined, AttrUndefined},
|
||||||
Gutter: ColorAttr{colUndefined, AttrUndefined},
|
Gutter: ColorAttr{colUndefined, AttrUndefined},
|
||||||
|
PreviewBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||||
|
PreviewScrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||||
PreviewLabel: ColorAttr{colUndefined, AttrUndefined},
|
PreviewLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||||
Separator: ColorAttr{colUndefined, AttrUndefined},
|
Separator: ColorAttr{colUndefined, AttrUndefined},
|
||||||
Scrollbar: ColorAttr{colUndefined, AttrUndefined},
|
Scrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||||
@ -639,6 +649,8 @@ func init() {
|
|||||||
PreviewFg: ColorAttr{colUndefined, AttrUndefined},
|
PreviewFg: ColorAttr{colUndefined, AttrUndefined},
|
||||||
PreviewBg: ColorAttr{colUndefined, AttrUndefined},
|
PreviewBg: ColorAttr{colUndefined, AttrUndefined},
|
||||||
Gutter: ColorAttr{colUndefined, AttrUndefined},
|
Gutter: ColorAttr{colUndefined, AttrUndefined},
|
||||||
|
PreviewBorder: ColorAttr{colUndefined, AttrUndefined},
|
||||||
|
PreviewScrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||||
PreviewLabel: ColorAttr{colUndefined, AttrUndefined},
|
PreviewLabel: ColorAttr{colUndefined, AttrUndefined},
|
||||||
Separator: ColorAttr{colUndefined, AttrUndefined},
|
Separator: ColorAttr{colUndefined, AttrUndefined},
|
||||||
Scrollbar: ColorAttr{colUndefined, AttrUndefined},
|
Scrollbar: ColorAttr{colUndefined, AttrUndefined},
|
||||||
@ -682,8 +694,10 @@ func initTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool) {
|
|||||||
theme.PreviewFg = o(theme.Fg, theme.PreviewFg)
|
theme.PreviewFg = o(theme.Fg, theme.PreviewFg)
|
||||||
theme.PreviewBg = o(theme.Bg, theme.PreviewBg)
|
theme.PreviewBg = o(theme.Bg, theme.PreviewBg)
|
||||||
theme.PreviewLabel = o(theme.BorderLabel, theme.PreviewLabel)
|
theme.PreviewLabel = o(theme.BorderLabel, theme.PreviewLabel)
|
||||||
|
theme.PreviewBorder = o(theme.Border, theme.PreviewBorder)
|
||||||
theme.Separator = o(theme.Border, theme.Separator)
|
theme.Separator = o(theme.Border, theme.Separator)
|
||||||
theme.Scrollbar = o(theme.Border, theme.Scrollbar)
|
theme.Scrollbar = o(theme.Border, theme.Scrollbar)
|
||||||
|
theme.PreviewScrollbar = o(theme.PreviewBorder, theme.PreviewScrollbar)
|
||||||
|
|
||||||
initPalette(theme)
|
initPalette(theme)
|
||||||
}
|
}
|
||||||
@ -721,6 +735,6 @@ func initPalette(theme *ColorTheme) {
|
|||||||
ColBorderLabel = pair(theme.BorderLabel, theme.Bg)
|
ColBorderLabel = pair(theme.BorderLabel, theme.Bg)
|
||||||
ColPreviewLabel = pair(theme.PreviewLabel, theme.PreviewBg)
|
ColPreviewLabel = pair(theme.PreviewLabel, theme.PreviewBg)
|
||||||
ColPreview = pair(theme.PreviewFg, theme.PreviewBg)
|
ColPreview = pair(theme.PreviewFg, theme.PreviewBg)
|
||||||
ColPreviewBorder = pair(theme.Border, theme.PreviewBg)
|
ColPreviewBorder = pair(theme.PreviewBorder, theme.PreviewBg)
|
||||||
ColPreviewScrollbar = pair(theme.Scrollbar, theme.PreviewBg)
|
ColPreviewScrollbar = pair(theme.PreviewScrollbar, theme.PreviewBg)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user