From 802b5be90d58aeb2344b100d81f88a053b6e0c24 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 9 Jun 2025 15:58:08 -0400 Subject: kernel: cons: Invert console cursor color Signed-off-by: Ian Moffett --- sys/dev/cons/cons.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'sys') diff --git a/sys/dev/cons/cons.c b/sys/dev/cons/cons.c index 671d5f0..88f394b 100644 --- a/sys/dev/cons/cons.c +++ b/sys/dev/cons/cons.c @@ -44,7 +44,7 @@ cons_draw_cursor((SCR), (SCR)->bg) #define SHOW_CURSOR(SCR) \ - cons_draw_cursor((SCR), (SCR)->fg) + cons_draw_cursor((SCR), rgb_invert((SCR)->bg)) /* Console background from kconf */ #if defined(__CONSOLE_BG) @@ -67,6 +67,23 @@ static void cons_draw_cursor(struct cons_screen *scr, uint32_t color); static int cons_handle_special(struct cons_screen *scr, char c); static void cons_clear_scr(struct cons_screen *scr, uint32_t bg); +static uint32_t +rgb_invert(uint32_t rgb) +{ + uint8_t r, g, b; + uint32_t ret; + + r = (rgb >> 16) & 0xFF; + g = (rgb >> 8) & 0xFF; + b = rgb & 0xFF; + + ret = (255 - r) << 16; + ret |= (255 - g) << 8; + ret |= 255 - b; + return ret; +} + + /* * Render a character onto the screen. * -- cgit v1.2.3