RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
field.h File Reference

field.h — the editable text field element: a caller-owned byte buffer, its caret/selection/view state, a retained wrap layout, the painter and the one input function; and the animated label, which shares the field's glyph motion. More...

#include <stddef.h>
#include <stdint.h>
#include "fb.h"
#include "font.h"
#include "geom.h"
#include "input.h"
#include "scroll.h"
#include "style.h"
#include "text.h"
#include "draw_target.h"
#include "host.h"
#include "text_shape.h"
#include "ui_context.h"

Data Structures

struct  rmgui_field_edit_t
 One undo record. More...
struct  rmgui_field_history_t
 Caller-owned history ring, zero-initialized before attachment to one field. More...
struct  rmgui_field_action_t
 One action button inside the field's rect. More...
struct  rmgui_field_actions_t
 A field's action table: action[0, count), count <= RMGUI_FIELD_ACTION_MAX, host-owned and read whenever the field is laid out or measured. More...
struct  rmgui_field_mask_t
struct  rmgui_field_t
 Retained state of one field. More...
struct  rmgui_field_metrics_t
 How a field's text is measured and sized. More...
struct  rmgui_field_row_t
 One wrapped row: bytes [start, end) are drawn; width is their pixel width. More...
struct  rmgui_field_layout_t
 The retained wrap/scroll layout of one field, produced by rmgui_field_layout and kept current by rmgui_field_input. More...
struct  rmgui_field_glyph_t
 One recorded edit: inserted bytes [at, at + length) of the current text, age_ms < RMGUI_FIELD_GLYPHS_DURATION_MS, or (ghost_length > 0, length 0) deleted bytes ghost[0, ghost_length) drawn at byte at, age_ms < RMGUI_FIELD_GLYPHS_ERASE_MS. More...
struct  rmgui_field_glyphs_t
 The glyph motion of one field. More...
struct  rmgui_label_run_t
 One styled run of a label: the next length bytes of its text drawn in color. More...
struct  rmgui_label_text_t
 A label's text as painted: the well-formed UTF-8 text[0, length), coloured by runs[0, run_count) in order from byte 0, and by color past the last run (every byte when run_count is 0). More...
struct  rmgui_label_glyphs_t
 The glyph motion of one label. More...

Macros

#define RMGUI_FIELD_CAPACITY_MAX   (UINT16_MAX - 1u)
 Type-imposed byte ceiling (terminator excluded).
#define RMGUI_FIELD_VISIBLE_MAX   32
 Most rows a field shows at once; a taller content box leaves the rows below this count empty and scrolls instead.
#define RMGUI_FIELD_ROWS_CAP   (RMGUI_FIELD_VISIBLE_MAX + 4)
 Rows a layout retains: the visible window, the row above it and a short lookahead that lets an edit's reflow stop as soon as the wrap converges.
#define RMGUI_FIELD_ACTION_MAX   8
 Most actions one field carries.
#define RMGUI_FIELD_GLYPHS_WIPE_MS   200
 Milliseconds an insertion takes to reveal under RMGUI_FIELD_GLYPHS_WIPE.
#define RMGUI_FIELD_GLYPHS_LAND_MS   180
 Milliseconds an insertion takes to settle under RMGUI_FIELD_GLYPHS_LAND.
#define RMGUI_FIELD_GLYPHS_ERASE_MS   140
 Milliseconds a deletion's gap takes to close, in either mode.
#define RMGUI_FIELD_GLYPHS_DURATION_MS   200
 Milliseconds from an edit until its glyphs rest at their static paint in either mode: the longest of the three durations above.
#define RMGUI_FIELD_GLYPHS_CAP   8
 Edits animated at once; a further edit retires the oldest.
#define RMGUI_FIELD_GLYPHS_GHOST_CAP   32
 Longest deletion, in bytes, whose glyphs are kept for the wipe-out; a longer deletion, or one removing a '&#92;n', vanishes at once.

Enumerations

enum  rmgui_field_command_t {
  RMGUI_FIELD_COMMAND_COPY , RMGUI_FIELD_COMMAND_CUT , RMGUI_FIELD_COMMAND_PASTE , RMGUI_FIELD_COMMAND_SELECT_ALL ,
  RMGUI_FIELD_COMMAND_UNDO , RMGUI_FIELD_COMMAND_REDO
}
 Direct editing commands; shortcut CHAR keys use ASCII A/C/V/X/Y/Z with CTRL or META (SHIFT+Z redoes). More...
enum  rmgui_field_caret_t { RMGUI_FIELD_CARET_HIDDEN , RMGUI_FIELD_CARET_SHOWN }
 Caret visibility for one paint: the host owns the blink decision. More...
