This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository terminology.
View the commit online.
commit 913f1b3d5873aef42c34a2641ee425f8ffc67ea2
Author: Boris Faure <[email protected]>
AuthorDate: Sat Nov 28 20:45:48 2026 +0000
termptyesc: report the text area and cell sizes (XTWINOPS)
Answer the XTWINOPS size reports: CSI 18 t replies CSI 8 ; rows ;
cols t, CSI 16 t replies CSI 6 ; cell_h ; cell_w t, CSI 14 t and
14;0 t reply CSI 4 ; height ; width t with the text area in pixels,
14;2 t the whole window. Height comes before width in every reply
(XTerm Control Sequences, "Window manipulation (XTWINOPS)").
tmux sends CSI 18 t and CSI 14 t on every resize when TIOCGWINSZ
reports 0 pixels and, while that query is open, holds a lone Escape
for 500 ms instead of its escape-time; with no reply the query stays
open until a 5 second timer clears it (tmux/tty.c). ssh sessions that
lose the pixel size and opentui (CSI 14 t) ask too.
While the cell size is not known, 14 and 16 answer 0. Above 65535
pixels the winsize reports 0 but CSI 14 t still reports the real
value; the reply stays truthful. 11, 13, 15, 19, 20 and 21 stay
unanswered: no client needs them, the position and screen reports
leak information, and 20/21 are an injection vector.
---
src/bin/termio.c | 9 +++++++++
src/bin/termio.h | 1 +
src/bin/termpty.c | 45 +++++++++++++++++++++++++++++++++++++++++
src/bin/termptyesc.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
src/bin/tytest.c | 1 +
src/bin/tytest_common.c | 9 +++++++++
src/bin/unit_tests.h | 1 +
tests/tests.results | 1 +
tests/xtwinops-report.sh | 19 ++++++++++++++++++
9 files changed, 138 insertions(+)
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 12406574..39770553 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -361,6 +361,15 @@ termio_character_size_get(const Evas_Object *obj, int *w, int *h)
if (h) *h = sd->font.chh;
}
+void
+termio_window_size_get(const Evas_Object *obj, int *w, int *h)
+{
+ const Termio *sd = evas_object_smart_data_get(obj);
+
+ EINA_SAFETY_ON_NULL_RETURN(sd);
+ evas_object_geometry_get(sd->win, NULL, NULL, w, h);
+}
+
int
termio_scroll_get(const Evas_Object *obj)
{
diff --git a/src/bin/termio.h b/src/bin/termio.h
index 754d1a78..86f1db3e 100644
--- a/src/bin/termio.h
+++ b/src/bin/termio.h
@@ -46,6 +46,7 @@ void termio_mouseover_suspend_pushpop(Evas_Object *obj, int dir);
void termio_event_feed_mouse_in(Evas_Object *obj);
void termio_size_get(const Evas_Object *obj, int *w, int *h);
void termio_character_size_get(const Evas_Object *obj, int *w, int *h);
+void termio_window_size_get(const Evas_Object *obj, int *w, int *h);
int termio_scroll_get(const Evas_Object *obj);
void termio_font_size_set(Evas_Object *obj, int size);
void termio_grid_size_set(Evas_Object *obj, int w, int h);
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 1d10734d..51400f59 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -3500,6 +3500,51 @@ tytest_pty_winsize(void)
return 0;
}
+int
+tytest_xtwinops_report(void)
+{
+ Termpty ty;
+
+ _ty_test_init(&ty, 80, 24);
+
+ _ty_feed(&ty, "\x1b[18t");
+ _ty_reply_is(&ty, "\x1b[8;24;80t");
+ _ty_feed(&ty, "\x1b[16t");
+ _ty_reply_is(&ty, "\x1b[6;15;7t");
+ _ty_feed(&ty, "\x1b[14t\x1b[14;0t");
+ _ty_reply_is(&ty, "\x1b[4;360;560t\x1b[4;360;560t");
+ _ty_feed(&ty, "\x1b[14;2t");
+ _ty_reply_is(&ty, "\x1b[4;362;562t");
+
+ /* unknown second parameter: no reply */
+ _ty_feed(&ty, "\x1b[14;1t");
+ assert(ty.write_buffer.len == 0);
+ /* 11, 13, 15, 19, 20, 21 stay unanswered */
+ _ty_feed(&ty, "\x1b[11t\x1b[13t\x1b[15t\x1b[19t\x1b[20t\x1b[21t");
+ assert(ty.write_buffer.len == 0);
+
+ /* cell size not known yet: 14 and 16 answer 0 */
+ termpty_cell_size_set(&ty, 0, 0);
+ _ty_feed(&ty, "\x1b[14t\x1b[16t");
+ _ty_reply_is(&ty, "\x1b[4;0;0t\x1b[6;0;0t");
+ termpty_cell_size_set(&ty, TY_CH_W, TY_CH_H);
+
+ /* the reports follow a resize */
+ termpty_resize(&ty, 100, 30);
+ _ty_feed(&ty, "\x1b[18t\x1b[14t");
+ _ty_reply_is(&ty, "\x1b[8;30;100t\x1b[4;450;700t");
+
+ /* a pixel product that overflows int is clamped, not wrapped */
+ ty.w = 100000;
+ ty.h = 100000;
+ termpty_cell_size_set(&ty, 100000, 100000);
+ _ty_feed(&ty, "\x1b[14t");
+ _ty_reply_is(&ty, "\x1b[4;2147483647;2147483647t");
+
+ _ty_test_shutdown(&ty);
+ return 0;
+}
+
int
tytest_color_scheme_notify(void)
{
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index a7871379..bfae2e3e 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -3608,6 +3608,49 @@ _title_icon_stack_pop(Termpty *ty, Eina_Unicode **p)
_title_icon_elem_free(elem);
}
+/* XTWINOPS CSI 14 t: reply CSI 4 ; height ; width t, Ps=2 for the window */
+static void
+_report_text_area_pixels(Termpty *ty, Eina_Unicode **ptr)
+{
+ char bf[64];
+ int what = _csi_arg_get(ty, ptr);
+ int w = 0, h = 0, len;
+
+ if ((what == -ESC_ARG_NO_VALUE) || (what == 0))
+ {
+ int64_t wp = (int64_t)ty->w * ty->cell_w;
+ int64_t hp = (int64_t)ty->h * ty->cell_h;
+ w = (int)MAX(0, MIN(wp, INT32_MAX));
+ h = (int)MAX(0, MIN(hp, INT32_MAX));
+ }
+ else if (what == 2)
+ termio_window_size_get(ty->obj, &w, &h);
+ else
+ return;
+ len = snprintf(bf, sizeof(bf), "\033[4;%d;%dt", h, w);
+ termpty_write(ty, bf, len);
+}
+
+/* XTWINOPS CSI 16 t: reply CSI 6 ; height ; width t */
+static void
+_report_cell_pixels(Termpty *ty)
+{
+ char bf[64];
+ int len = snprintf(bf, sizeof(bf), "\033[6;%d;%dt", ty->cell_h, ty->cell_w);
+
+ termpty_write(ty, bf, len);
+}
+
+/* XTWINOPS CSI 18 t: reply CSI 8 ; height ; width t */
+static void
+_report_text_area_chars(Termpty *ty)
+{
+ char bf[64];
+ int len = snprintf(bf, sizeof(bf), "\033[8;%d;%dt", ty->h, ty->w);
+
+ termpty_write(ty, bf, len);
+}
+
static void
_handle_window_manipulation(Termpty *ty, Eina_Unicode **ptr)
{
@@ -3622,6 +3665,15 @@ _handle_window_manipulation(Termpty *ty, Eina_Unicode **ptr)
case 8:
_handle_resize_by_chars(ty, &b);
break;
+ case 14:
+ _report_text_area_pixels(ty, &b);
+ break;
+ case 16:
+ _report_cell_pixels(ty);
+ break;
+ case 18:
+ _report_text_area_chars(ty);
+ break;
case 22:
_title_icon_stack_push(ty, &b);
break;
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index 0d16208a..3a986233 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -100,6 +100,7 @@ static struct {
{ "kam", tytest_kam},
{ "decarm", tytest_decarm},
{ "pty_winsize", tytest_pty_winsize},
+ { "xtwinops_report", tytest_xtwinops_report},
{ "color_scheme_notify", tytest_color_scheme_notify},
{ "kitty_kbd_query", tytest_kitty_kbd_query},
{ "kitty_kbd_stack", tytest_kitty_kbd_stack},
diff --git a/src/bin/tytest_common.c b/src/bin/tytest_common.c
index 72a51cdc..15de0a6c 100644
--- a/src/bin/tytest_common.c
+++ b/src/bin/tytest_common.c
@@ -260,6 +260,15 @@ termio_size_get(const Evas_Object *obj EINA_UNUSED,
if (h) *h = _sd.grid.h;
}
+/* text area plus a one-pixel frame per side, distinct from the 14;0 reply */
+void
+termio_window_size_get(const Evas_Object *obj EINA_UNUSED,
+ int *w, int *h)
+{
+ if (w) *w = 2 * TY_OFFSET_X + _sd.grid.w * _sd.font.chw;
+ if (h) *h = 2 * TY_OFFSET_Y + _sd.grid.h * _sd.font.chh;
+}
+
Termpty *
termio_pty_get(const Evas_Object *obj EINA_UNUSED)
{
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index 0604f017..ebb6af50 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -73,6 +73,7 @@ int tytest_decrqm(void);
int tytest_kam(void);
int tytest_decarm(void);
int tytest_pty_winsize(void);
+int tytest_xtwinops_report(void);
int tytest_color_scheme_notify(void);
int tytest_kitty_kbd_query(void);
int tytest_kitty_kbd_stack(void);
diff --git a/tests/tests.results b/tests/tests.results
index edec78a5..3fef044a 100644
--- a/tests/tests.results
+++ b/tests/tests.results
@@ -248,3 +248,4 @@ kitty-kbd-altscreen.sh df9913f9d85f856c75dd525a806da4f6
kitty-kbd-reset.sh bd10ee95b6b71d150fbe1a11c7b6ac94
kitty-kbd-unsupported.sh 63cfb663085848fd972e9ba667a2901b
kitty-kbd-malformed.sh 70f115545d4cda821177c842c2f96a7f
+xtwinops-report.sh 757afd3ceaccd27991020e2fa41613b5
diff --git a/tests/xtwinops-report.sh b/tests/xtwinops-report.sh
new file mode 100755
index 00000000..9d925312
--- /dev/null
+++ b/tests/xtwinops-report.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+# shellcheck source=tests/utils.sh
+. "$(dirname "$0")/utils.sh"
+
+# cell 7x15, grid 80x24 in tytest
+printf '\033[18t'
+printf '\033[16t'
+printf '\033[14t'
+printf '\033[14;0t'
+printf '\033[14;2t'
+# unknown second parameter: no reply
+printf '\033[14;1t'
+# after a resize the reports follow
+printf '\033[8;30;100t'
+printf '\033[18t\033[14t'
+# still unanswered
+printf '\033[11t\033[13t\033[15t\033[19t\033[20t\033[21t'
+# the title stack still works
+printf '\033]2;before\007\033[22;2t\033]2;after\007\033[23;2t'
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.