|
RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
|
text.h — text measurement seams and the paragraph line breaker shared by the layout kernel, the painters and the field. More...
#include <stddef.h>#include <stdint.h>Data Structures | |
| union | rmgui_text_prefix_cursor_t |
| Opaque provider state for one forward scan; zero it before the first call. More... | |
| struct | rmgui_text_line_t |
| One broken line: text[offset, end) is painted; the next line starts at next (after trailing blanks and a consumed newline). More... | |
Macros | |
| #define | RMGUI_TEXT_PREFIX_CURSOR_BYTES 64u |
Typedefs | |
| typedef int(*) | rmgui_text_measure_fn(const void *ud, const char *text, int font_px, int max_w, int *out_w, int *out_h) |
| Measures NUL-terminated text at font_px: max_w 0 measures one unwrapped line, max_w > 0 the text wrapped at that width. | |
| typedef int(*) | rmgui_text_prefix_fn(const void *ud, const char *text, size_t length, size_t start, size_t end, int font_px, void *cursor, int *out_w, int *out_h) |
| Measures text[start, end) of the length-byte text as one line. | |
Functions | |
| int | rmgui_text_flow_line (const char *text, size_t length, size_t offset, int font_px, int max_w, rmgui_text_measure_fn measure, const void *userdata, char *scratch, size_t scratch_capacity, rmgui_text_line_t *line) |
| Breaks the line of text (length bytes) starting at offset at the last blank that fits max_w (0: no limit), inside a token when its first word alone overflows (at least one codepoint). | |
| int | rmgui_text_flow_line_prefix (const char *text, size_t length, size_t offset, int font_px, int max_w, rmgui_text_measure_fn measure, rmgui_text_prefix_fn prefix, const void *userdata, char *scratch, size_t scratch_capacity, rmgui_text_line_t *line) |
| rmgui_text_flow_line through an exact-prefix provider, linear in the line length. | |
text.h — text measurement seams and the paragraph line breaker shared by the layout kernel, the painters and the field.
Offsets and lengths are UTF-8 byte counts.
| #define RMGUI_TEXT_PREFIX_CURSOR_BYTES 64u |
| typedef int(*) rmgui_text_measure_fn(const void *ud, const char *text, int font_px, int max_w, int *out_w, int *out_h) |
Measures NUL-terminated text at font_px: max_w 0 measures one unwrapped line, max_w > 0 the text wrapped at that width.
ud is the provider's context (for the built-in font, the rmgui_font_t). Its provider defines whether measurement only reads it or fills caller-owned caches. Returns 0 with *out_w >= 0 and *out_h >= 0 (the line breaker additionally requires *out_h >= 1); any other return is a failure the caller propagates.
| typedef int(*) rmgui_text_prefix_fn(const void *ud, const char *text, size_t length, size_t start, size_t end, int font_px, void *cursor, int *out_w, int *out_h) |
Measures text[start, end) of the length-byte text as one line.
Calls sharing one zeroed cursor (RMGUI_TEXT_PREFIX_CURSOR_BYTES bytes) must use the same text and start with non-decreasing end. Same return contract as rmgui_text_measure_fn.
| int rmgui_text_flow_line | ( | const char * | text, |
| size_t | length, | ||
| size_t | offset, | ||
| int | font_px, | ||
| int | max_w, | ||
| rmgui_text_measure_fn | measure, | ||
| const void * | userdata, | ||
| char * | scratch, | ||
| size_t | scratch_capacity, | ||
| rmgui_text_line_t * | line ) |
Breaks the line of text (length bytes) starting at offset at the last blank that fits max_w (0: no limit), inside a token when its first word alone overflows (at least one codepoint).
A newline always ends the line. scratch must not overlap text and must hold the bytes from offset to the next newline (or length), plus a terminating NUL. Returns 0, or -1 on bad arguments, insufficient scratch or a measure failure, leaving line unchanged. No allocation or text length cap.
| int rmgui_text_flow_line_prefix | ( | const char * | text, |
| size_t | length, | ||
| size_t | offset, | ||
| int | font_px, | ||
| int | max_w, | ||
| rmgui_text_measure_fn | measure, | ||
| rmgui_text_prefix_fn | prefix, | ||
| const void * | userdata, | ||
| char * | scratch, | ||
| size_t | scratch_capacity, | ||
| rmgui_text_line_t * | line ) |
rmgui_text_flow_line through an exact-prefix provider, linear in the line length.
With prefix non-NULL, measure and scratch are unused (NULL, 0 is sufficient); otherwise falls back to rmgui_text_flow_line and its scratch requirements. Failure leaves line unchanged.