mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-06-03 07:50:49 +00:00
Allow customizing scrollbar of the preview window via --scrollbar=xy
This commit is contained in:
parent
43436e48e0
commit
17a13f00f8
|
@ -5,6 +5,15 @@ CHANGELOG
|
||||||
------
|
------
|
||||||
- Added color name `preview-border` and `preview-scrollbar`
|
- Added color name `preview-border` and `preview-scrollbar`
|
||||||
- Added new border style `block` which uses [block elements](https://en.wikipedia.org/wiki/Block_Elements)
|
- Added new border style `block` which uses [block elements](https://en.wikipedia.org/wiki/Block_Elements)
|
||||||
|
- `--scrollbar` can take two characters, one for the main window, the other
|
||||||
|
for the preview window
|
||||||
|
- Putting it altogether
|
||||||
|
```sh
|
||||||
|
fzf-tmux -p 80% --padding 1,2 --preview 'bat --style=plain --color=always {}' \
|
||||||
|
--color 'bg:#222233,bg+:#333344,gutter:#222233,border:#111122,scrollbar:#ffaa00' \
|
||||||
|
--color 'preview-bg:#332233,preview-border:#222222,preview-scrollbar:#00aaff' \
|
||||||
|
--preview-window 'border-block' --border block --scrollbar '▌▐'
|
||||||
|
```
|
||||||
- Bug fixes and improvements
|
- Bug fixes and improvements
|
||||||
|
|
||||||
0.40.0
|
0.40.0
|
||||||
|
|
|
@ -377,9 +377,10 @@ Do not display horizontal separator on the info line. A synonym for
|
||||||
\fB--separator=''\fB
|
\fB--separator=''\fB
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "--scrollbar=" "CHAR"
|
.BI "--scrollbar=" "CHAR1[CHAR2]"
|
||||||
Use the given character to render scrollbar. (default: '│' or ':' depending on
|
Use the given character to render scrollbar. (default: '│' or ':' depending on
|
||||||
\fB--no-unicode\fR).
|
\fB--no-unicode\fR). The optional \fBCHAR2\fR is used to render scrollbar of
|
||||||
|
the preview window.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B "--no-scrollbar"
|
.B "--no-scrollbar"
|
||||||
|
|
|
@ -75,7 +75,7 @@ const usage = `usage: fzf [options]
|
||||||
--info=STYLE Finder info style [default|hidden|inline|inline:SEPARATOR]
|
--info=STYLE Finder info style [default|hidden|inline|inline:SEPARATOR]
|
||||||
--separator=STR String to form horizontal separator on info line
|
--separator=STR String to form horizontal separator on info line
|
||||||
--no-separator Hide info line separator
|
--no-separator Hide info line separator
|
||||||
--scrollbar[=CHAR] Scrollbar character
|
--scrollbar[=C1[C2]] Scrollbar character(s) (each for main and preview window)
|
||||||
--no-scrollbar Hide scrollbar
|
--no-scrollbar Hide scrollbar
|
||||||
--prompt=STR Input prompt (default: '> ')
|
--prompt=STR Input prompt (default: '> ')
|
||||||
--pointer=STR Pointer to the current line (default: '>')
|
--pointer=STR Pointer to the current line (default: '>')
|
||||||
|
@ -1960,8 +1960,16 @@ func postProcessOptions(opts *Options) {
|
||||||
errorExit("--height option is currently not supported on this platform")
|
errorExit("--height option is currently not supported on this platform")
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Scrollbar != nil && runewidth.StringWidth(*opts.Scrollbar) > 1 {
|
if opts.Scrollbar != nil {
|
||||||
errorExit("scrollbar display width should be 1")
|
runes := []rune(*opts.Scrollbar)
|
||||||
|
if len(runes) > 2 {
|
||||||
|
errorExit("--scrollbar should be given one or two characters")
|
||||||
|
}
|
||||||
|
for _, r := range runes {
|
||||||
|
if runewidth.RuneWidth(r) != 1 {
|
||||||
|
errorExit("scrollbar display width should be 1")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default actions for CTRL-N / CTRL-P when --history is set
|
// Default actions for CTRL-N / CTRL-P when --history is set
|
||||||
|
|
|
@ -199,6 +199,7 @@ type Terminal struct {
|
||||||
header0 []string
|
header0 []string
|
||||||
ellipsis string
|
ellipsis string
|
||||||
scrollbar string
|
scrollbar string
|
||||||
|
previewScrollbar string
|
||||||
ansi bool
|
ansi bool
|
||||||
tabstop int
|
tabstop int
|
||||||
margin [4]sizeSpec
|
margin [4]sizeSpec
|
||||||
|
@ -690,8 +691,16 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
||||||
} else {
|
} else {
|
||||||
t.scrollbar = "|"
|
t.scrollbar = "|"
|
||||||
}
|
}
|
||||||
|
t.previewScrollbar = t.scrollbar
|
||||||
} else {
|
} 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()]
|
_, 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.previewer.bar[i] = bar
|
||||||
t.pborder.Move(y, x)
|
t.pborder.Move(y, x)
|
||||||
if i >= yoff+barStart && i < yoff+barStart+barLength {
|
if i >= yoff+barStart && i < yoff+barStart+barLength {
|
||||||
t.pborder.CPrint(tui.ColPreviewScrollbar, t.scrollbar)
|
t.pborder.CPrint(tui.ColPreviewScrollbar, t.previewScrollbar)
|
||||||
} else {
|
} else {
|
||||||
t.pborder.CPrint(tui.ColPreviewScrollbar, " ")
|
t.pborder.CPrint(tui.ColPreviewScrollbar, " ")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user