Allow customizing the color of preview scrollbar via 'preview-scrollbar'
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 9499910 · Browse files · 4 files·+186 added−164 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+186 added−164 removed
- other:+186 added−164 removed
Provenance
- Commit
5a39102- Tree
0e9195c- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
9499910
4 files changed+186 added−164 removed
modified:man/man1/fzf.1+24 added-22 removed
431 unmodified lines432 \fB16 \fRColor scheme for 16-color terminal433 \fBbw \fRNo colors (equivalent to \fB--no-color\fR)434 435 .B COLOR NAMES:436- \fBfg \fRText437- \fBpreview-fg \fRPreview window text438- \fBbg \fRBackground439- \fBpreview-bg \fRPreview window background440- \fBhl \fRHighlighted substrings441- \fBfg+ \fRText (current line)442- \fBbg+ \fRBackground (current line)443- \fBgutter \fRGutter on the left444- \fBhl+ \fRHighlighted substrings (current line)445- \fBquery \fRQuery string446- \fBdisabled \fRQuery string when search is disabled (\fB--disabled\fR)447- \fBinfo \fRInfo line (match counters)448- \fBborder \fRBorder around the window (\fB--border\fR and \fB--preview\fR)449- \fBseparator \fRHorizontal separator on info line450- \fBscrollbar \fRScrollbar451- \fBlabel \fRBorder label (\fB--border-label\fR and \fB--preview-label\fR)452- \fBpreview-label \fRBorder label of the preview window (\fB--preview-label\fR)453- \fBprompt \fRPrompt454- \fBpointer \fRPointer to the current line455- \fBmarker \fRMulti-select marker456- \fBspinner \fRStreaming input indicator457- \fBheader \fRHeader436+ \fBfg \fRText437+ \fBpreview-fg \fRPreview window text438+ \fBbg \fRBackground439+ \fBpreview-bg \fRPreview window background440+ \fBhl \fRHighlighted substrings441+ \fBfg+ \fRText (current line)442+ \fBbg+ \fRBackground (current line)443+ \fBgutter \fRGutter on the left444+ \fBhl+ \fRHighlighted substrings (current line)445+ \fBquery \fRQuery string446+ \fBdisabled \fRQuery string when search is disabled (\fB--disabled\fR)447+ \fBinfo \fRInfo line (match counters)448+ \fBborder \fRBorder around the window (\fB--border\fR and \fB--preview\fR)449+ \fBscrollbar \fRScrollbar450+ \fBpreview-border \fRBorder around the preview window (\fB--preview\fR)451+ \fBpreview-scrollbar \fRScrollbar452+ \fBseparator \fRHorizontal separator on info line453+ \fBlabel \fRBorder label (\fB--border-label\fR and \fB--preview-label\fR)454+ \fBpreview-label \fRBorder label of the preview window (\fB--preview-label\fR)455+ \fBprompt \fRPrompt456+ \fBpointer \fRPointer to the current line457+ \fBmarker \fRMulti-select marker458+ \fBspinner \fRStreaming input indicator459+ \fBheader \fRHeader460 461 .B ANSI COLORS:462 \fB-1 \fRDefault terminal foreground/background color463 \fB \fR(or the original color of the text)820 unmodified linesmodified:src/tui/tui.go+154 added-140 removed
251 unmodified lines252 return p.merge(other, colDefault)253 }254 255 type ColorTheme struct {256- Colored bool257- Input ColorAttr258- Disabled ColorAttr259- Fg ColorAttr260- Bg ColorAttr261- PreviewFg ColorAttr262- PreviewBg ColorAttr263- DarkBg ColorAttr264- Gutter ColorAttr265- Prompt ColorAttr266- Match ColorAttr267- Current ColorAttr268- CurrentMatch ColorAttr269- Spinner ColorAttr270- Info ColorAttr271- Cursor ColorAttr272- Selected ColorAttr273- Header ColorAttr274- Separator ColorAttr275- Scrollbar ColorAttr276- Border ColorAttr277- BorderLabel ColorAttr278- PreviewLabel ColorAttr256+ Colored bool257+ Input ColorAttr258+ Disabled ColorAttr259+ Fg ColorAttr260+ Bg ColorAttr261+ PreviewFg ColorAttr262+ PreviewBg ColorAttr263+ DarkBg ColorAttr264+ Gutter ColorAttr265+ Prompt ColorAttr266+ Match ColorAttr267+ Current ColorAttr268+ CurrentMatch ColorAttr269+ Spinner ColorAttr270+ Info ColorAttr271+ Cursor ColorAttr272+ Selected ColorAttr273+ Header ColorAttr274+ Separator ColorAttr275+ Scrollbar ColorAttr276+ Border ColorAttr277+ PreviewBorder ColorAttr278+ PreviewScrollbar ColorAttr279+ BorderLabel ColorAttr280+ PreviewLabel ColorAttr281 }282 283 type Event struct {284 Type EventType224 unmodified lines509 )510 511 func EmptyTheme() *ColorTheme {512 return &ColorTheme{511- Colored: true,512- Input: ColorAttr{colUndefined, AttrUndefined},513- Fg: ColorAttr{colUndefined, AttrUndefined},514- Bg: ColorAttr{colUndefined, AttrUndefined},515- DarkBg: ColorAttr{colUndefined, AttrUndefined},516- Prompt: ColorAttr{colUndefined, AttrUndefined},517- Match: ColorAttr{colUndefined, AttrUndefined},518- Current: ColorAttr{colUndefined, AttrUndefined},519- CurrentMatch: ColorAttr{colUndefined, AttrUndefined},520- Spinner: ColorAttr{colUndefined, AttrUndefined},521- Info: ColorAttr{colUndefined, AttrUndefined},522- Cursor: ColorAttr{colUndefined, AttrUndefined},523- Selected: ColorAttr{colUndefined, AttrUndefined},524- Header: ColorAttr{colUndefined, AttrUndefined},525- Border: ColorAttr{colUndefined, AttrUndefined},526- BorderLabel: ColorAttr{colUndefined, AttrUndefined},527- Disabled: ColorAttr{colUndefined, AttrUndefined},528- PreviewFg: ColorAttr{colUndefined, AttrUndefined},529- PreviewBg: ColorAttr{colUndefined, AttrUndefined},530- Gutter: ColorAttr{colUndefined, AttrUndefined},531- PreviewLabel: ColorAttr{colUndefined, AttrUndefined},532- Separator: ColorAttr{colUndefined, AttrUndefined},533- Scrollbar: ColorAttr{colUndefined, AttrUndefined},513+ Colored: true,514+ Input: ColorAttr{colUndefined, AttrUndefined},515+ Fg: ColorAttr{colUndefined, AttrUndefined},516+ Bg: ColorAttr{colUndefined, AttrUndefined},517+ DarkBg: ColorAttr{colUndefined, AttrUndefined},518+ Prompt: ColorAttr{colUndefined, AttrUndefined},519+ Match: ColorAttr{colUndefined, AttrUndefined},520+ Current: ColorAttr{colUndefined, AttrUndefined},521+ CurrentMatch: ColorAttr{colUndefined, AttrUndefined},522+ Spinner: ColorAttr{colUndefined, AttrUndefined},523+ Info: ColorAttr{colUndefined, AttrUndefined},524+ Cursor: ColorAttr{colUndefined, AttrUndefined},525+ Selected: ColorAttr{colUndefined, AttrUndefined},526+ Header: ColorAttr{colUndefined, AttrUndefined},527+ Border: ColorAttr{colUndefined, AttrUndefined},528+ BorderLabel: ColorAttr{colUndefined, AttrUndefined},529+ Disabled: ColorAttr{colUndefined, AttrUndefined},530+ PreviewFg: ColorAttr{colUndefined, AttrUndefined},531+ PreviewBg: ColorAttr{colUndefined, AttrUndefined},532+ Gutter: ColorAttr{colUndefined, AttrUndefined},533+ PreviewBorder: ColorAttr{colUndefined, AttrUndefined},534+ PreviewScrollbar: ColorAttr{colUndefined, AttrUndefined},535+ PreviewLabel: ColorAttr{colUndefined, AttrUndefined},536+ Separator: ColorAttr{colUndefined, AttrUndefined},537+ Scrollbar: ColorAttr{colUndefined, AttrUndefined},538 }539 }540 541 func NoColorTheme() *ColorTheme {542 return &ColorTheme{539- Colored: false,540- Input: ColorAttr{colDefault, AttrUndefined},541- Fg: ColorAttr{colDefault, AttrUndefined},542- Bg: ColorAttr{colDefault, AttrUndefined},543- DarkBg: ColorAttr{colDefault, AttrUndefined},544- Prompt: ColorAttr{colDefault, AttrUndefined},545- Match: ColorAttr{colDefault, Underline},546- Current: ColorAttr{colDefault, Reverse},547- CurrentMatch: ColorAttr{colDefault, Reverse | Underline},548- Spinner: ColorAttr{colDefault, AttrUndefined},549- Info: ColorAttr{colDefault, AttrUndefined},550- Cursor: ColorAttr{colDefault, AttrUndefined},551- Selected: ColorAttr{colDefault, AttrUndefined},552- Header: ColorAttr{colDefault, AttrUndefined},553- Border: ColorAttr{colDefault, AttrUndefined},554- BorderLabel: ColorAttr{colDefault, AttrUndefined},555- Disabled: ColorAttr{colDefault, AttrUndefined},556- PreviewFg: ColorAttr{colDefault, AttrUndefined},557- PreviewBg: ColorAttr{colDefault, AttrUndefined},558- Gutter: ColorAttr{colDefault, AttrUndefined},559- PreviewLabel: ColorAttr{colDefault, AttrUndefined},560- Separator: ColorAttr{colDefault, AttrUndefined},561- Scrollbar: ColorAttr{colDefault, AttrUndefined},543+ Colored: false,544+ Input: ColorAttr{colDefault, AttrUndefined},545+ Fg: ColorAttr{colDefault, AttrUndefined},546+ Bg: ColorAttr{colDefault, AttrUndefined},547+ DarkBg: ColorAttr{colDefault, AttrUndefined},548+ Prompt: ColorAttr{colDefault, AttrUndefined},549+ Match: ColorAttr{colDefault, Underline},550+ Current: ColorAttr{colDefault, Reverse},551+ CurrentMatch: ColorAttr{colDefault, Reverse | Underline},552+ Spinner: ColorAttr{colDefault, AttrUndefined},553+ Info: ColorAttr{colDefault, AttrUndefined},554+ Cursor: ColorAttr{colDefault, AttrUndefined},555+ Selected: ColorAttr{colDefault, AttrUndefined},556+ Header: ColorAttr{colDefault, AttrUndefined},557+ Border: ColorAttr{colDefault, AttrUndefined},558+ BorderLabel: ColorAttr{colDefault, AttrUndefined},559+ Disabled: ColorAttr{colDefault, AttrUndefined},560+ PreviewFg: ColorAttr{colDefault, AttrUndefined},561+ PreviewBg: ColorAttr{colDefault, AttrUndefined},562+ Gutter: ColorAttr{colDefault, AttrUndefined},563+ PreviewBorder: ColorAttr{colDefault, AttrUndefined},564+ PreviewScrollbar: ColorAttr{colDefault, AttrUndefined},565+ PreviewLabel: ColorAttr{colDefault, AttrUndefined},566+ Separator: ColorAttr{colDefault, AttrUndefined},567+ Scrollbar: ColorAttr{colDefault, AttrUndefined},568 }569 }570 571 func errorExit(message string) {2 unmodified lines574 }575 576 func init() {577 Default16 = &ColorTheme{572- Colored: true,573- Input: ColorAttr{colDefault, AttrUndefined},574- Fg: ColorAttr{colDefault, AttrUndefined},575- Bg: ColorAttr{colDefault, AttrUndefined},576- DarkBg: ColorAttr{colBlack, AttrUndefined},577- Prompt: ColorAttr{colBlue, AttrUndefined},578- Match: ColorAttr{colGreen, AttrUndefined},579- Current: ColorAttr{colYellow, AttrUndefined},580- CurrentMatch: ColorAttr{colGreen, AttrUndefined},581- Spinner: ColorAttr{colGreen, AttrUndefined},582- Info: ColorAttr{colWhite, AttrUndefined},583- Cursor: ColorAttr{colRed, AttrUndefined},584- Selected: ColorAttr{colMagenta, AttrUndefined},585- Header: ColorAttr{colCyan, AttrUndefined},586- Border: ColorAttr{colBlack, AttrUndefined},587- BorderLabel: ColorAttr{colWhite, AttrUndefined},588- Disabled: ColorAttr{colUndefined, AttrUndefined},589- PreviewFg: ColorAttr{colUndefined, AttrUndefined},590- PreviewBg: ColorAttr{colUndefined, AttrUndefined},591- Gutter: ColorAttr{colUndefined, AttrUndefined},592- PreviewLabel: ColorAttr{colUndefined, AttrUndefined},593- Separator: ColorAttr{colUndefined, AttrUndefined},594- Scrollbar: ColorAttr{colUndefined, AttrUndefined},578+ Colored: true,579+ Input: ColorAttr{colDefault, AttrUndefined},580+ Fg: ColorAttr{colDefault, AttrUndefined},581+ Bg: ColorAttr{colDefault, AttrUndefined},582+ DarkBg: ColorAttr{colBlack, AttrUndefined},583+ Prompt: ColorAttr{colBlue, AttrUndefined},584+ Match: ColorAttr{colGreen, AttrUndefined},585+ Current: ColorAttr{colYellow, AttrUndefined},586+ CurrentMatch: ColorAttr{colGreen, AttrUndefined},587+ Spinner: ColorAttr{colGreen, AttrUndefined},588+ Info: ColorAttr{colWhite, AttrUndefined},589+ Cursor: ColorAttr{colRed, AttrUndefined},590+ Selected: ColorAttr{colMagenta, AttrUndefined},591+ Header: ColorAttr{colCyan, AttrUndefined},592+ Border: ColorAttr{colBlack, AttrUndefined},593+ BorderLabel: ColorAttr{colWhite, AttrUndefined},594+ Disabled: ColorAttr{colUndefined, AttrUndefined},595+ PreviewFg: ColorAttr{colUndefined, AttrUndefined},596+ PreviewBg: ColorAttr{colUndefined, AttrUndefined},597+ Gutter: ColorAttr{colUndefined, AttrUndefined},598+ PreviewBorder: ColorAttr{colUndefined, AttrUndefined},599+ PreviewScrollbar: ColorAttr{colUndefined, AttrUndefined},600+ PreviewLabel: ColorAttr{colUndefined, AttrUndefined},601+ Separator: ColorAttr{colUndefined, AttrUndefined},602+ Scrollbar: ColorAttr{colUndefined, AttrUndefined},603 }604 Dark256 = &ColorTheme{597- Colored: true,598- Input: ColorAttr{colDefault, AttrUndefined},599- Fg: ColorAttr{colDefault, AttrUndefined},600- Bg: ColorAttr{colDefault, AttrUndefined},601- DarkBg: ColorAttr{236, AttrUndefined},602- Prompt: ColorAttr{110, AttrUndefined},603- Match: ColorAttr{108, AttrUndefined},604- Current: ColorAttr{254, AttrUndefined},605- CurrentMatch: ColorAttr{151, AttrUndefined},606- Spinner: ColorAttr{148, AttrUndefined},607- Info: ColorAttr{144, AttrUndefined},608- Cursor: ColorAttr{161, AttrUndefined},609- Selected: ColorAttr{168, AttrUndefined},610- Header: ColorAttr{109, AttrUndefined},611- Border: ColorAttr{59, AttrUndefined},612- BorderLabel: ColorAttr{145, AttrUndefined},613- Disabled: ColorAttr{colUndefined, AttrUndefined},614- PreviewFg: ColorAttr{colUndefined, AttrUndefined},615- PreviewBg: ColorAttr{colUndefined, AttrUndefined},616- Gutter: ColorAttr{colUndefined, AttrUndefined},617- PreviewLabel: ColorAttr{colUndefined, AttrUndefined},618- Separator: ColorAttr{colUndefined, AttrUndefined},619- Scrollbar: ColorAttr{colUndefined, AttrUndefined},605+ Colored: true,606+ Input: ColorAttr{colDefault, AttrUndefined},607+ Fg: ColorAttr{colDefault, AttrUndefined},608+ Bg: ColorAttr{colDefault, AttrUndefined},609+ DarkBg: ColorAttr{236, AttrUndefined},610+ Prompt: ColorAttr{110, AttrUndefined},611+ Match: ColorAttr{108, AttrUndefined},612+ Current: ColorAttr{254, AttrUndefined},613+ CurrentMatch: ColorAttr{151, AttrUndefined},614+ Spinner: ColorAttr{148, AttrUndefined},615+ Info: ColorAttr{144, AttrUndefined},616+ Cursor: ColorAttr{161, AttrUndefined},617+ Selected: ColorAttr{168, AttrUndefined},618+ Header: ColorAttr{109, AttrUndefined},619+ Border: ColorAttr{59, AttrUndefined},620+ BorderLabel: ColorAttr{145, AttrUndefined},621+ Disabled: ColorAttr{colUndefined, AttrUndefined},622+ PreviewFg: ColorAttr{colUndefined, AttrUndefined},623+ PreviewBg: ColorAttr{colUndefined, AttrUndefined},624+ Gutter: ColorAttr{colUndefined, AttrUndefined},625+ PreviewBorder: ColorAttr{colUndefined, AttrUndefined},626+ PreviewScrollbar: ColorAttr{colUndefined, AttrUndefined},627+ PreviewLabel: ColorAttr{colUndefined, AttrUndefined},628+ Separator: ColorAttr{colUndefined, AttrUndefined},629+ Scrollbar: ColorAttr{colUndefined, AttrUndefined},630 }631 Light256 = &ColorTheme{622- Colored: true,623- Input: ColorAttr{colDefault, AttrUndefined},624- Fg: ColorAttr{colDefault, AttrUndefined},625- Bg: ColorAttr{colDefault, AttrUndefined},626- DarkBg: ColorAttr{251, AttrUndefined},627- Prompt: ColorAttr{25, AttrUndefined},628- Match: ColorAttr{66, AttrUndefined},629- Current: ColorAttr{237, AttrUndefined},630- CurrentMatch: ColorAttr{23, AttrUndefined},631- Spinner: ColorAttr{65, AttrUndefined},632- Info: ColorAttr{101, AttrUndefined},633- Cursor: ColorAttr{161, AttrUndefined},634- Selected: ColorAttr{168, AttrUndefined},635- Header: ColorAttr{31, AttrUndefined},636- Border: ColorAttr{145, AttrUndefined},637- BorderLabel: ColorAttr{59, AttrUndefined},638- Disabled: ColorAttr{colUndefined, AttrUndefined},639- PreviewFg: ColorAttr{colUndefined, AttrUndefined},640- PreviewBg: ColorAttr{colUndefined, AttrUndefined},641- Gutter: ColorAttr{colUndefined, AttrUndefined},642- PreviewLabel: ColorAttr{colUndefined, AttrUndefined},643- Separator: ColorAttr{colUndefined, AttrUndefined},644- Scrollbar: ColorAttr{colUndefined, AttrUndefined},632+ Colored: true,633+ Input: ColorAttr{colDefault, AttrUndefined},634+ Fg: ColorAttr{colDefault, AttrUndefined},635+ Bg: ColorAttr{colDefault, AttrUndefined},636+ DarkBg: ColorAttr{251, AttrUndefined},637+ Prompt: ColorAttr{25, AttrUndefined},638+ Match: ColorAttr{66, AttrUndefined},639+ Current: ColorAttr{237, AttrUndefined},640+ CurrentMatch: ColorAttr{23, AttrUndefined},641+ Spinner: ColorAttr{65, AttrUndefined},642+ Info: ColorAttr{101, AttrUndefined},643+ Cursor: ColorAttr{161, AttrUndefined},644+ Selected: ColorAttr{168, AttrUndefined},645+ Header: ColorAttr{31, AttrUndefined},646+ Border: ColorAttr{145, AttrUndefined},647+ BorderLabel: ColorAttr{59, AttrUndefined},648+ Disabled: ColorAttr{colUndefined, AttrUndefined},649+ PreviewFg: ColorAttr{colUndefined, AttrUndefined},650+ PreviewBg: ColorAttr{colUndefined, AttrUndefined},651+ Gutter: ColorAttr{colUndefined, AttrUndefined},652+ PreviewBorder: ColorAttr{colUndefined, AttrUndefined},653+ PreviewScrollbar: ColorAttr{colUndefined, AttrUndefined},654+ PreviewLabel: ColorAttr{colUndefined, AttrUndefined},655+ Separator: ColorAttr{colUndefined, AttrUndefined},656+ Scrollbar: ColorAttr{colUndefined, AttrUndefined},657 }658 }659 660 func initTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool) {32 unmodified lines693 theme.Gutter = o(theme.DarkBg, theme.Gutter)694 theme.PreviewFg = o(theme.Fg, theme.PreviewFg)695 theme.PreviewBg = o(theme.Bg, theme.PreviewBg)696 theme.PreviewLabel = o(theme.BorderLabel, theme.PreviewLabel)697+ theme.PreviewBorder = o(theme.Border, theme.PreviewBorder)698 theme.Separator = o(theme.Border, theme.Separator)699 theme.Scrollbar = o(theme.Border, theme.Scrollbar)700+ theme.PreviewScrollbar = o(theme.PreviewBorder, theme.PreviewScrollbar)701 702 initPalette(theme)703 }704 29 unmodified lines734 ColBorder = pair(theme.Border, theme.Bg)735 ColBorderLabel = pair(theme.BorderLabel, theme.Bg)736 ColPreviewLabel = pair(theme.PreviewLabel, theme.PreviewBg)737 ColPreview = pair(theme.PreviewFg, theme.PreviewBg)724- ColPreviewBorder = pair(theme.Border, theme.PreviewBg)725- ColPreviewScrollbar = pair(theme.Scrollbar, theme.PreviewBg)738+ ColPreviewBorder = pair(theme.PreviewBorder, theme.PreviewBg)739+ ColPreviewScrollbar = pair(theme.PreviewScrollbar, theme.PreviewBg)740 }modified:src/options.go+4 added
886 unmodified lines887 case "hl+":888 mergeAttr(&theme.CurrentMatch)889 case "border":890 mergeAttr(&theme.Border)891+ case "preview-border":892+ mergeAttr(&theme.PreviewBorder)893 case "separator":894 mergeAttr(&theme.Separator)895 case "scrollbar":896 mergeAttr(&theme.Scrollbar)897+ case "preview-scrollbar":898+ mergeAttr(&theme.PreviewScrollbar)899 case "label":900 mergeAttr(&theme.BorderLabel)901 case "preview-label":902 mergeAttr(&theme.PreviewLabel)1183 unmodified linesmodified:src/terminal.go+4 added-2 removed
1928 unmodified lines1929 1930 func (t *Terminal) renderPreviewScrollbar(yoff int, barLength int, barStart int) {1931 height := t.pwindow.Height()1932 w := t.pborder.Width()1933+ redraw := false1934 if len(t.previewer.bar) != height {1935+ redraw = true1936 t.previewer.bar = make([]bool, height)1937 }1938 xshift := -1 - t.borderWidth1939 if !t.previewOpts.border.HasRight() {8 unmodified lines1948 y := i + yshift1949 1950 // Avoid unnecessary redraws1951 bar := i >= yoff+barStart && i < yoff+barStart+barLength1950- if bar == t.previewer.bar[i] && !t.tui.NeedScrollbarRedraw() {1952+ if !redraw && bar == t.previewer.bar[i] && !t.tui.NeedScrollbarRedraw() {1953 continue1954 }1955 1956 t.previewer.bar[i] = bar1957 t.pborder.Move(y, x)1958 if i >= yoff+barStart && i < yoff+barStart+barLength {1959 t.pborder.CPrint(tui.ColPreviewScrollbar, t.scrollbar)1960 } else {1959- t.pborder.Print(" ")1961+ t.pborder.CPrint(tui.ColPreviewScrollbar, " ")1962 }1963 }1964 }1965 1735 unmodified lines