Documentation
¶
Index ¶
- func AllBindings() []key.Binding
- func ConnectionIndicator(connected bool) string
- func CounterIndicator(label string, current, total int) string
- func HelpBinding(keys, desc string) string
- func IsDown(msg tea.KeyMsg) bool
- func IsEnter(msg tea.KeyMsg) bool
- func IsEscape(msg tea.KeyMsg) bool
- func IsHelp(msg tea.KeyMsg) bool
- func IsLeft(msg tea.KeyMsg) bool
- func IsQuit(msg tea.KeyMsg) bool
- func IsRight(msg tea.KeyMsg) bool
- func IsTab(msg tea.KeyMsg) bool
- func IsUp(msg tea.KeyMsg) bool
- func ModeIndicator(mode string, active bool) string
- func NavigationBindings() []key.Binding
- func QuickHelp(pairs ...string) string
- func QuitBindings() []key.Binding
- func RenderBadge(text string, render ...func(string) string) string
- func RenderBytes(bytes int64) string
- func RenderCountBadge(count int, label string) string
- func RenderDashHeader(cs *iostreams.ColorScheme, cfg DashHeaderConfig) string
- func RenderDetailPanel(title string, pairs []KeyValuePair, width int) string
- func RenderDivider(width int) string
- func RenderEmptyState(message string, width, height int) string
- func RenderError(err error, width int) string
- func RenderHeader(cfg HeaderConfig) string
- func RenderHelpBar(bindings []key.Binding, width int) string
- func RenderHelpGrid(bindings []key.Binding, columns, width int) string
- func RenderInfoPanel(title, content string, width int) string
- func RenderKeyValueTable(pairs []KeyValuePair, width int) string
- func RenderLabelValue(label, value string) string
- func RenderLabeledDivider(label string, width int) string
- func RenderLeftLabeledDivider(label string, width int) string
- func RenderPercentage(value float64) string
- func RenderProgress(cfg ProgressConfig) string
- func RenderScrollablePanel(title string, lines []string, offset, visibleLines, width int) string
- func RenderStatus(cfg StatusConfig) string
- func RenderStatusBar(left, center, right string, width int) string
- func RenderStatusBarWithSections(sections []StatusBarSection, width int) string
- func RenderStepperBar(steps []Step, width int) string
- func RenderTable(cfg TableConfig) string
- func RenderTag(text string, render ...func(string) string) string
- func RenderTags(tags []string, render ...func(string) string) string
- func RunProgram(ios *iostreams.IOStreams, model tea.Model, opts ...ProgramOption) (tea.Model, error)
- func TimerIndicator(label string, value string) string
- type BrowserConfig
- type BrowserField
- type BrowserFieldKind
- type BrowserLayer
- type BrowserLayerTarget
- type BrowserPageOption
- type BrowserResult
- type CancelledPage
- type ConfirmField
- func (f ConfirmField) BoolValue() bool
- func (f ConfirmField) Init() tea.Cmd
- func (f ConfirmField) IsConfirmed() bool
- func (f ConfirmField) SetSize(w, h int) ConfirmField
- func (f ConfirmField) Update(msg tea.Msg) (ConfirmField, tea.Cmd)
- func (f ConfirmField) Value() string
- func (f ConfirmField) View() string
- type DashHeaderConfig
- type DashboardConfig
- type DashboardRenderer
- type DashboardResult
- type EscapeHandler
- type FieldBrowserModel
- type FieldEditor
- type FieldOption
- type FormEditorModel
- type HeaderConfig
- type HelpConfig
- type HelpModel
- func (m HelpModel) Bindings() []key.Binding
- func (m HelpModel) FullHelp() string
- func (m HelpModel) SetBindings(bindings []key.Binding) HelpModel
- func (m HelpModel) SetSeparator(sep string) HelpModel
- func (m HelpModel) SetShowAll(showAll bool) HelpModel
- func (m HelpModel) SetWidth(width int) HelpModel
- func (m HelpModel) ShortHelp() string
- func (m HelpModel) View() string
- type HookResult
- type ItemListEditorModel
- func (m ItemListEditorModel) Err() string
- func (m ItemListEditorModel) Init() tea.Cmd
- func (m ItemListEditorModel) IsCancelled() bool
- func (m ItemListEditorModel) IsConfirmed() bool
- func (m ItemListEditorModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m ItemListEditorModel) Value() string
- func (m ItemListEditorModel) View() string
- type KVEditorModel
- type KVEditorOption
- type KeyMap
- type KeyValuePair
- type LifecycleHook
- type ListConfig
- type ListEditorModel
- func (m ListEditorModel) Err() string
- func (m ListEditorModel) Init() tea.Cmd
- func (m ListEditorModel) IsCancelled() bool
- func (m ListEditorModel) IsConfirmed() bool
- func (m ListEditorModel) Update(msg tea.Msg) (ListEditorModel, tea.Cmd)
- func (m ListEditorModel) Value() string
- func (m ListEditorModel) View() string
- type ListEditorOption
- type ListItem
- type ListModel
- func (m ListModel) IsEmpty() bool
- func (m ListModel) Items() []ListItem
- func (m ListModel) Len() int
- func (m ListModel) PageDown() ListModel
- func (m ListModel) PageUp() ListModel
- func (m ListModel) Select(index int) ListModel
- func (m ListModel) SelectFirst() ListModel
- func (m ListModel) SelectLast() ListModel
- func (m ListModel) SelectNext() ListModel
- func (m ListModel) SelectPrev() ListModel
- func (m ListModel) SelectedIndex() int
- func (m ListModel) SelectedItem() ListItem
- func (m ListModel) SetHeight(height int) ListModel
- func (m ListModel) SetItems(items []ListItem) ListModel
- func (m ListModel) SetShowDescriptions(show bool) ListModel
- func (m ListModel) SetWidth(width int) ListModel
- func (m ListModel) SetWrap(wrap bool) ListModel
- func (m ListModel) Update(msg tea.Msg) (ListModel, tea.Cmd)
- func (m ListModel) View() string
- type PanelConfig
- type PanelGroup
- func (g PanelGroup) Add(panel PanelModel) PanelGroup
- func (g PanelGroup) Focus(index int) PanelGroup
- func (g PanelGroup) FocusNext() PanelGroup
- func (g PanelGroup) FocusPrev() PanelGroup
- func (g PanelGroup) FocusedIndex() int
- func (g PanelGroup) FocusedPanel() PanelModel
- func (g PanelGroup) Panels() []PanelModel
- func (g PanelGroup) RenderHorizontal(gap int) string
- func (g PanelGroup) RenderVertical(gap int) string
- type PanelModel
- func (p PanelModel) Content() string
- func (p PanelModel) Height() int
- func (p PanelModel) IsFocused() bool
- func (p PanelModel) SetContent(content string) PanelModel
- func (p PanelModel) SetFocused(focused bool) PanelModel
- func (p PanelModel) SetHeight(height int) PanelModel
- func (p PanelModel) SetPadding(padding int) PanelModel
- func (p PanelModel) SetTitle(title string) PanelModel
- func (p PanelModel) SetWidth(width int) PanelModel
- func (p PanelModel) Title() string
- func (p PanelModel) View() string
- func (p PanelModel) Width() int
- type ProgramOption
- type ProgressConfig
- type ProgressDisplayConfig
- type ProgressResult
- type ProgressStep
- type ProgressStepStatus
- type Resetter
- type SelectField
- func (f SelectField) Init() tea.Cmd
- func (f SelectField) IsConfirmed() bool
- func (f SelectField) SelectedIndex() int
- func (f SelectField) SetSize(w, h int) SelectField
- func (f SelectField) Update(msg tea.Msg) (SelectField, tea.Cmd)
- func (f SelectField) Value() string
- func (f SelectField) View() string
- type SimpleListItem
- type SpinnerModel
- type SpinnerTickMsg
- type SpinnerType
- type StatusBarModel
- func (m StatusBarModel) Center() string
- func (m StatusBarModel) Left() string
- func (m StatusBarModel) Right() string
- func (m StatusBarModel) SetCenter(s string) StatusBarModel
- func (m StatusBarModel) SetLeft(s string) StatusBarModel
- func (m StatusBarModel) SetRight(s string) StatusBarModel
- func (m StatusBarModel) SetWidth(width int) StatusBarModel
- func (m StatusBarModel) View() string
- func (m StatusBarModel) Width() int
- type StatusBarSection
- type StatusConfig
- type Step
- type StepState
- type StructFieldDef
- type TUI
- func (t *TUI) IOStreams() *iostreams.IOStreams
- func (t *TUI) NewTable(headers ...string) *TablePrinter
- func (t *TUI) RegisterHooks(hooks ...LifecycleHook)
- func (t *TUI) RunProgress(mode string, cfg ProgressDisplayConfig, ch <-chan ProgressStep) ProgressResult
- func (t *TUI) RunWizard(steps []WizardStep) (WizardResult, error)
- type TableConfig
- type TablePrinter
- func (tp *TablePrinter) AddRow(cols ...string)
- func (tp *TablePrinter) Len() int
- func (tp *TablePrinter) Render() error
- func (tp *TablePrinter) WithCellStyle(fn func(string) string) *TablePrinter
- func (tp *TablePrinter) WithHeaderStyle(fn func(string) string) *TablePrinter
- func (tp *TablePrinter) WithPrimaryStyle(fn func(string) string) *TablePrinter
- type TextField
- type TextFieldOption
- type TextareaEditorModel
- func (m TextareaEditorModel) Err() string
- func (m TextareaEditorModel) Init() tea.Cmd
- func (m TextareaEditorModel) IsCancelled() bool
- func (m TextareaEditorModel) IsConfirmed() bool
- func (m TextareaEditorModel) Update(msg tea.Msg) (TextareaEditorModel, tea.Cmd)
- func (m TextareaEditorModel) Value() string
- func (m TextareaEditorModel) View() string
- type TextareaEditorOption
- type ViewportConfig
- type ViewportModel
- func (v ViewportModel) AtBottom() bool
- func (v ViewportModel) AtTop() bool
- func (v ViewportModel) Height() int
- func (v ViewportModel) Init() tea.Cmd
- func (v ViewportModel) ScrollPercent() float64
- func (v ViewportModel) ScrollToBottom() ViewportModel
- func (v ViewportModel) ScrollToTop() ViewportModel
- func (v ViewportModel) SetContent(s string) ViewportModel
- func (v ViewportModel) SetSize(width, height int) ViewportModel
- func (v ViewportModel) SetTitle(title string) ViewportModel
- func (v ViewportModel) Title() string
- func (v ViewportModel) Update(msg tea.Msg) (ViewportModel, tea.Cmd)
- func (v ViewportModel) View() string
- func (v ViewportModel) Width() int
- type WizardPage
- func NewBrowserPage(browser *FieldBrowserModel, opts ...BrowserPageOption) WizardPage
- func NewConfirmPage(id, prompt string, defaultYes bool) WizardPage
- func NewSelectPage(id, prompt string, options []FieldOption, defaultIdx int) WizardPage
- func NewTextPage(id, prompt string, opts ...TextFieldOption) WizardPage
- type WizardResult
- type WizardStep
- type WizardValues
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectionIndicator ¶
ConnectionIndicator creates a connection status indicator.
func CounterIndicator ¶
CounterIndicator creates a counter display for the status bar.
func HelpBinding ¶
HelpBinding creates a single help binding display.
func ModeIndicator ¶
ModeIndicator creates a styled mode indicator for the status bar.
func NavigationBindings ¶
NavigationBindings returns common navigation key bindings.
func QuitBindings ¶
QuitBindings returns quit-related key bindings.
func RenderBadge ¶
RenderBadge renders text as a styled badge. If no render function is provided, uses BadgeStyle.
func RenderBytes ¶
RenderBytes renders a byte count in human-readable format.
func RenderCountBadge ¶
RenderCountBadge renders a count with a label, like "3 tasks".
func RenderDashHeader ¶ added in v0.5.0
func RenderDashHeader(cs *iostreams.ColorScheme, cfg DashHeaderConfig) string
RenderDashHeader renders a full-width dashboard header bar:
━━ Title ━━━━━━━━━━━━━━━━━━━━ subtitle ━━
Title is bold+primary, fill and subtitle are muted.
func RenderDetailPanel ¶
func RenderDetailPanel(title string, pairs []KeyValuePair, width int) string
RenderDetailPanel renders a panel with key-value pairs.
func RenderDivider ¶
RenderDivider renders a horizontal divider line.
func RenderEmptyState ¶
RenderEmptyState renders a centered empty state message.
func RenderError ¶
RenderError renders an error message.
func RenderHeader ¶
func RenderHeader(cfg HeaderConfig) string
RenderHeader renders a header with title, optional subtitle, and timestamp.
func RenderHelpBar ¶
RenderHelpBar renders a help bar with the given bindings.
func RenderHelpGrid ¶
RenderHelpGrid renders bindings in a grid layout.
func RenderInfoPanel ¶
RenderInfoPanel renders a simple info panel with title and content.
func RenderKeyValueTable ¶
func RenderKeyValueTable(pairs []KeyValuePair, width int) string
RenderKeyValueTable renders a table of key-value pairs.
func RenderLabelValue ¶
RenderLabelValue renders a label-value pair.
func RenderLabeledDivider ¶
RenderLabeledDivider renders a divider with a centered label.
func RenderLeftLabeledDivider ¶ added in v0.6.0
RenderLeftLabeledDivider renders a divider with a left-aligned label followed by a trailing rule.
func RenderPercentage ¶
RenderPercentage renders a percentage value with appropriate styling.
func RenderProgress ¶
func RenderProgress(cfg ProgressConfig) string
RenderProgress renders a progress indicator. If ShowBar is true, renders a progress bar. Otherwise renders "current/total".
func RenderScrollablePanel ¶
RenderScrollablePanel renders a panel that shows scrollable content.
func RenderStatus ¶
func RenderStatus(cfg StatusConfig) string
RenderStatus renders a status indicator like "● RUNNING". Delegates to iostreams.StatusIndicator for style and symbol selection.
func RenderStatusBar ¶
RenderStatusBar is a convenience function that renders a status bar.
func RenderStatusBarWithSections ¶
func RenderStatusBarWithSections(sections []StatusBarSection, width int) string
RenderStatusBarWithSections renders a status bar with styled sections.
func RenderStepperBar ¶
RenderStepperBar renders a horizontal step indicator.
Completed steps show a checkmark icon with their title and optional value. Active steps show a filled circle icon with their title. Pending steps show an empty circle icon with their title. Skipped steps are hidden entirely.
Example output:
✓ Build Image: Yes → ◉ Flavor → ○ Submit
func RenderTag ¶
RenderTag renders a tag-like element. If no render function is provided, uses TagStyle.
func RenderTags ¶
RenderTags renders multiple tags inline. If no render function is provided, uses TagStyle.
func RunProgram ¶
func RunProgram(ios *iostreams.IOStreams, model tea.Model, opts ...ProgramOption) (tea.Model, error)
RunProgram creates and runs a BubbleTea program with the given IOStreams. It returns the final model state after the program exits.
func TimerIndicator ¶
TimerIndicator creates a timer display for the status bar.
Types ¶
type BrowserConfig ¶ added in v0.6.0
type BrowserConfig struct {
Title string // Title displayed at the top
Fields []BrowserField // Fields to display
LayerTargets []BrowserLayerTarget // Per-field save destinations (Local, User, etc.)
Layers []BrowserLayer // Discovered layers for per-field provenance display
// OnFieldSaved is called when the user saves a single field to a layer.
// fieldPath is the dotted path, value is the new string value,
// targetIdx is the index into LayerTargets. Return error to show to user.
OnFieldSaved func(fieldPath, value string, targetIdx int) error
// OnFieldDeleted is called when the user deletes a field from a layer.
// fieldPath is the dotted path, targetIdx is the index into LayerTargets.
// Deletion removes the key from the target YAML file entirely, letting
// lower-priority layers show through. Return error to show to user.
OnFieldDeleted func(fieldPath string, targetIdx int) error
// OnRefresh is called after a successful save or delete to get fresh
// field values and layer data from the store. The TUI replaces its
// displayed state with the returned data, ensuring the winning values
// and layer breakdowns are always accurate. If nil, the field and
// layer displays are not refreshed.
OnRefresh func() (fields []BrowserField, layers []BrowserLayer)
}
BrowserConfig configures the field browser.
type BrowserField ¶ added in v0.6.0
type BrowserField struct {
Path string // Dotted path used as key (e.g. "build.image")
Label string // Human-readable label
Description string // Help text
Kind BrowserFieldKind // Widget type for editing
Value string // Formatted current value (compact summary for browse display)
EditValue string // Full value for editor pre-population (YAML for Map/StructSlice)
Default string // Shown when Value is empty or "<unset>"
Source string // Where this value came from (e.g. "~/.config/clawker/clawker.yaml")
Options []string // For Select fields
// Validator is called with the editor's Value() before confirming.
// The string format depends on Kind: comma-separated for StringSlice,
// YAML for Map/StructSlice, raw text for Text, Go literal for Int/Duration.
Validator func(string) error
Required bool // Whether the field must have a value
ReadOnly bool // Whether the field is not editable
Order int // Sort order (lower = first)
// Editor is a custom editor factory. When non-nil, the field browser uses
// it instead of the default kind-based dispatch. The returned value must
// satisfy [FieldEditor]. Domain adapters provide this via overrides.
Editor func(label, value string) any
}
BrowserField represents a single field in the field browser.
type BrowserFieldKind ¶ added in v0.6.0
type BrowserFieldKind int
BrowserFieldKind identifies how a field should be edited.
const ( BrowserText BrowserFieldKind = iota // Single-line text input BrowserBool // true/false select BrowserTriState // Deprecated: mapped to BrowserBool. Retained for iota stability. BrowserSelect // Bounded enum with Options BrowserInt // Integer text input BrowserStringSlice // List editor (comma-separated) BrowserDuration // Duration text input BrowserMap // Key-value map editor (default: KVEditorModel) BrowserStructSlice // Struct slice editor (default: YAML textarea) )
type BrowserLayer ¶ added in v0.6.0
type BrowserLayer struct {
Label string // Human-readable label (e.g. "~/.config/clawker/clawker.yaml")
Data map[string]any // Raw YAML data from this layer
}
BrowserLayer represents a discovered configuration layer with its raw data. Used to show per-layer value breakdowns for the selected field.
type BrowserLayerTarget ¶ added in v0.6.0
type BrowserLayerTarget struct {
Label string // "Original", "Local", "User"
Description string // Shortened path for display
}
BrowserLayerTarget represents a save destination for a single field.
type BrowserPageOption ¶ added in v0.6.0
type BrowserPageOption func(*browserPage)
BrowserPageOption configures a browserPage.
func WithCancelKey ¶ added in v0.6.0
func WithCancelKey(key string) BrowserPageOption
WithCancelKey sets the key that cancels out of the browser page. The wizard will treat this as a full cancellation. Only checked when the browser is in its base (browse) state.
func WithDoneKey ¶ added in v0.6.0
func WithDoneKey(key string) BrowserPageOption
WithDoneKey sets the key that completes the browser page and advances the wizard. Only checked when the browser is in its base (browse) state.
type BrowserResult ¶ added in v0.6.0
type BrowserResult struct {
Saved bool // True if any field was persisted
Cancelled bool // True if the user cancelled
SavedCount int // Number of fields successfully saved
}
BrowserResult holds the outcome of a field browser session.
type CancelledPage ¶ added in v0.6.0
type CancelledPage interface {
IsCancelled() bool
}
CancelledPage is an optional interface for pages that can signal cancellation (e.g. a browser page with a configured cancel key). When IsCancelled returns true, the wizard treats it as a full cancel.
type ConfirmField ¶
ConfirmField is a standalone BubbleTea model for yes/no confirmation.
func NewConfirmField ¶
func NewConfirmField(id, prompt string, defaultYes bool) ConfirmField
NewConfirmField creates a new ConfirmField with the given default value.
func (ConfirmField) BoolValue ¶
func (f ConfirmField) BoolValue() bool
BoolValue returns the boolean value of the toggle.
func (ConfirmField) Init ¶
func (f ConfirmField) Init() tea.Cmd
Init returns nil — no initial command is needed.
func (ConfirmField) IsConfirmed ¶
func (f ConfirmField) IsConfirmed() bool
IsConfirmed returns true if the user has confirmed their choice.
func (ConfirmField) SetSize ¶
func (f ConfirmField) SetSize(w, h int) ConfirmField
SetSize satisfies the wizard's updateAllFieldSizes contract. ConfirmField renders at a fixed layout, so width/height are unused.
func (ConfirmField) Update ¶
func (f ConfirmField) Update(msg tea.Msg) (ConfirmField, tea.Cmd)
Update handles key messages. Left/Right/Tab toggle the value. Enter confirms. 'y' sets true, 'n' sets false.
func (ConfirmField) Value ¶
func (f ConfirmField) Value() string
Value returns "yes" or "no" based on the current toggle state.
func (ConfirmField) View ¶
func (f ConfirmField) View() string
View renders the confirm field with prompt and [ Yes ] / [ No ] toggle.
type DashHeaderConfig ¶ added in v0.5.0
type DashHeaderConfig struct {
Title string // e.g., "Firewall Bypass"
Subtitle string // e.g., agent name — rendered muted on the right
Width int
}
DashHeaderConfig configures a full-width dashboard header bar.
type DashboardConfig ¶ added in v0.1.4
type DashboardConfig struct {
HelpText string // e.g., "q detach ctrl+c stop"
}
DashboardConfig configures the generic dashboard.
type DashboardRenderer ¶ added in v0.1.4
type DashboardRenderer interface {
// ProcessEvent handles a domain event received from the channel.
ProcessEvent(ev any)
// View renders the dashboard content for the given terminal width.
// Should NOT include the help line — the framework handles that.
View(cs *iostreams.ColorScheme, width int) string
}
DashboardRenderer controls the content of a channel-driven dashboard. Consumer packages implement this interface with domain-specific logic.
type DashboardResult ¶ added in v0.1.4
type DashboardResult struct {
Err error // display error only
Detached bool // user pressed q/Esc
Interrupted bool // user pressed Ctrl+C
}
DashboardResult is returned when the dashboard exits.
func RunDashboard ¶ added in v0.1.4
func RunDashboard(ios *iostreams.IOStreams, renderer DashboardRenderer, cfg DashboardConfig, ch <-chan any) DashboardResult
RunDashboard runs a generic channel-driven dashboard. Events are read from ch and dispatched to renderer.ProcessEvent(). Returns when the channel is closed or the user presses q/Esc/Ctrl+C.
type EscapeHandler ¶ added in v0.6.0
type EscapeHandler interface {
HandlesEscape() bool
}
EscapeHandler is an optional interface for pages that handle Esc internally (e.g. exiting edit mode in a FieldBrowserModel). When HandlesEscape returns true, the wizard delegates Esc to the page instead of navigating back.
type FieldBrowserModel ¶ added in v0.6.0
type FieldBrowserModel struct {
// contains filtered or unexported fields
}
FieldBrowserModel is a generic tabbed field browser/editor. It knows nothing about stores, reflection, or config schemas.
func NewFieldBrowser ¶ added in v0.6.0
func NewFieldBrowser(cfg BrowserConfig) *FieldBrowserModel
NewFieldBrowser creates a field browser from the given config.
func (*FieldBrowserModel) InBaseState ¶ added in v0.6.0
func (m *FieldBrowserModel) InBaseState() bool
InBaseState returns true when the browser is in its root browse state (not editing, picking a layer, or confirming a delete). Callers embedding the browser as a wizard page use this to decide whether navigation keys (like Esc) should be handled by the parent or delegated to the browser.
func (*FieldBrowserModel) Init ¶ added in v0.6.0
func (m *FieldBrowserModel) Init() tea.Cmd
func (*FieldBrowserModel) Result ¶ added in v0.6.0
func (m *FieldBrowserModel) Result() BrowserResult
Result returns the browser result after the program exits.
func (*FieldBrowserModel) View ¶ added in v0.6.0
func (m *FieldBrowserModel) View() string
type FieldEditor ¶ added in v0.6.0
type FieldEditor interface {
tea.Model
Value() string // Edited value as a string (YAML for complex types).
IsConfirmed() bool // True when the user accepted the edit.
IsCancelled() bool // True when the user cancelled the edit.
Err() string // Current validation error message, or "" if none.
}
FieldEditor is the contract for custom field editors plugged into FieldBrowserModel via the [BrowserField.Editor] factory.
All built-in editors (ListEditorModel, TextareaEditorModel, KVEditorModel, ItemListEditorModel) satisfy this interface. Domain adapters can implement their own editors as well.
type FieldOption ¶
FieldOption represents a selectable option with a label and description.
type FormEditorModel ¶ added in v0.6.0
type FormEditorModel struct {
// contains filtered or unexported fields
}
FormEditorModel presents a vertical multi-field form for editing a single struct's fields. Each field is a labeled textarea that supports multiline YAML values.
Navigation: Tab/Shift+Tab between fields. Ctrl+S saves, Esc cancels.
Used internally by ItemListEditorModel to edit individual items. Not a standalone FieldEditor — the item list owns the lifecycle.
This is a reusable building block for domain adapters. Currently unused — available for future domain customization via [storeui.Override] Editor factories.
func NewFormEditor ¶ added in v0.6.0
func NewFormEditor(fields []StructFieldDef, values map[string]string) FormEditorModel
NewFormEditor creates a form from field definitions and initial values. values maps YAML keys to their current string values.
func (FormEditorModel) Init ¶ added in v0.6.0
func (m FormEditorModel) Init() tea.Cmd
func (FormEditorModel) IsCancelled ¶ added in v0.6.0
func (m FormEditorModel) IsCancelled() bool
IsCancelled returns true if the user cancelled the form.
func (FormEditorModel) IsConfirmed ¶ added in v0.6.0
func (m FormEditorModel) IsConfirmed() bool
IsConfirmed returns true if the user accepted the form.
func (FormEditorModel) Update ¶ added in v0.6.0
func (m FormEditorModel) Update(msg tea.Msg) (FormEditorModel, tea.Cmd)
func (FormEditorModel) Values ¶ added in v0.6.0
func (m FormEditorModel) Values() map[string]string
Values returns the edited field values as a map of key → value.
func (FormEditorModel) View ¶ added in v0.6.0
func (m FormEditorModel) View() string
type HeaderConfig ¶
HeaderConfig configures a header component.
type HelpConfig ¶
type HelpConfig struct {
Width int
ShowAll bool // Show all bindings vs short help
Separator string
}
HelpConfig configures the help bar component.
func DefaultHelpConfig ¶
func DefaultHelpConfig() HelpConfig
DefaultHelpConfig returns sensible defaults for a help bar.
type HelpModel ¶
type HelpModel struct {
// contains filtered or unexported fields
}
HelpModel represents a help bar showing key bindings.
func NewHelp ¶
func NewHelp(cfg HelpConfig) HelpModel
NewHelp creates a new help bar with the given configuration.
func (HelpModel) SetBindings ¶
SetBindings sets the key bindings to display.
func (HelpModel) SetSeparator ¶
SetSeparator sets the separator between bindings.
func (HelpModel) SetShowAll ¶
SetShowAll sets whether to show all bindings.
type HookResult ¶
type HookResult struct {
Continue bool // false = quit execution
Message string // reason for quitting (only meaningful when Continue=false)
Err error // hook's own failure (independent of Continue)
}
HookResult controls execution flow after a lifecycle hook fires.
type ItemListEditorModel ¶ added in v0.6.0
type ItemListEditorModel struct {
// contains filtered or unexported fields
}
ItemListEditorModel lets the user manage a list of structs by navigating, editing, deleting, and adding items. Each item is edited via a FormEditorModel.
Input: a label, a YAML-formatted string value, and field definitions. Output: Value() returns the edited YAML string.
This is a reusable building block for domain adapters that want a structured list editor instead of the default YAML textarea. Wire it via the Editor factory on [storeui.Override]. Currently unused — available for future domain customization.
func NewItemListEditor ¶ added in v0.6.0
func NewItemListEditor(label string, value string, fields []StructFieldDef) ItemListEditorModel
NewItemListEditor creates an item list editor from a label, YAML value, and field defs.
func (ItemListEditorModel) Err ¶ added in v0.6.0
func (m ItemListEditorModel) Err() string
Err returns the current validation error message, or empty string if none. ItemListEditorModel does not support validation yet — this always returns "".
func (ItemListEditorModel) Init ¶ added in v0.6.0
func (m ItemListEditorModel) Init() tea.Cmd
func (ItemListEditorModel) IsCancelled ¶ added in v0.6.0
func (m ItemListEditorModel) IsCancelled() bool
IsCancelled returns true if the user cancelled editing.
func (ItemListEditorModel) IsConfirmed ¶ added in v0.6.0
func (m ItemListEditorModel) IsConfirmed() bool
IsConfirmed returns true if the user accepted the list.
func (ItemListEditorModel) Value ¶ added in v0.6.0
func (m ItemListEditorModel) Value() string
Value returns the current items as a YAML-formatted string.
func (ItemListEditorModel) View ¶ added in v0.6.0
func (m ItemListEditorModel) View() string
type KVEditorModel ¶ added in v0.6.0
type KVEditorModel struct {
// contains filtered or unexported fields
}
KVEditorModel lets the user manage a map[string]string by navigating, editing, deleting, and adding key-value pairs.
Input: a label and a YAML-formatted string value (marshaled map[string]string). Output: Value() returns the edited YAML string.
This is a reusable building block for domain adapters that want a structured map editor instead of the default YAML textarea. Wire it via the Editor factory on [storeui.Override]. Currently unused — available for future domain customization.
func NewKVEditor ¶ added in v0.6.0
func NewKVEditor(label string, value string, opts ...KVEditorOption) KVEditorModel
NewKVEditor creates a KV editor from a label and YAML-formatted map string.
func (KVEditorModel) Err ¶ added in v0.6.0
func (m KVEditorModel) Err() string
Err returns the current validation error message, or empty string if none.
func (KVEditorModel) Init ¶ added in v0.6.0
func (m KVEditorModel) Init() tea.Cmd
func (KVEditorModel) IsCancelled ¶ added in v0.6.0
func (m KVEditorModel) IsCancelled() bool
IsCancelled returns true if the user cancelled editing.
func (KVEditorModel) IsConfirmed ¶ added in v0.6.0
func (m KVEditorModel) IsConfirmed() bool
IsConfirmed returns true if the user accepted the map.
func (KVEditorModel) Value ¶ added in v0.6.0
func (m KVEditorModel) Value() string
Value returns the current pairs as a YAML-formatted string. When duplicate keys exist (valid in the editor — the user may save different keys to different layers), the last occurrence wins in the output map.
func (KVEditorModel) View ¶ added in v0.6.0
func (m KVEditorModel) View() string
type KVEditorOption ¶ added in v0.6.0
type KVEditorOption func(*KVEditorModel)
KVEditorOption is a functional option for configuring a KVEditorModel.
func WithKVValidator ¶ added in v0.6.0
func WithKVValidator(fn func(string) error) KVEditorOption
WithKVValidator sets a validation function called when the user confirms the entire map. If the function returns an error, the editor displays it and does not confirm.
type KeyMap ¶
type KeyMap struct {
Quit key.Binding
Up key.Binding
Down key.Binding
Left key.Binding
Right key.Binding
Enter key.Binding
Escape key.Binding
Help key.Binding
Tab key.Binding
}
KeyMap defines common key bindings used across TUI components.
type KeyValuePair ¶
KeyValuePair represents a key-value pair for display.
type LifecycleHook ¶
type LifecycleHook func(component, event string) HookResult
LifecycleHook is called at key moments during TUI component execution. component identifies the source (e.g., "progress"), event names the moment (e.g., "before_complete"). Implementations may block (for pausing) or return quickly (for logging). nil hooks are never called — components check before firing.
type ListConfig ¶
ListConfig configures a list component.
func DefaultListConfig ¶
func DefaultListConfig() ListConfig
DefaultListConfig returns sensible defaults for a list.
type ListEditorModel ¶ added in v0.6.0
type ListEditorModel struct {
// contains filtered or unexported fields
}
ListEditorModel lets the user manage a string list by navigating, editing, deleting, and adding individual items.
Input: a label and a comma-separated string value. Output: Value() returns the edited comma-separated string.
func NewListEditor ¶ added in v0.6.0
func NewListEditor(label string, value string, opts ...ListEditorOption) ListEditorModel
NewListEditor creates a list editor from a label and comma-separated value.
func (ListEditorModel) Err ¶ added in v0.6.0
func (m ListEditorModel) Err() string
Err returns the current validation error message, or empty string if none.
func (ListEditorModel) Init ¶ added in v0.6.0
func (m ListEditorModel) Init() tea.Cmd
Init returns nil — no initial command is needed.
func (ListEditorModel) IsCancelled ¶ added in v0.6.0
func (m ListEditorModel) IsCancelled() bool
IsCancelled returns true if the user cancelled editing.
func (ListEditorModel) IsConfirmed ¶ added in v0.6.0
func (m ListEditorModel) IsConfirmed() bool
IsConfirmed returns true if the user accepted the list.
func (ListEditorModel) Update ¶ added in v0.6.0
func (m ListEditorModel) Update(msg tea.Msg) (ListEditorModel, tea.Cmd)
Update handles key messages for list browsing and inline editing.
func (ListEditorModel) Value ¶ added in v0.6.0
func (m ListEditorModel) Value() string
Value returns the current items as a comma-separated string.
func (ListEditorModel) View ¶ added in v0.6.0
func (m ListEditorModel) View() string
View renders the list editor with items, inline input, and help bar.
type ListEditorOption ¶ added in v0.6.0
type ListEditorOption func(*ListEditorModel)
ListEditorOption is a functional option for configuring a ListEditorModel.
func WithListValidator ¶ added in v0.6.0
func WithListValidator(fn func(string) error) ListEditorOption
WithListValidator sets a validation function called when the user confirms the list. If the function returns an error, the editor displays it and does not confirm.
type ListItem ¶
type ListItem interface {
// Title returns the main display text.
Title() string
// Description returns optional secondary text.
Description() string
// FilterValue returns the string used for filtering.
FilterValue() string
}
ListItem represents an item that can be displayed in a list.
type ListModel ¶
type ListModel struct {
// contains filtered or unexported fields
}
ListModel is a lightweight selectable list component.
func NewList ¶
func NewList(cfg ListConfig) ListModel
NewList creates a new list with the given configuration.
func (ListModel) SelectFirst ¶
SelectFirst moves selection to the first item.
func (ListModel) SelectLast ¶
SelectLast moves selection to the last item.
func (ListModel) SelectNext ¶
SelectNext moves selection to the next item.
func (ListModel) SelectPrev ¶
SelectPrev moves selection to the previous item.
func (ListModel) SelectedIndex ¶
SelectedIndex returns the index of the selected item.
func (ListModel) SelectedItem ¶
SelectedItem returns the currently selected item, or nil if empty.
func (ListModel) SetShowDescriptions ¶
SetShowDescriptions sets whether to show descriptions.
type PanelConfig ¶
PanelConfig configures a panel component.
func DefaultPanelConfig ¶
func DefaultPanelConfig() PanelConfig
DefaultPanelConfig returns sensible defaults for a panel.
type PanelGroup ¶
type PanelGroup struct {
// contains filtered or unexported fields
}
PanelGroup manages a group of panels with focus handling.
func NewPanelGroup ¶
func NewPanelGroup(panels ...PanelModel) PanelGroup
NewPanelGroup creates a new panel group.
func (PanelGroup) Add ¶
func (g PanelGroup) Add(panel PanelModel) PanelGroup
Add adds a panel to the group.
func (PanelGroup) Focus ¶
func (g PanelGroup) Focus(index int) PanelGroup
Focus sets focus to a specific panel index.
func (PanelGroup) FocusNext ¶
func (g PanelGroup) FocusNext() PanelGroup
FocusNext moves focus to the next panel.
func (PanelGroup) FocusPrev ¶
func (g PanelGroup) FocusPrev() PanelGroup
FocusPrev moves focus to the previous panel.
func (PanelGroup) FocusedIndex ¶
func (g PanelGroup) FocusedIndex() int
FocusedIndex returns the index of the focused panel.
func (PanelGroup) FocusedPanel ¶
func (g PanelGroup) FocusedPanel() PanelModel
FocusedPanel returns the currently focused panel.
func (PanelGroup) Panels ¶
func (g PanelGroup) Panels() []PanelModel
Panels returns all panels in the group.
func (PanelGroup) RenderHorizontal ¶
func (g PanelGroup) RenderHorizontal(gap int) string
RenderHorizontal renders panels in a horizontal row.
func (PanelGroup) RenderVertical ¶
func (g PanelGroup) RenderVertical(gap int) string
RenderVertical renders panels in a vertical stack.
type PanelModel ¶
type PanelModel struct {
// contains filtered or unexported fields
}
PanelModel represents a bordered content container.
func NewPanel ¶
func NewPanel(cfg PanelConfig) PanelModel
NewPanel creates a new panel with the given configuration.
func (PanelModel) Content ¶
func (p PanelModel) Content() string
Content returns the panel's content.
func (PanelModel) IsFocused ¶
func (p PanelModel) IsFocused() bool
IsFocused returns whether the panel is focused.
func (PanelModel) SetContent ¶
func (p PanelModel) SetContent(content string) PanelModel
SetContent sets the panel's content.
func (PanelModel) SetFocused ¶
func (p PanelModel) SetFocused(focused bool) PanelModel
SetFocused sets whether the panel is focused.
func (PanelModel) SetHeight ¶
func (p PanelModel) SetHeight(height int) PanelModel
SetHeight sets the panel's height.
func (PanelModel) SetPadding ¶
func (p PanelModel) SetPadding(padding int) PanelModel
SetPadding sets the panel's internal padding.
func (PanelModel) SetTitle ¶
func (p PanelModel) SetTitle(title string) PanelModel
SetTitle sets the panel's title.
func (PanelModel) SetWidth ¶
func (p PanelModel) SetWidth(width int) PanelModel
SetWidth sets the panel's width.
type ProgramOption ¶
type ProgramOption func(*programOptions)
ProgramOption configures a BubbleTea program.
func WithAltScreen ¶
func WithAltScreen(enabled bool) ProgramOption
WithAltScreen enables or disables the alternate screen buffer.
func WithMouseMotion ¶
func WithMouseMotion(enabled bool) ProgramOption
WithMouseMotion enables or disables mouse motion events.
type ProgressConfig ¶
ProgressConfig configures a progress indicator.
type ProgressDisplayConfig ¶
type ProgressDisplayConfig struct {
Title string // e.g., "Building"
Subtitle string // e.g., image tag
CompletionVerb string // Success summary verb (e.g., "Built", "Deployed"). Default: "Completed"
MaxVisible int // per-stage child window size (default: 5)
LogLines int // per-step log buffer capacity (default: 3)
// Callbacks — all optional. nil = passthrough / no-op.
IsInternal func(string) bool // filter function (nil = show all)
CleanName func(string) string // name cleaning (nil = passthrough)
ParseGroup func(string) string // group/stage detection (nil = no groups)
FormatDuration func(time.Duration) string // duration formatting (nil = default)
// Lifecycle hook — called at key moments. nil = no-op.
OnLifecycle LifecycleHook
// AltScreen enables the alternate screen buffer for TTY mode.
// When true, progress output is rendered in the alt screen and cleared
// when the display finishes — useful for clean handoff to a container TTY.
AltScreen bool
}
ProgressDisplayConfig configures the progress display. Domain-specific logic flows in through callbacks — the display itself has zero knowledge of what is being tracked.
type ProgressResult ¶
type ProgressResult struct {
Err error // only set if the progress display itself errors
}
ProgressResult contains the outcome of a progress display.
func RunProgress ¶
func RunProgress(ios *iostreams.IOStreams, mode string, cfg ProgressDisplayConfig, ch <-chan ProgressStep) ProgressResult
RunProgress runs a progress display, consuming steps from ch until it is closed. It selects TTY (BubbleTea) or plain mode based on the terminal and mode setting. The mode parameter can be "auto", "plain", or "tty". Channel closure signals completion — the caller closes ch when done.
type ProgressStep ¶
type ProgressStep struct {
ID string
Name string
Status ProgressStepStatus
LogLine string
Cached bool
Error string
}
ProgressStep represents a single progress update from the pipeline. The caller sends these on a channel consumed by RunProgress.
type ProgressStepStatus ¶
type ProgressStepStatus int
ProgressStepStatus represents the state of a progress step.
const ( StepPending ProgressStepStatus = iota StepRunning StepComplete StepCached StepError )
type Resetter ¶ added in v0.6.0
type Resetter interface {
Reset()
}
Resetter is an optional interface for pages that support being reset when the user navigates backward in the wizard.
type SelectField ¶
type SelectField struct {
ID string
Prompt string
Options []FieldOption
// contains filtered or unexported fields
}
SelectField is a standalone BubbleTea model for arrow-key selection. It wraps ListModel for navigation state but renders its own compact view with label + description on a single line.
func NewSelectField ¶
func NewSelectField(id, prompt string, options []FieldOption, defaultIdx int) SelectField
NewSelectField creates a new SelectField with the given options. defaultIdx sets the initially selected option (clamped to valid range).
func (SelectField) Init ¶
func (f SelectField) Init() tea.Cmd
Init returns nil — no initial command is needed.
func (SelectField) IsConfirmed ¶
func (f SelectField) IsConfirmed() bool
IsConfirmed returns true if the user has confirmed their selection.
func (SelectField) SelectedIndex ¶
func (f SelectField) SelectedIndex() int
SelectedIndex returns the index of the currently selected option.
func (SelectField) SetSize ¶
func (f SelectField) SetSize(w, h int) SelectField
SetSize sets the width and height available for rendering.
func (SelectField) Update ¶
func (f SelectField) Update(msg tea.Msg) (SelectField, tea.Cmd)
Update handles key messages. Up/Down delegate to the internal list. Enter confirms the selection and sends tea.Quit for standalone use.
func (SelectField) Value ¶
func (f SelectField) Value() string
Value returns the label of the currently selected option.
func (SelectField) View ¶
func (f SelectField) View() string
View renders the select field with prompt and compact option list. Each option shows label and description on one line:
> bookworm Debian stable (Recommended) trixie Debian testing
type SimpleListItem ¶
SimpleListItem is a basic implementation of ListItem.
func (SimpleListItem) Description ¶
func (i SimpleListItem) Description() string
Description implements ListItem.
func (SimpleListItem) FilterValue ¶
func (i SimpleListItem) FilterValue() string
FilterValue implements ListItem.
type SpinnerModel ¶
type SpinnerModel struct {
// contains filtered or unexported fields
}
SpinnerModel is a wrapper around bubbles/spinner with clawker styling.
func NewDefaultSpinner ¶
func NewDefaultSpinner(label string) SpinnerModel
NewDefaultSpinner creates a spinner with default settings.
func NewSpinner ¶
func NewSpinner(spinnerType SpinnerType, label string) SpinnerModel
NewSpinner creates a new spinner with the specified type and label.
func (SpinnerModel) SetLabel ¶
func (m SpinnerModel) SetLabel(label string) SpinnerModel
SetLabel updates the spinner's label.
func (SpinnerModel) SetSpinnerType ¶
func (m SpinnerModel) SetSpinnerType(t SpinnerType) SpinnerModel
SetSpinnerType changes the spinner animation type.
func (SpinnerModel) Tick ¶
func (m SpinnerModel) Tick() tea.Msg
Tick returns a command to tick the spinner.
func (SpinnerModel) Update ¶
func (m SpinnerModel) Update(msg tea.Msg) (SpinnerModel, tea.Cmd)
Update handles messages for the spinner.
type SpinnerTickMsg ¶
SpinnerTickMsg is sent when the spinner should update.
type SpinnerType ¶
type SpinnerType int
SpinnerType defines the animation style for a spinner.
const ( SpinnerDots SpinnerType = iota SpinnerLine SpinnerMiniDots SpinnerJump SpinnerPulse SpinnerPoints SpinnerGlobe SpinnerMoon SpinnerMonkey )
type StatusBarModel ¶
type StatusBarModel struct {
// contains filtered or unexported fields
}
StatusBarModel represents a single-line status bar with left/center/right sections.
func NewStatusBar ¶
func NewStatusBar(width int) StatusBarModel
NewStatusBar creates a new status bar with the given width.
func (StatusBarModel) Center ¶
func (m StatusBarModel) Center() string
Center returns the center section content.
func (StatusBarModel) Left ¶
func (m StatusBarModel) Left() string
Left returns the left section content.
func (StatusBarModel) Right ¶
func (m StatusBarModel) Right() string
Right returns the right section content.
func (StatusBarModel) SetCenter ¶
func (m StatusBarModel) SetCenter(s string) StatusBarModel
SetCenter sets the center section content.
func (StatusBarModel) SetLeft ¶
func (m StatusBarModel) SetLeft(s string) StatusBarModel
SetLeft sets the left section content.
func (StatusBarModel) SetRight ¶
func (m StatusBarModel) SetRight(s string) StatusBarModel
SetRight sets the right section content.
func (StatusBarModel) SetWidth ¶
func (m StatusBarModel) SetWidth(width int) StatusBarModel
SetWidth sets the status bar width.
func (StatusBarModel) Width ¶
func (m StatusBarModel) Width() int
Width returns the status bar width.
type StatusBarSection ¶
StatusBarSection represents a styled section of the status bar.
type StatusConfig ¶
StatusConfig configures a status indicator.
type Step ¶
type Step struct {
Title string // Short label for the bar
Value string // Displayed next to completed steps (e.g., "bookworm")
State StepState
}
Step represents a single step in a stepper bar.
type StepState ¶
type StepState int
StepState represents the state of a step in a stepper bar.
const ( // StepPendingState indicates the step has not been started. StepPendingState StepState = iota // StepActiveState indicates the step is currently active. StepActiveState // StepCompleteState indicates the step has been completed. StepCompleteState // StepSkippedState indicates the step was skipped (hidden from display). StepSkippedState )
type StructFieldDef ¶ added in v0.6.0
type StructFieldDef struct {
Key string // YAML key (e.g. "cmd", "alpine")
Label string // Human-readable label (e.g. "Command", "Alpine")
}
StructFieldDef describes a single field within a struct, used by FormEditorModel and ItemListEditorModel to display and edit struct members without domain knowledge.
type TUI ¶
type TUI struct {
// contains filtered or unexported fields
}
TUI provides the interactive presentation layer. Constructed once via Factory; hooks registered separately after construction. This enables pointer-sharing: commands capture *TUI eagerly at NewCmd time, while hooks are registered later (e.g., in PersistentPreRunE after flag parsing).
func (*TUI) IOStreams ¶
IOStreams returns the underlying IOStreams for callers that need direct access.
func (*TUI) NewTable ¶
func (t *TUI) NewTable(headers ...string) *TablePrinter
NewTable creates a TablePrinter bound to this TUI's IOStreams.
func (*TUI) RegisterHooks ¶
func (t *TUI) RegisterHooks(hooks ...LifecycleHook)
RegisterHooks appends one or more lifecycle hooks. Hooks fire in registration order; the first non-continue result short-circuits.
func (*TUI) RunProgress ¶
func (t *TUI) RunProgress(mode string, cfg ProgressDisplayConfig, ch <-chan ProgressStep) ProgressResult
RunProgress displays a multi-step progress view, delegating to the package-level RunProgress function. Registered hooks are injected into cfg.OnLifecycle if the caller has not already set one.
func (*TUI) RunWizard ¶
func (t *TUI) RunWizard(steps []WizardStep) (WizardResult, error)
RunWizard runs a multi-step wizard using the given steps. Each step wraps a pre-constructed WizardPage — the wizard is a generic page sequencer that delegates rendering and input to each page model. Returns the collected values and whether the wizard was submitted (vs cancelled).
type TableConfig ¶
RenderTable renders a simple table with headers and rows.
type TablePrinter ¶
type TablePrinter struct {
// contains filtered or unexported fields
}
TablePrinter renders tabular data with TTY-aware styling. In styled mode (TTY + color), delegates to iostreams.RenderStyledTable (lipgloss/table). In plain mode (non-TTY/piped), uses text/tabwriter for machine-friendly output.
func (*TablePrinter) AddRow ¶
func (tp *TablePrinter) AddRow(cols ...string)
AddRow appends a data row. Missing columns are padded with empty strings; extra columns beyond the header count are discarded.
func (*TablePrinter) Len ¶
func (tp *TablePrinter) Len() int
Len returns the number of data rows (excluding the header).
func (*TablePrinter) Render ¶
func (tp *TablePrinter) Render() error
Render writes the table to ios.Out. Returns nil if there are no headers.
func (*TablePrinter) WithCellStyle ¶
func (tp *TablePrinter) WithCellStyle(fn func(string) string) *TablePrinter
WithCellStyle overrides the default cell style. The function receives cell text and returns styled text. Pass nil to use the default (plain with padding).
func (*TablePrinter) WithHeaderStyle ¶
func (tp *TablePrinter) WithHeaderStyle(fn func(string) string) *TablePrinter
WithHeaderStyle overrides the header row style. The function receives cell text and returns styled text. Pass nil to use the default (TableHeaderStyle).
func (*TablePrinter) WithPrimaryStyle ¶
func (tp *TablePrinter) WithPrimaryStyle(fn func(string) string) *TablePrinter
WithPrimaryStyle overrides the first-column style. The function receives cell text and returns styled text. Pass nil to use the default (TablePrimaryColumnStyle).
type TextField ¶
TextField is a standalone BubbleTea model for text input. It wraps the bubbles textinput component with validation support.
func NewTextField ¶
func NewTextField(id, prompt string, opts ...TextFieldOption) TextField
NewTextField creates a new TextField with the given options.
func (TextField) IsConfirmed ¶
IsConfirmed returns true if the user has confirmed the input.
func (TextField) Update ¶
Update handles key messages. Enter validates and confirms. All other keys are delegated to the underlying textinput.
type TextFieldOption ¶
type TextFieldOption func(*TextField)
TextFieldOption is a functional option for configuring a TextField.
func WithDefault ¶
func WithDefault(s string) TextFieldOption
WithDefault sets the initial value of the text input.
func WithPlaceholder ¶
func WithPlaceholder(s string) TextFieldOption
WithPlaceholder sets the placeholder text shown when the input is empty.
func WithRequired ¶
func WithRequired() TextFieldOption
WithRequired marks the field as required — an empty value is rejected on Enter.
func WithValidator ¶
func WithValidator(fn func(string) error) TextFieldOption
WithValidator sets a validation function called on Enter. If the function returns an error, the field displays it and does not confirm.
type TextareaEditorModel ¶ added in v0.6.0
type TextareaEditorModel struct {
// contains filtered or unexported fields
}
TextareaEditorModel provides multiline text editing with ctrl+s save and esc cancel.
func NewTextareaEditor ¶ added in v0.6.0
func NewTextareaEditor(label string, value string, opts ...TextareaEditorOption) TextareaEditorModel
NewTextareaEditor creates a multiline text editor with the given label and initial value.
func (TextareaEditorModel) Err ¶ added in v0.6.0
func (m TextareaEditorModel) Err() string
Err returns the current validation error message, or empty string if none.
func (TextareaEditorModel) Init ¶ added in v0.6.0
func (m TextareaEditorModel) Init() tea.Cmd
Init returns the textarea blink command.
func (TextareaEditorModel) IsCancelled ¶ added in v0.6.0
func (m TextareaEditorModel) IsCancelled() bool
IsCancelled returns true if the user cancelled.
func (TextareaEditorModel) IsConfirmed ¶ added in v0.6.0
func (m TextareaEditorModel) IsConfirmed() bool
IsConfirmed returns true if the user saved.
func (TextareaEditorModel) Update ¶ added in v0.6.0
func (m TextareaEditorModel) Update(msg tea.Msg) (TextareaEditorModel, tea.Cmd)
Update handles key messages: ctrl+s saves, esc cancels, everything else delegates.
func (TextareaEditorModel) Value ¶ added in v0.6.0
func (m TextareaEditorModel) Value() string
Value returns the current textarea content.
func (TextareaEditorModel) View ¶ added in v0.6.0
func (m TextareaEditorModel) View() string
View renders the textarea editor with label, content area, and help bar.
type TextareaEditorOption ¶ added in v0.6.0
type TextareaEditorOption func(*TextareaEditorModel)
TextareaEditorOption is a functional option for configuring a TextareaEditorModel.
func WithTextareaValidator ¶ added in v0.6.0
func WithTextareaValidator(fn func(string) error) TextareaEditorOption
WithTextareaValidator sets a validation function called when the user saves (Ctrl+S). If the function returns an error, the editor displays it and does not confirm.
type ViewportConfig ¶
ViewportConfig configures a viewport component.
type ViewportModel ¶
type ViewportModel struct {
// contains filtered or unexported fields
}
ViewportModel wraps a bubbles viewport with consistent styling. It provides scrollable content within a bordered panel.
func NewViewport ¶
func NewViewport(cfg ViewportConfig) ViewportModel
NewViewport creates a new viewport with the given configuration.
func (ViewportModel) AtBottom ¶
func (v ViewportModel) AtBottom() bool
AtBottom returns true if the viewport is scrolled to the bottom.
func (ViewportModel) AtTop ¶
func (v ViewportModel) AtTop() bool
AtTop returns true if the viewport is scrolled to the top.
func (ViewportModel) Height ¶
func (v ViewportModel) Height() int
Height returns the viewport height.
func (ViewportModel) ScrollPercent ¶
func (v ViewportModel) ScrollPercent() float64
ScrollPercent returns the scroll position as a percentage (0.0 to 1.0).
func (ViewportModel) ScrollToBottom ¶
func (v ViewportModel) ScrollToBottom() ViewportModel
ScrollToBottom scrolls to the bottom of the content.
func (ViewportModel) ScrollToTop ¶
func (v ViewportModel) ScrollToTop() ViewportModel
ScrollToTop scrolls to the top of the content.
func (ViewportModel) SetContent ¶
func (v ViewportModel) SetContent(s string) ViewportModel
SetContent sets the viewport content.
func (ViewportModel) SetSize ¶
func (v ViewportModel) SetSize(width, height int) ViewportModel
SetSize sets the viewport dimensions.
func (ViewportModel) SetTitle ¶
func (v ViewportModel) SetTitle(title string) ViewportModel
SetTitle sets the viewport title.
func (ViewportModel) Title ¶
func (v ViewportModel) Title() string
Title returns the viewport title.
func (ViewportModel) Update ¶
func (v ViewportModel) Update(msg tea.Msg) (ViewportModel, tea.Cmd)
Update implements tea.Model.
type WizardPage ¶ added in v0.6.0
type WizardPage interface {
tea.Model
// IsComplete returns true when the page is done and the wizard should advance.
IsComplete() bool
// Value returns the collected value as a string. Empty for pages that
// persist their own state (e.g. a FieldBrowserModel with per-field save).
Value() string
}
WizardPage is the interface that wizard steps must satisfy. Any tea.Model that can report completion and extract a value works as a page.
func NewBrowserPage ¶ added in v0.6.0
func NewBrowserPage(browser *FieldBrowserModel, opts ...BrowserPageOption) WizardPage
NewBrowserPage wraps a FieldBrowserModel as a WizardPage. The browser handles per-field saves via its OnFieldSaved callback. Use WithDoneKey to set which key completes the page, and WithCancelKey to set which key cancels the wizard. Esc in browse mode triggers wizard back-navigation; Esc in edit/picker mode is delegated to the browser via the EscapeHandler interface.
func NewConfirmPage ¶ added in v0.6.0
func NewConfirmPage(id, prompt string, defaultYes bool) WizardPage
NewConfirmPage wraps a ConfirmField as a WizardPage.
func NewSelectPage ¶ added in v0.6.0
func NewSelectPage(id, prompt string, options []FieldOption, defaultIdx int) WizardPage
NewSelectPage wraps a SelectField as a WizardPage.
func NewTextPage ¶ added in v0.6.0
func NewTextPage(id, prompt string, opts ...TextFieldOption) WizardPage
NewTextPage wraps a TextField as a WizardPage.
type WizardResult ¶
type WizardResult struct {
Values WizardValues
Submitted bool
}
WizardResult is returned by RunWizard.
type WizardStep ¶ added in v0.6.0
type WizardStep struct {
ID string
Title string // StepperBar label
Page WizardPage
SkipIf func(WizardValues) bool
// HelpKeys provides custom help bar entries for this step.
// If nil, a default help bar (esc/back, ctrl+c/quit) is shown.
HelpKeys []string // alternating key, description pairs for QuickHelp
}
WizardStep defines a single step in the wizard. Each step wraps a pre-constructed WizardPage — the wizard is a generic page sequencer that delegates rendering and input to the page model.
type WizardValues ¶
WizardValues is a map of step ID to string value.