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(-)
@@ -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);
@@ -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;