class
TUI::InputField
- TUI::InputField
- TUI::FormField
- Reference
- Object
Overview
Single-line text field. Wire format is the raw text itself (see
#value/#start) — no newline handling of any kind, unlike
ScrollableField (src/tui/form/scrollable_field.cr), which is where
multi-line free-text editing now lives. Esc and Enter both commit —
there's no discard-in-place gesture (per FormField's stated Esc
convention) and, being single-line, there's nowhere sensible for
Enter to put a newline anyway.
Owns its own cursor/scroll state (@col, @col_offset) because
Runtime hides the native terminal cursor for the app's whole
lifetime — see #render for how the cursor is instead drawn as a
reverse-video cell.
Defined in:
tui/form/input_field.crConstructors
Instance Method Summary
-
#cursor_offset : NamedTuple(row: Int32, col: Int32)
Local column offset from the
xorigin passed to#render, where the native terminal cursor should be placed while this field is being edited. -
#handle_key(ev : KeyEvent) : Symbol | Nil
Returns :commit or :cancel once the edit finishes; nil while it's still in progress (the key was consumed either way).
-
#render(buffer : Buffer, y : Int32, x : Int32, width : Int32, height : Int32 = 1, focused : Bool = true) : Nil
Draws this field's current edit state.
-
#start(current_value : String) : Nil
Loads a persisted wire-value string into this field's edit state.
-
#status_hint : String
Fragment of a host's status-bar hint describing this field's own key bindings while it's being edited — owned here (rather than left for a host to re-derive per kind) so the bindings shown to the user can never drift from what #handle_key actually does.
-
#value : String
The composed value after a :commit result.
Instance methods inherited from class TUI::FormField
handle_key(ev : KeyEvent) : Symbol | Nil
handle_key,
render(buffer : Buffer, y : Int32, x : Int32, width : Int32, height : Int32 = 1, focused : Bool = true) : Nil
render,
start(current_value : String) : Nil
start,
status_hint : String
status_hint,
value : String
value
Constructor Detail
Instance Method Detail
Local column offset from the x origin passed to #render, where
the native terminal cursor should be placed while this field is
being edited.
Returns :commit or :cancel once the edit finishes; nil while it's still in progress (the key was consumed either way).
Draws this field's current edit state. height bounds how many
buffer rows this field may draw into. focused gates any
keyboard-cursor decoration that should be suppressed when
rendering a persisted value outside an active edit session (only
FlagsField uses this — see its #render).
Loads a persisted wire-value string into this field's edit state.
Fragment of a host's status-bar hint describing this field's own key bindings while it's being edited — owned here (rather than left for a host to re-derive per kind) so the bindings shown to the user can never drift from what #handle_key actually does.
The composed value after a :commit result.