Add preview-half-page-down and preview-half-page-up (#2145)

This commit is contained in:
Tinmarino 2020-10-05 09:58:56 -03:00 committed by GitHub
parent 825d401403
commit c0aa5a438f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 0 deletions

View File

@ -13,6 +13,9 @@ CHANGELOG
- Added `--preview-window` option for sharp edges (`--preview-window sharp`)
- Reduced vertical padding around the preview window when `--preview-window
noborder` is used
- Added actions for preview window
- `preview-half-page-up`
- `preview-half-page-down`
- Vim
- Popup width and height can be given in absolute integer values
- Added `fzf#exec()` function for getting the path of fzf executable

View File

@ -718,6 +718,8 @@ A key or an event can be bound to one or more of the following actions.
\fBpreview-up\fR \fIshift-up\fR
\fBpreview-page-down\fR
\fBpreview-page-up\fR
\fBpreview-half-page-down\fR
\fBpreview-half-page-up\fR
\fBprevious-history\fR (\fIctrl-p\fR on \fB--history\fR)
\fBprint-query\fR (print query and exit)
\fBrefresh-preview\fR

View File

@ -854,6 +854,10 @@ func parseKeymap(keymap map[int][]action, str string) {
appendAction(actPreviewPageUp)
case "preview-page-down":
appendAction(actPreviewPageDown)
case "preview-half-page-up":
appendAction(actPreviewHalfPageUp)
case "preview-half-page-down":
appendAction(actPreviewHalfPageDown)
default:
t := isExecuteAction(specLower)
if t == actIgnore {

View File

@ -236,6 +236,8 @@ const (
actPreviewDown
actPreviewPageUp
actPreviewPageDown
actPreviewHalfPageUp
actPreviewHalfPageDown
actPreviousHistory
actNextHistory
actExecute
@ -1953,6 +1955,14 @@ func (t *Terminal) Loop() {
if t.hasPreviewWindow() {
scrollPreview(t.pwindow.Height())
}
case actPreviewHalfPageUp:
if t.hasPreviewWindow() {
scrollPreview(-t.pwindow.Height()/2)
}
case actPreviewHalfPageDown:
if t.hasPreviewWindow() {
scrollPreview(t.pwindow.Height()/2)
}
case actBeginningOfLine:
t.cx = 0
case actBackwardChar: