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 eba7f6acaacf413f05ea057e34239d0ec12a7211
Author: Boris Faure <[email protected]>
AuthorDate: Sat Sep 12 16:06:51 2026 +0200
termptyesc: implement XTQMODKEYS
the query for XTMODKEYS
---
src/bin/termpty.c | 33 +++++++++++++++++++++++++++++++++
src/bin/termptyesc.c | 21 +++++++++++++++++++--
src/bin/tytest.c | 1 +
src/bin/unit_tests.h | 1 +
4 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 11eac4a9..238fdc13 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -2232,6 +2232,17 @@ tytest_sync_change_cb_altscreen(void)
return 0;
}
+/* Compare what was written back to the application, then drop it. */
+static void
+_ty_reply_is(Termpty *ty, const char *expected)
+{
+ size_t len = strlen(expected);
+
+ assert(ty->write_buffer.len == len);
+ assert(!memcmp(ty->write_buffer.buf + ty->write_buffer.gap, expected, len));
+ ty_sb_free(&ty->write_buffer);
+}
+
/* XTMODKEYS: CSI > Pp ; Pv m, Pp selects the resource, Pv is the value. */
int
tytest_xmodkeys_set(void)
@@ -2272,4 +2283,26 @@ tytest_xmodkeys_set(void)
return 0;
}
+/* XTQMODKEYS: CSI ? Pp m, answered as an XTMODKEYS set. */
+int
+tytest_xmodkeys_query(void)
+{
+ Termpty ty;
+
+ _ty_test_init(&ty, 80, 24);
+
+ _ty_feed(&ty, "\x1b[?4m");
+ _ty_reply_is(&ty, "\x1b[>4;0m");
+
+ _ty_feed(&ty, "\x1b[>4;2m");
+ _ty_feed(&ty, "\x1b[?4m");
+ _ty_reply_is(&ty, "\x1b[>4;2m");
+
+ _ty_feed(&ty, "\x1b[?1m");
+ _ty_reply_is(&ty, "\x1b[>1;0m");
+
+ _ty_test_shutdown(&ty);
+ return 0;
+}
+
#endif /* BINARY_TYFUZZ || BINARY_TYTEST */
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index c45e7ca3..104a4501 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -3475,7 +3475,7 @@ _xmod_resource_is_valid(int resource)
}
}
-/* XTMODKEYS: CSI > Pp ; Pv m and CSI > Pp n */
+/* XTMODKEYS: CSI > Pp ; Pv m and CSI > Pp n. XTQMODKEYS: CSI ? Pp m */
static void
_handle_xmodkeys(Termpty *ty,
Eina_Unicode cmd, Eina_Unicode **ptr)
@@ -3485,7 +3485,24 @@ _handle_xmodkeys(Termpty *ty,
Eina_Unicode param = *b;
b++;
if (param == '?')
- return;
+ { /* query */
+ char bf[32];
+ int len;
+ int resource = _csi_arg_get(ty, &b);
+
+ if (resource == -ESC_ARG_NO_VALUE)
+ return;
+ if (!_xmod_resource_is_valid(resource))
+ {
+ ERR("XTQMODKEYS: Invalid sequence");
+ ty->decoding_error = EINA_TRUE;
+ return;
+ }
+ len = snprintf(bf, sizeof(bf), "\033[>%d;%dm",
+ resource, ty->termstate.xmod[resource]);
+ termpty_write(ty, bf, len);
+ return;
+ }
if (param != '>')
{
ERR("XMODKEYS: Invalid sequence");
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index a5cb7ed9..8bfcba7c 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -57,6 +57,7 @@ static struct {
{ "sync_change_cb_altscreen", tytest_sync_change_cb_altscreen},
{ "percent_decode", tytest_percent_decode},
{ "xmodkeys_set", tytest_xmodkeys_set},
+ { "xmodkeys_query", tytest_xmodkeys_query},
{ NULL, NULL},
};
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index afa2fd42..d6102444 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -31,5 +31,6 @@ int tytest_sync_change_cb_watchdog(void);
int tytest_sync_change_cb_altscreen(void);
int tytest_percent_decode(void);
int tytest_xmodkeys_set(void);
+int tytest_xmodkeys_query(void);
#endif
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.