Skip to content

Commit

Permalink
Implement multi-line display of multi-line items
Browse files Browse the repository at this point in the history
  • Loading branch information
junegunn committed May 19, 2024
1 parent 5b204c5 commit 17d8bb9
Show file tree
Hide file tree
Showing 6 changed files with 399 additions and 180 deletions.
3 changes: 3 additions & 0 deletions man/man1/fzf.1
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ the details.
.B "--cycle"
Enable cyclic scroll
.TP
.B "--no-multi-line"
Disable multi-line display of items when using \fB--read0\fR
.TP
.B "--keep-right"
Keep the right end of the line visible when it's too long. Effective only when
the query string is empty.
Expand Down
7 changes: 7 additions & 0 deletions src/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const Usage = `usage: fzf [options]
--no-mouse Disable mouse
--bind=KEYBINDS Custom key bindings. Refer to the man page.
--cycle Enable cyclic scroll
--no-multi-line Disable multi-line display of items when using --read0
--keep-right Keep the right end of the line visible on overflow
--scroll-off=LINES Number of screen lines to keep above or below when
scrolling to the top or to the bottom (default: 0)
Expand Down Expand Up @@ -409,6 +410,7 @@ type Options struct {
MinHeight int
Layout layoutType
Cycle bool
MultiLine bool
CursorLine bool
KeepRight bool
Hscroll bool
Expand Down Expand Up @@ -506,6 +508,7 @@ func defaultOptions() *Options {
MinHeight: 10,
Layout: layoutDefault,
Cycle: false,
MultiLine: true,
KeepRight: false,
Hscroll: true,
HscrollOff: 10,
Expand Down Expand Up @@ -2062,6 +2065,10 @@ func parseOptions(opts *Options, allArgs []string) error {
opts.CursorLine = false
case "--no-cycle":
opts.Cycle = false
case "--multi-line":
opts.MultiLine = true
case "--no-multi-line":
opts.MultiLine = false
case "--keep-right":
opts.KeepRight = true
case "--no-keep-right":
Expand Down
8 changes: 5 additions & 3 deletions src/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Offset [2]int32
type colorOffset struct {
offset [2]int32
color tui.ColorPair
match bool
}

type Result struct {
Expand Down Expand Up @@ -109,7 +110,7 @@ func (result *Result) colorOffsets(matchOffsets []Offset, theme *tui.ColorTheme,
if len(itemColors) == 0 {
var offsets []colorOffset
for _, off := range matchOffsets {
offsets = append(offsets, colorOffset{offset: [2]int32{off[0], off[1]}, color: colMatch})
offsets = append(offsets, colorOffset{offset: [2]int32{off[0], off[1]}, color: colMatch, match: true})
}
return offsets
}
Expand Down Expand Up @@ -193,12 +194,13 @@ func (result *Result) colorOffsets(matchOffsets []Offset, theme *tui.ColorTheme,
}
}
colors = append(colors, colorOffset{
offset: [2]int32{int32(start), int32(idx)}, color: color})
offset: [2]int32{int32(start), int32(idx)}, color: color, match: true})
} else {
ansi := itemColors[curr-1]
colors = append(colors, colorOffset{
offset: [2]int32{int32(start), int32(idx)},
color: ansiToColorPair(ansi, colBase)})
color: ansiToColorPair(ansi, colBase),
match: false})
}
}
}
Expand Down
Loading

0 comments on commit 17d8bb9

Please sign in to comment.