Add horizontal separator after info panel (counter)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Close #3029
authored by Junegunn Choi · committed by Junegunn Choi · parent e61585f · Browse files · 5 files·+60 added−21 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+60 added−21 removed
- other:+60 added−21 removed
Provenance
- Commit
b9ca1fe- Tree
1501e81- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
e61585f
5 files changed+60 added−21 removed
modified:man/man1/fzf.1+1 added
392 unmodified lines393 \fBhl+ \fRHighlighted substrings (current line)394 \fBquery \fRQuery string395 \fBdisabled \fRQuery string when search is disabled396 \fBinfo \fRInfo line (match counters)397+ \fBseparator \fRHorizontal separator on info line (match counters)398 \fBborder \fRBorder around the window (\fB--border\fR and \fB--preview\fR)399 \fBlabel \fRBorder label (\fB--border-label\fR)400 \fBprompt \fRPrompt401 \fBpointer \fRPointer to the current line691 unmodified linesmodified:src/tui/tui.go+9 added
265 unmodified lines266 Info ColorAttr267 Cursor ColorAttr268 Selected ColorAttr269 Header ColorAttr270+ Separator ColorAttr271 Border ColorAttr272 BorderLabel ColorAttr273 }274 164 unmodified lines439 ColCurrentSelectedEmpty ColorPair440 ColSpinner ColorPair441 ColInfo ColorPair442 ColHeader ColorPair443+ ColSeparator ColorPair444 ColBorder ColorPair445 ColPreview ColorPair446 ColPreviewBorder ColorPair447 ColBorderLabel ColorPair18 unmodified lines466 Info: ColorAttr{colUndefined, AttrUndefined},467 Cursor: ColorAttr{colUndefined, AttrUndefined},468 Selected: ColorAttr{colUndefined, AttrUndefined},469 Header: ColorAttr{colUndefined, AttrUndefined},470+ Separator: ColorAttr{colUndefined, AttrUndefined},471 Border: ColorAttr{colUndefined, AttrUndefined},472 BorderLabel: ColorAttr{colUndefined, AttrUndefined},473 }474 }17 unmodified lines492 Info: ColorAttr{colDefault, AttrRegular},493 Cursor: ColorAttr{colDefault, AttrRegular},494 Selected: ColorAttr{colDefault, AttrRegular},495 Header: ColorAttr{colDefault, AttrRegular},496+ Separator: ColorAttr{colDefault, AttrRegular},497 Border: ColorAttr{colDefault, AttrRegular},498 BorderLabel: ColorAttr{colDefault, AttrRegular},499 }500 }22 unmodified lines523 Info: ColorAttr{colWhite, AttrUndefined},524 Cursor: ColorAttr{colRed, AttrUndefined},525 Selected: ColorAttr{colMagenta, AttrUndefined},526 Header: ColorAttr{colCyan, AttrUndefined},527+ Separator: ColorAttr{colBlack, AttrUndefined},528 Border: ColorAttr{colBlack, AttrUndefined},529 BorderLabel: ColorAttr{colWhite, AttrUndefined},530 }531 Dark256 = &ColorTheme{14 unmodified lines546 Info: ColorAttr{144, AttrUndefined},547 Cursor: ColorAttr{161, AttrUndefined},548 Selected: ColorAttr{168, AttrUndefined},549 Header: ColorAttr{109, AttrUndefined},550+ Separator: ColorAttr{59, AttrUndefined},551 Border: ColorAttr{59, AttrUndefined},552 BorderLabel: ColorAttr{145, AttrUndefined},553 }554 Light256 = &ColorTheme{14 unmodified lines569 Info: ColorAttr{101, AttrUndefined},570 Cursor: ColorAttr{161, AttrUndefined},571 Selected: ColorAttr{168, AttrUndefined},572 Header: ColorAttr{31, AttrUndefined},573+ Separator: ColorAttr{145, AttrUndefined},574 Border: ColorAttr{145, AttrUndefined},575 BorderLabel: ColorAttr{59, AttrUndefined},576 }577 }29 unmodified lines607 theme.Info = o(baseTheme.Info, theme.Info)608 theme.Cursor = o(baseTheme.Cursor, theme.Cursor)609 theme.Selected = o(baseTheme.Selected, theme.Selected)610 theme.Header = o(baseTheme.Header, theme.Header)611+ theme.Separator = o(baseTheme.Separator, theme.Separator)612 theme.Border = o(baseTheme.Border, theme.Border)613 theme.BorderLabel = o(baseTheme.BorderLabel, theme.BorderLabel)614 615 initPalette(theme)25 unmodified lines641 ColCurrentSelectedEmpty = pair(blank, theme.DarkBg)642 ColSpinner = pair(theme.Spinner, theme.Bg)643 ColInfo = pair(theme.Info, theme.Bg)644 ColHeader = pair(theme.Header, theme.Bg)645+ ColSeparator = pair(theme.Separator, theme.Bg)646 ColBorder = pair(theme.Border, theme.Bg)647 ColBorderLabel = pair(theme.BorderLabel, theme.Bg)648 ColPreview = pair(theme.PreviewFg, theme.PreviewBg)649 ColPreviewBorder = pair(theme.Border, theme.PreviewBg)1 unmodified linemodified:src/options.go+32 added-17 removed
67 unmodified lines68 [POSITIVE_INTEGER: columns from left|69 NEGATIVE_INTEGER: columns from right] (default: 0)70 --margin=MARGIN Screen margin (TRBL | TB,RL | T,RL,B | T,R,B,L)71 --padding=PADDING Padding inside border (TRBL | TB,RL | T,RL,B | T,R,B,L)72- --info=STYLE Finder info style [default|inline|hidden]72+ --info=STYLE Finder info style [default|inline|hidden[:nosep]]73 --prompt=STR Input prompt (default: '> ')74 --pointer=STR Pointer to the current line (default: '>')75 --marker=STR Multi-select marker (default: '>')76 --header=STR String to print as header91 unmodified lines168 layoutReverse169 layoutReverseList170 )171 172-type infoStyle int172+type infoLayout int173+type infoStyle struct {174+ layout infoLayout175+ separator bool176+}177 178 const (175- infoDefault infoStyle = iota179+ infoDefault infoLayout = iota180 infoInline181 infoHidden182 )183 129 unmodified lines313 Hscroll: true,314 HscrollOff: 10,315 ScrollOff: 0,316 FileWord: false,313- InfoStyle: infoDefault,317+ InfoStyle: infoStyle{layout: infoDefault, separator: true},318 JumpLabels: defaultJumpLabels,319 Prompt: "> ",320 Pointer: ">",321 Marker: ">",494 unmodified lines816 case "hl+":817 mergeAttr(&theme.CurrentMatch)818 case "border":819 mergeAttr(&theme.Border)820+ case "separator":821+ mergeAttr(&theme.Separator)822 case "label":823 mergeAttr(&theme.BorderLabel)824 case "prompt":825 mergeAttr(&theme.Prompt)393 unmodified lines1219 return layoutDefault1220 }1221 1222 func parseInfoStyle(str string) infoStyle {1223+ layout := infoDefault1224+ separator := true1225+1226+ for _, token := range regexp.MustCompile("[,:]").Split(strings.ToLower(str), -1) {1217- switch str {1218- case "default":1219- return infoDefault1220- case "inline":1221- return infoInline1222- case "hidden":1223- return infoHidden1224- default:1225- errorExit("invalid info style (expected: default / inline / hidden)")1227+ switch token {1228+ case "default":1229+ layout = infoDefault1230+ case "inline":1231+ layout = infoInline1232+ case "hidden":1233+ layout = infoHidden1234+ case "nosep":1235+ separator = false1236+ case "sep":1237+ separator = true1238+ default:1239+ errorExit("invalid info style (expected: default|inline|hidden[:nosep])")1240+ }1241 }1227- return infoDefault1242+ return infoStyle{layout: layout, separator: separator}1243 }1244 1245 func parsePreviewWindow(opts *previewOpts, input string) {1246 tokenRegex := regexp.MustCompile(`[:,]*(<([1-9][0-9]*)\(([^)<]+)\)|[^,:]+)`)253 unmodified lines1500 case "--info":1501 opts.InfoStyle = parseInfoStyle(1502 nextString(allArgs, &i, "info style required"))1503 case "--no-info":1489- opts.InfoStyle = infoHidden1504+ opts.InfoStyle.layout = infoHidden1505 case "--inline-info":1491- opts.InfoStyle = infoInline1506+ opts.InfoStyle.layout = infoInline1507 case "--no-inline-info":1493- opts.InfoStyle = infoDefault1508+ opts.InfoStyle.layout = infoDefault1509 case "--jump-labels":1510 opts.JumpLabels = nextString(allArgs, &i, "label characters required")1511 validateJumpLabels = true1512 case "-1", "--select-1":376 unmodified linesmodified:src/terminal.go+13 added-4 removed
493 unmodified lines494 effectiveMinHeight := minHeight495 if previewBox != nil && opts.Preview.aboveOrBelow() {496 effectiveMinHeight += 1 + borderLines(opts.Preview.border)497 }498- if opts.InfoStyle != infoDefault {498+ if opts.InfoStyle.layout != infoDefault {499 effectiveMinHeight--500 }501 effectiveMinHeight += borderLines(opts.BorderShape)502 return util.Min(termHeight, util.Max(evaluateHeight(opts, termHeight), effectiveMinHeight))173 unmodified lines676 return output, promptLen677 }678 679 func (t *Terminal) noInfoLine() bool {680- return t.infoStyle != infoDefault680+ return t.infoStyle.layout != infoDefault681 }682 683 // Input returns current query string684 func (t *Terminal) Input() (bool, []rune) {467 unmodified lines1152 1153 func (t *Terminal) printInfo() {1154 pos := 01155 line := t.promptLine()1156- switch t.infoStyle {1156+ switch t.infoStyle.layout {1157 case infoDefault:1158 t.move(line+1, 0, true)1159 if t.reading {1160 duration := int64(spinnerDuration)40 unmodified lines1201 }1202 if t.failed != nil && t.count == 0 {1203 output = fmt.Sprintf("[Command failed: %s]", *t.failed)1204 }1205+ maxWidth := t.window.Width() - pos1205- output = t.trimMessage(output, t.window.Width()-pos)1206+ output = t.trimMessage(output, maxWidth)1207 t.window.CPrint(tui.ColInfo, output)1208+1209+ if t.infoStyle.separator && len(output) < maxWidth-2 {1210+ bar := "─"1211+ if !t.unicode {1212+ bar = "-"1213+ }1214+ t.window.CPrint(tui.ColSeparator, " "+strings.Repeat(bar, maxWidth-len(output)-2))1215+ }1216 }1217 1218 func (t *Terminal) printHeader() {1219 if len(t.header) == 0 {1858 unmodified linesmodified:CHANGELOG.md+5 added
22 unmodified lines23 24 # Right-aligned (negative integer)25 fzf --height=10 --border-label="╢ $label ╟" --border=bottom --border-label-pos=-3 --color=label:italic:black26 ```27+- Info panel (counter) will be followed by a horizontal separator by default28+ - The color of the separator can be customized via `--color=separator:...`29+ - Separator can be disabled by adding `:nosep` to `--info`30+ - `--info=nosep`31+ - `--info=inline:nosep`32 33 0.34.034 ------35 - Added support for adaptive `--height`. If the `--height` value is prefixed1339 unmodified lines