From 87750b027691cd67a20ae6c5b95df65c33e8294e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 2 May 2025 08:46:40 -0600 Subject: expo: Allow strings to be editable In some cases dynamic text is needed, e.g. for a menu countdown. Add a function which handles this, allowing the caller to take control of the text that is shown on each render. Signed-off-by: Simon Glass --- include/expo.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include') diff --git a/include/expo.h b/include/expo.h index 32d69f269a7..7c6ab4bf630 100644 --- a/include/expo.h +++ b/include/expo.h @@ -469,6 +469,23 @@ int expo_str(struct expo *exp, const char *name, uint id, const char *str); */ const char *expo_get_str(struct expo *exp, uint id); +/** + * expo_edit_str() - Make a string writeable + * + * This allows a string to be updated under the control of the caller. The + * buffer must remain valid while the expo is active. + * + * @exp: Expo to use + * @id: String ID to look up + * @orig: If non-NULL, returns the original buffer, which can be used by the + * caller. It is no-longer used by expo so must be uninited by the caller. + * It contains a snapshot of the string contents + * @copyp: Returns a pointer to the new, writeable buffer + * Return: 0 if OK, -ENOENT if the id was not found, -ENOMEM if out of memory + */ +int expo_edit_str(struct expo *exp, uint id, struct abuf *orig, + struct abuf **copyp); + /** * expo_set_display() - set the display to use for a expo * -- cgit v1.2.3