enum  rmgui_field_slot_t { RMGUI_FIELD_SLOT_LEAD = 0 , RMGUI_FIELD_SLOT_TRAIL = 1 }
 Which strip of the field an action button sits in: LEAD left of the text, TRAIL right of it. More...
enum  rmgui_field_glyphs_mode_t { RMGUI_FIELD_GLYPHS_WIPE , RMGUI_FIELD_GLYPHS_LAND }
 How rmgui_field_glyphs_paint shows an insertion. More...

Functions

int rmgui_field_bind (rmgui_field_t *self, char *storage, size_t capacity)
 Bind host storage of capacity bytes plus one terminator byte and adopt its current NUL-terminated contents (scanned up to capacity); the caret lands at the end, no selection, view follows the caret, states cleared; hint, multiline, actions, host, history and scratch configuration are kept; history and preedit contents are cleared.
int rmgui_field_adopt (rmgui_field_t *self, const char *text, size_t length)
 Replace the whole text with length bytes of text (a program value, a restored draft).
int rmgui_field_selection (const rmgui_field_t *self, size_t *start, size_t *end)
 0 with the ordered UTF-8 bounds of the selection in *start and *end (either may be NULL) when a non-empty span is selected; -1 otherwise (unbound, NULL self, or an empty selection), outputs untouched.
void rmgui_field_select_all (rmgui_field_t *self)
 Select the whole text (anchor 0, caret at the end).
size_t rmgui_field_insert (rmgui_field_t *self, const char *text, size_t bytes)
 Insert the longest well-formed, NUL-free UTF-8 prefix of text[0, bytes) that fits the capacity at the caret, replacing the selection: the host's edit (an action inserting a glyph, a paste), the same edit a TEXT event makes.
int rmgui_field_command (rmgui_field_t *self, rmgui_field_command_t command)
 Apply a direct command; 0 on success, -1 on missing service/storage, empty undo/redo, invalid command, or clipboard refusal.
int rmgui_field_layout (const rmgui_field_t *self, const rmgui_field_metrics_t *metrics, rmgui_rect_t content, rmgui_field_layout_t *layout)
 Bring layout up to date with self, metrics and the field's content box (its rect inset by rmgui_paint_face_inset for RMGUI_STYLE_CLASS_TEXT_FIELD).
void rmgui_field_layout_invalidate (rmgui_field_layout_t *layout)
 Discard the retained layout so the next rmgui_field_layout recomputes it, including wrapped rows and shaped runs.
rmgui_size_t rmgui_field_measure (const rmgui_style_resolved_t *rs, const rmgui_field_metrics_t *metrics, const rmgui_field_t *self, const rmgui_field_layout_t *layout)
 Outer size: the TEXT_FIELD face inset on every side around one caret column plus every action of self (as laid out with a non-empty text) horizontally, and rows of line_height vertically: min(min_rows, RMGUI_FIELD_VISIBLE_MAX) rows, or with max_rows > 0 and layout current for self (rmgui_field_layout or rmgui_field_input since the last byte change) the rows the text wraps to at the layout's text column without a scrollbar gutter, clamped to [min_rows, min(max_rows, RMGUI_FIELD_VISIBLE_MAX)].
void rmgui_field_paint (rmgui_fb_t *fb, rmgui_font_t *font, const rmgui_style_resolved_t *rs, rmgui_rect_t rect, rmgui_rect_t clip, const rmgui_field_t *self, const rmgui_field_layout_t *layout, rmgui_field_caret_t caret)
 Paint the face and border of rect, then the visible rows in font, selection (inverted pixels), caret (when caret is SHOWN and the caret row is in view), scrollbar and action buttons from layout.
void rmgui_field_paint_to (rmgui_target_t *, rmgui_font_t *, const rmgui_style_resolved_t *, rmgui_rect_t, rmgui_rect_t, const rmgui_field_t *, const rmgui_field_layout_t *, rmgui_field_caret_t)
 Explicit destination field paint.
int rmgui_field_prepare (const rmgui_ui_t *ui, const rmgui_field_t *field, const rmgui_field_layout_t *layout)
 Stage the current layout's display runs, including masked text, shaping, composition and action labels, before recording.
int rmgui_field_draw (const rmgui_ui_t *ui, const rmgui_field_t *field, const rmgui_field_layout_t *layout, rmgui_rect_t box, rmgui_field_caret_t caret)
 Draw a bound field using its current caller-owned layout and device-space text metrics.
