diff options
| author | Simon Glass <[email protected]> | 2025-04-02 06:29:36 +1300 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2025-05-02 13:40:25 -0600 |
| commit | 236ae39fb0c571d2553271a7fa75920348f9c5eb (patch) | |
| tree | c8790ebae8423023fa1585ce6557a3369da6316c /include | |
| parent | 0d0b2341dd419c7c56def9e23f31625da2d31168 (diff) | |
video: Begin support for measuring multiple lines of text
Update the vidconsole API so that measure() can measure multiple lines
of text. This will make it easier to implement multi-line fields in
expo.
Tidy up the function comments while we are here.
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'include')
| -rw-r--r-- | include/video_console.h | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/include/video_console.h b/include/video_console.h index 13197fa4518..ee9ce3c0e37 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -6,6 +6,7 @@ #ifndef __video_console_h #define __video_console_h +#include <alist.h> #include <video.h> struct abuf; @@ -120,6 +121,19 @@ struct vidconsole_bbox { }; /** + * vidconsole_mline - Holds information about a line of measured text + * + * @bbox: Bounding box of the line, assuming it starts at 0,0 + * @start: String index of the first character in the line + * @len: Number of characters in the line + */ +struct vidconsole_mline { + struct vidconsole_bbox bbox; + int start; + int len; +}; + +/** * struct vidconsole_ops - Video console operations * * These operations work on either an absolute console position (measured @@ -228,18 +242,23 @@ struct vidconsole_ops { int (*select_font)(struct udevice *dev, const char *name, uint size); /** - * measure() - Measure the bounds of some text + * measure() - Measure the bounding box of some text * - * @dev: Device to adjust + * @dev: Console device to use * @name: Font name to use (NULL to use default) * @size: Font size to use (0 to use default) * @text: Text to measure * @bbox: Returns bounding box of text, assuming it is positioned * at 0,0 + * @lines: If non-NULL, this must be an alist of + * struct vidconsole_mline inited by caller. A separate + * record is added for each line of text + * * Returns: 0 on success, -ENOENT if no such font */ int (*measure)(struct udevice *dev, const char *name, uint size, - const char *text, struct vidconsole_bbox *bbox); + const char *text, struct vidconsole_bbox *bbox, + struct alist *lines); /** * nominal() - Measure the expected width of a line of text @@ -320,19 +339,24 @@ int vidconsole_get_font(struct udevice *dev, int seq, */ int vidconsole_select_font(struct udevice *dev, const char *name, uint size); -/* - * vidconsole_measure() - Measuring the bounding box of some text +/** + * vidconsole_measure() - Measure the bounding box of some text * - * @dev: Console device to use - * @name: Font name, NULL for default - * @size: Font size, ignored if @name is NULL - * @text: Text to measure - * @bbox: Returns nounding box of text - * Returns: 0 if OK, -ve on error + * @dev: Device to adjust + * @name: Font name to use (NULL to use default) + * @size: Font size to use (0 to use default) + * @text: Text to measure + * @bbox: Returns bounding box of text, assuming it is positioned + * at 0,0 + * @lines: If non-NULL, this must be an alist of + * struct vidconsole_mline inited by caller. The list is emptied + * and then a separate record is added for each line of text + * + * Returns: 0 on success, -ENOENT if no such font */ int vidconsole_measure(struct udevice *dev, const char *name, uint size, - const char *text, struct vidconsole_bbox *bbox); - + const char *text, struct vidconsole_bbox *bbox, + struct alist *lines); /** * vidconsole_nominal() - Measure the expected width of a line of text * |
