diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2016-09-25 04:12:44 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2016-09-25 04:12:44 +0900 |
commit | 8c8b5b313e85cc3c13a1ebe33a6d718577d15a2f (patch) | |
tree | cb97d2704562fe85d71dd41b936e52da1f845876 /src/terminal.go | |
parent | 66d55fd89349b38e61ba2180ea8e7d8e5656c878 (diff) |
Add preview-page-up and preview-page-down actions
Diffstat (limited to 'src/terminal.go')
-rw-r--r-- | src/terminal.go | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/terminal.go b/src/terminal.go index 9bb92629..2d7f4c6a 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -174,6 +174,8 @@ const ( actTogglePreview actPreviewUp actPreviewDown + actPreviewPageUp + actPreviewPageDown actPreviousHistory actNextHistory actExecute @@ -1123,6 +1125,11 @@ func (t *Terminal) Loop() { req(reqInfo) } } + scrollPreview := func(amount int) { + t.previewer.offset = util.Constrain( + t.previewer.offset+amount, 0, t.previewer.lines-t.pwindow.Height) + req(reqPreviewRefresh) + } for key, ret := range t.expect { if keyMatch(key, event) { t.pressed = ret @@ -1171,15 +1178,19 @@ func (t *Terminal) Loop() { return false case actPreviewUp: if t.isPreviewEnabled() { - t.previewer.offset = util.Constrain( - t.previewer.offset-1, 0, t.previewer.lines-t.pwindow.Height) - req(reqPreviewRefresh) + scrollPreview(-1) } case actPreviewDown: if t.isPreviewEnabled() { - t.previewer.offset = util.Constrain( - t.previewer.offset+1, 0, t.previewer.lines-t.pwindow.Height) - req(reqPreviewRefresh) + scrollPreview(1) + } + case actPreviewPageUp: + if t.isPreviewEnabled() { + scrollPreview(-t.pwindow.Height) + } + case actPreviewPageDown: + if t.isPreviewEnabled() { + scrollPreview(t.pwindow.Height) } case actBeginningOfLine: t.cx = 0 @@ -1350,9 +1361,7 @@ func (t *Terminal) Loop() { t.vmove(me.S) req(reqList) } else if t.isPreviewEnabled() && t.pwindow.Enclose(my, mx) { - t.previewer.offset = util.Constrain( - t.previewer.offset-me.S, 0, t.previewer.lines-t.pwindow.Height) - req(reqPreviewRefresh) + scrollPreview(-me.S) } } else if t.window.Enclose(my, mx) { mx -= t.window.Left |