diff options
author | Simon Glass | 2023-10-01 19:13:19 -0600 |
---|---|---|
committer | Tom Rini | 2023-10-11 15:43:55 -0400 |
commit | 9899eef2cb41a9cde1dca87f3ddb041e347b177a (patch) | |
tree | cd4cae81e91813fc35a63532e1cae7aaa324f989 /include/video_console.h | |
parent | 9e55d09596a5b6ec1f8cbfc3e97d29b9929dee86 (diff) |
video: Allow saving and restoring text-entry state
Text entry operates within a context which includes quite a bit of
information. For example, with Truetype fonts, each character in the
text string has a position stored, so that it is possible to
backspace to that character. This information is built up as strings
are drawn on the display.
For the command line, there is just a single context. It is created
when command-line entry starts and it is destroyed (or at least not
needed anymore) when the user presses <enter> to enter the command.
By contrast, expo needs to be able to switch in and out of a text-entry
context, since it is also displaying other objects in the scene.
Add a way to save and restore the entry context for a vidconsole. This
is only needed for the truetype vidconsole, so add a method for that,
storing the information in an abuf struct.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/video_console.h')
-rw-r--r-- | include/video_console.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/include/video_console.h b/include/video_console.h index 5234c85efd6..28d65451889 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -8,6 +8,7 @@ #include <video.h> +struct abuf; struct video_priv; #define VID_FRAC_DIV 256 @@ -239,6 +240,30 @@ struct vidconsole_ops { */ int (*nominal)(struct udevice *dev, const char *name, uint size, uint num_chars, struct vidconsole_bbox *bbox); + + /** + * entry_save() - Save any text-entry information for later use + * + * Saves text-entry context such as a list of positions for each + * character in the string. + * + * @dev: Console device to use + * @buf: Buffer to hold saved data + * Return: 0 if OK, -ENOMEM if out of memory + */ + int (*entry_save)(struct udevice *dev, struct abuf *buf); + + /** + * entry_restore() - Restore text-entry information for current use + * + * Restores text-entry context such as a list of positions for each + * character in the string. + * + * @dev: Console device to use + * @buf: Buffer containing data to restore + * Return: 0 if OK, -ve on error + */ + int (*entry_restore)(struct udevice *dev, struct abuf *buf); }; /* Get a pointer to the driver operations for a video console device */ @@ -294,6 +319,30 @@ int vidconsole_nominal(struct udevice *dev, const char *name, uint size, uint num_chars, struct vidconsole_bbox *bbox); /** + * vidconsole_entry_save() - Save any text-entry information for later use + * + * Saves text-entry context such as a list of positions for each + * character in the string. + * + * @dev: Console device to use + * @buf: Buffer to hold saved data + * Return: 0 if OK, -ENOMEM if out of memory + */ +int vidconsole_entry_save(struct udevice *dev, struct abuf *buf); + +/** + * entry_restore() - Restore text-entry information for current use + * + * Restores text-entry context such as a list of positions for each + * character in the string. + * + * @dev: Console device to use + * @buf: Buffer containing data to restore + * Return: 0 if OK, -ve on error + */ +int vidconsole_entry_restore(struct udevice *dev, struct abuf *buf); + +/** * vidconsole_push_colour() - Temporarily change the font colour * * @dev: Device to adjust |