From: Simon Glass <simon.glass@canonical.com>
Add a line_chars field to scene_obj_txtedit to specify the nominal
number of characters in a line. This is consistent with the
line_chars field in scene_obj_textline.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
boot/scene_textedit.c | 3 ++-
include/expo.h | 5 ++++-
test/boot/expo.c | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
@@ -19,7 +19,7 @@ enum {
};
int scene_texted(struct scene *scn, const char *name, uint id,
- struct scene_obj_txtedit **teditp)
+ uint line_chars, struct scene_obj_txtedit **teditp)
{
struct scene_obj_txtedit *ted;
char *buf;
@@ -36,6 +36,7 @@ int scene_texted(struct scene *scn, const char *name, uint id,
return log_msg_ret("buf", -ENOMEM);
buf = abuf_data(&ted->buf);
*buf = '\0';
+ ted->line_chars = line_chars;
if (teditp)
*teditp = ted;
@@ -546,12 +546,14 @@ struct scene_obj_box {
* @obj: Basic object information
* @label_id: ID of the label text object (not string ID), or 0 if none
* @edit_id: ID of the editable text object (not string ID)
+ * @line_chars: Nominal number of characters in a line
* @buf: Text buffer containing current text
*/
struct scene_obj_txtedit {
struct scene_obj obj;
uint label_id;
uint edit_id;
+ uint line_chars;
struct abuf buf;
};
@@ -892,11 +894,12 @@ int scene_box_set_fill(struct scene *scn, uint id, bool fill);
* @scn: Scene to update
* @name: Name to use (this is allocated by this call)
* @id: ID to use for the new object (0 to allocate one)
+ * @line_chars: Nominal number of characters in a line
* @teditp: If non-NULL, returns the new object
* Returns: ID number for the object (typically @id), or -ve on error
*/
int scene_texted(struct scene *scn, const char *name, uint id,
- struct scene_obj_txtedit **teditp);
+ uint line_chars, struct scene_obj_txtedit **teditp);
/**
* scene_txt_set_font() - Set the font for an object
@@ -1511,7 +1511,7 @@ static int expo_render_textedit(struct unit_test_state *uts)
ut_assertok(create_test_expo(uts, &exp, &scn, &menu, &buf, &logo_copy));
dev = exp->display;
- id = scene_texted(scn, "texted", OBJ_TEXTED, &ted);
+ id = scene_texted(scn, "texted", OBJ_TEXTED, 40, &ted);
ut_assert(id > 0);
ut_assertok(scene_obj_set_bbox(scn, OBJ_TEXTED, 100, 200, 400, 300));