Expand description
Multi-field input form with a stable two-column layout.
Two entry points:
-
High-level: build a
FormStatefrom a list ofFormField, route keys throughFormState::handle_key, and render withrender_form. Suitable for self-contained settings/wizard-style screens. -
Low-level primitives:
label_prefix,input_row,select_row,error_lines. Use these when you want the same visual style but manage focus/buffer state yourself (e.g. ygg’s blueprint detail panel, which stores its form values inside a snapshot-backed buffer).
§Visual language
label value← row, inactivelabel [ lhs│rhs ]← row, active, software caretlabel ◀ option ▶← row, active, enum / bool cyclelabel * value← row with validation error (red*)└ message wrapped over…← per-row error, red italic…more text← continuation, aligned under message
The │ caret is drawn in-band (software cursor). Hide the terminal’s
hardware cursor (Frame::set_cursor_position omitted) so only one caret
is visible.
Structs§
- Form
Field - One row in a form.
- Form
State - Form state: fields + focus + per-field cursor + touched set.
- Form
Style - Styling knobs for
render_form.
Enums§
- Field
Input - The interactive value held by a
FormField. - Form
Event - Outcome of routing a key through
FormState::handle_key.
Functions§
- error_
lines - Render a per-row inline error message, wrapped to
max_width. The first line is prefixed with└, continuations with two spaces so the message text stays aligned. Indented byindentcolumns so it sits under the row’s label. - input_
row - Render a text-input row.
- label_
prefix - Build the label-column spans for a row. Output:
" <label><*|space><filler>"— two-space left indent, label, then a red bold*iferroris true (else a space), padded so all values line up at columnindent + 2 + pad + 2. - render_
form - Render a form inside
area, applying the default styling. - render_
form_ with - Render a form with explicit style options and per-field errors.
- select_
row - Render a select-style row: when active, the value is framed with
◀ … ▶cycle glyphs. When inactive, it renders plain. - wrap_
chars - Word-wrap
sinto chunks of at mostwidthchars each. Breaks on whitespace; hard-breaks words longer thanwidth.