mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-15 01:44:03 +00:00
Add preview-page-up and preview-page-down actions
This commit is contained in:
parent
66d55fd893
commit
8c8b5b313e
@ -667,6 +667,10 @@ func parseKeymap(keymap map[int]actionType, execmap map[int]string, str string)
|
|||||||
keymap[key] = actPreviewUp
|
keymap[key] = actPreviewUp
|
||||||
case "preview-down":
|
case "preview-down":
|
||||||
keymap[key] = actPreviewDown
|
keymap[key] = actPreviewDown
|
||||||
|
case "preview-page-up":
|
||||||
|
keymap[key] = actPreviewPageUp
|
||||||
|
case "preview-page-down":
|
||||||
|
keymap[key] = actPreviewPageDown
|
||||||
default:
|
default:
|
||||||
if isExecuteAction(actLower) {
|
if isExecuteAction(actLower) {
|
||||||
var offset int
|
var offset int
|
||||||
|
@ -174,6 +174,8 @@ const (
|
|||||||
actTogglePreview
|
actTogglePreview
|
||||||
actPreviewUp
|
actPreviewUp
|
||||||
actPreviewDown
|
actPreviewDown
|
||||||
|
actPreviewPageUp
|
||||||
|
actPreviewPageDown
|
||||||
actPreviousHistory
|
actPreviousHistory
|
||||||
actNextHistory
|
actNextHistory
|
||||||
actExecute
|
actExecute
|
||||||
@ -1123,6 +1125,11 @@ func (t *Terminal) Loop() {
|
|||||||
req(reqInfo)
|
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 {
|
for key, ret := range t.expect {
|
||||||
if keyMatch(key, event) {
|
if keyMatch(key, event) {
|
||||||
t.pressed = ret
|
t.pressed = ret
|
||||||
@ -1171,15 +1178,19 @@ func (t *Terminal) Loop() {
|
|||||||
return false
|
return false
|
||||||
case actPreviewUp:
|
case actPreviewUp:
|
||||||
if t.isPreviewEnabled() {
|
if t.isPreviewEnabled() {
|
||||||
t.previewer.offset = util.Constrain(
|
scrollPreview(-1)
|
||||||
t.previewer.offset-1, 0, t.previewer.lines-t.pwindow.Height)
|
|
||||||
req(reqPreviewRefresh)
|
|
||||||
}
|
}
|
||||||
case actPreviewDown:
|
case actPreviewDown:
|
||||||
if t.isPreviewEnabled() {
|
if t.isPreviewEnabled() {
|
||||||
t.previewer.offset = util.Constrain(
|
scrollPreview(1)
|
||||||
t.previewer.offset+1, 0, t.previewer.lines-t.pwindow.Height)
|
}
|
||||||
req(reqPreviewRefresh)
|
case actPreviewPageUp:
|
||||||
|
if t.isPreviewEnabled() {
|
||||||
|
scrollPreview(-t.pwindow.Height)
|
||||||
|
}
|
||||||
|
case actPreviewPageDown:
|
||||||
|
if t.isPreviewEnabled() {
|
||||||
|
scrollPreview(t.pwindow.Height)
|
||||||
}
|
}
|
||||||
case actBeginningOfLine:
|
case actBeginningOfLine:
|
||||||
t.cx = 0
|
t.cx = 0
|
||||||
@ -1350,9 +1361,7 @@ func (t *Terminal) Loop() {
|
|||||||
t.vmove(me.S)
|
t.vmove(me.S)
|
||||||
req(reqList)
|
req(reqList)
|
||||||
} else if t.isPreviewEnabled() && t.pwindow.Enclose(my, mx) {
|
} else if t.isPreviewEnabled() && t.pwindow.Enclose(my, mx) {
|
||||||
t.previewer.offset = util.Constrain(
|
scrollPreview(-me.S)
|
||||||
t.previewer.offset-me.S, 0, t.previewer.lines-t.pwindow.Height)
|
|
||||||
req(reqPreviewRefresh)
|
|
||||||
}
|
}
|
||||||
} else if t.window.Enclose(my, mx) {
|
} else if t.window.Enclose(my, mx) {
|
||||||
mx -= t.window.Left
|
mx -= t.window.Left
|
||||||
|
Loading…
Reference in New Issue
Block a user