diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2025-06-10 00:26:57 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2025-06-10 23:02:23 +0900 |
| commit | 3b68dcdd81394f1ac9f743e1f74ff754f95eef9e (patch) | |
| tree | e4856fba0fee27eb1ae98ca15844ec04bf60ff5a /src/tui | |
| parent | 39db02616158020b180a56dc8f1bdcf9f8365945 (diff) | |
| download | fzf-3b68dcdd81394f1ac9f743e1f74ff754f95eef9e.tar.gz | |
Add footer
Options:
--footer=STR String to print as footer
--footer-border[=STYLE] Draw border around the footer section
[rounded|sharp|bold|block|thinblock|double|horizontal|vertical|
top|bottom|left|right|line|none] (default: line)
--footer-label=LABEL Label to print on the footer border
--footer-label-pos=COL Position of the footer label
[POSITIVE_INTEGER: columns from left|
NEGATIVE_INTEGER: columns from right][:bottom]
(default: 0 or center)
The default border type for footer is 'line', which draws a single
separator between the footer and the list. It changes its position
depending on `--layout`, so you don't have to manually switch between
'top' and 'bottom'
The 'line' style is now supported by other border types as well.
`--list-border` is the only exception.
Diffstat (limited to 'src/tui')
| -rw-r--r-- | src/tui/light.go | 11 | ||||
| -rw-r--r-- | src/tui/tcell.go | 4 | ||||
| -rw-r--r-- | src/tui/tui.go | 41 |
3 files changed, 55 insertions, 1 deletions
diff --git a/src/tui/light.go b/src/tui/light.go index eb3de098..54abbe5c 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -829,11 +829,14 @@ func (r *LightRenderer) NewWindow(top int, left int, width int, height int, wind case WindowHeader: w.fg = r.theme.Header.Color w.bg = r.theme.HeaderBg.Color + case WindowFooter: + w.fg = r.theme.Footer.Color + w.bg = r.theme.FooterBg.Color case WindowPreview: w.fg = r.theme.PreviewFg.Color w.bg = r.theme.PreviewBg.Color } - if erase && !w.bg.IsDefault() && w.border.shape != BorderNone { + if erase && !w.bg.IsDefault() && w.border.shape != BorderNone && w.height > 0 { // fzf --color bg:blue --border --padding 1,2 w.Erase() } @@ -889,6 +892,8 @@ func (w *LightWindow) drawBorderHorizontal(top, bottom bool) { color = ColInputBorder case WindowHeader: color = ColHeaderBorder + case WindowFooter: + color = ColFooterBorder case WindowPreview: color = ColPreviewBorder } @@ -914,6 +919,8 @@ func (w *LightWindow) drawBorderVertical(left, right bool) { color = ColInputBorder case WindowHeader: color = ColHeaderBorder + case WindowFooter: + color = ColFooterBorder case WindowPreview: color = ColPreviewBorder } @@ -941,6 +948,8 @@ func (w *LightWindow) drawBorderAround(onlyHorizontal bool) { color = ColInputBorder case WindowHeader: color = ColHeaderBorder + case WindowFooter: + color = ColFooterBorder case WindowPreview: color = ColPreviewBorder } diff --git a/src/tui/tcell.go b/src/tui/tcell.go index a2630463..762768da 100644 --- a/src/tui/tcell.go +++ b/src/tui/tcell.go @@ -600,6 +600,8 @@ func (r *FullscreenRenderer) NewWindow(top int, left int, width int, height int, normal = ColNormal case WindowHeader: normal = ColHeader + case WindowFooter: + normal = ColFooter case WindowInput: normal = ColInput case WindowPreview: @@ -865,6 +867,8 @@ func (w *TcellWindow) drawBorder(onlyHorizontal bool) { style = ColListBorder.style() case WindowHeader: style = ColHeaderBorder.style() + case WindowFooter: + style = ColFooterBorder.style() case WindowInput: style = ColInputBorder.style() case WindowPreview: diff --git a/src/tui/tui.go b/src/tui/tui.go index 06dbccb0..c8844753 100644 --- a/src/tui/tui.go +++ b/src/tui/tui.go @@ -359,6 +359,10 @@ type ColorTheme struct { HeaderBg ColorAttr HeaderBorder ColorAttr HeaderLabel ColorAttr + Footer ColorAttr + FooterBg ColorAttr + FooterBorder ColorAttr + FooterLabel ColorAttr Separator ColorAttr Scrollbar ColorAttr Border ColorAttr @@ -612,6 +616,7 @@ const ( WindowPreview WindowInput WindowHeader + WindowFooter ) type Renderer interface { @@ -720,6 +725,9 @@ var ( ColHeader ColorPair ColHeaderBorder ColorPair ColHeaderLabel ColorPair + ColFooter ColorPair + ColFooterBorder ColorPair + ColFooterLabel ColorPair ColSeparator ColorPair ColScrollbar ColorPair ColGapLine ColorPair @@ -758,6 +766,7 @@ func EmptyTheme() *ColorTheme { Cursor: ColorAttr{colUndefined, AttrUndefined}, Marker: ColorAttr{colUndefined, AttrUndefined}, Header: ColorAttr{colUndefined, AttrUndefined}, + Footer: ColorAttr{colUndefined, AttrUndefined}, Border: ColorAttr{colUndefined, AttrUndefined}, BorderLabel: ColorAttr{colUndefined, AttrUndefined}, ListLabel: ColorAttr{colUndefined, AttrUndefined}, @@ -778,6 +787,9 @@ func EmptyTheme() *ColorTheme { HeaderBg: ColorAttr{colUndefined, AttrUndefined}, HeaderBorder: ColorAttr{colUndefined, AttrUndefined}, HeaderLabel: ColorAttr{colUndefined, AttrUndefined}, + FooterBg: ColorAttr{colUndefined, AttrUndefined}, + FooterBorder: ColorAttr{colUndefined, AttrUndefined}, + FooterLabel: ColorAttr{colUndefined, AttrUndefined}, GapLine: ColorAttr{colUndefined, AttrUndefined}, Nth: ColorAttr{colUndefined, AttrUndefined}, } @@ -825,6 +837,9 @@ func NoColorTheme() *ColorTheme { HeaderBg: ColorAttr{colDefault, AttrUndefined}, HeaderBorder: ColorAttr{colDefault, AttrUndefined}, HeaderLabel: ColorAttr{colDefault, AttrUndefined}, + FooterBg: ColorAttr{colDefault, AttrUndefined}, + FooterBorder: ColorAttr{colDefault, AttrUndefined}, + FooterLabel: ColorAttr{colDefault, AttrUndefined}, GapLine: ColorAttr{colDefault, AttrUndefined}, Nth: ColorAttr{colUndefined, AttrUndefined}, } @@ -852,6 +867,7 @@ func init() { Cursor: ColorAttr{colRed, AttrUndefined}, Marker: ColorAttr{colMagenta, AttrUndefined}, Header: ColorAttr{colCyan, AttrUndefined}, + Footer: ColorAttr{colCyan, AttrUndefined}, Border: ColorAttr{colBlack, AttrUndefined}, BorderLabel: ColorAttr{colWhite, AttrUndefined}, Ghost: ColorAttr{colUndefined, Dim}, @@ -869,6 +885,12 @@ func init() { InputBg: ColorAttr{colUndefined, AttrUndefined}, InputBorder: ColorAttr{colUndefined, AttrUndefined}, InputLabel: ColorAttr{colUndefined, AttrUndefined}, + HeaderBg: ColorAttr{colUndefined, AttrUndefined}, + HeaderBorder: ColorAttr{colUndefined, AttrUndefined}, + HeaderLabel: ColorAttr{colUndefined, AttrUndefined}, + FooterBg: ColorAttr{colUndefined, AttrUndefined}, + FooterBorder: ColorAttr{colUndefined, AttrUndefined}, + FooterLabel: ColorAttr{colUndefined, AttrUndefined}, GapLine: ColorAttr{colUndefined, AttrUndefined}, Nth: ColorAttr{colUndefined, AttrUndefined}, } @@ -893,6 +915,7 @@ func init() { Cursor: ColorAttr{161, AttrUndefined}, Marker: ColorAttr{168, AttrUndefined}, Header: ColorAttr{109, AttrUndefined}, + Footer: ColorAttr{109, AttrUndefined}, Border: ColorAttr{59, AttrUndefined}, BorderLabel: ColorAttr{145, AttrUndefined}, Ghost: ColorAttr{colUndefined, Dim}, @@ -910,6 +933,12 @@ func init() { InputBg: ColorAttr{colUndefined, AttrUndefined}, InputBorder: ColorAttr{colUndefined, AttrUndefined}, InputLabel: ColorAttr{colUndefined, AttrUndefined}, + HeaderBg: ColorAttr{colUndefined, AttrUndefined}, + HeaderBorder: ColorAttr{colUndefined, AttrUndefined}, + HeaderLabel: ColorAttr{colUndefined, AttrUndefined}, + FooterBg: ColorAttr{colUndefined, AttrUndefined}, + FooterBorder: ColorAttr{colUndefined, AttrUndefined}, + FooterLabel: ColorAttr{colUndefined, AttrUndefined}, GapLine: ColorAttr{colUndefined, AttrUndefined}, Nth: ColorAttr{colUndefined, AttrUndefined}, } @@ -934,6 +963,7 @@ func init() { Cursor: ColorAttr{161, AttrUndefined}, Marker: ColorAttr{168, AttrUndefined}, Header: ColorAttr{31, AttrUndefined}, + Footer: ColorAttr{31, AttrUndefined}, Border: ColorAttr{145, AttrUndefined}, BorderLabel: ColorAttr{59, AttrUndefined}, Ghost: ColorAttr{colUndefined, Dim}, @@ -954,6 +984,9 @@ func init() { HeaderBg: ColorAttr{colUndefined, AttrUndefined}, HeaderBorder: ColorAttr{colUndefined, AttrUndefined}, HeaderLabel: ColorAttr{colUndefined, AttrUndefined}, + FooterBg: ColorAttr{colUndefined, AttrUndefined}, + FooterBorder: ColorAttr{colUndefined, AttrUndefined}, + FooterLabel: ColorAttr{colUndefined, AttrUndefined}, GapLine: ColorAttr{colUndefined, AttrUndefined}, Nth: ColorAttr{colUndefined, AttrUndefined}, } @@ -989,6 +1022,7 @@ func InitTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool, hasInp theme.Cursor = o(baseTheme.Cursor, theme.Cursor) theme.Marker = o(baseTheme.Marker, theme.Marker) theme.Header = o(baseTheme.Header, theme.Header) + theme.Footer = o(baseTheme.Footer, theme.Footer) theme.Border = o(baseTheme.Border, theme.Border) theme.BorderLabel = o(baseTheme.BorderLabel, theme.BorderLabel) @@ -1042,6 +1076,10 @@ func InitTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool, hasInp theme.HeaderBorder = o(theme.Border, theme.HeaderBorder) theme.HeaderLabel = o(theme.BorderLabel, theme.HeaderLabel) + theme.FooterBg = o(theme.Bg, theme.FooterBg) + theme.FooterBorder = o(theme.Border, theme.FooterBorder) + theme.FooterLabel = o(theme.BorderLabel, theme.FooterLabel) + initPalette(theme) } @@ -1095,6 +1133,9 @@ func initPalette(theme *ColorTheme) { ColHeader = pair(theme.Header, theme.HeaderBg) ColHeaderBorder = pair(theme.HeaderBorder, theme.HeaderBg) ColHeaderLabel = pair(theme.HeaderLabel, theme.HeaderBg) + ColFooter = pair(theme.Footer, theme.FooterBg) + ColFooterBorder = pair(theme.FooterBorder, theme.FooterBg) + ColFooterLabel = pair(theme.FooterLabel, theme.FooterBg) } func runeWidth(r rune) int { |
