[Concept,18/22] expo: Correct rendering of textlines when open

Message ID 20251207201628.2882382-19-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>

When a textline is open, we must render the edit string and show the
cursor. The easiest way to do this is to draw the string again, then
move the cursor back to the correct place.

There is no need to change the font, since the rendering function
handles this.

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

 boot/scene_textline.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)
  

Patch

diff --git a/boot/scene_textline.c b/boot/scene_textline.c
index 7e01959c40d..20e2d7f33c4 100644
--- a/boot/scene_textline.c
+++ b/boot/scene_textline.c
@@ -189,28 +189,21 @@  int scene_textline_render_deps(struct scene *scn,
 {
 	const bool open = tline->obj.flags & SCENEOF_OPEN;
 	struct udevice *cons = scn->expo->cons;
-	struct scene_obj_txt *txt;
-	int ret;
-
-	scene_render_deps(scn, tline->label_id);
-	scene_render_deps(scn, tline->edit_id);
+	uint i;
 
-	/* show the vidconsole cursor if open */
+	/* if open, render the edit text on top of the background */
 	if (open) {
-		/* get the position within the field */
-		txt = scene_obj_find(scn, tline->edit_id, SCENEOBJT_NONE);
-		if (!txt)
-			return log_msg_ret("cur", -ENOENT);
-
-		if (txt->gen.font_name || txt->gen.font_size) {
-			ret = vidconsole_select_font(cons,
-						     txt->gen.font_name,
-						     txt->gen.font_size);
-		} else {
-			ret = vidconsole_select_font(cons, NULL, 0);
-		}
+		int ret;
 
 		ret = vidconsole_entry_restore(cons, &scn->entry_save);
+		if (ret)
+			return log_msg_ret("sav", ret);
+		scene_render_obj(scn, tline->edit_id);
+
+		/* move cursor back to the correct position */
+		for (i = scn->cls.num; i < scn->cls.eol_num; i++)
+			vidconsole_put_char(cons, '\b');
+		ret = vidconsole_entry_save(cons, &scn->entry_save);
 		if (ret)
 			return log_msg_ret("sav", ret);