aboutsummaryrefslogtreecommitdiff
path: root/working/eat-sixel-patch/eat-xtwinops.patch
blob: 4347d72959d79487eca8b11b63df06684a230eae (plain)
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
--- a/eat.el
+++ b/eat.el
@@ -2809,6 +2809,33 @@
        (funcall (eat--t-term-input-fn eat--t-term) eat--t-term
                 "\e[>0;0;0c")))))
 
+(defun eat--t-send-window-size-report (n)
+  "Respond to XTWINOPS window size report request N.
+
+N is 14 (text area size in pixels), 16 (cell size in pixels) or 18
+\(text area size in characters).  Other operations are ignored.
+Multiplexers like tmux send \\='CSI 14 t\\=' to discover the cell
+pixel size they need before they will emit Sixel to a terminal."
+  (let ((disp (eat--t-term-display eat--t-term)))
+    (pcase n
+      (14
+       (funcall (eat--t-term-input-fn eat--t-term) eat--t-term
+                (format "\e[4;%i;%it"
+                        (* (eat--t-disp-height disp)
+                           (eat--t-term-char-height eat--t-term))
+                        (* (eat--t-disp-width disp)
+                           (eat--t-term-char-width eat--t-term)))))
+      (16
+       (funcall (eat--t-term-input-fn eat--t-term) eat--t-term
+                (format "\e[6;%i;%it"
+                        (eat--t-term-char-height eat--t-term)
+                        (eat--t-term-char-width eat--t-term))))
+      (18
+       (funcall (eat--t-term-input-fn eat--t-term) eat--t-term
+                (format "\e[8;%i;%it"
+                        (eat--t-disp-height disp)
+                        (eat--t-disp-width disp)))))))
+
 (defun eat--t-send-graphics-attrs (attr operation)
   "Send graphics attributes.
 
@@ -3632,6 +3659,9 @@
                  ;; CSI s.
                  (`((?s) nil nil)
                   (eat--t-save-cur))
+                 ;; CSI <n> t.
+                 (`((?t) nil ((,n)))
+                  (eat--t-send-window-size-report n))
                  ;; CSI u.
                  (`((?u) nil nil)
                   (eat--t-restore-cur)))))))