ptyfwd: reset color after two tty reset sequences, too

When we patch in a bg color we must make sure that when certain "reset"
sequences are transferred we fix up the bg color again.

Do so for \033[!p ("soft terminal reset") and \033c ("reset to initial
state" aka "full reset").
This commit is contained in:
Lennart Poettering
2024-07-18 15:41:33 +02:00
parent dbc66f87b3
commit 46b89b83e3
+19 -1
View File
@@ -443,6 +443,16 @@ static int pty_forward_ansi_process(PTYForward *f, size_t offset) {
} else if (c == ']') {
f->ansi_color_state = ANSI_COLOR_STATE_OSC_SEQUENCE;
continue;
} else if (c == 'c') {
/* "Full reset" aka "Reset to initial state"*/
r = insert_background_color(f, i+1);
if (r < 0)
return r;
i += r;
f->ansi_color_state = ANSI_COLOR_STATE_TEXT;
continue;
}
break;
@@ -462,7 +472,15 @@ static int pty_forward_ansi_process(PTYForward *f, size_t offset) {
} else {
/* Otherwise, the CSI sequence is over */
if (c == 'm') {
if (c == 'p' && streq_ptr(f->csi_sequence, "!")) {
/* CSI ! p → "Soft Reset", let's immediately fix our bg color again */
r = insert_background_color(f, i+1);
if (r < 0)
return r;
i += r;
} else if (c == 'm') {
/* This is an "SGR" (Select Graphic Rendition) sequence. Patch in our background color. */
r = insert_background_fix(f, i);
if (r < 0)