summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.18
-rw-r--r--doc/ranger.pod5
-rw-r--r--ranger/config/rc.conf3
-rw-r--r--ranger/container/settings.py1
-rw-r--r--ranger/gui/widgets/pager.py16
5 files changed, 26 insertions, 7 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 3521d762..1fbab6a4 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35)
+.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
 .\"
 .\" Standard preamble:
 .\" ========================================================================
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.9.2" "2019-10-02" "ranger manual"
+.TH RANGER 1 "ranger-1.9.2" "2019-11-06" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -1142,6 +1142,10 @@ Increase it in case of experiencing display corruption.
 Offset in pixels for the inner border of the terminal. Some terminals require
 the offset to be specified explicitly, among others st and UXterm, some don't
 like urxvt.
+.IP "wrap_plaintext_previews [bool]" 4
+.IX Item "wrap_plaintext_previews [bool]"
+Whether or not to wrap long lines in the pager, this includes previews of plain
+text files.
 .IP "wrap_scroll [bool]" 4
 .IX Item "wrap_scroll [bool]"
 Enable scroll wrapping \- moving down while on the last item will wrap around to
diff --git a/doc/ranger.pod b/doc/ranger.pod
index be964b37..4be53a48 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -1192,6 +1192,11 @@ Offset in pixels for the inner border of the terminal. Some terminals require
 the offset to be specified explicitly, among others st and UXterm, some don't
 like urxvt.
 
+=item wrap_plaintext_previews [bool]
+
+Whether or not to wrap long lines in the pager, this includes previews of plain
+text files.
+
 =item wrap_scroll [bool]
 
 Enable scroll wrapping - moving down while on the last item will wrap around to
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index e557d4de..c3e0f299 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -147,6 +147,9 @@ set preview_files true
 set preview_directories true
 set collapse_preview true
 
+# Wrap long lines in plain text previews?
+set wrap_plaintext_previews false
+
 # Save the console history on exit?
 set save_console_history true
 
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index 6fc2da5e..7549325a 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -98,6 +98,7 @@ ALLOWED_SETTINGS = {
     'viewmode': str,
     'w3m_delay': float,
     'w3m_offset': int,
+    'wrap_plaintext_previews': bool,
     'wrap_scroll': bool,
     'xterm_alt_key': bool,
 }
diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py
index c1aa2765..fd0e7887 100644
--- a/ranger/gui/widgets/pager.py
+++ b/ranger/gui/widgets/pager.py
@@ -246,11 +246,17 @@ class Pager(Widget):  # pylint: disable=too-many-instance-attributes
         while True:
             try:
                 line = self._get_line(i).expandtabs(4)
-                if self.markup == 'ansi':
-                    line = ansi.char_slice(line, startx, self.wid) + ansi.reset
-                else:
-                    line = line[startx:self.wid + startx]
-                yield line.rstrip().replace('\r\n', '\n')
+                for part in ((0,) if not
+                        self.fm.settings.wrap_plaintext_previews else
+                        range(max(1, ((len(line) - 1) // self.wid) + 1))):
+                    shift = part * self.wid
+                    if self.markup == 'ansi':
+                        line_bit = ansi.char_slice(line, startx + shift,
+                                self.wid + shift) + ansi.reset
+                    else:
+                        line_bit = line[startx + shift
+                                        :self.wid + startx + shift]
+                    yield line_bit.rstrip().replace('\r\n', '\n')
             except IndexError:
                 return
             i += 1