feat: add alt-gutter color option (#4602)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* Add alt-gutter color option * Simplify the code ---------
authored by RT · committed by GitHub · parent 60a5be1 · Browse files · 4 files·+28 added−6 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
Diff stats
4 files+28 added−6 removed
- other:+28 added−6 removed
Provenance
- Commit
771e35b- Tree
c2d2ab3- Author
RT <hedgieinsocks@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
60a5be1
4 files changed+28 added−6 removed
modified:man/man1/fzf.1+1 added
270 unmodified lines271 \fBcurrent\-bg (bg+) \fRBackground (current line)272 \fBgutter \fRGutter on the left273 \fBcurrent\-hl (hl+) \fRHighlighted substrings (current line)274 \fBalt\-bg \fRAlternate background color to create striped lines275+ \fBalt\-gutter \fRAlternate gutter color to create the striped pattern276 \fBquery (input\-fg) \fRQuery string277 \fBghost \fRGhost text (\fB\-\-ghost\fR, \fBdim\fR applied by default)278 \fBdisabled \fRQuery string when search is disabled (\fB\-\-disabled\fR)279 \fBinfo \fRInfo line (match counters)1907 unmodified linesmodified:src/tui/tui.go+11 added
454 unmodified lines455 PreviewFg ColorAttr456 PreviewBg ColorAttr457 DarkBg ColorAttr458 Gutter ColorAttr459+ AltGutter ColorAttr460 Prompt ColorAttr461 InputBg ColorAttr462 InputBorder ColorAttr463 InputLabel ColorAttr362 unmodified lines826 ColMatch ColorPair827 ColCursor ColorPair828 ColCursorEmpty ColorPair829 ColCursorEmptyChar ColorPair830+ ColAltCursorEmpty ColorPair831+ ColAltCursorEmptyChar ColorPair832 ColMarker ColorPair833 ColSelected ColorPair834 ColSelectedMatch ColorPair835 ColCurrent ColorPair57 unmodified lines893 Disabled: defaultColor,894 PreviewFg: defaultColor,895 PreviewBg: defaultColor,896 Gutter: undefined,897+ AltGutter: undefined,898 PreviewBorder: defaultColor,899 PreviewScrollbar: defaultColor,900 PreviewLabel: defaultColor,901 ListLabel: defaultColor,44 unmodified lines946 Disabled: undefined,947 PreviewFg: undefined,948 PreviewBg: undefined,949 Gutter: undefined,950+ AltGutter: undefined,951 PreviewBorder: undefined,952 PreviewScrollbar: undefined,953 PreviewLabel: undefined,954 Separator: undefined,40 unmodified lines995 Disabled: undefined,996 PreviewFg: undefined,997 PreviewBg: undefined,998 Gutter: undefined,999+ AltGutter: undefined,1000 PreviewBorder: undefined,1001 PreviewScrollbar: undefined,1002 PreviewLabel: undefined,1003 ListLabel: undefined,42 unmodified lines1046 Disabled: undefined,1047 PreviewFg: undefined,1048 PreviewBg: undefined,1049 Gutter: undefined,1050+ AltGutter: undefined,1051 PreviewBorder: undefined,1052 PreviewScrollbar: undefined,1053 PreviewLabel: undefined,1054 ListLabel: undefined,42 unmodified lines1097 Disabled: undefined,1098 PreviewFg: undefined,1099 PreviewBg: undefined,1100 Gutter: undefined,1101+ AltGutter: undefined,1102 PreviewBorder: undefined,1103 PreviewScrollbar: undefined,1104 PreviewLabel: undefined,1105 ListLabel: undefined,109 unmodified lines1215 if !baseTheme.Colored && gutter.IsUndefined() {1216 gutter.Attr = Dim1217 }1218 theme.Gutter = o(theme.DarkBg, gutter)1219+ theme.AltGutter = o(theme.Gutter, theme.AltGutter)1220 theme.PreviewFg = o(theme.Fg, theme.PreviewFg)1221 theme.PreviewBg = o(theme.Bg, theme.PreviewBg)1222 theme.PreviewLabel = o(theme.BorderLabel, theme.PreviewLabel)1223 theme.PreviewBorder = o(theme.Border, theme.PreviewBorder)61 unmodified lines1285 ColSelectedMatch = pair(theme.SelectedMatch, theme.SelectedBg)1286 ColCursor = pair(theme.Cursor, theme.Gutter)1287 ColCursorEmpty = pair(blank, theme.Gutter)1288 ColCursorEmptyChar = pair(theme.Gutter, theme.ListBg)1289+ ColAltCursorEmpty = pair(blank, theme.AltGutter)1290+ ColAltCursorEmptyChar = pair(theme.AltGutter, theme.ListBg)1291 if theme.SelectedBg.Color != theme.ListBg.Color {1292 ColMarker = pair(theme.Marker, theme.SelectedBg)1293 } else {1294 ColMarker = pair(theme.Marker, theme.ListBg)34 unmodified linesmodified:src/options.go+2 added
1474 unmodified lines1475 case "nomatch":1476 mergeAttr(&theme.Nomatch)1477 case "gutter":1478 mergeAttr(&theme.Gutter)1479+ case "alt-gutter":1480+ mergeAttr(&theme.AltGutter)1481 case "hl":1482 mergeAttr(&theme.Match)1483 case "current-hl", "hl+":1484 mergeAttr(&theme.CurrentMatch)2327 unmodified linesmodified:src/terminal.go+14 added-6 removed
3200 unmodified lines3201 t.markEmptyLine(line)3202 t.renderBar(line, barRange)3203 }3204 3205-func (t *Terminal) gutter(current bool) {3205+func (t *Terminal) gutter(current bool, alt bool) {3206 var color tui.ColorPair3207 if current {3208 color = tui.ColCurrentCursorEmpty3209 } else if !t.raw && t.gutterReverse || t.raw && t.gutterRawReverse {3210+ if alt {3211+ color = tui.ColAltCursorEmpty3212+ } else {3210- color = tui.ColCursorEmpty3213+ color = tui.ColCursorEmpty3214+ }3215 } else {3216+ if alt {3217+ color = tui.ColAltCursorEmptyChar3218+ } else {3212- color = tui.ColCursorEmptyChar3219+ color = tui.ColCursorEmptyChar3220+ }3221 }3222 gutter := t.pointerEmpty3223 if t.raw {3224 gutter = t.pointerEmptyRaw2 unmodified lines3227 }3228 3229 func (t *Terminal) renderGapLine(line int, barRange [2]int, drawLine bool) {3230 t.move(line, 0, false)3223- t.gutter(false)3231+ t.gutter(false, false)3232 t.window.Print(t.markerEmpty)3233 x := t.pointerLen + t.markerLen3234 3235 width := t.window.Width() - x - 1165 unmodified lines3401 if w < 0 {3402 return indentSize3403 }3404 if len(label) == 0 {3397- t.gutter(true)3405+ t.gutter(true, false)3406 } else {3407 t.window.CPrint(tui.ColCurrentCursor, label)3408 }3409 if w-t.markerLen < 0 {13 unmodified lines3423 if w < 0 {3424 return indentSize3425 }3426 if len(label) == 0 {3419- t.gutter(false)3427+ t.gutter(false, index%2 == 1)3428 } else {3429 t.window.CPrint(tui.ColCursor, label)3430 }3431 if w-t.markerLen < 0 {3954 unmodified lines