Add --preview-window option for cyclic scrolling

Close #2182
This commit is contained in:
Junegunn Choi
2020-10-06 10:05:57 +09:00
parent c0aa5a438f
commit 3cc8a74a91
3 changed files with 16 additions and 7 deletions

View File

@@ -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