summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2016-02-28 21:10:41 +0100
committerhut <hut@lepus.uberspace.de>2016-02-28 21:10:41 +0100
commitcb2b20166657d0716f4aefd777fa8f7dd80e8d3e (patch)
tree00f670592daceca6ff93a39685245c77dba503ec /ranger
parent55f9030f784a823a6bce7f498fb6a18e2bd9672b (diff)
parentf398483373811bd5e98ab6d47ef166598dab5c5e (diff)
downloadranger-cb2b20166657d0716f4aefd777fa8f7dd80e8d3e.tar.gz
Merge branch 'iterm-tmux-image-support' of https://github.com/a-morales/ranger
Diffstat (limited to 'ranger')
-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):
18 19 20 21 22 23 24 25 26 27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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




                                                                               



                                             

















                                                                                    
                              













                                                                             
                                




                                   
 



















                                                                       







































                                                                                 
pecs/ranger/blame/ranger.py?h=v1.9.0&id=dc27af1255a285bc5387e00dc459f55043a4c092'>^
d8084b41 ^
cba63cf3 ^
b4250dbc ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52