summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/ext/img_display.py14
-rw-r--r--ranger/gui/widgets/pager.py6
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()
 
ref='#n79'>79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141