m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-15 14:53:47 -05:00

Allow customizing scrollbar of the preview window via --scrollbar=xy

This commit is contained in:
Junegunn Choi
2023-05-16 23:53:10 +09:00
parent 43436e48e0
commit 17a13f00f8
4 changed files with 34 additions and 7 deletions

View File

@@ -199,6 +199,7 @@ type Terminal struct {
header0 []string
ellipsis string
scrollbar string
previewScrollbar string
ansi bool
tabstop int
margin [4]sizeSpec
@@ -690,8 +691,16 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
} else {
t.scrollbar = "|"
}
t.previewScrollbar = t.scrollbar
} else {
t.scrollbar = *opts.Scrollbar
runes := []rune(*opts.Scrollbar)
if len(runes) > 0 {
t.scrollbar = string(runes[0])
t.previewScrollbar = t.scrollbar
if len(runes) > 1 {
t.previewScrollbar = string(runes[1])
}
}
}
_, t.hasLoadActions = t.keymap[tui.Load.AsEvent()]
@@ -1956,7 +1965,7 @@ func (t *Terminal) renderPreviewScrollbar(yoff int, barLength int, barStart int)
t.previewer.bar[i] = bar
t.pborder.Move(y, x)
if i >= yoff+barStart && i < yoff+barStart+barLength {
t.pborder.CPrint(tui.ColPreviewScrollbar, t.scrollbar)
t.pborder.CPrint(tui.ColPreviewScrollbar, t.previewScrollbar)
} else {
t.pborder.CPrint(tui.ColPreviewScrollbar, " ")
}