From 909c486d7cc52efd0db0a1922778fe5c17e5be24 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 Oct 2023 19:13:23 -0600 Subject: expo: Fix up comments for get_cur_menuitem_text() et al This internal function could use a comment. Add one. Also tidy up a few other comments. Signed-off-by: Simon Glass fixup: comments --- include/expo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/expo.h') diff --git a/include/expo.h b/include/expo.h index 9d2e817eb97..5b21110cde3 100644 --- a/include/expo.h +++ b/include/expo.h @@ -505,7 +505,7 @@ int scene_txt(struct scene *scn, const char *name, uint id, uint str_id, struct scene_obj_txt **txtp); /** - * scene_txt_str() - add a new string to expr and text object to a scene + * scene_txt_str() - add a new string to expo and text object to a scene * * @scn: Scene to update * @name: Name to use (this is allocated by this call) -- cgit v1.2.3 From d88edd2bda2150b253fac702dd26ec4c01ccf988 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 Oct 2023 19:13:27 -0600 Subject: expo: Allow highlighting other scene-object types So far only menus can be highlighted. With the coming addition of text lines we need to be able to highlight other objects. Add a function to determine whether an object can be highlighted. Signed-off-by: Simon Glass --- include/expo.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/expo.h') diff --git a/include/expo.h b/include/expo.h index 5b21110cde3..c16b3dd61b0 100644 --- a/include/expo.h +++ b/include/expo.h @@ -146,6 +146,8 @@ enum scene_obj_t { SCENEOBJT_NONE = 0, SCENEOBJT_IMAGE, SCENEOBJT_TEXT, + + /* types from here on can be highlighted */ SCENEOBJT_MENU, }; @@ -203,6 +205,12 @@ struct scene_obj { struct list_head sibling; }; +/* object can be highlighted when moving around expo */ +static inline bool scene_obj_can_highlight(const struct scene_obj *obj) +{ + return obj->type >= SCENEOBJT_MENU; +} + /** * struct scene_obj_img - information about an image object in a scene * -- cgit v1.2.3 From 93f99b35ec7d32b86a00cd066d2f8107cc9c23ed Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 Oct 2023 19:13:31 -0600 Subject: expo: Add some scene fields needed for text entry Add the CLI state, a buffer to hold the old value of the text being edited and a place to save vidconsole entry context. These will be use by the textline object. Set an upper limit on the maximum number of characters in a textline object supported by expo, at least for now. Signed-off-by: Simon Glass --- include/expo.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include/expo.h') diff --git a/include/expo.h b/include/expo.h index c16b3dd61b0..a535bc1695d 100644 --- a/include/expo.h +++ b/include/expo.h @@ -7,11 +7,14 @@ #ifndef __EXPO_H #define __EXPO_H +#include #include #include struct udevice; +#include + /** * enum expoact_type - types of actions reported by the expo * @@ -121,6 +124,9 @@ struct expo_string { * @id: ID number of the scene * @title_id: String ID of title of the scene (allocated) * @highlight_id: ID of highlighted object, if any + * @cls: cread state to use for input + * @buf: Buffer for input + * @entry_save: Buffer to hold vidconsole text-entry information * @sibling: Node to link this scene to its siblings * @obj_head: List of objects in the scene */ @@ -130,6 +136,9 @@ struct scene { uint id; uint title_id; uint highlight_id; + struct cli_line_state cls; + struct abuf buf; + struct abuf entry_save; struct list_head sibling; struct list_head obj_head; }; @@ -180,6 +189,11 @@ enum scene_obj_flags_t { SCENEOF_OPEN = 1 << 2, }; +enum { + /* Maximum number of characters allowed in an line editor */ + EXPO_MAX_CHARS = 250, +}; + /** * struct scene_obj - information about an object in a scene * -- cgit v1.2.3 From 4db7519032f94bc769a7a32421b26b2ec58cbbe5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 Oct 2023 19:13:32 -0600 Subject: expo: Add basic support for textline objects A textline is a line of text which can be edited by the user. It has a maximum length (in chracters) but otherwise there are no restrictions. Signed-off-by: Simon Glass --- include/expo.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'include/expo.h') diff --git a/include/expo.h b/include/expo.h index a535bc1695d..264745f7f01 100644 --- a/include/expo.h +++ b/include/expo.h @@ -150,6 +150,7 @@ struct scene { * @SCENEOBJT_IMAGE: Image data to render * @SCENEOBJT_TEXT: Text line to render * @SCENEOBJT_MENU: Menu containing items the user can select + * @SCENEOBJT_TEXTLINE: Line of text the user can edit */ enum scene_obj_t { SCENEOBJT_NONE = 0, @@ -158,6 +159,7 @@ enum scene_obj_t { /* types from here on can be highlighted */ SCENEOBJT_MENU, + SCENEOBJT_TEXTLINE, }; /** @@ -318,6 +320,27 @@ struct scene_menitem { struct list_head sibling; }; +/** + * struct scene_obj_textline - information about a textline in a scene + * + * A textline has a prompt and a line of editable text + * + * @obj: Basic object information + * @label_id: ID of the label text, or 0 if none + * @edit_id: ID of the editable text + * @max_chars: Maximum number of characters allowed + * @buf: Text buffer containing current text + * @pos: Cursor position + */ +struct scene_obj_textline { + struct scene_obj obj; + uint label_id; + uint edit_id; + uint max_chars; + struct abuf buf; + uint pos; +}; + /** * expo_new() - create a new expo * @@ -552,6 +575,19 @@ int scene_txt_str(struct scene *scn, const char *name, uint id, uint str_id, int scene_menu(struct scene *scn, const char *name, uint id, struct scene_obj_menu **menup); +/** + * scene_textline() - create a textline + * + * @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 + * @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); + /** * scene_txt_set_font() - Set the font for an object * -- cgit v1.2.3