mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 05/20] fbconsole: respect hidden cursor everywhere
Date: Sun,  3 May 2026 10:33:07 +0200	[thread overview]
Message-ID: <20260503084430.2765761-6-a.fatoum@barebox.org> (raw)
In-Reply-To: <20260503084430.2765761-1-a.fatoum@barebox.org>

video_invertchar() unconditionally inverts the cell's color to represent
a cursor. show_cursor() does so only when HIDE_CURSOR has not been set
for the frame buffer console.

Rename show_cursor() to reflect what it really does (toggle the cursor's
visibility state) and replace all outside uses of video_invertchar()
with the new toggle_cursor_visibility() to ensure that an explicitly
hidden cursor is not unintentionally unhidden.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 drivers/video/fbconsole.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/video/fbconsole.c b/drivers/video/fbconsole.c
index 5b7c1a13a8bc..2833d4200aa1 100644
--- a/drivers/video/fbconsole.c
+++ b/drivers/video/fbconsole.c
@@ -331,10 +331,10 @@ static void video_invertchar(struct fbc_priv *priv, int x, int y)
 	fb_blit_area(priv, x, y);
 }
 
-static void show_cursor(struct fbc_priv *priv, int x, int y)
+static void toggle_cursor_visibility(struct fbc_priv *priv)
 {
 	if (!(priv->flags & HIDE_CURSOR))
-		video_invertchar(priv, x, y);
+		video_invertchar(priv, priv->x, priv->y);
 }
 
 static void fb_scroll_up_0(struct fbc_priv *priv, void *adr, int width, int height)
@@ -451,7 +451,7 @@ static void fb_scroll_up(struct fbc_priv *priv)
 
 static void printchar(struct fbc_priv *priv, int c)
 {
-	video_invertchar(priv, priv->x, priv->y);
+	toggle_cursor_visibility(priv);
 
 	switch (c) {
 	case '\007': /* bell: ignore */
@@ -493,9 +493,7 @@ static void printchar(struct fbc_priv *priv, int c)
 		priv->y = priv->rows - 1;
 	}
 
-	show_cursor(priv, priv->x, priv->y);
-
-	return;
+	toggle_cursor_visibility(priv);
 }
 
 static void fbc_parse_colors(struct fbc_priv *priv)
@@ -564,7 +562,7 @@ static void fbc_parse_csi(struct fbc_priv *priv)
 
 			priv->flags &= ~HIDE_CURSOR;
 			/* show cursor now */
-			show_cursor(priv, priv->x, priv->y);
+			toggle_cursor_visibility(priv);
 			break;
 		}
 		break;
@@ -573,7 +571,7 @@ static void fbc_parse_csi(struct fbc_priv *priv)
 		switch (priv->csi_cmd) {
 		case '?': /* cursor invisible */
 			/* hide cursor now */
-			video_invertchar(priv, priv->x, priv->y);
+			toggle_cursor_visibility(priv);
 			priv->flags |= HIDE_CURSOR;
 
 			break;
@@ -581,10 +579,10 @@ static void fbc_parse_csi(struct fbc_priv *priv)
 		break;
 	case 'J':
 		cls(priv);
-		show_cursor(priv, priv->x, priv->y);
+		toggle_cursor_visibility(priv);
 		return;
 	case 'H':
-		show_cursor(priv, priv->x, priv->y);
+		toggle_cursor_visibility(priv);
 
 		pos = simple_strtoul(priv->csi, &end, 10);
 		priv->y = clamp(pos - 1, 0, (int) priv->rows - 1);
@@ -592,11 +590,11 @@ static void fbc_parse_csi(struct fbc_priv *priv)
 		pos = simple_strtoul(end + 1, NULL, 10);
 		priv->x = clamp(pos - 1, 0, (int) priv->cols - 1);
 
-		show_cursor(priv, priv->x, priv->y);
+		toggle_cursor_visibility(priv);
 		break;
 	case 'K':
 		pos = simple_strtoul(priv->csi, &end, 10);
-		video_invertchar(priv, priv->x, priv->y);
+		toggle_cursor_visibility(priv);
 		switch (pos) {
 		case 0:
 			for (i = priv->x; i < priv->cols; i++)
@@ -607,7 +605,7 @@ static void fbc_parse_csi(struct fbc_priv *priv)
 				drawchar(priv, i, priv->y, ' ');
 			break;
 		}
-		video_invertchar(priv, priv->x, priv->y);
+		toggle_cursor_visibility(priv);
 
 		break;
 	}
-- 
2.47.3




  parent reply	other threads:[~2026-05-03  8:45 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-03  8:33 [PATCH 00/20] fbconsole: support TUI-relevant escape sequences Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 01/20] fbconsole: remove incomplete CSI_CNT state Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 02/20] fbconsole: improve handling of unexpected escape sequences Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 03/20] fbconsole: fix handling of CSI buffer overflow Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 04/20] fbconsole: do not reset cursor visibility alongside attributes Ahmad Fatoum
2026-05-03  8:33 ` Ahmad Fatoum [this message]
2026-05-03  8:33 ` [PATCH 06/20] fbconsole: call fb_blit_area for every drawchar Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 07/20] fbconsole: skip fb_flush when processing escape sequences Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 08/20] fbconsole: factor out helpers for clamped cursor row/col setting Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 09/20] fbconsole: precompute foreground/background colors Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 10/20] fbconsole: collect renderable state into struct fbc_screen_state Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 11/20] fbconsole: implement CSI A/B/C/D cursor movement sequences Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 12/20] fbconsole: restrict cursor visibility to DEC private mode 25 Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 13/20] fbconsole: add new clear_chars helper Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 14/20] fbconsole: implement erase entire line CSI Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 15/20] fbconsole: support ESC[0J and ESC[1J partial screen clear Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 16/20] fbconsole: implement DEC save/restore cursor Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 17/20] fbconsole: implement VT100 deferred wrap (last column flag) Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 18/20] fbconsole: implement alternate screen buffer (ESC[?1049h/l) Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 19/20] fbconsole: adapt logging depending on activated streams Ahmad Fatoum
2026-05-03  8:33 ` [PATCH 20/20] netconsole: suppress log message when opening console file Ahmad Fatoum
2026-05-07 10:38 ` [PATCH 00/20] fbconsole: support TUI-relevant escape sequences Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260503084430.2765761-6-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox