expo: Begin implementation of a text editor
It is useful to be able to edit text, e.g. to allow the user to edit the
environment or the command-line arguments for the OS.
Add the beginnings of an implementation. Future work is needed to finish
this: keypress handling and scrolling. For now it just displays the
text.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/test/boot/expo.c b/test/boot/expo.c
index b9093b5..e624a00 100644
--- a/test/boot/expo.c
+++ b/test/boot/expo.c
@@ -30,6 +30,7 @@
OBJ_MENU_TITLE,
OBJ_BOX,
OBJ_BOX2,
+ OBJ_TEXTED,
/* strings */
STR_SCENE_TITLE,
@@ -37,6 +38,7 @@
STR_TEXT,
STR_TEXT2,
STR_TEXT3,
+ STR_TEXTED,
STR_MENU_TITLE,
STR_POINTER_TEXT,
@@ -462,6 +464,7 @@
{
struct scene_obj_menu *menu;
struct scene *scn, *scn2;
+ struct abuf orig, *text;
struct expo_action act;
struct scene_obj *obj;
struct udevice *dev;
@@ -556,6 +559,14 @@
ut_assert(id > 0);
ut_assertok(scene_obj_set_bbox(scn, OBJ_BOX, 500, 200, 1000, 350));
+ id = scene_texted(scn, "editor", OBJ_TEXTED, STR_TEXTED, NULL);
+ ut_assert(id > 0);
+ ut_assertok(scene_obj_set_bbox(scn, OBJ_TEXTED, 100, 200, 400, 650));
+ ut_assertok(expo_edit_str(exp, STR_TEXTED, &orig, &text));
+
+ abuf_printf(text, "This\nis the initial contents of the text editor "
+ "but it is quite likely that more will be added later");
+
scn2 = expo_lookup_scene_id(exp, SCENE1);
ut_asserteq_ptr(scn, scn2);
scn2 = expo_lookup_scene_id(exp, SCENE2);
@@ -666,9 +677,12 @@
ut_asserteq(ITEM2, scene_menu_get_cur_item(scn, OBJ_MENU));
ut_assertok(scene_arrange(scn));
ut_assertok(expo_render(exp));
- ut_asserteq(16304, video_compress_fb(uts, dev, false));
+ ut_asserteq(19673, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
+ /* hide the text editor since the following tets don't need it */
+ scene_obj_set_hide(scn, OBJ_TEXTED, true);
+
/* do some alignment checks */
ut_assertok(scene_obj_set_halign(scn, OBJ_TEXT3, SCENEOA_CENTRE));
ut_assertok(expo_render(exp));