mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-02-13 01:18:36 +00:00
parent
56fef7c8df
commit
9d6637c1b3
10
CHANGELOG.md
10
CHANGELOG.md
@ -61,6 +61,16 @@ Also, fzf now offers "style presets" for quick customization, which can be activ
|
|||||||
- `transform-header-label`
|
- `transform-header-label`
|
||||||
- Added `--preview-border[=STYLE]` as short for `--preview-window=border[-STYLE]`
|
- Added `--preview-border[=STYLE]` as short for `--preview-window=border[-STYLE]`
|
||||||
- Added new preview border style `line` which draws a single separator line between the preview window and the rest of the interface
|
- Added new preview border style `line` which draws a single separator line between the preview window and the rest of the interface
|
||||||
|
- fzf will now render a dashed line (`┈┈`) in each `--gap` for better visual separation.
|
||||||
|
```sh
|
||||||
|
# All bash/zsh functions, highlighted
|
||||||
|
declare -f |
|
||||||
|
perl -0 -pe 's/^}\n/}\0/gm' |
|
||||||
|
bat --plain --language bash --color always |
|
||||||
|
fzf --read0 --ansi --layout reverse --multi --highlight-line \
|
||||||
|
--gap
|
||||||
|
```
|
||||||
|
* You can customize the line using `--gap-line[=STR]`.
|
||||||
- You can specify `border-native` to `--tmux` so that native tmux border is used instead of `--border`. This can be useful if you start a different program from inside the popup.
|
- You can specify `border-native` to `--tmux` so that native tmux border is used instead of `--border`. This can be useful if you start a different program from inside the popup.
|
||||||
```sh
|
```sh
|
||||||
fzf --tmux border-native --bind 'enter:execute:less {}'
|
fzf --tmux border-native --bind 'enter:execute:less {}'
|
||||||
|
@ -582,6 +582,7 @@ type Options struct {
|
|||||||
HeaderLines int
|
HeaderLines int
|
||||||
HeaderFirst bool
|
HeaderFirst bool
|
||||||
Gap int
|
Gap int
|
||||||
|
GapLine *string
|
||||||
Ellipsis *string
|
Ellipsis *string
|
||||||
Scrollbar *string
|
Scrollbar *string
|
||||||
Margin [4]sizeSpec
|
Margin [4]sizeSpec
|
||||||
@ -2567,6 +2568,15 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
|
|||||||
}
|
}
|
||||||
case "--no-gap":
|
case "--no-gap":
|
||||||
opts.Gap = 0
|
opts.Gap = 0
|
||||||
|
case "--gap-line":
|
||||||
|
if given, bar := optionalNextString(); given {
|
||||||
|
opts.GapLine = &bar
|
||||||
|
} else {
|
||||||
|
opts.GapLine = nil
|
||||||
|
}
|
||||||
|
case "--no-gap-line":
|
||||||
|
empty := ""
|
||||||
|
opts.GapLine = &empty
|
||||||
case "--ellipsis":
|
case "--ellipsis":
|
||||||
str, err := nextString("ellipsis string required")
|
str, err := nextString("ellipsis string required")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -2987,6 +2997,14 @@ func postProcessOptions(opts *Options) error {
|
|||||||
opts.Pointer = &defaultPointer
|
opts.Pointer = &defaultPointer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opts.GapLine == nil {
|
||||||
|
defaultGapLine := "┈"
|
||||||
|
if !opts.Unicode {
|
||||||
|
defaultGapLine = "-"
|
||||||
|
}
|
||||||
|
opts.GapLine = &defaultGapLine
|
||||||
|
}
|
||||||
|
|
||||||
markerLen := 1
|
markerLen := 1
|
||||||
if opts.Marker == nil {
|
if opts.Marker == nil {
|
||||||
if opts.MarkerMulti != nil && opts.MarkerMulti[0] == "" {
|
if opts.MarkerMulti != nil && opts.MarkerMulti[0] == "" {
|
||||||
|
@ -267,6 +267,8 @@ type Terminal struct {
|
|||||||
hscrollOff int
|
hscrollOff int
|
||||||
scrollOff int
|
scrollOff int
|
||||||
gap int
|
gap int
|
||||||
|
gapLine labelPrinter
|
||||||
|
gapLineLen int
|
||||||
wordRubout string
|
wordRubout string
|
||||||
wordNext string
|
wordNext string
|
||||||
cx int
|
cx int
|
||||||
@ -949,6 +951,11 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
|
|||||||
t.separator, t.separatorLen = t.ansiLabelPrinter(bar, &tui.ColSeparator, true)
|
t.separator, t.separatorLen = t.ansiLabelPrinter(bar, &tui.ColSeparator, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gap line
|
||||||
|
if t.gap > 0 && len(*opts.GapLine) > 0 {
|
||||||
|
t.gapLine, t.gapLineLen = t.ansiLabelPrinter(*opts.GapLine, &tui.ColListBorder, true)
|
||||||
|
}
|
||||||
|
|
||||||
if opts.Ellipsis != nil {
|
if opts.Ellipsis != nil {
|
||||||
t.ellipsis = *opts.Ellipsis
|
t.ellipsis = *opts.Ellipsis
|
||||||
} else if t.unicode {
|
} else if t.unicode {
|
||||||
@ -2446,9 +2453,7 @@ func (t *Terminal) canSpanMultiLines() bool {
|
|||||||
return t.multiLine || t.wrap || t.gap > 0
|
return t.multiLine || t.wrap || t.gap > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Terminal) renderEmptyLine(line int, barRange [2]int) {
|
func (t *Terminal) renderBar(line int, barRange [2]int) {
|
||||||
t.move(line, 0, true)
|
|
||||||
t.markEmptyLine(line)
|
|
||||||
// If the screen is not filled with the list in non-multi-line mode,
|
// If the screen is not filled with the list in non-multi-line mode,
|
||||||
// scrollbar is not visible at all. But in multi-line mode, we may need
|
// scrollbar is not visible at all. But in multi-line mode, we may need
|
||||||
// to redraw the scrollbar character at the end.
|
// to redraw the scrollbar character at the end.
|
||||||
@ -2457,6 +2462,29 @@ func (t *Terminal) renderEmptyLine(line int, barRange [2]int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Terminal) renderEmptyLine(line int, barRange [2]int) {
|
||||||
|
t.move(line, 0, true)
|
||||||
|
t.markEmptyLine(line)
|
||||||
|
t.renderBar(line, barRange)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Terminal) renderGapLine(line int, barRange [2]int, drawLine bool) {
|
||||||
|
t.move(line, 0, false)
|
||||||
|
t.window.CPrint(tui.ColCursorEmpty, t.pointerEmpty)
|
||||||
|
t.window.Print(t.markerEmpty)
|
||||||
|
x := t.pointerLen + t.markerLen
|
||||||
|
|
||||||
|
width := t.window.Width() - x - 1
|
||||||
|
if drawLine && t.gapLine != nil {
|
||||||
|
t.gapLine(t.window, width)
|
||||||
|
} else {
|
||||||
|
t.move(line, x, true)
|
||||||
|
}
|
||||||
|
t.markOtherLine(line)
|
||||||
|
t.renderBar(line, barRange)
|
||||||
|
t.prevLines[line].width = width
|
||||||
|
}
|
||||||
|
|
||||||
func (t *Terminal) printList() {
|
func (t *Terminal) printList() {
|
||||||
t.constrain()
|
t.constrain()
|
||||||
barLength, barStart := t.getScrollbar()
|
barLength, barStart := t.getScrollbar()
|
||||||
@ -2629,7 +2657,7 @@ func (t *Terminal) printItem(result Result, line int, maxLine int, index int, cu
|
|||||||
}
|
}
|
||||||
for i := 0; i < t.gap && finalLineNum < maxLine; i++ {
|
for i := 0; i < t.gap && finalLineNum < maxLine; i++ {
|
||||||
finalLineNum++
|
finalLineNum++
|
||||||
t.renderEmptyLine(finalLineNum, barRange)
|
t.renderGapLine(finalLineNum, barRange, i == t.gap-1)
|
||||||
}
|
}
|
||||||
return finalLineNum
|
return finalLineNum
|
||||||
}
|
}
|
||||||
|
@ -3423,28 +3423,28 @@ class TestGoFZF < TestBase
|
|||||||
│ >
|
│ >
|
||||||
│ 100/100 ──────
|
│ 100/100 ──────
|
||||||
│ > 1
|
│ > 1
|
||||||
│
|
│ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈
|
||||||
│ 2
|
│ 2
|
||||||
│
|
│ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈
|
||||||
│ 3
|
│ 3
|
||||||
│
|
│ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈
|
||||||
│ 4
|
│ 4
|
||||||
BLOCK
|
BLOCK
|
||||||
tmux.until { assert_block(block, _1) }
|
tmux.until { assert_block(block, _1) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gap_2
|
def test_gap_2
|
||||||
tmux.send_keys %(seq 100 | #{FZF} --gap=2 --border --reverse), :Enter
|
tmux.send_keys %(seq 100 | #{FZF} --gap=2 --gap-line xyz --border --reverse), :Enter
|
||||||
block = <<~BLOCK
|
block = <<~BLOCK
|
||||||
╭─────────────────
|
╭─────────────────
|
||||||
│ >
|
│ >
|
||||||
│ 100/100 ──────
|
│ 100/100 ──────
|
||||||
│ > 1
|
│ > 1
|
||||||
│
|
│
|
||||||
│
|
│ xyzxyzxyzxyzxy
|
||||||
│ 2
|
│ 2
|
||||||
│
|
│
|
||||||
│
|
│ xyzxyzxyzxyzxy
|
||||||
│ 3
|
│ 3
|
||||||
BLOCK
|
BLOCK
|
||||||
tmux.until { assert_block(block, _1) }
|
tmux.until { assert_block(block, _1) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user