Documentation
¶
Overview ¶
Package field is one editable settings row: a label plus either free text (KindText, wrapping bubbles/textinput) or a cycled value from a closed set (KindChoice, no textinput at all - so an invalid value is unreachable, not merely rejected). This is the only editing primitive the settings screen has; there is no separate multi-field form type until a second section needs one.
Index ¶
- type Kind
- type Model
- func (m *Model) Blur()
- func (m *Model) Cycle(delta int)
- func (m *Model) Focus() tea.Cmd
- func (m Model) Focused() bool
- func (m *Model) SetChoices(choices []string, active string)
- func (m *Model) SetTheme(t theme.Theme, tier theme.Tier)
- func (m *Model) SetValidate(f func(string) error)
- func (m *Model) SetValue(v string)
- func (m *Model) SetWidth(w int)
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) Validate() error
- func (m Model) Value() string
- func (m Model) View() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
Model is one field. Theme/Tier are exported like picker.Model's own fields; SetTheme exists anyway (not a bare assignment) because KindText's embedded textinput carries hard-coded styles bubbles ships with, and forgetting to restyle it is exactly the composer.go:79-96 bug this package must not repeat.
func New ¶
New builds a field. width is the full row width available for the value; KindText clamps its input to it, KindChoice ignores it (a single value never wraps).
func (*Model) Cycle ¶
Cycle moves a KindChoice field to the next (delta>0) or previous (delta<0) value, wrapping. A no-op on KindText.
func (*Model) Focus ¶
Focus arms the field for input. KindText forwards to textinput's own Focus (which returns the cursor-blink Cmd); KindChoice has nothing to focus beyond the marker its owner draws.
func (*Model) SetChoices ¶
SetChoices sets a KindChoice field's closed value set and starts the cursor on active (or the first choice if active matches none).
func (*Model) SetTheme ¶
SetTheme restyles the field, including KindText's embedded textinput - see the package doc for why this cannot be a bare field assignment.
func (*Model) SetValidate ¶
SetValidate injects the field's validation rule. A KindEnvName-style variant is not a separate Kind: the POSIX env-var check, the positive-int check, and every other rule this screen needs are a few lines each, injected here.
func (Model) Update ¶
Update forwards a key to the embedded textinput while a KindText field is focused. KindChoice never reaches here: its owner drives Cycle directly, since there is no free-text buffer to route keys into.
func (Model) Validate ¶
Validate runs the injected rule against the current value. A field with no injected rule is always valid.