From: Lennart Poettering Date: Thu, 6 Mar 2025 15:07:02 +0000 (+0100) Subject: terminal-util: during terminal reset clear from beginning of line to end of screen X-Git-Tag: v258-rc1~1159 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4efd46c44bc599a71da1ff24149291ef10df61ff;p=thirdparty%2Fsystemd.git terminal-util: during terminal reset clear from beginning of line to end of screen tianocore does some weird shit with its terminal emulation and regular fills half the terminal with grey background and then invokes us with this not cleared up. Hence let us clear this up for it: as part of the ansi sequence based reset let's position the cursor explicitly at the beginning of the current line, and erase everything till the end of the screen. This makes boot output in tianocore vms much much cleaner. Note that this does *not* erase any terminal output *before* the cursor position where we take over, because that typically contains valuable information still we should not erase. --- diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 5303910b4c5..50ad4c89af3 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -974,7 +974,9 @@ static int terminal_reset_ansi_seq(int fd) { k = loop_write_full(fd, "\033[!p" /* soft terminal reset */ "\033]104\007" /* reset colors */ - "\033[?7h", /* enable line-wrapping */ + "\033[?7h" /* enable line-wrapping */ + "\033[1G" /* place cursor at beginning of current line */ + "\033[0J", /* erase till end of screen */ SIZE_MAX, 100 * USEC_PER_MSEC); if (k < 0)