diff options
author | Wojciech Siewierski <wojciech@siewierski.eu> | 2019-12-28 01:05:18 +0100 |
---|---|---|
committer | Wojciech Siewierski <wojciech@siewierski.eu> | 2019-12-28 01:05:18 +0100 |
commit | 45f58365d6b0ef475407571c77cb98cd7ae1717e (patch) | |
tree | 6025c18e780ad3f9248f2c10b3299848d3aa40bb | |
parent | e351a753b2a060392ea795e37120f4761ac41b4b (diff) | |
parent | 6bd428ff46a398603b108c897e48c98d2a0e536f (diff) | |
download | ranger-45f58365d6b0ef475407571c77cb98cd7ae1717e.tar.gz |
Merge branch 'wraptext' of https://github.com/toonn/ranger
-rw-r--r-- | doc/ranger.1 | 6 | ||||
-rw-r--r-- | doc/ranger.pod | 5 | ||||
-rw-r--r-- | ranger/config/rc.conf | 3 | ||||
-rw-r--r-- | ranger/container/settings.py | 1 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 3 | ||||
-rw-r--r-- | ranger/gui/widgets/pager.py | 17 |
6 files changed, 29 insertions, 6 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1 index 0d3efc16..e3896877 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.2" "2019-12-22" "ranger manual" +.TH RANGER 1 "ranger-1.9.2" "2019-12-28" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -1203,6 +1203,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 5d6f9b01..911b6480 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -1293,6 +1293,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 ab24f287..752dff77 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/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index ecc66f44..1412ef6a 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -48,6 +48,9 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes level 0 => current file/directory level <0 => parent directories """ + self.need_redraw = False + self.image = None + self.need_clear_image = True Pager.__init__(self, win) Widget.__init__(self, win) # pylint: disable=non-parent-init-called self.level = level diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index c1aa2765..064f28ca 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -246,11 +246,18 @@ 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 |