class TUI::BoolField

Overview

Two-state toggle, rendered as ◉ yes ○ no / ○ yes ◉ no. Wire format is the literal string "true" or "false" (see #value/#start). Left/Right and Space are equivalent ways to flip @bool_pending; Enter and Esc both commit — there's no cancel path, matching FormField's stated rationale that a bool edit has no sensible discard-in-place gesture.

Defined in:

tui/form/bool_field.cr

Constructors

Instance Method Summary

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

def self.new #

[View source]

Instance Method Detail

def handle_key(ev : KeyEvent) : Symbol | Nil #
Description copied from class TUI::FormField

Returns :commit or :cancel once the edit finishes; nil while it's still in progress (the key was consumed either way).


[View source]
def render(buffer : Buffer, y : Int32, x : Int32, width : Int32, height : Int32 = 1, focused : Bool = true) : Nil #
Description copied from class TUI::FormField

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).


[View source]
def start(current_value : String) : Nil #
Description copied from class TUI::FormField

Loads a persisted wire-value string into this field's edit state.


[View source]
def status_hint : String #
Description copied from class TUI::FormField

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.


[View source]
def value : String #
Description copied from class TUI::FormField

The composed value after a :commit result.


[View source]