[PATCH 33/36] expo: Plumb in textline to cedit

Simon Glass sjg at chromium.org
Tue Sep 19 20:09:03 CEST 2023


Support textlines in the configuration editor.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 boot/cedit.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/boot/cedit.c b/boot/cedit.c
index 407793aaddd..f2387170127 100644
--- a/boot/cedit.c
+++ b/boot/cedit.c
@@ -81,6 +81,12 @@ int cedit_arange(struct expo *exp, struct video_priv *vpriv, uint scene_id)
 			scene_menu_arrange(scn, (struct scene_obj_menu *)obj);
 			y += 50;
 			break;
+		case SCENEOBJT_TEXTLINE:
+			scene_obj_set_pos(scn, obj->id, 50, y);
+			scene_textline_arrange(scn,
+					(struct scene_obj_textline *)obj);
+			y += 50;
+			break;
 		}
 	}
 
@@ -295,6 +301,7 @@ static int h_write_settings(struct scene_obj *obj, void *vpriv)
 {
 	struct cedit_iter_priv *priv = vpriv;
 	struct abuf *buf = priv->buf;
+	int ret;
 
 	switch (obj->type) {
 	case SCENEOBJT_NONE:
@@ -305,7 +312,7 @@ static int h_write_settings(struct scene_obj *obj, void *vpriv)
 		const struct scene_obj_menu *menu;
 		const char *str;
 		char name[80];
-		int ret, i;
+		int i;
 
 		/* write the ID of the current item */
 		menu = (struct scene_obj_menu *)obj;
@@ -335,6 +342,15 @@ static int h_write_settings(struct scene_obj *obj, void *vpriv)
 
 		break;
 	}
+	case SCENEOBJT_TEXTLINE: {
+		const struct scene_obj_textline *tline;
+
+		tline = (struct scene_obj_textline *)obj;
+		ret = write_dt_string(buf, obj->name, abuf_data(&tline->buf));
+		if (ret)
+			return log_msg_ret("wr2", ret);
+		break;
+	}
 	}
 
 	return 0;
@@ -405,6 +421,19 @@ static int h_read_settings(struct scene_obj *obj, void *vpriv)
 
 		break;
 	}
+	case SCENEOBJT_TEXTLINE: {
+		const struct scene_obj_textline *tline;
+		const char *val;
+		int len;
+
+		tline = (struct scene_obj_textline *)obj;
+
+		val = ofnode_read_prop(node, obj->name, &len);
+		if (len >= tline->max_chars)
+			return log_msg_ret("str", -ENOSPC);
+		strcpy(abuf_data(&tline->buf), val);
+		break;
+	}
 	}
 
 	return 0;
@@ -472,6 +501,20 @@ static int h_write_settings_env(struct scene_obj *obj, void *vpriv)
 		if (ret)
 			return log_msg_ret("st2", ret);
 		break;
+	case SCENEOBJT_TEXTLINE: {
+		const struct scene_obj_textline *tline;
+
+		tline = (struct scene_obj_textline *)obj;
+		str = abuf_data(&tline->buf);
+		ret = env_set(var, str);
+		if (ret)
+			return log_msg_ret("set", ret);
+
+		if (priv->verbose)
+			printf("%s=%s\n", var, str);
+
+		break;
+	}
 	}
 
 	return 0;
@@ -521,6 +564,19 @@ static int h_read_settings_env(struct scene_obj *obj, void *vpriv)
 		 */
 		menu->cur_item_id = val;
 		break;
+	case SCENEOBJT_TEXTLINE: {
+		const struct scene_obj_textline *tline;
+		const char *value;
+
+		tline = (struct scene_obj_textline *)obj;
+		value = env_get(var);
+		if (strlen(value) >= tline->max_chars)
+			return log_msg_ret("str", -ENOSPC);
+		if (priv->verbose)
+			printf("%s=%s\n", var, value);
+		strcpy(abuf_data(&tline->buf), value);
+		break;
+	}
 	}
 
 	return 0;
-- 
2.42.0.459.ge4e396fd5e-goog



More information about the U-Boot mailing list