[Concept,08/16] expo: Rename textline max_chars to line_chars

Message ID 20260118204303.1982533-9-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>

Rename the max_chars field to line_chars to better describe its purpose.
This field represents the nominal number of characters in a line, which
for textline is also a hard limit.

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

 boot/cedit.c            |  4 ++--
 boot/expo_build.c       |  6 +++---
 boot/expo_dump.c        |  2 +-
 boot/scene_textline.c   | 16 ++++++++--------
 doc/usage/cmd/cedit.rst |  2 +-
 include/expo.h          | 10 +++++-----
 6 files changed, 20 insertions(+), 20 deletions(-)
  

Patch

diff --git a/boot/cedit.c b/boot/cedit.c
index d58ae0ba51c..5a334787453 100644
--- a/boot/cedit.c
+++ b/boot/cedit.c
@@ -538,7 +538,7 @@  static int h_read_settings(struct scene_obj *obj, void *vpriv)
 		tline = (struct scene_obj_textline *)obj;
 
 		val = ofnode_read_prop(node, obj->name, &len);
-		if (len >= tline->max_chars)
+		if (len >= tline->line_chars)
 			return log_msg_ret("str", -ENOSPC);
 		strcpy(abuf_data(&tline->buf), val);
 		break;
@@ -708,7 +708,7 @@  static int h_read_settings_env(struct scene_obj *obj, void *vpriv)
 
 		tline = (struct scene_obj_textline *)obj;
 		value = env_get(var);
-		if (value && strlen(value) >= tline->max_chars)
+		if (value && strlen(value) >= tline->line_chars)
 			return log_msg_ret("str", -ENOSPC);
 		if (!value)
 			value = "";
