From 106f8b5c9a6fa611eb61b60db6282b99666a7402 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Wed, 6 May 2020 23:44:05 +0200 Subject: [PATCH] termptyesc: handle terminal query New, still debated on https://gitlab.freedesktop.org/terminal-wg/specifications/issues/8 --- src/bin/termptyesc.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c index 1014ab2f..44b7433d 100644 --- a/src/bin/termptyesc.c +++ b/src/bin/termptyesc.c @@ -2293,6 +2293,29 @@ _handle_esc_csi_decscusr(Termpty *ty, Eina_Unicode **b) termio_set_cursor_shape(ty->obj, shape); } +static void +_handle_esc_csi_term_version(Termpty *ty, Eina_Unicode **b) +{ + int arg = _csi_arg_get(ty, b); + + DBG("CSI Term version (%d)", arg); + + switch (arg) + { + case -ESC_ARG_ERROR: + return; + case -ESC_ARG_NO_VALUE: + EINA_FALLTHROUGH; + case 0: + break; + default: + WRN("Invalid Term Version %d", arg); + ty->decoding_error = EINA_TRUE; + return; + } + TERMPTY_WRITE_STR("\033P>|" PACKAGE_NAME " " PACKAGE_VERSION "\033\\"); +} + static void _handle_esc_csi_decsace(Termpty *ty, Eina_Unicode **b) { @@ -3456,8 +3479,13 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce) } else { - WRN("TODO: Load LEDs (DECLL)"); - ty->decoding_error = EINA_TRUE; + if (*b == '>') + _handle_esc_csi_term_version(ty, &b); + else + { + WRN("TODO: Load LEDs (DECLL)"); + ty->decoding_error = EINA_TRUE; + } } break; case 'r':