class
TUI::FlagsField
- TUI::FlagsField
- TUI::FormField
- Reference
- Object
Overview
Multi-select from a fixed Array(FormEnumOption), tracked by a
Set(Int32) of selected indices kept independent from
@focus_index — unlike EnumField, where focus is the selection.
Wire format is a decimal string of a bitmask, bit i set meaning
option i is selected; #value composes that bitmask and
#decode_flags (called from #start) parses it back. Up/Down move
focus; Space toggles the focused option in/out of @selected; Enter
commits; Esc cancels without writing back, per FormField's stated
rationale that a picker with nothing chosen yet has no sensible
commit value.
Defined in:
tui/form/flags_field.crConstructors
Instance Method Summary
-
#cursor_style : Style
Applied to the focused checkbox row (see #render).
-
#cursor_style=(cursor_style : Style)
Applied to the focused checkbox row (see #render).
-
#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
focusedgates the reverse-video keyboard-cursor row — pass false when drawing a field's persisted state outside an active edit session, so an always-visible option list doesn't show a stray highlight on whichever row @focus_index happens to default to (0, from #initialize, unrelated to @selected). -
#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
Applied to the focused checkbox row (see #render).
Returns :commit or :cancel once the edit finishes; nil while it's still in progress (the key was consumed either way).
focused gates the reverse-video keyboard-cursor row — pass false
when drawing a field's persisted state outside an active edit
session, so an always-visible option list doesn't show a stray
highlight on whichever row @focus_index happens to default to (0,
from #initialize, unrelated to @selected).
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.