[Concept,09/16] expo: Add line_chars to scene_obj_txtedit

Message ID 20260118204303.1982533-10-sjg@u-boot.org
State New
Headers
Series expo: Continue preparations for textedit (part D) |

Commit Message

Simon Glass Jan. 18, 2026, 8:42 p.m. UTC
  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(-)
  

Patch

diff --git a/boot/scene_textedit.c b/boot/scene_textedit.c
index 3c1edf38592..a55285f00cd 100644
--- a/boot/scene_textedit.c
+++ b/boot/scene_textedit.c
@@ -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;
diff --git a/include/expo.h b/include/expo.h
index 39245228574..2d57e67d51c 100644
--- a/include/expo.h
+++ b/include/expo.h
@@ -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
diff --git a/test/boot/expo.c b/test/boot/expo.c
index 7d76431208a..dc9ebe702b8 100644
--- a/test/boot/expo.c
+++ b/test/boot/expo.c
@@ -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));