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