From 99b2cad147b58b424f059c1fc49d68da57cf3bfa Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 2 Jul 2025 15:34:01 -0400 Subject: kernel: console: Add 'show_curs' feat flag Add 'show_curs' feat flag to enable/disable whether or not the cursor should be drawn Signed-off-by: Ian Moffett --- sys/dev/cons/cons.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'sys/dev/cons') diff --git a/sys/dev/cons/cons.c b/sys/dev/cons/cons.c index 4df854c..2cef071 100644 --- a/sys/dev/cons/cons.c +++ b/sys/dev/cons/cons.c @@ -235,8 +235,14 @@ cons_handle_special(struct cons_screen *scr, char c) static void cons_draw_cursor(struct cons_screen *scr, uint32_t color) { + struct console_feat *featp; size_t idx; + featp = &scr->feat; + if (!featp->show_curs) { + color = scr->bg; + } + /* Past screen width? */ if (scr->curs_col >= scr->ncols) { scr->curs_col = 0; @@ -437,14 +443,27 @@ static int ctl_feat_write(struct ctlfs_dev *cdp, struct sio_txn *sio) { struct cons_screen *scr = &g_root_scr; - struct console_feat *featp; + struct console_feat *featp, oldfeat; featp = &scr->feat; + oldfeat = *featp; if (sio->len > sizeof(*featp)) { sio->len = sizeof(*featp); } memcpy(featp, sio->buf, sio->len); + + /* + * If we are suddenly trying to reset the cursor + * status, redraw it. + */ + if (featp->show_curs != oldfeat.show_curs) { + if (featp->show_curs == 0) { + HIDE_CURSOR(scr); + } else { + SHOW_CURSOR(scr); + } + } return sio->len; } @@ -528,6 +547,7 @@ cons_init(void) featp = &g_root_scr.feat; featp->ansi_esc = 1; + featp->show_curs = 1; g_root_scr.ch_col = 0; g_root_scr.ch_row = 0; g_root_scr.fg = CONSOLE_FG; -- cgit v1.2.3