[Concept,25/42] video: truetype: Record the position where CLI entry starts

Message ID 20250919201507.4024144-26-sjg@u-boot.org
State New
Headers
Series video: Support a cursor more generally |

Commit Message

Simon Glass Sept. 19, 2025, 8:14 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

Implement the mark_start() method for the truetype console by recording
which pos[] record corresponds to this event. We can be sure that the
user will not be able to backspace past this point.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/video/console_truetype.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
  

Patch

diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index d87b3828bb0..edd2eb0a309 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -173,6 +173,8 @@  struct console_tt_metrics {
  *		start of the current command line.
  * @pos_ptr:	Current position in the position history
  * @cur_fontdata:	Current fixed font data (NULL if using TrueType)
+ * @pos_start:	Value of pos_ptr when the cursor is at the start of the text
+ *	being entered by the user
  */
 struct console_tt_priv {
 	struct console_tt_metrics *cur_met;
@@ -181,6 +183,7 @@  struct console_tt_priv {
 	struct pos_info pos[POS_HISTORY_SIZE];
 	int pos_ptr;
 	struct video_fontdata *cur_fontdata;
+	int pos_start;
 };
 
 /**
@@ -1060,6 +1063,15 @@  const char *console_truetype_get_font_size(struct udevice *dev, uint *sizep)
 	}
 }
 
+static int truetype_mark_start(struct udevice *dev)
+{
+	struct console_tt_priv *priv = dev_get_priv(dev);
+
+	priv->pos_start = priv->pos_ptr;
+
+	return 0;
+}
+
 static int console_truetype_probe(struct udevice *dev)
 {
 	struct console_tt_priv *priv = dev_get_priv(dev);
@@ -1106,6 +1118,7 @@  struct vidconsole_ops console_truetype_ops = {
 	.entry_save	= truetype_entry_save,
 	.entry_restore	= truetype_entry_restore,
 	.get_cursor_info	= truetype_get_cursor_info,
+	.mark_start	= truetype_mark_start,
 };
 
 U_BOOT_DRIVER(vidconsole_truetype) = {