[Concept,21/27] expo: Add a txtin function to render dependencies

Message ID 20260119204130.3972647-22-sjg@u-boot.org
State New
Headers
Series Expo debugging and textedit improvements (part E) |

Commit Message

Simon Glass Jan. 19, 2026, 8:41 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Factor out the render_deps code from scene_textline_render_deps() into
a shared helper scene_txtin_render_deps(). This handles cursor display
when a text-input object is open, including entry restore/save and
cursor positioning.

For now, only textlines are supported.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 boot/scene.c          |  3 +--
 boot/scene_internal.h | 25 +++++++++++++------------
 boot/scene_textline.c | 29 -----------------------------
 boot/scene_txtin.c    | 29 +++++++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 43 deletions(-)
  

Patch

diff --git a/boot/scene.c b/boot/scene.c
index b64ddf51630..ae3851cc82c 100644
--- a/boot/scene.c
+++ b/boot/scene.c
@@ -993,8 +993,7 @@  int scene_render_deps(struct scene *scn, uint id)
 					       (struct scene_obj_menu *)obj);
 			break;
 		case SCENEOBJT_TEXTLINE:
-			scene_textline_render_deps(scn,
-					(struct scene_obj_textline *)obj);
+			scene_txtin_render_deps(scn, obj, scene_obj_txtin(obj));
 			break;
 		}
 	}
diff --git a/boot/scene_internal.h b/boot/scene_internal.h
index d3c67777cb1..96bc4e06ad6 100644
--- a/boot/scene_internal.h
+++ b/boot/scene_internal.h
@@ -372,18 +372,6 @@  int scene_render_deps(struct scene *scn, uint id);
  */
 int scene_menu_render_deps(struct scene *scn, struct scene_obj_menu *menu);
 
-/**
- * scene_textline_render_deps() - Render a textline and its dependencies
- *
- * Renders the textline and all of its attached objects
- *
- * @scn: Scene to render
- * @tline: textline to render
- * Returns: 0 if OK, -ve on error
- */
-int scene_textline_render_deps(struct scene *scn,
-			       struct scene_obj_textline *tline);
-
 /**
  * scene_iter_objs() - Iterate through all scene objects
  *
@@ -558,6 +546,19 @@  void scene_txtin_calc_bbox(struct scene_obj *obj, struct scene_txtin *tin,
 			   struct vidconsole_bbox *bbox,
 			   struct vidconsole_bbox *edit_bbox);
 
+/**
+ * scene_txtin_render_deps() - Render dependencies for a text-input object
+ *
+ * Renders the edit text on top of the background if open
+ *
+ * @scn: Scene containing the object
+ * @obj: Object to render
+ * @tin: Text-input info
+ * Return: 0 if OK, -ve on error
+ */
+int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj,
+			    struct scene_txtin *tin);
+
 /**
  * scene_obj_calc_bbox() - Calculate bounding boxes for an object
  *
diff --git a/boot/scene_textline.c b/boot/scene_textline.c
index f940be3ed28..46ab53e30c9 100644
--- a/boot/scene_textline.c
+++ b/boot/scene_textline.c
@@ -152,35 +152,6 @@  bool scene_textline_within(const struct scene *scn,
 	return scene_within(scn, tline->tin.edit_id, x, y);
 }
 
-int scene_textline_render_deps(struct scene *scn,
-			       struct scene_obj_textline *tline)
-{
-	const bool open = tline->obj.flags & SCENEOF_OPEN;
-	struct udevice *cons = scn->expo->cons;
-	uint i;
-
-	/* if open, render the edit text on top of the background */
-	if (open) {
-		int ret;
-
-		ret = vidconsole_entry_restore(cons, &scn->entry_save);
-		if (ret)
-			return log_msg_ret("sav", ret);
-		scene_render_obj(scn, tline->tin.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);
-
-		vidconsole_show_cursor(cons);
-	}
-
-	return 0;
-}
-
 /**
  * scene_textline_putch() - Output a character to the vidconsole
  *
diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c
index 99fad16c11f..2e7c496310d 100644
--- a/boot/scene_txtin.c
+++ b/boot/scene_txtin.c
@@ -57,6 +57,35 @@  int scene_txtin_arrange(struct scene *scn, struct expo_arrange_info *arr,
 	return x;
 }
 
+int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj,
+			    struct scene_txtin *tin)
+{
+	const bool open = obj->flags & SCENEOF_OPEN;
+	struct udevice *cons = scn->expo->cons;
+	uint i;
+
+	/* if open, render the edit text on top of the background */
+	if (open) {
+		int ret;
+
+		ret = vidconsole_entry_restore(cons, &scn->entry_save);
+		if (ret)
+			return log_msg_ret("sav", ret);
+		scene_render_obj(scn, tin->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);
+
+		vidconsole_show_cursor(cons);
+	}
+
+	return 0;
+}
+
 void scene_txtin_calc_bbox(struct scene_obj *obj, struct scene_txtin *tin,
 			   struct vidconsole_bbox *bbox,
 			   struct vidconsole_bbox *edit_bbox)