summary refs log tree commit diff stats
diff options
context:
space:
mode:
authora-morales <antonio.morales@originate.com>2016-01-29 10:20:20 -0800
committera-morales <antonio.morales@originate.com>2016-01-29 10:20:20 -0800
commitf398483373811bd5e98ab6d47ef166598dab5c5e (patch)
treeb675a8695baa84f3906678c071f0c9aa1f024efb
parent34e28e6159dece029770a0c172e25021beea9edf (diff)
downloadranger-f398483373811bd5e98ab6d47ef166598dab5c5e.tar.gz
update Iterm2 ImageDisplayer to work within tmux
-rw-r--r--ranger/ext/img_display.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py
index 91a13a57..9df64316 100644
--- a/ranger/ext/img_display.py
+++ b/ranger/ext/img_display.py
@@ -199,11 +199,18 @@ class ITerm2ImageDisplayer(ImageDisplayer, FileManagerAware):
         image_width = self._fit_width(
             image_width, image_height, max_cols, max_rows)
         content = self._encode_image_content(path)
-        text = "\033]1337;File=inline=1;preserveAspectRatio=0;"
-        text += "size={0};width={1}px:{2}\a\n".format(
+        display_protocol = "\033"
+        close_protocol = "\a"
+        if "screen" in os.environ['TERM']:
+            display_protocol += "Ptmux;\033\033"
+            close_protocol += "\033\\"
+
+        text = "{0}]1337;File=inline=1;preserveAspectRatio=0;size={1};width={2}px:{3}{4}\n".format(
+            display_protocol,
             str(len(content)),
             str(int(image_width)),
-            content)
+            content,
+            close_protocol)
         return text
 
     def _fit_width(self, width, height, max_cols, max_rows):
>142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257