rmgui_input_result_t rmgui_field_input (rmgui_field_t *self, rmgui_field_layout_t *layout, rmgui_rect_t rect, const rmgui_input_t *in)
 Apply one event to the field whose arranged rect is rect, keeping layout current (an edit re-wraps only the rows it affects).
int rmgui_field_step (rmgui_field_t *self, rmgui_field_layout_t *layout, uint16_t dt_ms)
 Advance a held scrollbar arrow by dt_ms (rmgui_scroll_step's countdown and catch-up), moving the window one row per repeat and keeping layout current.
rmgui_input_result_t rmgui_field_glyphs_input (rmgui_field_glyphs_t *glyphs, rmgui_field_t *self, rmgui_field_layout_t *layout, rmgui_rect_t rect, const rmgui_input_t *in)
 rmgui_field_input, and when the event changed the field's bytes, record that edit in glyphs at age 0: the inserted bytes, and the deleted bytes when there are at most RMGUI_FIELD_GLYPHS_GHOST_CAP of them and none is '&#92;n' (a deletion joining rows vanishes at once).
int rmgui_field_glyphs_step (rmgui_field_glyphs_t *glyphs, uint32_t dt_ms)
 Age every recorded edit by dt_ms and retire insertions reaching RMGUI_FIELD_GLYPHS_DURATION_MS and deletions reaching RMGUI_FIELD_GLYPHS_ERASE_MS.
int rmgui_field_glyphs_is_moving (const rmgui_field_glyphs_t *glyphs)
 1 while an edit is recorded (count > 0: a step still changes the record), else 0 (also for NULL).
void rmgui_field_glyphs_paint (rmgui_fb_t *fb, rmgui_font_t *font, const rmgui_style_resolved_t *rs, rmgui_rect_t rect, rmgui_rect_t clip, const rmgui_field_t *self, const rmgui_field_layout_t *layout, rmgui_field_caret_t caret, const rmgui_field_glyphs_t *glyphs, rmgui_field_glyphs_mode_t mode)
 rmgui_field_paint with the recorded edits animated in mode by their age.
int rmgui_label_glyphs_note (rmgui_label_glyphs_t *glyphs, const rmgui_label_text_t *before, const rmgui_label_text_t *after)
 Record the change of a label's text from before to after at age 0, as the one replacement between their longest common prefix and, after it, their longest common suffix, both ending on codepoint boundaries.
int rmgui_label_glyphs_step (rmgui_label_glyphs_t *glyphs, uint32_t dt_ms)
 rmgui_field_glyphs_step for a label's record: ages every edit by dt_ms, with the same retirement and the same composition (step(a) then step(b) leaves the record step(a + b) does).
int rmgui_label_glyphs_is_moving (const rmgui_label_glyphs_t *glyphs)
 1 while an edit is recorded (count > 0), else 0 (also for NULL).
void rmgui_label_glyphs_paint (rmgui_fb_t *fb, rmgui_font_t *font, rmgui_rect_t rect, rmgui_rect_t clip, int font_px, int wrap_w, const rmgui_label_text_t *label, const rmgui_label_glyphs_t *glyphs, rmgui_field_glyphs_mode_t mode)
 Paint label at font_px with its first line box's top-left at (rect.x, rect.y), writing only pixels inside rect ∩ clip.
void rmgui_field_glyphs_paint_to (rmgui_target_t *, rmgui_font_t *, const rmgui_style_resolved_t *, rmgui_rect_t, rmgui_rect_t, const rmgui_field_t *, const rmgui_field_layout_t *, rmgui_field_caret_t, const rmgui_field_glyphs_t *, rmgui_field_glyphs_mode_t)
 Explicit destination animated field paint, including ordered RGB inversion.
void rmgui_label_glyphs_paint_to (rmgui_target_t *, rmgui_font_t *, rmgui_rect_t, rmgui_rect_t, int, int, const rmgui_label_text_t *, const rmgui_label_glyphs_t *, rmgui_field_glyphs_mode_t)
 Explicit destination label animation.

Detailed Description

field.h — the editable text field element: a caller-owned byte buffer, its caret/selection/view state, a retained wrap layout, the painter and the one input function; and the animated label, which shares the field's glyph motion.

All geometry is in logical framebuffer pixels; all byte offsets are UTF-8 boundaries into the bound buffer.

Macro Definition Documentation

◆ RMGUI_FIELD_CAPACITY_MAX

#define RMGUI_FIELD_CAPACITY_MAX   (UINT16_MAX - 1u)

Type-imposed byte ceiling (terminator excluded).

A field of N newline bytes owns N+1 rows; uint16_t row counts and the reserved caret-row sentinel therefore permit at most UINT16_MAX-1 bytes, regardless of caller storage.

◆ RMGUI_FIELD_VISIBLE_MAX

#define RMGUI_FIELD_VISIBLE_MAX   32

Most rows a field shows at once; a taller content box leaves the rows below this count empty and scrolls instead.

◆ RMGUI_FIELD_ROWS_CAP

#define RMGUI_FIELD_ROWS_CAP   (RMGUI_FIELD_VISIBLE_MAX + 4)

Rows a layout retains: the visible window, the row above it and a short lookahead that lets an edit's reflow stop as soon as the wrap converges.

◆ RMGUI_FIELD_ACTION_MAX

#define RMGUI_FIELD_ACTION_MAX   8

Most actions one field carries.

◆ RMGUI_FIELD_GLYPHS_WIPE_MS

#define RMGUI_FIELD_GLYPHS_WIPE_MS   200

Milliseconds an insertion takes to reveal under RMGUI_FIELD_GLYPHS_WIPE.

◆ RMGUI_FIELD_GLYPHS_LAND_MS

#define RMGUI_FIELD_GLYPHS_LAND_MS   180

Milliseconds an insertion takes to settle under RMGUI_FIELD_GLYPHS_LAND.

◆ RMGUI_FIELD_GLYPHS_ERASE_MS

#define RMGUI_FIELD_GLYPHS_ERASE_MS   140

Milliseconds a deletion's gap takes to close, in either mode.

◆ RMGUI_FIELD_GLYPHS_DURATION_MS

#define RMGUI_FIELD_GLYPHS_DURATION_MS   200

Milliseconds from an edit until its glyphs rest at their static paint in either mode: the longest of the three durations above.

◆ RMGUI_FIELD_GLYPHS_CAP

#define RMGUI_FIELD_GLYPHS_CAP   8

Edits animated at once; a further edit retires the oldest.

A deletion's ghost also retires the previous deletion's ghost, so at most one ghost animates at a time; insertions are retired by age and capacity only.

◆ RMGUI_FIELD_GLYPHS_GHOST_CAP

#define RMGUI_FIELD_GLYPHS_GHOST_CAP   32

Longest deletion, in bytes, whose glyphs are kept for the wipe-out; a longer deletion, or one removing a '&#92;n', vanishes at once.

Enumeration Type Documentation

◆ rmgui_field_command_t

Direct editing commands; shortcut CHAR keys use ASCII A/C/V/X/Y/Z with CTRL or META (SHIFT+Z redoes).

Letter case is ignored.

Enumerator
RMGUI_FIELD_COMMAND_COPY 
RMGUI_FIELD_COMMAND_CUT 
RMGUI_FIELD_COMMAND_PASTE 
RMGUI_FIELD_COMMAND_SELECT_ALL 
RMGUI_FIELD_COMMAND_UNDO 
RMGUI_FIELD_COMMAND_REDO 

◆ rmgui_field_caret_t

Caret visibility for one paint: the host owns the blink decision.

Enumerator
RMGUI_FIELD_CARET_HIDDEN 
RMGUI_FIELD_CARET_SHOWN 

◆ rmgui_field_slot_t

Which strip of the field an action button sits in: LEAD left of the text, TRAIL right of it.

Enumerator
RMGUI_FIELD_SLOT_LEAD 
RMGUI_FIELD_SLOT_TRAIL 

◆ rmgui_field_glyphs_mode_t

How rmgui_field_glyphs_paint shows an insertion.

A deletion is wiped out in either mode: the deleted glyphs stay drawn where they were, shrinking from the right while the text after them closes the gap.

Enumerator
RMGUI_FIELD_GLYPHS_WIPE 

inserted glyphs fade in behind a soft edge moving left to right

RMGUI_FIELD_GLYPHS_LAND 

inserted glyphs start larger and settle to size

Function Documentation

◆ rmgui_field_bind()

int rmgui_field_bind ( rmgui_field_t * self,
char * storage,
size_t capacity )

Bind host storage of capacity bytes plus one terminator byte and adopt its current NUL-terminated contents (scanned up to capacity); the caret lands at the end, no selection, view follows the caret, states cleared; hint, multiline, actions, host, history and scratch configuration are kept; history and preedit contents are cleared.

Returns 0, or -1 (self unchanged) when self or storage is NULL, capacity is 0 or above RMGUI_FIELD_CAPACITY_MAX, or the contents are not well-formed UTF-8.

◆ rmgui_field_adopt()

int rmgui_field_adopt ( rmgui_field_t * self,
const char * text,
size_t length )

Replace the whole text with length bytes of text (a program value, a restored draft).

Caret and anchor are clamped to the new text; changed bytes also unpin the view. Returns 0, or -1 (self unchanged) when self is unbound, text is NULL with length > 0, length exceeds the capacity, or the bytes contain NUL or are not well-formed UTF-8.

◆ rmgui_field_selection()

int rmgui_field_selection ( const rmgui_field_t * self,
size_t * start,
size_t * end )

0 with the ordered UTF-8 bounds of the selection in *start and *end (either may be NULL) when a non-empty span is selected; -1 otherwise (unbound, NULL self, or an empty selection), outputs untouched.

◆ rmgui_field_select_all()

void rmgui_field_select_all ( rmgui_field_t * self)

Select the whole text (anchor 0, caret at the end).

No-op when unbound.

◆ rmgui_field_insert()

size_t rmgui_field_insert ( rmgui_field_t * self,
const char * text,
size_t bytes )

Insert the longest well-formed, NUL-free UTF-8 prefix of text[0, bytes) that fits the capacity at the caret, replacing the selection: the host's edit (an action inserting a glyph, a paste), the same edit a TEXT event makes.

The caret lands after the inserted bytes and the view follows it; the layout re-wraps at its next rmgui_field_layout. Returns the bytes inserted: 0, field unchanged, when self is unbound, text is NULL or no byte of it fits.

◆ rmgui_field_command()

int rmgui_field_command ( rmgui_field_t * self,
rmgui_field_command_t command )

Apply a direct command; 0 on success, -1 on missing service/storage, empty undo/redo, invalid command, or clipboard refusal.

Refusal leaves the field unchanged. Paste is all-or-nothing and validates UTF-8. Copy/cut require a nonempty selection. Re-layout before painting after a successful command. Attached history and host records are borrowed; never allocated internally.

◆ rmgui_field_layout()

int rmgui_field_layout ( const rmgui_field_t * self,
const rmgui_field_metrics_t * metrics,
rmgui_rect_t content,
rmgui_field_layout_t * layout )

Bring layout up to date with self, metrics and the field's content box (its rect inset by rmgui_paint_face_inset for RMGUI_STYLE_CLASS_TEXT_FIELD).

When nothing changed, a field without actions returns without measuring. A caret or view change reuses wrapped rows; content-width, metrics or external text changes re-wrap the text. Actions: each existing action is a button one line_height high at the top of the content box, its label's width plus half a line height wide; LEAD buttons line up from the box's left edge, TRAIL buttons end at its right edge, and a quarter line height separates neighbouring buttons and each strip from the text column between them. An edit that adds or removes a needs_content action re-lays the strips and re-wraps. Rows wrap at the text column's width, or at that width minus the scale_percent-rounded scrollbar gutter when the text overflows the visible rows at full width; the text is never truncated. Returns 0, or -1 (layout unchanged) for NULL arguments, an unbound self, invalid metrics, an invalid action table, or a measurement the metrics' font refuses (a font holding no face). With text_options, bidi -> fallback -> shaper supplies every row, width and caret. Caller workspace must fit the whole text, every glyph and every row; selection storage must fit its complete visual union. Refusal leaves the output layout struct unchanged. Shaping may invalidate borrowed workspace on entry, including on refusal: check the return value and do not use a previously borrowed shaped result after a refused shaping attempt.

◆ rmgui_field_layout_invalidate()

void rmgui_field_layout_invalidate ( rmgui_field_layout_t * layout)

Discard the retained layout so the next rmgui_field_layout recomputes it, including wrapped rows and shaped runs.

Use this when a borrowed font or shaping options change in place without changing address. This does not change the field or its caller-owned storage and configuration. Re-layout before using the layout for measurement, input or drawing. NULL is a no-op.

◆ rmgui_field_measure()

rmgui_size_t rmgui_field_measure ( const rmgui_style_resolved_t * rs,
const rmgui_field_metrics_t * metrics,
const rmgui_field_t * self,
const rmgui_field_layout_t * layout )

Outer size: the TEXT_FIELD face inset on every side around one caret column plus every action of self (as laid out with a non-empty text) horizontally, and rows of line_height vertically: min(min_rows, RMGUI_FIELD_VISIBLE_MAX) rows, or with max_rows > 0 and layout current for self (rmgui_field_layout or rmgui_field_input since the last byte change) the rows the text wraps to at the layout's text column without a scrollbar gutter, clamped to [min_rows, min(max_rows, RMGUI_FIELD_VISIBLE_MAX)].

self and layout may be NULL (no actions, min_rows). {0,0} for a NULL rs or metrics, an invalid line_height, min_rows or max_rows, an invalid action table, or a measurement the font refuses.

◆ rmgui_field_paint()

void rmgui_field_paint ( rmgui_fb_t * fb,
rmgui_font_t * font,
const rmgui_style_resolved_t * rs,
rmgui_rect_t rect,
rmgui_rect_t clip,
const rmgui_field_t * self,
const rmgui_field_layout_t * layout,
rmgui_field_caret_t caret )

Paint the face and border of rect, then the visible rows in font, selection (inverted pixels), caret (when caret is SHOWN and the caret row is in view), scrollbar and action buttons from layout.

An empty text with a hint paints the hint on the first row in rs->text_placeholder. An action is outlined in the border colour with its label centred in the text colour, filled with the border colour while it is pressed with the pointer over it. Background, border, text/caret and placeholder colours come from rs (resolved for TEXT_FIELD and its state); text size comes from the layout's metrics. Nothing outside rect ∩ clip ∩ framebuffer is touched. When layout is not current for self, or font is not the font of the layout's metrics, only the face is painted. With text_options, explicitly call rmgui_text_shape_prepare_to(&layout->shaped, target) after layout/input and before painting; also prepare layout->shaped_aux when its length is nonzero (hint or preedit). Preparation may allocate the CPU raster cache; painting never does. Cache eviction requires preparation again. Shaped mode never substitutes legacy text drawing. Hint/preedit use auxiliary_text_options.

◆ rmgui_field_paint_to()

void rmgui_field_paint_to ( rmgui_target_t * ,
rmgui_font_t * ,
const rmgui_style_resolved_t * ,
rmgui_rect_t ,
rmgui_rect_t ,
const rmgui_field_t * ,
const rmgui_field_layout_t * ,
rmgui_field_caret_t  )

Explicit destination field paint.

Selection records ordered RGB inversion with alpha unchanged. Text must be prepared and skins immutable through submit/discard. No allocation; failures latch on the stream.

◆ rmgui_field_prepare()

int rmgui_field_prepare ( const rmgui_ui_t * ui,
const rmgui_field_t * field,
const rmgui_field_layout_t * layout )

Stage the current layout's display runs, including masked text, shaping, composition and action labels, before recording.

The bound field and caller-owned layout are borrowed; ui->font must match the layout font. A CPU target only needs preparation for shaped text. Returns 0 or -1 on error.

◆ rmgui_field_draw()

int rmgui_field_draw ( const rmgui_ui_t * ui,
const rmgui_field_t * field,
const rmgui_field_layout_t * layout,
rmgui_rect_t box,
rmgui_field_caret_t caret )

Draw a bound field using its current caller-owned layout and device-space text metrics.

The layout and box must share target coordinates, and the layout font must match ui->font. Caret timing is caller-owned. Returns -1 for invalid arguments or style, otherwise 0; check the target for errors.

◆ rmgui_field_input()

rmgui_input_result_t rmgui_field_input ( rmgui_field_t * self,
rmgui_field_layout_t * layout,
rmgui_rect_t rect,
const rmgui_input_t * in )

Apply one event to the field whose arranged rect is rect, keeping layout current (an edit re-wraps only the rows it affects).

TEXT: inserts the longest well-formed UTF-8 prefix without NUL that fits, replacing the selection -> CHANGE (value 0) when bytes changed. KEY SPACE inserts " "; BACKSPACE/DELETE remove the selection or one codepoint -> CHANGE when bytes changed; LEFT/RIGHT move one codepoint and HOME/END to the text edges, SHIFT extends the selection; ESCAPE drops the selection -> CANCEL. ENTER: SUBMIT in a one-line field; in a multiline field it inserts "&#92;n" -> CHANGE. UP/DOWN in a multiline field move the caret to the codepoint boundary nearest the kept column on the row above/below (the text start from the first row, its end from the last), SHIFT extending; a one-line field leaves them unconsumed. Other keys: consumed = 0. CTRL/ALT LEFT/RIGHT moves by words, SHIFT extending; CTRL/ALT BACKSPACE/DELETE removes that span. ALT HOME/END moves to the current newline-delimited paragraph edge; unmodified HOME/END retains text-edge motion. ASCII/Latin letters, digits and underscore form word runs; whitespace and punctuation form separate runs; CJK/other scripts are single-codepoint words. CHAR CTRL/META shortcuts invoke commands above. COMPOSITION: copy valid UTF-8 and byte-boundary cursor/selection into caller preedit storage; refuse invalid/oversized input unchanged. Paint it inline underlined on the caret row, clipped horizontally; committed wrap stays unchanged until TEXT. ESC/focus loss cancels it. Shaped fields require independent auxiliary_text_options workspace and preparation of shaped_aux; preedit cursor/selection remain logical bytes. Shaped LEFT/RIGHT follow text_options->caret_policy (AUTO visual in RTL), retain boundary affinity, and skip ligature interiors. UP/DOWN preserve the visual column; editing/accessibility offsets remain logical bytes. A primary double-click selects a word, triple-click a paragraph; shift-click keeps the selection anchor. host: request TEXT cursor over the enabled text region and report the current caret rectangle to the optional text_input_rect callback. POINTER_PRESS inside: on an action, presses it and captures (RELEASE inside the same action -> ACTION, value its index in the table; elsewhere it is dropped); otherwise places the caret (or drags the scrollbar) and captures; MOVE while captured extends the selection; RELEASE ends it. WHEEL inside: scrolls one row per notches_y, consumed only when it moved; notches_x is ignored. FOCUS_IN/FOCUS_OUT: set/clear FOCUSED. While DISABLED only HOVER, FOCUSED and wheel scrolling respond; an inside PRESS reports REFUSED (value 0, consumed 1, captured 0), others report NONE. NULL self/layout/in yields an all-zero result.

◆ rmgui_field_step()

int rmgui_field_step ( rmgui_field_t * self,
rmgui_field_layout_t * layout,
uint16_t dt_ms )

Advance a held scrollbar arrow by dt_ms (rmgui_scroll_step's countdown and catch-up), moving the window one row per repeat and keeping layout current.

A press on an arrow moves one row at once through rmgui_field_input; a host that wants hold-to-repeat calls this each frame while the field's capture is 2. Returns 1 when the window moved, otherwise 0 (also for NULL arguments, a stale layout, dt_ms 0 or no held arrow).

Glyph motion: a caller-owned record of a field's most recent edits that rmgui_field_glyphs_paint animates. Only edits made through rmgui_field_glyphs_input are recorded; the record describes the field exactly as that call left it, and any other change to the field's bytes (rmgui_field_adopt, rmgui_field_bind, rmgui_field_input) makes it stale: a stale record paints nothing extra and the next recording call discards it.

◆ rmgui_field_glyphs_input()

rmgui_input_result_t rmgui_field_glyphs_input ( rmgui_field_glyphs_t * glyphs,
rmgui_field_t * self,
rmgui_field_layout_t * layout,
rmgui_rect_t rect,
const rmgui_input_t * in )

rmgui_field_input, and when the event changed the field's bytes, record that edit in glyphs at age 0: the inserted bytes, and the deleted bytes when there are at most RMGUI_FIELD_GLYPHS_GHOST_CAP of them and none is '&#92;n' (a deletion joining rows vanishes at once).

A recorded ghost retires the record's earlier ghost. Recorded spans follow later recorded edits; an edit inside or across a span retires it. NULL glyphs, self, layout or in yields an all-zero result and changes nothing.

◆ rmgui_field_glyphs_step()

int rmgui_field_glyphs_step ( rmgui_field_glyphs_t * glyphs,
uint32_t dt_ms )

Age every recorded edit by dt_ms and retire insertions reaching RMGUI_FIELD_GLYPHS_DURATION_MS and deletions reaching RMGUI_FIELD_GLYPHS_ERASE_MS.

Steps compose: step(a) then step(b) leaves the record step(a + b) does. 1 when the record changed, 0 when nothing was animating or glyphs is NULL.

◆ rmgui_field_glyphs_is_moving()

int rmgui_field_glyphs_is_moving ( const rmgui_field_glyphs_t * glyphs)

1 while an edit is recorded (count > 0: a step still changes the record), else 0 (also for NULL).

◆ rmgui_field_glyphs_paint()

void rmgui_field_glyphs_paint ( rmgui_fb_t * fb,
rmgui_font_t * font,
const rmgui_style_resolved_t * rs,
rmgui_rect_t rect,
rmgui_rect_t clip,
const rmgui_field_t * self,
const rmgui_field_layout_t * layout,
rmgui_field_caret_t caret,
const rmgui_field_glyphs_t * glyphs,
rmgui_field_glyphs_mode_t mode )

rmgui_field_paint with the recorded edits animated in mode by their age.

Rows holding no animating glyph paint exactly as rmgui_field_paint; with nothing animating, or a stale or NULL glyphs, or a mode outside rmgui_field_glyphs_mode_t, every byte equals rmgui_field_paint's. On a row holding deleted glyphs, the text, selection and caret after them move right by the width those glyphs still occupy. The caret at their byte paints at their right edge when it stood after them before the deletion (BACKSPACE, or a selection deleted or replaced with the caret at its end), else left of them. Nothing outside rect ∩ clip ∩ framebuffer is touched. With text_options the same static shaped text, selection and caret are painted regardless of glyph records/mode: motion is reduced deliberately, never mixing legacy glyph records with shaped clusters.

Animated label: the glyph motion above for text a host paints without a field. The host reports each change of the label's text to rmgui_label_glyphs_note, steps the record with its clock, and paints the label through rmgui_label_glyphs_paint, which animates the recorded edits as rmgui_field_glyphs_paint does (same modes, durations and bounds) while every glyph, moving or deleted, keeps the colour of its styled run.

◆ rmgui_label_glyphs_note()

int rmgui_label_glyphs_note ( rmgui_label_glyphs_t * glyphs,
const rmgui_label_text_t * before,
const rmgui_label_text_t * after )

Record the change of a label's text from before to after at age 0, as the one replacement between their longest common prefix and, after it, their longest common suffix, both ending on codepoint boundaries.

The edit is recorded as rmgui_field_glyphs_input records a field's: inserted bytes animate, deleted bytes keep their glyphs (at most RMGUI_FIELD_GLYPHS_GHOST_CAP bytes, none '&#92;n') in the colours before gave them and retire the record's earlier ghost, recorded spans follow the edit or retire when it reaches into them, and a full record retires its oldest edit. A record whose length is not before->length is discarded first; texts with equal bytes record nothing. before and after may share storage while before's bytes are unchanged (an in-place append). 0; -1, record unchanged, when glyphs is NULL or either text breaks rmgui_label_text_t's pointer contract.

◆ rmgui_label_glyphs_step()

int rmgui_label_glyphs_step ( rmgui_label_glyphs_t * glyphs,
uint32_t dt_ms )

rmgui_field_glyphs_step for a label's record: ages every edit by dt_ms, with the same retirement and the same composition (step(a) then step(b) leaves the record step(a + b) does).

1 when the record changed, 0 when nothing was animating, dt_ms is 0 or glyphs is NULL.

◆ rmgui_label_glyphs_is_moving()

int rmgui_label_glyphs_is_moving ( const rmgui_label_glyphs_t * glyphs)

1 while an edit is recorded (count > 0), else 0 (also for NULL).

◆ rmgui_label_glyphs_paint()

void rmgui_label_glyphs_paint ( rmgui_fb_t * fb,
rmgui_font_t * font,
rmgui_rect_t rect,
rmgui_rect_t clip,
int font_px,
int wrap_w,
const rmgui_label_text_t * label,
const rmgui_label_glyphs_t * glyphs,
rmgui_field_glyphs_mode_t mode )

Paint label at font_px with its first line box's top-left at (rect.x, rect.y), writing only pixels inside rect ∩ clip.

Rows are broken as rmgui_paint_paragraph breaks them at flow width wrap_w (0: rows end only at newlines), one rmgui_font_line_height(font_px) apart; rows below rect ∩ clip are not broken. Each row draws every longest span of one colour at rect.x plus the width of the row's bytes before it. That is the static paint, which every row holding no recorded edit shows, and every row shows with a NULL or zeroed glyphs, a record whose length is not label->length, or a mode outside rmgui_field_glyphs_mode_t: for a label of one colour it equals, byte for byte, rmgui_paint_paragraph of a TEXT node with this rect and clip, text_x rect.x, text_y rect.y and flow_w wrap_w. A row holding recorded edits animates them in mode by their age as rmgui_field_glyphs_paint does, each glyph in the colour of its run and each deleted glyph in the colour it was recorded with. NULL fb or font, font_px < 1 or a label breaking rmgui_label_text_t's pointer contract paints nothing.

◆ rmgui_field_glyphs_paint_to()

Explicit destination animated field paint, including ordered RGB inversion.

Prepare every drawn size, hint, action and ghost glyph before RECORD.

◆ rmgui_label_glyphs_paint_to()

void rmgui_label_glyphs_paint_to ( rmgui_target_t * ,
rmgui_font_t * ,
rmgui_rect_t ,
rmgui_rect_t ,
int ,
int ,
const rmgui_label_text_t * ,
const rmgui_label_glyphs_t * ,
rmgui_field_glyphs_mode_t  )

Explicit destination label animation.

Prepare current/ghost glyphs at every emitted size before RECORD; no allocation and stream failures latch.