expo: Use standard numbering for save and discard
Set aside some expo IDs for 'save' and 'discard' buttons. This avoids
needing to store the IDs for these. Adjust the documentation and expo
tool for the new EXPOID_BASE_ID value.
Ignore these objects when saving and loading the cedit, since they do
not contain real data.
Adjust 'cedit run' to return failure when the user exits the expo
without saving. Update the test for this change as well.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/boot/cedit.c b/boot/cedit.c
index 5758cc5..cd935d4 100644
--- a/boot/cedit.c
+++ b/boot/cedit.c
@@ -154,7 +154,7 @@
struct video_priv *vid_priv;
uint scene_id;
struct scene *scn;
- bool done;
+ bool done, save;
int ret;
cli_ch_init(cch);
@@ -164,6 +164,7 @@
scene_id = ret;
done = false;
+ save = false;
do {
struct expo_action act;
int ichar, key;
@@ -208,6 +209,15 @@
case EXPOACT_OPEN:
scene_set_open(scn, act.select.id, true);
cedit_arange(exp, vid_priv, scene_id);
+ switch (scn->highlight_id) {
+ case EXPOID_SAVE:
+ done = true;
+ save = true;
+ break;
+ case EXPOID_DISCARD:
+ done = true;
+ break;
+ }
break;
case EXPOACT_CLOSE:
scene_set_open(scn, act.select.id, false);
@@ -229,6 +239,8 @@
if (ret)
return log_msg_ret("end", ret);
+ if (!save)
+ return -EACCES;
return 0;
}
@@ -477,6 +489,9 @@
const char *str;
int val, ret;
+ if (obj->id < EXPOID_BASE_ID)
+ return 0;
+
snprintf(var, sizeof(var), "c.%s", obj->name);
switch (obj->type) {
@@ -549,6 +564,9 @@
char var[60];
int val;
+ if (obj->id < EXPOID_BASE_ID)
+ return 0;
+
snprintf(var, sizeof(var), "c.%s", obj->name);
switch (obj->type) {
@@ -644,7 +662,7 @@
int val, ret;
uint i, seq;
- if (obj->type != SCENEOBJT_MENU)
+ if (obj->type != SCENEOBJT_MENU || obj->id < EXPOID_BASE_ID)
return 0;
menu = (struct scene_obj_menu *)obj;
@@ -734,7 +752,7 @@
int val, ret;
uint i;
- if (obj->type != SCENEOBJT_MENU)
+ if (obj->type != SCENEOBJT_MENU || obj->id < EXPOID_BASE_ID)
return 0;
menu = (struct scene_obj_menu *)obj;