diff options
-rw-r--r-- | ranger/ext/img_display.py | 5 | ||||
-rw-r--r-- | ranger/gui/widgets/pager.py | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index a89f6d8b..307c7b75 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -15,6 +15,9 @@ from subprocess import Popen, PIPE W3MIMGDISPLAY_PATH = '/usr/lib/w3m/w3mimgdisplay' W3MIMGDISPLAY_OPTIONS = [] +class ImgDisplayUnsupportedException(Exception): + pass + def _get_font_dimensions(): """ Get the height and width of a character displayed in the terminal in @@ -49,7 +52,7 @@ def draw(path, start_x, start_y, max_width, max_height): """ fontw, fonth = _get_font_dimensions() if fontw == 0 or fonth == 0: - return + raise ImgDisplayUnsupportedException() max_width_pixels = max_width * fontw max_height_pixels = max_height * fonth diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index e9ce8b5c..4e8161a5 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -84,6 +84,8 @@ class Pager(Widget): self.need_redraw_image = False try: img_display.draw(self.image, self.x, self.y, self.wid, self.hei) + except img_display.ImgDisplayUnsupportedException: + self.fm.settings.preview_images = False except Exception as e: self.fm.notify(e, bad=True) |