diff --git a/boot/expo_build.c b/boot/expo_build.c
index 60a9cd71b7e..76611b4f6d7 100644
--- a/boot/expo_build.c
+++ b/boot/expo_build.c
@@ -328,17 +328,17 @@  static int textline_build(struct build_info *info, ofnode node,
 	uint edit_id;
 	const char *name;
 	char buf[80];
-	u32 max_chars;
+	u32 line_chars;
 	int ret;
 
 	name = ofnode_get_name(node);
 
 	info->err_prop = "max-chars";
-	ret = ofnode_read_u32(node, "max-chars", &max_chars);
+	ret = ofnode_read_u32(node, "max-chars", &line_chars);
 	if (ret)
 		return log_msg_ret("max", -ENOENT);
 
-	ret = scene_textline(scn, name, id, max_chars, &ted);
+	ret = scene_textline(scn, name, id, line_chars, &ted);
 	if (ret < 0)
 		return log_msg_ret("ted", ret);
 
diff --git a/boot/expo_dump.c b/boot/expo_dump.c
index 5f9ea22c50a..2cd74e137d4 100644
--- a/boot/expo_dump.c
+++ b/boot/expo_dump.c
@@ -109,7 +109,7 @@  static void dump_textline(struct dump_ctx *ctx,
 	outf(ctx, "Textline: label_id %x edit_id %x\n",
 	     tline->label_id, tline->edit_id);
 	ctx->indent += 2;
-	outf(ctx, "max_chars %x pos %x\n", tline->max_chars, tline->pos);
+	outf(ctx, "line_chars %x pos %x\n", tline->line_chars, tline->pos);
 	ctx->indent -= 2;
 }
 
diff --git a/boot/scene_textline.c b/boot/scene_textline.c
index 082b39f2497..2270e1496e9 100644
--- a/boot/scene_textline.c
+++ b/boot/scene_textline.c
@@ -16,14 +16,14 @@ 
 #include <linux/string.h>
 #include "scene_internal.h"
 
-int scene_textline(struct scene *scn, const char *name, uint id, uint max_chars,
-		   struct scene_obj_textline **tlinep)
+int scene_textline(struct scene *scn, const char *name, uint id,
+		   uint line_chars, struct scene_obj_textline **tlinep)
 {
 	struct scene_obj_textline *tline;
 	char *buf;
 	int ret;
 
-	if (max_chars >= EXPO_MAX_CHARS)
+	if (line_chars >= EXPO_MAX_CHARS)
 		return log_msg_ret("chr", -E2BIG);
 
 	ret = scene_obj_add(scn, name, id, SCENEOBJT_TEXTLINE,
@@ -31,12 +31,12 @@  int scene_textline(struct scene *scn, const char *name, uint id, uint max_chars,
 			    (struct scene_obj **)&tline);
 	if (ret < 0)
 		return log_msg_ret("obj", -ENOMEM);
-	if (!abuf_init_size(&tline->buf, max_chars + 1))
+	if (!abuf_init_size(&tline->buf, line_chars + 1))
 		return log_msg_ret("buf", -ENOMEM);
 	buf = abuf_data(&tline->buf);
 	*buf = '\0';
-	tline->pos = max_chars;
-	tline->max_chars = max_chars;
+	tline->pos = line_chars;
+	tline->line_chars = line_chars;
 
 	if (tlinep)
 		*tlinep = tline;
@@ -73,7 +73,7 @@  int scene_textline_calc_dims(struct scene_obj_textline *tline,
 		return log_msg_ret("dim", -ENOENT);
 
 	ret = vidconsole_nominal(cons, txt->gen.font_name, txt->gen.font_size,
-				 tline->max_chars, &bbox);
+				 tline->line_chars, &bbox);
 	if (ret)
 		return log_msg_ret("nom", ret);
 
@@ -246,7 +246,7 @@  int scene_textline_open(struct scene *scn, struct scene_obj_textline *tline)
 
 	vidconsole_set_cursor_pos(cons, txt->obj.bbox.x0, txt->obj.bbox.y0);
 	vidconsole_entry_start(cons);
-	cli_cread_init(&scn->cls, abuf_data(&tline->buf), tline->max_chars);
+	cli_cread_init(&scn->cls, abuf_data(&tline->buf), tline->line_chars);
 	scn->cls.insert = true;
 	scn->cls.putch = scene_textline_putch;
 	ret = vidconsole_entry_save(cons, &scn->entry_save);
diff --git a/doc/usage/cmd/cedit.rst b/doc/usage/cmd/cedit.rst
index 0eb8f09dc2c..5d2071bdd1a 100644
--- a/doc/usage/cmd/cedit.rst
+++ b/doc/usage/cmd/cedit.rst
@@ -362,7 +362,7 @@  This shows dumping the cedit::
         bbox: (0,0)-(0,0)
         dims: 0x0
         Textline: label_id 39 edit_id 18
-            max_chars 20 pos 20
+            line_chars 14 pos 14
         Object 39 (title): type text
         flags
         bbox: (0,0)-(0,0)
diff --git a/include/expo.h b/include/expo.h
index 9d6300024fc..39245228574 100644
--- a/include/expo.h
+++ b/include/expo.h
@@ -510,7 +510,7 @@  struct scene_menitem {
  * @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)
- * @max_chars: Maximum number of characters allowed
+ * @line_chars: Nominal number of characters in a line (also a hard limit)
  * @buf: Text buffer containing current text
  * @pos: Cursor position
  */
@@ -518,7 +518,7 @@  struct scene_obj_textline {
 	struct scene_obj obj;
 	uint label_id;
 	uint edit_id;
-	uint max_chars;
+	uint line_chars;
 	struct abuf buf;
 	uint pos;
 };
@@ -855,12 +855,12 @@  int scene_menu(struct scene *scn, const char *name, uint id,
  * @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)
- * @max_chars: Maximum length of the textline in characters
+ * @line_chars: Number of characters in a line (also a hard limit)
  * @tlinep: If non-NULL, returns the new object
  * Returns: ID number for the object (typically @id), or -ve on error
  */
-int scene_textline(struct scene *scn, const char *name, uint id, uint max_chars,
-		   struct scene_obj_textline **tlinep);
+int scene_textline(struct scene *scn, const char *name, uint id,
+		   uint line_chars, struct scene_obj_textline **tlinep);
 
 /**
  *  scene_box() - create a box