commit 7a30e87
uint
·
2026-05-16 12:24:13 +0000 UTC
parent 137df8e
add OSC swallowing
2 files changed,
+16,
-0
+2,
-0
1@@ -16,6 +16,8 @@ enum TState {
2 TSTATE_NORMAL,
3 TSTATE_ESC,
4 TSTATE_CSI,
5+ TSTATE_OSC,
6+ TSTATE_OSC_ESC,
7 };
8
9 typedef struct {
+14,
-0
1@@ -728,6 +728,9 @@ bool term_write(Term* t, Caret* c, const char* s, size_t n)
2 csi_reset(t);
3 t->state = TSTATE_CSI;
4 }
5+ else if (ch == ']') {
6+ t->state = TSTATE_OSC;
7+ }
8 else if (ch == '7') {
9 t->saved = *c;
10 t->state = TSTATE_NORMAL;
11@@ -776,6 +779,17 @@ bool term_write(Term* t, Caret* c, const char* s, size_t n)
12 t->state = TSTATE_NORMAL;
13 }
14 break;
15+
16+ case TSTATE_OSC:
17+ if (ch == '\a')
18+ t->state = TSTATE_NORMAL;
19+ else if (ch == '\x1B')
20+ t->state = TSTATE_OSC_ESC;
21+ break;
22+
23+ case TSTATE_OSC_ESC:
24+ t->state = ch == '\\' ? TSTATE_NORMAL : TSTATE_OSC;
25+ break;
26 }
27
28 if (old.x != c->x || old.y != c->y)