diff options
author | Simon Glass <sjg@chromium.org> | 2025-05-02 08:46:46 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2025-05-30 09:49:32 +0100 |
commit | e005f18b933f3f4555fd08a4d66a1f9aee8f47e1 (patch) | |
tree | 0c73361684a683f767457b7c6dfebe9829f6b84f /include/expo.h | |
parent | 09f6f915fea90ea21a1a7b6a0a6907f89034dae1 (diff) |
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>
Diffstat (limited to 'include/expo.h')
-rw-r--r-- | include/expo.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/include/expo.h b/include/expo.h index 001f7db2553..16f2f18c4fa 100644 --- a/include/expo.h +++ b/include/expo.h @@ -183,12 +183,14 @@ struct scene { * @SCENEOBJT_TEXT: Text line to render * @SCENEOBJT_MENU: Menu containing items the user can select * @SCENEOBJT_TEXTLINE: Line of text the user can edit + * @SCENEOBJT_TEXTEDIT: Simple text editor */ enum scene_obj_t { SCENEOBJT_NONE = 0, SCENEOBJT_IMAGE, SCENEOBJT_TEXT, SCENEOBJT_BOX, + SCENEOBJT_TEXTEDIT, /* types from here on can be highlighted */ SCENEOBJT_MENU, @@ -465,6 +467,21 @@ struct scene_obj_box { }; /** + * struct scene_obj_txtedit - information about a box in a scene + * + * A text editor which allows users to edit a small text file + * + * @obj: Basic object information + * @gen: Generic information common to all objects which show text + * @buf: Text buffer containing current text + */ +struct scene_obj_txtedit { + struct scene_obj obj; + struct scene_txt_generic gen; + struct abuf buf; +}; + +/** * struct expo_arrange_info - Information used when arranging a scene * * @label_width: Maximum width of labels in scene @@ -742,6 +759,19 @@ int scene_box(struct scene *scn, const char *name, uint id, uint width, struct scene_obj_box **boxp); /** + * scene_texted() - create a text editor + * + * @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) + * @strid: ID of the string to edit + * @teditp: If non-NULL, returns the new object + * Returns: ID number for the object (typically @id), or -ve on error + */ +int scene_texted(struct scene *scn, const char *name, uint id, uint strid, + struct scene_obj_txtedit **teditp); + +/** * scene_txt_set_font() - Set the font for an object * * @scn: Scene to update @@ -753,6 +783,17 @@ int scene_txt_set_font(struct scene *scn, uint id, const char *font_name, uint font_size); /** + * scene_txted_set_font() - Set the font for an object + * + * @scn: Scene to update + * @id: ID of object to update + * @font_name: Font name to use (allocated by caller) + * @font_size: Font size to use (nominal height in pixels) + */ +int scene_txted_set_font(struct scene *scn, uint id, const char *font_name, + uint font_size); + +/** * scene_obj_set_pos() - Set the postion of an object * * @scn: Scene to update |