diff --git a/kitty/control-codes.h b/kitty/control-codes.h index 75e17824c..04359cda4 100644 --- a/kitty/control-codes.h +++ b/kitty/control-codes.h @@ -70,6 +70,7 @@ #define ESC_ST '\\' #define ESC_PM '^' #define ESC_APC '_' +#define ESC_SOS 'X' // *Reset*. #define ESC_RIS 'c' diff --git a/kitty/vt-parser.c b/kitty/vt-parser.c index 188f43c34..ed1af8d03 100644 --- a/kitty/vt-parser.c +++ b/kitty/vt-parser.c @@ -158,7 +158,7 @@ static const int64_t digit_multipliers[] = { // Data structures {{{ typedef enum VTEState { - VTE_NORMAL, VTE_ESC = ESC, VTE_CSI = ESC_CSI, VTE_OSC = ESC_OSC, VTE_DCS = ESC_DCS, VTE_APC = ESC_APC, VTE_PM = ESC_PM + VTE_NORMAL, VTE_ESC = ESC, VTE_CSI = ESC_CSI, VTE_OSC = ESC_OSC, VTE_DCS = ESC_DCS, VTE_APC = ESC_APC, VTE_PM = ESC_PM, VTE_SOS = ESC_SOS } VTEState; static inline const char* @@ -171,6 +171,7 @@ vte_state_name(VTEState s) { case VTE_DCS: return "VTE_DCS"; case VTE_APC: return "VTE_APC"; case VTE_PM: return "VTE_PM"; + case VTE_SOS: return "VTE_SOS"; } static char buf[16]; snprintf(buf, sizeof(buf), "VTE_0x%x", s); @@ -269,6 +270,7 @@ consume_esc(PS *self) { case ESC_OSC: SET_STATE(OSC); break; case ESC_CSI: SET_STATE(CSI); reset_csi(&self->csi); break; case ESC_APC: SET_STATE(APC); break; + case ESC_SOS: SET_STATE(SOS); break; case ESC_PM: SET_STATE(PM); break; IS_ESCAPED_CHAR: return false; @@ -1344,6 +1346,20 @@ dispatch_pm(PS *self UNUSED, uint8_t *buf, size_t bufsz, bool is_extended UNUSED } +// }}} + +// SOS mode {{{ +static void +dispatch_sos(PS *self UNUSED, uint8_t *buf, size_t bufsz, bool is_extended UNUSED) { + if (bufsz < 2) return; + switch(buf[0]) { + default: + REPORT_ERROR("Unrecognized SOS code: 0x%x", buf[0]); + break; + } +} + + // }}} // Parse loop {{{ @@ -1373,6 +1389,8 @@ consume_input(PS *self, PyObject *dump_callback UNUSED, id_type window_id UNUSED consume(pm); case VTE_DCS: consume(dcs); + case VTE_SOS: + consume(sos); } #ifdef DUMP_COMMANDS diff --git a/kitty_tests/parser.py b/kitty_tests/parser.py index 6afb23a80..a091191f5 100644 --- a/kitty_tests/parser.py +++ b/kitty_tests/parser.py @@ -630,6 +630,7 @@ class TestParser(BaseTest): pb = partial(self.parse_bytes_dump, s) pb('a\033_+\\+\033\\bcde', ('draw', 'a'), ('Unrecognized APC code: 0x2b',), ('draw', 'bcde')) pb('a\033^+\\+\033\\bcde', ('draw', 'a'), ('Unrecognized PM code: 0x2b',), ('draw', 'bcde')) + pb('a\033X+\\+\033\\bcde', ('draw', 'a'), ('Unrecognized SOS code: 0x2b',), ('draw', 'bcde')) def test_graphics_command(self): from base64 import standard_b64encode