input

package
v2.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// IconSetSymbols - Unicode symbols.
	IconSetSymbols = IconSet{
		Running: "⏺",
		Success: "✓",
		Error:   "✗",
		Warning: "⚠",
		Info:    "ℹ",
		None:    "⏺",
	}
)
View Source
var (
	// SpinnerDots - Braille dots spinner (smooth).
	SpinnerDots = Spinner{
		Frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"},
	}
)

Functions

This section is empty.

Types

type Checklist

type Checklist struct {
	// contains filtered or unexported fields
}

Checklist displays a navigable list of checklist items.

func NewChecklist

func NewChecklist(opts ...ChecklistOption) *Checklist

NewChecklist creates a new checklist component.

func (*Checklist) AddItem

func (c *Checklist) AddItem(item ChecklistItem)

AddItem appends an item to the checklist.

func (*Checklist) Blur

func (c *Checklist) Blur()

Blur marks the component as unfocused.

func (*Checklist) CompletionCount

func (c *Checklist) CompletionCount() (done int, total int)

CompletionCount returns completed and total item counts.

Completed includes all non-pending statuses.

func (*Checklist) Focus

func (c *Checklist) Focus()

Focus marks the component as focused.

func (*Checklist) Focused

func (c *Checklist) Focused() bool

Focused returns whether the component has focus.

func (*Checklist) GetItem

func (c *Checklist) GetItem(id string) *ChecklistItem

GetItem returns a pointer to the item with a matching ID.

func (*Checklist) Init

func (c *Checklist) Init() tea.Cmd

Init initializes the checklist component.

func (*Checklist) ItemCount

func (c *Checklist) ItemCount() int

ItemCount returns total number of items including nested children.

func (*Checklist) RemoveItem

func (c *Checklist) RemoveItem(id string)

RemoveItem removes a checklist item by ID.

func (*Checklist) SetExpanded

func (c *Checklist) SetExpanded(id string, expanded bool)

SetExpanded sets one item's expanded state by ID.

func (*Checklist) SetItemStatus

func (c *Checklist) SetItemStatus(id string, status ChecklistItemStatus)

SetItemStatus sets a checklist item's status by ID.

func (*Checklist) ToggleItem

func (c *Checklist) ToggleItem(id string)

ToggleItem toggles a checklist item between done and pending.

func (*Checklist) Update

func (c *Checklist) Update(msg tea.Msg) (tui.Component, tea.Cmd)

Update handles Bubble Tea messages.

func (*Checklist) View

func (c *Checklist) View() string

View renders the checklist.

type ChecklistItem

type ChecklistItem struct {
	ID       string
	Label    string
	Status   ChecklistItemStatus
	Children []ChecklistItem
	Expanded bool
}

ChecklistItem is one checklist entry and optional nested children.

type ChecklistItemStatus

type ChecklistItemStatus int

ChecklistItemStatus represents one checklist item's execution state.

const (
	ItemPending ChecklistItemStatus = iota
	ItemInProgress
	ItemDone
	ItemSkipped
	ItemFailed
)

type ChecklistOption

type ChecklistOption func(*Checklist)

ChecklistOption configures a Checklist.

func WithChecklistDesignTokens

func WithChecklistDesignTokens(tokens *design.DesignTokens) ChecklistOption

WithChecklistDesignTokens applies design-system colors.

func WithChecklistIconSet

func WithChecklistIconSet(iconSet IconSet) ChecklistOption

WithChecklistIconSet sets status icons.

func WithChecklistItems

func WithChecklistItems(items ...ChecklistItem) ChecklistOption

WithChecklistItems sets the initial checklist items.

func WithChecklistTheme

func WithChecklistTheme(theme string) ChecklistOption

WithChecklistTheme applies a named design-system theme.

func WithChecklistTitle

func WithChecklistTitle(title string) ChecklistOption

WithChecklistTitle sets the checklist title.

func WithShowProgress

func WithShowProgress(show bool) ChecklistOption

WithShowProgress toggles progress display in the title row.

type Command

type Command struct {
	Name        string         // Display name of the command
	Description string         // Brief description of what the command does
	Category    string         // Category for grouping (e.g., "File", "Edit", "View")
	Action      func() tea.Cmd // Function to execute when command is selected
	Keybinding  string         // Optional keyboard shortcut (e.g., "Ctrl+S")
}

Command represents an executable command in the command palette with metadata for display and categorization.

type CommandPalette

type CommandPalette struct {
	// contains filtered or unexported fields
}

CommandPalette is a searchable command launcher inspired by VS Code's command palette. It provides a popup interface for quickly executing commands via keyboard.

func NewCommandPalette

func NewCommandPalette(commands []Command, opts ...CommandPaletteOption) *CommandPalette

NewCommandPalette creates a new command palette with the given list of commands.

