[Concept,04/22] video: Document the quirk in truetype_get_cursor_info()

Message ID 20251207201628.2882382-5-sjg@u-boot.org
State New
Headers
Series expo: Expand docs, dump and textlines in non-popup expos |

Commit Message

Simon Glass Dec. 7, 2025, 8:16 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

The current code is written to suggest that the cursor position
(priv->pos_ptr) might be respected. In fact a bug means that it never
is, since index is set to priv->pos_ptr, so the if() condition always
fails.

Further, when editing textline objects, the cursor index is always the
same as priv->pos_ptr anyway. Fix the bug but keep the current
behaviour, adding a comment for future readers.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 drivers/video/console_truetype.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 4ddf133f2e0..7f5a2262b17 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -1097,9 +1097,13 @@  static int truetype_get_cursor_info(struct udevice *dev)
 	 * figure out where to place the cursor. This driver ignores the
 	 * passed-in values, since an entry_restore() must have been done before
 	 * calling this function.
+	 *
+	 * A current quirk is that the cursor is always at xcur_frac, since we
+	 * output characters directly to the console as they are typed by the
+	 * user. So we never bother with priv->pos[index] for now.
 	 */
 	index = priv->pos_ptr;
-	if (index < priv->pos_ptr)
+	if (0 && index < priv->pos_count)
 		x = VID_TO_PIXEL(priv->pos[index].xpos_frac);
 	else
 		x = VID_TO_PIXEL(vc_priv->xcur_frac);