diff options
author | Ian Moffett <ian@osmora.org> | 2025-06-09 15:58:08 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-06-09 15:58:08 -0400 |
commit | 802b5be90d58aeb2344b100d81f88a053b6e0c24 (patch) | |
tree | 14fd736cecaad23e862615397b5ab9267a0dd640 | |
parent | cfd8270a83ddbd8ffdaa22d93f217e5904a9fd97 (diff) |
kernel: cons: Invert console cursor color
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/dev/cons/cons.c | 19 |
1 files changed, 18 insertions, 1 deletions
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. * |