Skip to content

Commit

Permalink
feature: add scroll_up/down_preview actions
Browse files Browse the repository at this point in the history
  • Loading branch information
amedama41 committed Aug 6, 2023
1 parent ff9cd7f commit 89f613b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/vfiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,12 @@ Toggle the automatic preview window.
#### toggle_preview
Toggle the preview window for the item in the current cursor.

#### scroll_down_preview
Scroll down in preview window.

#### scroll_up_preview
Scroll up in preview window.

---

### Action to view
Expand Down
18 changes: 18 additions & 0 deletions lua/vfiler/actions/preview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,22 @@ function M.toggle_preview(vfiler, context, view)
utils.open_preview(vfiler, context, view)
end

function M.scroll_down_preview(vfiler, context, view)
local in_preview = context.in_preview
local preview = in_preview.preview
if not preview then
return
end
preview:scroll_down()
end

function M.scroll_up_preview(vfiler, context, view)
local in_preview = context.in_preview
local preview = in_preview.preview
if not preview then
return
end
preview:scroll_up()
end

return M
10 changes: 10 additions & 0 deletions lua/vfiler/preview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,14 @@ function Preview:close()
self.opened = false
end

function Preview:scroll_down()
-- \x04 is <C-D>
vim.fn.win_execute(self._window:id(), 'normal! \x04', 'silent')
end

function Preview:scroll_up()
-- \x15 is <C-U>
vim.fn.win_execute(self._window:id(), 'normal! \x15', 'silent')
end

return Preview

0 comments on commit 89f613b

Please sign in to comment.