diff options
-rw-r--r-- | ranger/ext/img_display.py | 14 | ||||
-rw-r--r-- | ranger/gui/widgets/pager.py | 6 |
2 files changed, 18 insertions, 2 deletions
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 2db7d0e7..b56c7729 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -78,3 +78,17 @@ def draw(path, start_x, start_y, max_width, max_height): h = height, filename = path) _w3mimgdisplay(cmd) + +def clear(start_x, start_y, width, height): + """ + Clear a part of terminal display. + """ + fontw, fonth = _get_font_dimensions() + + cmd = "6;{x};{y};{w};{h}\n4;\n3;".format( + x = start_x * fontw, + y = start_y * fonth, + w = width * fontw, + h = height * fonth) + + _w3mimgdisplay(cmd) diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py index 141ed8a9..6ebde5a9 100644 --- a/ranger/gui/widgets/pager.py +++ b/ranger/gui/widgets/pager.py @@ -39,11 +39,13 @@ class Pager(Widget): def clear_image(self): if self.need_clear_image: - self.win.clear() - self.win.refresh() + img_display.clear(self.x, self.y, self.wid, self.hei) self.need_clear_image = False def close(self): + if self.image: + self.need_clear_image = True + self.clear_image() if self.source and self.source_is_stream: self.source.close() |