···
ctx->reverse_video = false;
ctx->dec_private = false;
ctx->insert_mode = false;
99
+
ctx->csi_unhandled = false;
ctx->unicode_remaining = 0;
ctx->charsets[0] = CHARSET_DEFAULT;
···
466
-
static void osc_parse(struct flanterm_context *ctx, uint8_t c) {
467
-
if (ctx->osc_escape && c == '\\') {
467
+
static bool osc_parse(struct flanterm_context *ctx, uint8_t c) {
468
+
// ESC \ terminates an OSC sequence cleanly
469
+
// but if ESC is followed by non-\, report failure from osc_parse and
470
+
// try parsing the character as another escape code
471
+
if (ctx->osc_escape) {
474
+
ctx->osc_escape = false;
475
+
ctx->escape = false;
478
+
ctx->osc_escape = false;
480
+
// escape stays true here
471
-
ctx->osc_escape = false;
488
+
// BEL is the other terminator
490
+
ctx->osc_escape = false;
492
+
ctx->escape = false;
483
-
ctx->osc_escape = false;
485
-
ctx->escape = false;
static void control_sequence_parse(struct flanterm_context *ctx, uint8_t c) {
···
ctx->scroll_enabled = false;
ctx->get_cursor_pos(ctx, &x, &y);
558
+
// CSI sequences are terminated by a byte in [0x40,0x7E]
559
+
// so skip all bytes until the terminator byte
560
+
if (ctx->csi_unhandled) {
561
+
if (c >= 0x40 && c <= 0x7E) {
562
+
ctx->csi_unhandled = false;
569
+
// Got ESC in the middle of an escape sequence, start a new one
···
linux_private_parse(ctx);
811
+
ctx->csi_unhandled = true;
···
848
+
// ESC \ is one of the two possible terminators of OSC sequences,
849
+
// so osc_parse consumes ESC.
850
+
// If it is then followed by \ it cleans correctly,
851
+
// otherwise it returns false, and it tries parsing it as another escape sequence
852
+
if (osc_parse(ctx, c)) {
if (ctx->control_sequence == true) {
···
875
+
ctx->csi_unhandled = false;
ctx->control_sequence = true;