[Concept,10/22] expo: Add prompt_id to struct scene

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

Add a prompt_id field to struct scene to track the prompt text object.
Update cedit_arange() to use title_id and prompt_id directly instead
of looking up objects by name, which is more robust.

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

 boot/cedit.c   | 11 ++++-------
 include/expo.h |  2 ++
 2 files changed, 6 insertions(+), 7 deletions(-)
  

Patch

diff --git a/boot/cedit.c b/boot/cedit.c
index c82519a0eb3..d58ae0ba51c 100644
--- a/boot/cedit.c
+++ b/boot/cedit.c
@@ -54,7 +54,6 @@  int cedit_arange(struct expo *exp, struct video_priv *vpriv, uint scene_id)
 {
 	struct expo_theme *theme = &exp->theme;
 	struct expo_arrange_info arr;
-	struct scene_obj_txt *txt;
 	struct scene_obj *obj;
 	struct scene *scn;
 	int y, ret;
@@ -63,13 +62,11 @@  int cedit_arange(struct expo *exp, struct video_priv *vpriv, uint scene_id)
 	if (!scn)
 		return log_msg_ret("scn", -ENOENT);
 
-	txt = scene_obj_find_by_name(scn, "prompt");
-	if (txt)
-		scene_obj_set_pos(scn, txt->obj.id, 0, vpriv->ysize - 50);
+	if (scn->prompt_id)
+		scene_obj_set_pos(scn, scn->prompt_id, 0, vpriv->ysize - 50);
 
-	txt = scene_obj_find_by_name(scn, "title");
-	if (txt)
-		scene_obj_set_pos(scn, txt->obj.id, 200, 10);
+	if (scn->title_id)
+		scene_obj_set_pos(scn, scn->title_id, 200, 10);
 
 	memset(&arr, '\0', sizeof(arr));
 	ret = scene_calc_arrange(scn, &arr);
diff --git a/include/expo.h b/include/expo.h
index e6093769421..f9f85b38b9c 100644
--- a/include/expo.h
+++ b/include/expo.h
@@ -204,6 +204,7 @@  struct expo_string {
  * @name: Name of the scene (allocated)
  * @id: ID number of the scene
  * @title_id: String ID of title of the scene (allocated)
+ * @prompt_id: String ID of prompt of the scene (allocated)
  * @highlight_id: ID of highlighted object, if any
  * @cls: cread state to use for input
  * @buf: Buffer for input
@@ -216,6 +217,7 @@  struct scene {
 	char *name;
 	uint id;
 	uint title_id;
+	uint prompt_id;
 	uint highlight_id;
 	struct cli_line_state cls;
 	struct abuf buf;