about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2018-10-08 01:36:47 +0200
committerWojciech Siewierski <wojciech.siewierski@onet.pl>2018-10-08 01:37:41 +0200
commit2af64f3a618cdb285fdf14b7ba5723fc4ff816a2 (patch)
tree352e0202e05fc0686169fcbc337c0596b7a5f7bc
parent48ac4fa4c0ad69f1f4e54d56d26add6567fc7de1 (diff)
downloadranger-2af64f3a618cdb285fdf14b7ba5723fc4ff816a2.tar.gz
Add a bindable action for scrolling the file preview
-rw-r--r--doc/ranger.15
-rw-r--r--doc/ranger.pod4
-rw-r--r--ranger/config/rc.conf2
-rw-r--r--ranger/core/actions.py11
4 files changed, 21 insertions, 1 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 4bbcc60c..70bca73b 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.9.2" "2018-09-10" "ranger manual"
+.TH RANGER 1 "ranger-1.9.2" "2018-10-08" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -1473,6 +1473,9 @@ This can be used to re-evaluate the rc.conf file after changing it:
 .Vb 1
 \& map X chain shell vim \-p %confdir/rc.conf %rangerdir/config/rc.conf; source %confdir/rc.conf
 .Ve
+.IP "scroll_preview \fIvalue\fR" 2
+.IX Item "scroll_preview value"
+Scroll the file preview by \fIvalue\fR lines.
 .IP "terminal" 2
 .IX Item "terminal"
 Spawns the \fIx\-terminal-emulator\fR starting in the current directory.
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 637973ac..0f1af58a 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -1572,6 +1572,10 @@ This can be used to re-evaluate the rc.conf file after changing it:
 
  map X chain shell vim -p %confdir/rc.conf %rangerdir/config/rc.conf; source %confdir/rc.conf
 
+=item scroll_preview I<value>
+
+Scroll the file preview by I<value> lines.
+
 =item terminal
 
 Spawns the I<x-terminal-emulator> starting in the current directory.
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index a32ab494..1e28f1e6 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -337,6 +337,8 @@ map <esc> change_mode normal
 map ~ set viewmode!
 
 map i display_file
+map <A-j> scroll_preview 1
+map <A-k> scroll_preview -1
 map ? help
 map W display_log
 map w taskview_open
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 2241bc5b..89c5124b 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -995,6 +995,17 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
         else:
             pager.set_source(fobj)
 
+    def scroll_preview(self, lines, narg=None):
+        """:scroll_preview <lines>
+
+Scroll the file preview by <lines> lines."""
+        preview_column = self.ui.browser.columns[-1]
+        if preview_column.target and preview_column.target.is_file:
+            if narg is not None:
+                lines = narg
+            preview_column.scrollbit = max(0, preview_column.scrollbit + lines)
+            preview_column.request_redraw()
+
     # --------------------------
     # -- Previews
     # --------------------------