summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorWojciech Siewierski <wojciech.siewierski@onet.pl>2016-10-16 13:14:22 +0200
committerWojciech Siewierski <wojciech.siewierski@onet.pl>2017-01-29 23:38:31 +0100
commit5fa47d6086b6dfccbd43dd48150fae8a5618afb3 (patch)
treeb9f263e615437050a86f0412b6fc4ad29c45aa8b
parent1fccef33f31d931757cb2d49674cfbb40f62954d (diff)
downloadranger-5fa47d6086b6dfccbd43dd48150fae8a5618afb3.tar.gz
Cleanup the urxvt image previews
-rw-r--r--ranger/ext/img_display.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py
index 0fb4ffa7..d8d0b20b 100644
--- a/ranger/ext/img_display.py
+++ b/ranger/ext/img_display.py
@@ -317,6 +317,14 @@ class URXVTImageDisplayer(ImageDisplayer, FileManagerAware):
 
     """
 
+    def __init__(self):
+        self.display_protocol = "\033"
+        self.close_protocol = "\a"
+        if "screen" in os.environ['TERM']:
+            self.display_protocol += "Ptmux;\033\033"
+            self.close_protocol += "\033\\"
+        self.display_protocol += "]20;"
+
     @staticmethod
     def _get_max_sizes():
         """Use the whole terminal."""
@@ -363,30 +371,22 @@ class URXVTImageDisplayer(ImageDisplayer, FileManagerAware):
         pct_x, pct_y = self._get_offsets()
         pct_width, pct_height = self._get_sizes()
 
-        display_protocol = "\033"
-        close_protocol = "\a"
-        if "screen" in os.environ['TERM']:
-            display_protocol += "Ptmux;\033\033"
-            close_protocol += "\033\\"
         sys.stdout.write(
-            display_protocol
-            + "]20;" + path + ";"
-            + "{pct_width}x{pct_height}+{pct_x}+{pct_y}:op=keep-aspect".format(
+            self.display_protocol +
+            path +
+            ";{pct_width}x{pct_height}+{pct_x}+{pct_y}:op=keep-aspect".format(
                 pct_width=pct_width, pct_height=pct_height, pct_x=pct_x, pct_y=pct_y
-            )
-            + close_protocol
+            ) +
+            self.close_protocol
         )
         sys.stdout.flush()
 
     def clear(self, start_x, start_y, width, height):
-        display_protocol = "\033"
-        close_protocol = "\a"
-        if "screen" in os.environ['TERM']:
-            display_protocol += "Ptmux;\033\033"
-            close_protocol += "\033\\"
-        sys.stdout.write(display_protocol
-                         + "]20;;100x100+1000+1000"
-                         + close_protocol)
+        sys.stdout.write(
+            self.display_protocol +
+            ";100x100+1000+1000" +
+            self.close_protocol
+        )
         sys.stdout.flush()
 
     def quit(self):