From fa82b5710357b78b227da38bf0a7913f281c15a0 Mon Sep 17 00:00:00 2001 From: tkchia Date: Sat, 10 Sep 2022 06:46:57 +0000 Subject: [PATCH] Bare metal VGA: implement "reverse video" (`\e[7m`) escape code --- libc/vga/tty.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libc/vga/tty.c b/libc/vga/tty.c index 3094c9db6..e213b11ca 100644 --- a/libc/vga/tty.c +++ b/libc/vga/tty.c @@ -270,7 +270,11 @@ static void TtySetCodepage(struct Tty *tty, char id) { */ static uint8_t TtyGetVgaAttr(struct Tty *tty) { - uint8_t attr = tty->fg | tty->bg << 4; + uint8_t attr; + if ((tty->pr & kTtyFlip) == 0) + attr = tty->fg | tty->bg << 4; + else + attr = tty->bg | tty->fg << 4; #ifdef VGA_USE_BLINK /* * If blinking is enabled, we can only have the 8 dark background color