diff options
-rw-r--r-- | doc/ranger.pod | 5 | ||||
-rw-r--r-- | ranger/config/rc.conf | 4 | ||||
-rw-r--r-- | ranger/container/settings.py | 2 | ||||
-rw-r--r-- | ranger/core/actions.py | 8 | ||||
-rw-r--r-- | ranger/ext/img_display.py | 10 |
5 files changed, 27 insertions, 2 deletions
diff --git a/doc/ranger.pod b/doc/ranger.pod index 4cac8ef9..7da4478b 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -1017,6 +1017,11 @@ Sets the view mode, which can be B<miller> to display the files in the traditional miller column view that shows multiple levels of the hierarchy, or B<multipane> to use multiple panes (one per tab) similar to midnight-commander. +=item w3m_delay [float] + +Delay in seconds before displaying an image with the w3m method. +Increase it in case of experiencing display corruption. + =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 1296f1ca..58d6d243 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -95,6 +95,10 @@ set preview_images false # whole terminal window. set preview_images_method w3m +# Delay in seconds before displaying an image with the w3m method. +# Increase it in case of experiencing display corruption. +set w3m_delay 0.02 + # Default iTerm2 font size (see: preview_images_method: iterm2) set iterm2_font_width 8 set iterm2_font_height 11 diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 170ace5a..11097cec 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -91,6 +91,7 @@ ALLOWED_SETTINGS = { 'vcs_backend_hg': str, 'vcs_backend_svn': str, 'viewmode': str, + 'w3m_delay': float, 'wrap_scroll': bool, 'xterm_alt_key': bool, } @@ -113,6 +114,7 @@ DEFAULT_VALUES = { type(None): None, str: "", int: 0, + float: 0.0, list: [], tuple: tuple([]), } diff --git a/ranger/core/actions.py b/ranger/core/actions.py index e8c47b9f..ae8e33d4 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -110,7 +110,8 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m self.settings.set(option_name, self._parse_option_value(option_name, value), localpath, tags) - def _parse_option_value(self, name, value): + def _parse_option_value( # pylint: disable=too-many-return-statements + self, name, value): types = self.fm.settings.types_of(name) if bool in types: if value.lower() in ('false', 'off', '0'): @@ -124,6 +125,11 @@ class Actions( # pylint: disable=too-many-instance-attributes,too-many-public-m return int(value) except ValueError: pass + if float in types: + try: + return float(value) + except ValueError: + pass if str in types: return value if list in types: diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 78d71cb2..4f447f39 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -60,7 +60,7 @@ class ImageDisplayer(object): pass -class W3MImageDisplayer(ImageDisplayer): +class W3MImageDisplayer(ImageDisplayer, FileManagerAware): """Implementation of ImageDisplayer using w3mimgdisplay, an utilitary program from w3m (a text-based web browser). w3mimgdisplay can display images either in virtual tty (using linux framebuffer) or in a Xorg session. @@ -119,6 +119,14 @@ class W3MImageDisplayer(ImageDisplayer): input_gen = self._generate_w3m_input(path, start_x, start_y, width, height) except ImageDisplayError: raise + + # Mitigate the issue with the horizontal black bars when + # selecting some images on some systems. 2 milliseconds seems + # enough. Adjust as necessary. + if self.fm.settings.w3m_delay > 0: + from time import sleep + sleep(self.fm.settings.w3m_delay) + self.process.stdin.write(input_gen) self.process.stdin.flush() self.process.stdout.readline() |