func (*CommandPalette) Blur

func (cp *CommandPalette) Blur()

Blur is called when this component loses focus.

func (*CommandPalette) Focus

func (cp *CommandPalette) Focus()

Focus is called when this component receives focus.

func (*CommandPalette) Focused

func (cp *CommandPalette) Focused() bool

Focused returns whether this component is currently focused.

func (*CommandPalette) Hide

func (cp *CommandPalette) Hide()

Hide conceals the command palette.

func (*CommandPalette) Init

func (cp *CommandPalette) Init() tea.Cmd

Init initializes the command palette.

func (*CommandPalette) IsVisible

func (cp *CommandPalette) IsVisible() bool

IsVisible returns whether the palette is currently visible.

func (*CommandPalette) Show

func (cp *CommandPalette) Show()

Show displays the command palette.

func (*CommandPalette) Update

func (cp *CommandPalette) Update(msg tea.Msg) (tui.Component, tea.Cmd)

Update handles messages.

func (*CommandPalette) View

func (cp *CommandPalette) View() string

View renders the command palette.

type CommandPaletteOption added in v2.11.0

type CommandPaletteOption func(*CommandPalette)

CommandPaletteOption configures a CommandPalette.

func WithCommandPaletteDesignTokens added in v2.11.0

func WithCommandPaletteDesignTokens(tokens *design.DesignTokens) CommandPaletteOption

WithCommandPaletteDesignTokens applies design-system colors.

type FloatingPalette

type FloatingPalette struct {
	// contains filtered or unexported fields
}

FloatingPalette is a centered floating command palette overlay.

func NewFloatingPalette

func NewFloatingPalette(commands []PaletteCommand, opts ...FloatingPaletteOption) *FloatingPalette

NewFloatingPalette creates a floating command palette component.

func (*FloatingPalette) Blur

func (fp *FloatingPalette) Blur()

Blur marks the palette as unfocused.

func (*FloatingPalette) Focus

func (fp *FloatingPalette) Focus()

Focus marks the palette as focused.

func (*FloatingPalette) Focused

func (fp *FloatingPalette) Focused() bool

Focused returns whether the palette has focus.

func (*FloatingPalette) GetSelectedCommand

func (fp *FloatingPalette) GetSelectedCommand() *PaletteCommand

GetSelectedCommand returns the currently selected filtered command.

func (*FloatingPalette) Hide

func (fp *FloatingPalette) Hide()

Hide conceals the palette.

func (*FloatingPalette) Init

func (fp *FloatingPalette) Init() tea.Cmd

Init initializes the component.

func (*FloatingPalette) IsVisible

func (fp *FloatingPalette) IsVisible() bool

IsVisible returns whether the palette is visible.

func (*FloatingPalette) SetCommands

func (fp *FloatingPalette) SetCommands(cmds []PaletteCommand)

SetCommands updates the command list and reapplies filtering.

func (*FloatingPalette) Show

func (fp *FloatingPalette) Show()

Show makes the palette visible and resets filter state.

func (*FloatingPalette) Toggle

func (fp *FloatingPalette) Toggle()

Toggle flips visibility.

func (*FloatingPalette) Update

func (fp *FloatingPalette) Update(msg tea.Msg) (tui.Component, tea.Cmd)

Update handles input and window size changes.

func (*FloatingPalette) View

func (fp *FloatingPalette) View() string

View renders the floating palette overlay.

type FloatingPaletteOption

type FloatingPaletteOption func(*FloatingPalette)

FloatingPaletteOption configures a FloatingPalette.

func WithFloatingPaletteDesignTokens

func WithFloatingPaletteDesignTokens(tokens *design.DesignTokens) FloatingPaletteOption

WithFloatingPaletteDesignTokens applies design-system colors.

func WithFloatingPaletteMargin

func WithFloatingPaletteMargin(margin int) FloatingPaletteOption

WithFloatingPaletteMargin sets the horizontal margin on each side.

func WithFloatingPaletteMaxResults

func WithFloatingPaletteMaxResults(n int) FloatingPaletteOption

WithFloatingPaletteMaxResults sets the maximum number of visible results.

func WithFloatingPalettePrompt

func WithFloatingPalettePrompt(prompt string) FloatingPaletteOption

WithFloatingPalettePrompt sets the input prompt.

func WithFloatingPaletteTheme

func WithFloatingPaletteTheme(theme string) FloatingPaletteOption

WithFloatingPaletteTheme applies a named design-system theme.

type IconSet

type IconSet struct {
	Running string
	Success string
	Error   string
	Warning string
	Info    string
	None    string
}

IconSet defines icons for different statuses.

type KeyBinding added in v2.3.0

type KeyBinding struct {
	Key         string
	Description string
	Category    string
}

KeyBinding represents a keyboard shortcut and its purpose.

