]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ptyfwd: when leaving a session with tinted background, clear to end of screen
authorLennart Poettering <lennart@poettering.net>
Fri, 19 Jan 2024 22:39:13 +0000 (23:39 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 20 Jan 2024 01:11:48 +0000 (01:11 +0000)
So if we tint the background of a ptyfwd session with a color and the
session ends, then so far we reset the bg color and clear till the end
of line.

Let's instead clear till the end of the screen. This is nicer since it
means that any follow-up output will not be affected by the changed
background color anymore.

src/basic/terminal-util.h
src/shared/ptyfwd.c

index ee60ff4840c3c7902eaaf5c7f8de7be99dced792..4822917f28fe38155abaea1e06f024e1f1a6a65b 100644 (file)
@@ -80,6 +80,9 @@
 /* Erase characters until the end of the line */
 #define ANSI_ERASE_TO_END_OF_LINE "\x1B[K"
 
+/* Erase characters until end of screen */
+#define ANSI_ERASE_TO_END_OF_SCREEN "\x1B[J"
+
 /* Move cursor up one line */
 #define ANSI_REVERSE_LINEFEED "\x1BM"
 
index 03660ad4178fc0d3bc5aa4ed0cca43d5397c6bb8..c05ce7948926e9748bdcebfb3e60911587db1faa 100644 (file)
@@ -115,7 +115,7 @@ static void pty_forward_disconnect(PTYForward *f) {
                 (void) fd_nonblock(f->output_fd, false);
 
                 if (colors_enabled())
-                        (void) loop_write(f->output_fd, ANSI_NORMAL ANSI_ERASE_TO_END_OF_LINE, SIZE_MAX);
+                        (void) loop_write(f->output_fd, ANSI_NORMAL ANSI_ERASE_TO_END_OF_SCREEN, SIZE_MAX);
 
                 if (f->close_output_fd)
                         f->output_fd = safe_close(f->output_fd);