summaryrefslogtreecommitdiffstats
path: root/src/shared/ptyfwd.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-07-18 14:28:52 +0200
committerLennart Poettering <lennart@poettering.net>2024-07-18 15:41:33 +0200
commit46b89b83e39a6eaa3cbc452ae5e9d3dbe25c8736 (patch)
tree6dc3121d322a3f4e78181e69254c65b9b0162f36 /src/shared/ptyfwd.c
parentmkosi: update debian commit reference (diff)
downloadsystemd-46b89b83e39a6eaa3cbc452ae5e9d3dbe25c8736.tar.xz
systemd-46b89b83e39a6eaa3cbc452ae5e9d3dbe25c8736.zip
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").
Diffstat (limited to '')
-rw-r--r--src/shared/ptyfwd.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c
index 842aef9270..83eef7f7d8 100644
--- a/src/shared/ptyfwd.c
+++ b/src/shared/ptyfwd.c
@@ -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)