mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 03:19:01 +00:00
parent
c0aa5a438f
commit
3cc8a74a91
@ -11,6 +11,7 @@ CHANGELOG
|
||||
--preview-window +{2}-/2
|
||||
```
|
||||
- Added `--preview-window` option for sharp edges (`--preview-window sharp`)
|
||||
- Added `--preview-window` option for cyclic scrolling (`--preview-window cycle`)
|
||||
- Reduced vertical padding around the preview window when `--preview-window
|
||||
noborder` is used
|
||||
- Added actions for preview window
|
||||
|
@ -80,7 +80,8 @@ const usage = `usage: fzf [options]
|
||||
Preview
|
||||
--preview=COMMAND Command to preview highlighted line ({})
|
||||
--preview-window=OPT Preview window layout (default: right:50%)
|
||||
[up|down|left|right][:SIZE[%]][:wrap][:hidden][:+SCROLL[-OFFSET]]
|
||||
[up|down|left|right][:SIZE[%]][:wrap][:cycle][:hidden]
|
||||
[:+SCROLL[-OFFSET]]
|
||||
[:rounded|sharp|noborder]
|
||||
|
||||
Scripting
|
||||
@ -163,6 +164,7 @@ type previewOpts struct {
|
||||
scroll string
|
||||
hidden bool
|
||||
wrap bool
|
||||
cycle bool
|
||||
border tui.BorderShape
|
||||
}
|
||||
|
||||
@ -262,7 +264,7 @@ func defaultOptions() *Options {
|
||||
ToggleSort: false,
|
||||
Expect: make(map[int]string),
|
||||
Keymap: make(map[int][]action),
|
||||
Preview: previewOpts{"", posRight, sizeSpec{50, true}, "", false, false, tui.BorderRounded},
|
||||
Preview: previewOpts{"", posRight, sizeSpec{50, true}, "", false, false, false, tui.BorderRounded},
|
||||
PrintQuery: false,
|
||||
ReadZero: false,
|
||||
Printer: func(str string) { fmt.Println(str) },
|
||||
@ -997,6 +999,7 @@ func parsePreviewWindow(opts *previewOpts, input string) {
|
||||
opts.size = sizeSpec{50, true}
|
||||
opts.hidden = false
|
||||
opts.wrap = false
|
||||
opts.cycle = false
|
||||
|
||||
tokens := strings.Split(input, ":")
|
||||
sizeRegex := regexp.MustCompile("^[0-9]+%?$")
|
||||
@ -1008,6 +1011,8 @@ func parsePreviewWindow(opts *previewOpts, input string) {
|
||||
opts.hidden = true
|
||||
case "wrap":
|
||||
opts.wrap = true
|
||||
case "cycle":
|
||||
opts.cycle = true
|
||||
case "up", "top":
|
||||
opts.position = posUp
|
||||
case "down", "bottom":
|
||||
@ -1281,7 +1286,7 @@ func parseOptions(opts *Options, allArgs []string) {
|
||||
opts.Preview.command = ""
|
||||
case "--preview-window":
|
||||
parsePreviewWindow(&opts.Preview,
|
||||
nextString(allArgs, &i, "preview window layout required: [up|down|left|right][:SIZE[%]][:rounded|sharp|noborder][:wrap][:hidden][:+SCROLL[-OFFSET]]"))
|
||||
nextString(allArgs, &i, "preview window layout required: [up|down|left|right][:SIZE[%]][:rounded|sharp|noborder][:wrap][:cycle][:hidden][:+SCROLL[-OFFSET]]"))
|
||||
case "--height":
|
||||
opts.Height = parseHeight(nextString(allArgs, &i, "height required: HEIGHT[%]"))
|
||||
case "--min-height":
|
||||
|
@ -1884,8 +1884,11 @@ func (t *Terminal) Loop() {
|
||||
if !t.previewer.more {
|
||||
return
|
||||
}
|
||||
newOffset := util.Constrain(
|
||||
t.previewer.offset+amount, 0, t.previewer.lines-1)
|
||||
newOffset := t.previewer.offset + amount
|
||||
if t.preview.cycle {
|
||||
newOffset = (newOffset + t.previewer.lines) % t.previewer.lines
|
||||
}
|
||||
newOffset = util.Constrain(newOffset, 0, t.previewer.lines-1)
|
||||
if t.previewer.offset != newOffset {
|
||||
t.previewer.offset = newOffset
|
||||
req(reqPreviewRefresh)
|
||||
@ -1957,11 +1960,11 @@ func (t *Terminal) Loop() {
|
||||
}
|
||||
case actPreviewHalfPageUp:
|
||||
if t.hasPreviewWindow() {
|
||||
scrollPreview(-t.pwindow.Height()/2)
|
||||
scrollPreview(-t.pwindow.Height() / 2)
|
||||
}
|
||||
case actPreviewHalfPageDown:
|
||||
if t.hasPreviewWindow() {
|
||||
scrollPreview(t.pwindow.Height()/2)
|
||||
scrollPreview(t.pwindow.Height() / 2)
|
||||
}
|
||||
case actBeginningOfLine:
|
||||
t.cx = 0
|
||||
|
Loading…
Reference in New Issue
Block a user