summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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):