type KeyOverlay added in v2.3.0

type KeyOverlay struct {
	// contains filtered or unexported fields
}

KeyOverlay is a centered help overlay that lists available shortcuts.

func NewKeyOverlay added in v2.3.0

func NewKeyOverlay(opts ...KeyOverlayOption) *KeyOverlay

NewKeyOverlay creates a new KeyOverlay.

func (*KeyOverlay) AddBinding added in v2.3.0

func (ko *KeyOverlay) AddBinding(key, desc, category string)

AddBinding appends a single key binding.

func (*KeyOverlay) AddBindings added in v2.3.0

func (ko *KeyOverlay) AddBindings(bindings []KeyBinding)

AddBindings appends multiple key bindings.

func (*KeyOverlay) Blur added in v2.3.0

func (ko *KeyOverlay) Blur()

Blur marks the overlay as unfocused.

func (*KeyOverlay) Focus added in v2.3.0

func (ko *KeyOverlay) Focus()

Focus marks the overlay as focused.

func (*KeyOverlay) Focused added in v2.3.0

func (ko *KeyOverlay) Focused() bool

Focused reports whether the overlay is focused.

func (*KeyOverlay) Init added in v2.3.0

func (ko *KeyOverlay) Init() tea.Cmd

Init initializes the overlay.

func (*KeyOverlay) SetVisible added in v2.3.0

func (ko *KeyOverlay) SetVisible(visible bool)

SetVisible sets whether the overlay is visible.

func (*KeyOverlay) Toggle added in v2.3.0

func (ko *KeyOverlay) Toggle()

Toggle flips the current visibility.

func (*KeyOverlay) Update added in v2.3.0

func (ko *KeyOverlay) Update(msg tea.Msg) (tui.Component, tea.Cmd)

Update handles key and window events.

func (*KeyOverlay) View added in v2.3.0

func (ko *KeyOverlay) View() string

View renders the overlay if visible.

func (*KeyOverlay) Visible added in v2.3.0

func (ko *KeyOverlay) Visible() bool

Visible reports whether the overlay is visible.

type KeyOverlayOption added in v2.3.0

type KeyOverlayOption func(*KeyOverlay)

KeyOverlayOption configures a KeyOverlay.

func WithKeyOverlayBindings added in v2.3.0

func WithKeyOverlayBindings(bindings []KeyBinding) KeyOverlayOption

WithKeyOverlayBindings sets initial key bindings.

func WithKeyOverlayTitle added in v2.3.0

func WithKeyOverlayTitle(title string) KeyOverlayOption

WithKeyOverlayTitle sets the overlay title.

func WithKeyOverlayWidth added in v2.3.0

func WithKeyOverlayWidth(width int) KeyOverlayOption

WithKeyOverlayWidth sets the preferred overlay width.

type PaletteCommand

type PaletteCommand struct {
	Name        string // command name e.g. 'diff'
	Description string // description text
	Shortcut    string // optional keyboard shortcut hint
}

PaletteCommand is a command shown in the floating command palette.

type PaletteDismissMsg

type PaletteDismissMsg struct{}

PaletteDismissMsg is emitted when the palette is dismissed.

type PaletteSelectMsg

type PaletteSelectMsg struct {
	Command PaletteCommand
}

PaletteSelectMsg is emitted when a command selection is confirmed.

type Spinner

type Spinner struct {
	Frames []string
}

Spinner defines an animation sequence.

func (Spinner) GetFrame

func (s Spinner) GetFrame(index int) string

GetFrame returns the frame at the given index.

type TextInput

type TextInput struct {
	// contains filtered or unexported fields
}

TextInput is a multi-line text input component for user messages.

func NewTextInput

func NewTextInput() *TextInput

NewTextInput creates a new text input component.

func (*TextInput) Blur

func (t *TextInput) Blur()

Blur is called when this component loses focus.

func (*TextInput) Focus

func (t *TextInput) Focus()

Focus is called when this component receives focus.

func (*TextInput) Focused

func (t *TextInput) Focused() bool

Focused returns whether this component is currently focused.

func (*TextInput) Init

func (t *TextInput) Init() tea.Cmd

Init initializes the text input.

func (*TextInput) OnSubmit

func (t *TextInput) OnSubmit(fn func(string) tea.Cmd)

OnSubmit sets the callback for when text is submitted.

func (*TextInput) Reset

func (t *TextInput) Reset()

Reset clears the text input.

func (*TextInput) SetValue

func (t *TextInput) SetValue(value string)

SetValue sets the text value.

func (*TextInput) Update

func (t *TextInput) Update(msg tea.Msg) (tui.Component, tea.Cmd)

Update handles messages.

func (*TextInput) Value

func (t *TextInput) Value() string

Value returns the current text value.

func (*TextInput) View

func (t *TextInput) View() string

View renders the text input.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL