Different marker for the first and last line of multi-line entries
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Can be configured via `--marker-multi-line`
authored by Junegunn Choi · committed by Junegunn Choi · parent 0ccbd79 · Browse files · 6 files·+323 added−139 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+323 added−139 removed
- tests:+52 added−2 removed
- other:+271 added−137 removed
Provenance
- Commit
2f51eb2- Tree
6ad0a17- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
0ccbd79
6 files changed+323 added−139 removed
modified:man/man1/fzf.1+4 added
453 unmodified lines454 .TP455 .BI "--marker=" "STR"456 Multi-select marker (default: '┃' or '>' depending on \fB--no-unicode\fR)457 .TP458+.BI "--marker-multi-line=" "STR"459+Multi-select marker for multi-line entries. 3 elements for top, middle, and bottom.460+(default: '╻┃╹' or '.|'' depending on \fB--no-unicode\fR)461+.TP462 .BI "--header=" "STR"463 The given string will be printed as the sticky header. The lines are displayed464 in the given order from top to bottom regardless of \fB--layout\fR option, and465 are not affected by \fB--with-nth\fR. ANSI color codes are processed even when1153 unmodified linesmodified:src/util/chars.go+7 added-7 removed
73 unmodified lines74 func (chars *Chars) Bytes() []byte {75 return chars.slice76 }77 78-func (chars *Chars) NumLines(atMost int) int {78+func (chars *Chars) NumLines(atMost int) (int, bool) {79 lines := 180 if runes := chars.optionalRunes(); runes != nil {81 for _, r := range runes {82 if r == '\n' {83 lines++84 }85- if lines >= atMost {86- return atMost85+ if lines > atMost {86+ return atMost, true87 }88 }89- return lines89+ return lines, false90 }91 92 for idx := 0; idx < len(chars.slice); idx++ {93 found := bytes.IndexByte(chars.slice[idx:], '\n')2 unmodified lines96 }97 98 idx += found99 lines++100- if lines >= atMost {101- return atMost100+ if lines > atMost {101+ return atMost, true102 }103 }104- return lines104+ return lines, false105 }106 107 func (chars *Chars) optionalRunes() []rune {108 if chars.inBytes {120 unmodified linesmodified:src/options.go+181 added-114 removed
25 unmodified lines26 27 Usage: fzf [options]28 29 Search30- -x, --extended Extended-search mode31- (enabled by default; +x or --no-extended to disable)32- -e, --exact Enable Exact-match33- -i, --ignore-case Case-insensitive match (default: smart-case match)34- +i, --no-ignore-case Case-sensitive match35- --scheme=SCHEME Scoring scheme [default|path|history]36- --literal Do not normalize latin script letters before matching37- -n, --nth=N[,..] Comma-separated list of field index expressions38- for limiting search scope. Each can be a non-zero39- integer or a range expression ([BEGIN]..[END]).40- --with-nth=N[,..] Transform the presentation of each line using41- field index expressions42- -d, --delimiter=STR Field delimiter regex (default: AWK-style)43- +s, --no-sort Do not sort the result44- --track Track the current selection when the result is updated45- --tac Reverse the order of the input46- --disabled Do not perform search47- --tiebreak=CRI[,..] Comma-separated list of sort criteria to apply48- when the scores are tied [length|chunk|begin|end|index]49- (default: length)50-30+ -x, --extended Extended-search mode31+ (enabled by default; +x or --no-extended to disable)32+ -e, --exact Enable Exact-match33+ -i, --ignore-case Case-insensitive match (default: smart-case match)34+ +i, --no-ignore-case Case-sensitive match35+ --scheme=SCHEME Scoring scheme [default|path|history]36+ --literal Do not normalize latin script letters before matching37+ -n, --nth=N[,..] Comma-separated list of field index expressions38+ for limiting search scope. Each can be a non-zero39+ integer or a range expression ([BEGIN]..[END]).40+ --with-nth=N[,..] Transform the presentation of each line using41+ field index expressions42+ -d, --delimiter=STR Field delimiter regex (default: AWK-style)43+ +s, --no-sort Do not sort the result44+ --track Track the current selection when the result is updated45+ --tac Reverse the order of the input46+ --disabled Do not perform search47+ --tiebreak=CRI[,..] Comma-separated list of sort criteria to apply48+ when the scores are tied [length|chunk|begin|end|index]49+ (default: length)50 Interface52- -m, --multi[=MAX] Enable multi-select with tab/shift-tab53- --no-mouse Disable mouse54- --bind=KEYBINDS Custom key bindings. Refer to the man page.55- --cycle Enable cyclic scroll56- --no-multi-line Disable multi-line display of items when using --read057- --keep-right Keep the right end of the line visible on overflow58- --scroll-off=LINES Number of screen lines to keep above or below when59- scrolling to the top or to the bottom (default: 0)60- --no-hscroll Disable horizontal scroll61- --hscroll-off=COLS Number of screen columns to keep to the right of the62- highlighted substring (default: 10)63- --filepath-word Make word-wise movements respect path separators64- --jump-labels=CHARS Label characters for jump mode51+ -m, --multi[=MAX] Enable multi-select with tab/shift-tab52+ --no-mouse Disable mouse53+ --bind=KEYBINDS Custom key bindings. Refer to the man page.54+ --cycle Enable cyclic scroll55+ --no-multi-line Disable multi-line display of items when using --read056+ --keep-right Keep the right end of the line visible on overflow57+ --scroll-off=LINES Number of screen lines to keep above or below when58+ scrolling to the top or to the bottom (default: 0)59+ --no-hscroll Disable horizontal scroll60+ --hscroll-off=COLS Number of screen columns to keep to the right of the61+ highlighted substring (default: 10)62+ --filepath-word Make word-wise movements respect path separators63+ --jump-labels=CHARS Label characters for jump mode64 65 Layout67- --height=[~]HEIGHT[%] Display fzf window below the cursor with the given68- height instead of using fullscreen.69- A negative value is calculated as the terminal height70- minus the given value.71- If prefixed with '~', fzf will determine the height72- according to the input size.73- --min-height=HEIGHT Minimum height when --height is given in percent74- (default: 10)75- --tmux=OPTS Start fzf in a tmux popup (requires tmux 3.3+)76- [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]]77- --layout=LAYOUT Choose layout: [default|reverse|reverse-list]78- --border[=STYLE] Draw border around the finder79- [rounded|sharp|bold|block|thinblock|double|horizontal|vertical|80- top|bottom|left|right|none] (default: rounded)81- --border-label=LABEL Label to print on the border82- --border-label-pos=COL Position of the border label83- [POSITIVE_INTEGER: columns from left|84- NEGATIVE_INTEGER: columns from right][:bottom]85- (default: 0 or center)86- --margin=MARGIN Screen margin (TRBL | TB,RL | T,RL,B | T,R,B,L)87- --padding=PADDING Padding inside border (TRBL | TB,RL | T,RL,B | T,R,B,L)88- --info=STYLE Finder info style89- [default|right|hidden|inline[-right][:PREFIX]]90- --separator=STR String to form horizontal separator on info line91- --no-separator Hide info line separator92- --scrollbar[=C1[C2]] Scrollbar character(s) (each for main and preview window)93- --no-scrollbar Hide scrollbar94- --prompt=STR Input prompt (default: '> ')95- --pointer=STR Pointer to the current line (default: '▌' or '>')96- --marker=STR Multi-select marker (default: '┃' or '>')97- --header=STR String to print as header98- --header-lines=N The first N lines of the input are treated as header99- --header-first Print header before the prompt line100- --ellipsis=STR Ellipsis to show when line is truncated (default: '..')66+ --height=[~]HEIGHT[%] Display fzf window below the cursor with the given67+ height instead of using fullscreen.68+ A negative value is calculated as the terminal height69+ minus the given value.70+ If prefixed with '~', fzf will determine the height71+ according to the input size.72+ --min-height=HEIGHT Minimum height when --height is given in percent73+ (default: 10)74+ --tmux=OPTS Start fzf in a tmux popup (requires tmux 3.3+)75+ [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]]76+ --layout=LAYOUT Choose layout: [default|reverse|reverse-list]77+ --border[=STYLE] Draw border around the finder78+ [rounded|sharp|bold|block|thinblock|double|horizontal|vertical|79+ top|bottom|left|right|none] (default: rounded)80+ --border-label=LABEL Label to print on the border81+ --border-label-pos=COL Position of the border label82+ [POSITIVE_INTEGER: columns from left|83+ NEGATIVE_INTEGER: columns from right][:bottom]84+ (default: 0 or center)85+ --margin=MARGIN Screen margin (TRBL | TB,RL | T,RL,B | T,R,B,L)86+ --padding=PADDING Padding inside border (TRBL | TB,RL | T,RL,B | T,R,B,L)87+ --info=STYLE Finder info style88+ [default|right|hidden|inline[-right][:PREFIX]]89+ --separator=STR String to form horizontal separator on info line90+ --no-separator Hide info line separator91+ --scrollbar[=C1[C2]] Scrollbar character(s) (each for main and preview window)92+ --no-scrollbar Hide scrollbar93+ --prompt=STR Input prompt (default: '> ')94+ --pointer=STR Pointer to the current line (default: '▌' or '>')95+ --marker=STR Multi-select marker (default: '┃' or '>')96+ --marker-multi-line=STR Multi-select marker for multi-line entries;97+ 3 elements for top, middle, and bottom (default: '╻┃╹')98+ --header=STR String to print as header99+ --header-lines=N The first N lines of the input are treated as header100+ --header-first Print header before the prompt line101+ --ellipsis=STR Ellipsis to show when line is truncated (default: '..')102 103 Display103- --ansi Enable processing of ANSI color codes104- --tabstop=SPACES Number of spaces for a tab character (default: 8)105- --color=COLSPEC Base scheme (dark|light|16|bw) and/or custom colors106- --highlight-line Highlight the whole current line107- --no-bold Do not use bold text104+ --ansi Enable processing of ANSI color codes105+ --tabstop=SPACES Number of spaces for a tab character (default: 8)106+ --color=COLSPEC Base scheme (dark|light|16|bw) and/or custom colors107+ --highlight-line Highlight the whole current line108+ --no-bold Do not use bold text109 110 History110- --history=FILE History file111- --history-size=N Maximum number of history entries (default: 1000)111+ --history=FILE History file112+ --history-size=N Maximum number of history entries (default: 1000)113 114 Preview114- --preview=COMMAND Command to preview highlighted line ({})115- --preview-window=OPT Preview window layout (default: right:50%)116- [up|down|left|right][,SIZE[%]]117- [,[no]wrap][,[no]cycle][,[no]follow][,[no]hidden]118- [,border-BORDER_OPT]119- [,+SCROLL[OFFSETS][/DENOM]][,~HEADER_LINES]120- [,default][,<SIZE_THRESHOLD(ALTERNATIVE_LAYOUT)]115+ --preview=COMMAND Command to preview highlighted line ({})116+ --preview-window=OPT Preview window layout (default: right:50%)117+ [up|down|left|right][,SIZE[%]]118+ [,[no]wrap][,[no]cycle][,[no]follow][,[no]hidden]119+ [,border-BORDER_OPT]120+ [,+SCROLL[OFFSETS][/DENOM]][,~HEADER_LINES]121+ [,default][,<SIZE_THRESHOLD(ALTERNATIVE_LAYOUT)]122 --preview-label=LABEL122- --preview-label-pos=N Same as --border-label and --border-label-pos,123- but for preview window123+ --preview-label-pos=N Same as --border-label and --border-label-pos,124+ but for preview window125 126 Scripting126- -q, --query=STR Start the finder with the given query127- -1, --select-1 Automatically select the only match128- -0, --exit-0 Exit immediately when there's no match129- -f, --filter=STR Filter mode. Do not start interactive finder.130- --print-query Print query as the first line131- --expect=KEYS Comma-separated list of keys to complete fzf132- --read0 Read input delimited by ASCII NUL characters133- --print0 Print output delimited by ASCII NUL characters134- --sync Synchronous search for multi-staged filtering135- --with-shell=STR Shell command and flags to start child processes with136- --listen[=[ADDR:]PORT] Start HTTP server to receive actions (POST /)137- (To allow remote process execution, use --listen-unsafe)127+ -q, --query=STR Start the finder with the given query128+ -1, --select-1 Automatically select the only match129+ -0, --exit-0 Exit immediately when there's no match130+ -f, --filter=STR Filter mode. Do not start interactive finder.131+ --print-query Print query as the first line132+ --expect=KEYS Comma-separated list of keys to complete fzf133+ --read0 Read input delimited by ASCII NUL characters134+ --print0 Print output delimited by ASCII NUL characters135+ --sync Synchronous search for multi-staged filtering136+ --with-shell=STR Shell command and flags to start child processes with137+ --listen[=[ADDR:]PORT] Start HTTP server to receive actions (POST /)138+ (To allow remote process execution, use --listen-unsafe)139 139- Directory traversal (Only used when $FZF_DEFAULT_COMMAND is not set)140- --walker=OPTS [file][,dir][,follow][,hidden] (default: file,follow,hidden)141- --walker-root=DIR Root directory from which to start walker (default: .)142- --walker-skip=DIRS Comma-separated list of directory names to skip143- (default: .git,node_modules)140+ Directory traversal (Only used when $FZF_DEFAULT_COMMAND is not set)141+ --walker=OPTS [file][,dir][,follow][,hidden] (default: file,follow,hidden)142+ --walker-root=DIR Root directory from which to start walker (default: .)143+ --walker-skip=DIRS Comma-separated list of directory names to skip144+ (default: .git,node_modules)145 146 Shell integration146- --bash Print script to set up Bash shell integration147- --zsh Print script to set up Zsh shell integration148- --fish Print script to set up Fish shell integration147+ --bash Print script to set up Bash shell integration148+ --zsh Print script to set up Zsh shell integration149+ --fish Print script to set up Fish shell integration150 151 Help151- --version Display version information and exit152- --help Show this message153- --man Show man page152+ --version Display version information and exit153+ --help Show this message154+ --man Show man page155 156 Environment variables156- FZF_DEFAULT_COMMAND Default command to use when input is tty157- FZF_DEFAULT_OPTS Default options (e.g. '--layout=reverse --info=inline')158- FZF_DEFAULT_OPTS_FILE Location of the file to read default options from159- FZF_API_KEY X-API-Key header for HTTP server (--listen)157+ FZF_DEFAULT_COMMAND Default command to use when input is tty158+ FZF_DEFAULT_OPTS Default options (e.g. '--layout=reverse --info=inline')159+ FZF_DEFAULT_OPTS_FILE Location of the file to read default options from160+ FZF_API_KEY X-API-Key header for HTTP server (--listen)161 162 `163 164 const defaultInfoPrefix = " < "273 unmodified lines438 JumpLabels string439 Prompt string440 Pointer *string441 Marker *string442+ MarkerMulti [3]string443 Query string444 Select1 bool445 Exit0 bool446 Filter *string1401 unmodified lines1848 }1849 return [4]sizeSpec{}, errors.New("invalid " + opt + ": " + margin)1850 }1851 1852+func parseMarkerMultiLine(str string) ([3]string, error) {1853+ gr := uniseg.NewGraphemes(str)1854+ parts := []string{}1855+ totalWidth := 01856+ for gr.Next() {1857+ s := string(gr.Runes())1858+ totalWidth += uniseg.StringWidth(s)1859+ parts = append(parts, s)1860+ }1861+1862+ result := [3]string{}1863+ if totalWidth != 3 && totalWidth != 6 {1864+ return result, fmt.Errorf("invalid total marker width: %d (expected: 3 or 6)", totalWidth)1865+ }1866+1867+ expected := totalWidth / 31868+ idx := 01869+ for _, part := range parts {1870+ expected -= uniseg.StringWidth(part)1871+ result[idx] += part1872+ if expected <= 0 {1873+ idx++1874+ expected = totalWidth / 31875+ }1876+ if idx == 3 {1877+ break1878+ }1879+ }1880+ return result, nil1881+}1882+1883 func parseOptions(opts *Options, allArgs []string) error {1884 var err error1885 var historyMax int1886 if opts.History == nil {331 unmodified lines2218 if err != nil {2219 return err2220 }2221 case "--pointer":2189- str, err := nextString(allArgs, &i, "pointer sign string required")2222+ str, err := nextString(allArgs, &i, "pointer sign required")2223 if err != nil {2224 return err2225 }2226 str = firstLine(str)2227 opts.Pointer = &str2228 case "--marker":2196- str, err := nextString(allArgs, &i, "selected sign string required")2229+ str, err := nextString(allArgs, &i, "marker sign required")2230 if err != nil {2231 return err2232 }2233 str = firstLine(str)2234 opts.Marker = &str2235+ case "--marker-multi-line":2236+ str, err := nextString(allArgs, &i, "marker sign for multi-line entries required")2237+ if err != nil {2238+ return err2239+ }2240+ if opts.MarkerMulti, err = parseMarkerMultiLine(firstLine(str)); err != nil {2241+ return err2242+ }2243 case "--sync":2244 opts.Sync = true2245 case "--no-sync", "--async":2246 opts.Sync = false232 unmodified lines2479 opts.Pointer = &str2480 } else if match, value := optString(arg, "--marker="); match {2481 str := firstLine(value)2482 opts.Marker = &str2483+ } else if match, value := optString(arg, "--marker-multi-line="); match {2484+ if opts.MarkerMulti, err = parseMarkerMultiLine(firstLine(value)); err != nil {2485+ return err2486+ }2487 } else if match, value := optString(arg, "-n", "--nth="); match {2488 if opts.Nth, err = splitNth(value); err != nil {2489 return err2490 }233 unmodified lines2724 }2725 opts.Pointer = &defaultPointer2726 }2727 2728+ markerLen := 12729 if opts.Marker == nil {2684- // "▏" looks better, but not all terminals render it correctly2730+ // "▎" looks better, but not all terminals render it correctly2731 defaultMarker := "┃"2732 if !opts.Unicode {2733 defaultMarker = ">"2734 }2735 opts.Marker = &defaultMarker2736+ } else {2737+ markerLen = uniseg.StringWidth(*opts.Marker)2738 }2739 2740+ markerMultiLen := 12741+ if len(opts.MarkerMulti[0]) == 0 {2742+ if opts.Unicode {2743+ opts.MarkerMulti = [3]string{"╻", "┃", "╹"}2744+ } else {2745+ opts.MarkerMulti = [3]string{".", "|", "'"}2746+ }2747+ } else {2748+ markerMultiLen = uniseg.StringWidth(opts.MarkerMulti[0])2749+ }2750+ if markerMultiLen > markerLen {2751+ padded := *opts.Marker + " "2752+ opts.Marker = &padded2753+ } else if markerMultiLen < markerLen {2754+ for idx := range opts.MarkerMulti {2755+ opts.MarkerMulti[idx] += " "2756+ }2757+ }2758+2759 // Default actions for CTRL-N / CTRL-P when --history is set2760 if opts.History != nil {2761 if _, prs := opts.Keymap[tui.CtrlP.AsEvent()]; !prs {2762 opts.Keymap[tui.CtrlP.AsEvent()] = toActions(actPrevHistory)124 unmodified linesmodified:src/terminal.go+73 added-16 removed
175 unmodified lines176 }177 178 type labelPrinter func(tui.Window, int)179 180+type markerClass int181+182+const (183+ markerSingle markerClass = iota184+ markerTop185+ markerMiddle186+ markerBottom187+)188+189 type StatusItem struct {190 Index int `json:"index"`191 Text string `json:"text"`192 }33 unmodified lines226 pointerEmpty string227 marker string228 markerLen int229 markerEmpty string230+ markerMultiLine [3]string231 queryLen [2]int232 layout layoutType233 fullscreen bool234 keepRight bool529 unmodified lines764 pointer: *opts.Pointer,765 pointerLen: uniseg.StringWidth(*opts.Pointer),766 marker: *opts.Marker,767 markerLen: uniseg.StringWidth(*opts.Marker),768+ markerMultiLine: opts.MarkerMulti,769 wordRubout: wordRubout,770 wordNext: wordNext,771 cx: len(input),772 cy: 0,321 unmodified lines1094 total := t.merger.Length()1095 offset := util.Max(0, util.Min(t.offset, total-maxItems-1))1096 for idx := 0; idx < maxItems && idx+offset < total; idx++ {1097 item := t.merger.Get(idx + offset)1087- numLines += item.item.text.NumLines(maxItems)1098+ lines, _ := item.item.text.NumLines(maxItems)1099+ numLines += lines1100 count++1101 }1102 if count == 0 {1103 return 1791 unmodified lines1895 colors: colors}1896 1897 t.printHighlighted(Result{item: item},1898 tui.ColHeader, tui.ColHeader, false, false, line, line, true,1887- func(int) { t.window.Print(" ") }, nil)1899+ func(markerClass) { t.window.Print(" ") }, nil)1900 }1901 }1902 1903 func (t *Terminal) printList() {71 unmodified lines1975 t.prevLines[line].hasBar = printBar(line, false)1976 if !t.multiLine {1977 return line1978 }1967- return line + item.text.NumLines(maxLine-line+1) - 11979+ lines, _ := item.text.NumLines(maxLine - line + 1)1980+ return line + lines - 11981 }1982 1983 maxWidth := t.window.Width() - (t.pointerLen + t.markerLen + 1)1984 postTask := func(lineNum int, width int) {19 unmodified lines2004 t.prevLines[lineNum] = newLine2005 }2006 2007 var finalLineNum int2008+ markerFor := func(markerClass markerClass) string {2009+ marker := t.marker2010+ switch markerClass {2011+ case markerTop:2012+ marker = t.markerMultiLine[0]2013+ case markerMiddle:2014+ marker = t.markerMultiLine[1]2015+ case markerBottom:2016+ marker = t.markerMultiLine[2]2017+ }2018+ return marker2019+ }2020 if current {1996- preTask := func(lineOffset int) {2021+ preTask := func(marker markerClass) {2022 if len(label) == 0 {2023 t.window.CPrint(tui.ColCurrentCursorEmpty, t.pointerEmpty)2024 } else {2025 t.window.CPrint(tui.ColCurrentCursor, label)2026 }2027 if selected {2003- t.window.CPrint(tui.ColCurrentMarker, t.marker)2028+ t.window.CPrint(tui.ColCurrentMarker, markerFor(marker))2029 } else {2030 t.window.CPrint(tui.ColCurrentSelectedEmpty, t.markerEmpty)2031 }2032 }2033 finalLineNum = t.printHighlighted(result, tui.ColCurrent, tui.ColCurrentMatch, true, true, line, maxLine, forceRedraw, preTask, postTask)2034 } else {2010- preTask := func(lineOffset int) {2035+ preTask := func(marker markerClass) {2036 if len(label) == 0 {2037 t.window.CPrint(tui.ColCursorEmpty, t.pointerEmpty)2038 } else {2039 t.window.CPrint(tui.ColCursor, label)2040 }2041 if selected {2017- t.window.CPrint(tui.ColMarker, t.marker)2042+ t.window.CPrint(tui.ColMarker, markerFor(marker))2043 } else {2044 t.window.Print(t.markerEmpty)2045 }2046 }47 unmodified lines2094 func (t *Terminal) overflow(runes []rune, max int) bool {2095 return t.displayWidthWithLimit(runes, 0, max) > max2096 }2097 2073-func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMatch tui.ColorPair, current bool, match bool, lineNum int, maxLineNum int, forceRedraw bool, preTask func(int), postTask func(int, int)) int {2098+func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMatch tui.ColorPair, current bool, match bool, lineNum int, maxLineNum int, forceRedraw bool, preTask func(markerClass), postTask func(int, int)) int {2099 var displayWidth int2100 item := result.item2101 matchOffsets := []Offset{}2102 var pos *[]int17 unmodified lines2120 2121 finalLineNum := lineNum2122 numItemLines := 12123 cutoff := 02099- if t.multiLine && t.layout == layoutDefault {2124+ overflow := false2125+ topCutoff := false2126+ if t.multiLine {2127 maxLines := maxLineNum - lineNum + 12101- numItemLines = item.text.NumLines(maxLines)2128+ numItemLines, overflow = item.text.NumLines(maxLines)2129 // Cut off the upper lines in the 'default' layout2103- if !current && maxLines == numItemLines {2104- cutoff = item.text.NumLines(math.MaxInt32) - maxLines2130+ if t.layout == layoutDefault && !current && maxLines == numItemLines && overflow {2131+ actualLines, _ := item.text.NumLines(math.MaxInt32)2132+ cutoff = actualLines - maxLines2133+ topCutoff = true2134 }2135 }2136 for lineOffset := 0; from <= len(text) && (lineNum <= maxLineNum || maxLineNum == 0); lineOffset++ {2137 finalLineNum = lineNum41 unmodified lines2179 }2180 t.move(actualLineNum, 0, forceRedraw)2181 2182 if preTask != nil {2154- preTask(lineOffset)2183+ var marker markerClass2184+ if numItemLines == 1 {2185+ if !overflow {2186+ marker = markerSingle2187+ } else if topCutoff {2188+ marker = markerBottom2189+ } else {2190+ marker = markerTop2191+ }2192+ } else {2193+ if lineOffset == 0 { // First line2194+ if topCutoff {2195+ marker = markerMiddle2196+ } else {2197+ marker = markerTop2198+ }2199+ } else if lineOffset == numItemLines-1 { // Last line2200+ if topCutoff || !overflow {2201+ marker = markerBottom2202+ } else {2203+ marker = markerMiddle2204+ }2205+ } else {2206+ marker = markerMiddle2207+ }2208+ }2209+2210+ preTask(marker)2211 }2212 2213 maxWidth := t.window.Width() - (t.pointerLen + t.markerLen + 1)2214 ellipsis, ellipsisWidth := util.Truncate(t.ellipsis, maxWidth/2)2342 unmodified lines4557 numItemsFound := 04558 linesSum := 04559 4560 add := func(i int) bool {4505- lines := t.merger.Get(i).item.text.NumLines(numItems - linesSum)4561+ lines, _ := t.merger.Get(i).item.text.NumLines(numItems - linesSum)4562 linesSum += lines4563 if linesSum >= numItems {4564 if numItemsFound == 0 {4565 numItemsFound = 136 unmodified lines4602 prevOffset := newOffset4603 numItems := t.merger.Length()4604 itemLines := 14605 if t.multiLine && t.cy < numItems {4550- itemLines = t.merger.Get(t.cy).item.text.NumLines(maxLines)4606+ itemLines, _ = t.merger.Get(t.cy).item.text.NumLines(maxLines)4607 }4608 linesBefore := t.cy - newOffset4609 if t.multiLine {4610 linesBefore = 04611 for i := newOffset; i < t.cy && i < numItems; i++ {4556- linesBefore += t.merger.Get(i).item.text.NumLines(maxLines - linesBefore - itemLines)4612+ lines, _ := t.merger.Get(i).item.text.NumLines(maxLines - linesBefore - itemLines)4613+ linesBefore += lines4614 }4615 }4616 linesAfter := maxLines - (linesBefore + itemLines)4617 100 unmodified linesmodified:test/test_go.rb+52 added-2 removed
2750 unmodified lines2751 end2752 2753 def assert_block(expected, lines)2754 cols = expected.lines.map(&:chomp).map(&:length).max2755- actual = lines.reverse.take(expected.lines.length).reverse.map { _1[0, cols].rstrip + "\n" }.join2756- assert_equal_org expected, actual2755+ top = lines.take(expected.lines.length).map { _1[0, cols].rstrip + "\n" }.join2756+ bottom = lines.reverse.take(expected.lines.length).reverse.map { _1[0, cols].rstrip + "\n" }.join2757+ assert_includes [top, bottom], expected2758 end2759 2760 def test_height_range_fit2761 tmux.send_keys 'seq 3 | fzf --height ~100% --info=inline --border rounded', :Enter506 unmodified lines3268 tmux.until { |lines| assert(lines.any? { |line| line.include?('1 / 1') }) }3269 tmux.send_keys '99'3270 tmux.until { |lines| assert(lines.any? { |line| line.include?('0 / 0') }) }3271 end3272+3273+ def test_fzf_multi_line3274+ tmux.send_keys %[(echo -en '0\\0'; echo -en '1\\n2\\0'; seq 1000) | fzf --read0 --multi --bind load:select-all --border rounded], :Enter3275+ block = <<~BLOCK3276+ │ ┃9983277+ │ ┃9993278+ │ ┃10003279+ │ ╹3280+ │ ╻13281+ │ ╹23282+ │ >>03283+ │ 3/3 (3)3284+ │ >3285+ ╰───────────3286+ BLOCK3287+ tmux.until { assert_block(block, _1) }3288+ tmux.send_keys :Up, :Up3289+ block = <<~BLOCK3290+ ╭───────3291+ │ >╻13292+ │ >┃23293+ │ >┃33294+ BLOCK3295+ tmux.until { assert_block(block, _1) }3296+3297+ block = <<~BLOCK3298+ │ >┃3299+ │3300+ │ >3301+ ╰───3302+ BLOCK3303+ tmux.until { assert_block(block, _1) }3304+ end3305+3306+ def test_fzf_multi_line_reverse3307+ tmux.send_keys %[(echo -en '0\\0'; echo -en '1\\n2\\0'; seq 1000) | fzf --read0 --multi --bind load:select-all --border rounded --reverse], :Enter3308+ block = <<~BLOCK3309+ ╭───────────3310+ │ >3311+ │ 3/3 (3)3312+ │ >>03313+ │ ╻13314+ │ ╹23315+ │ ╻13316+ │ ┃23317+ │ ┃33318+ BLOCK3319+ tmux.until { assert_block(block, _1) }3320+ end3321 end3322 3323 module TestShell3324 def setup520 unmodified linesmodified:CHANGELOG.md+6 added
8 unmodified lines9 fzf --read0 --ansi --multi --highlight-line --reverse --tmux 70%10 ```11 - To disable multi-line display, use `--no-multi-line`12 - The default `--pointer` and `--marker` have been changed from `>` to Unicode bar characters as they look better with multi-line items13+- Added `--marker-multi-line` to customize the select marker for multi-line entries with the default set to `╻┃╹`14+ ```15+ ╻First line16+ ┃...17+ ╹Last line18+ ```19 - Native `--tmux` integration to replace fzf-tmux script20 ```sh21 # --tmux [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]]22 # Center, 90% width and 70% height2102 unmodified lines