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