Documentation
¶
Overview ¶
Package tui provides terminal user interface components including a fuzzy-search selector for selecting items from lists.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCancelled = errors.ErrCanceled
ErrCancelled is returned when the user cancels the selection
Functions ¶
func RunInputForm ¶ added in v0.2.14
func RunInputForm(fields []InputField, useColors bool) (map[string]string, error)
RunInputForm displays the form and returns collected values. Returns nil map if user cancels (Escape), or error on failure.
Types ¶
type InputField ¶ added in v0.2.14
type InputField struct {
Name string // Parameter name (e.g., "id")
Description string // Optional description for the field
Default string // Default value (from session)
Value string // Current value
IsSecret bool // Whether the field should be masked (password-style input)
}
InputField represents a single input field in the form.
type InputFormModel ¶ added in v0.2.14
type InputFormModel struct {
// contains filtered or unexported fields
}
InputFormModel is a Bubbletea model for multi-field input.
func NewInputFormModel ¶ added in v0.2.14
func NewInputFormModel(fields []InputField, useColors bool) InputFormModel
NewInputFormModel creates a new input form with the given fields.
func (InputFormModel) Canceled ¶ added in v0.2.14
func (m InputFormModel) Canceled() bool
Canceled returns true if the form was canceled.
func (InputFormModel) Init ¶ added in v0.2.14
func (m InputFormModel) Init() tea.Cmd
Init initializes the model.
func (InputFormModel) Submitted ¶ added in v0.2.14
func (m InputFormModel) Submitted() bool
Submitted returns true if the form was submitted.
func (InputFormModel) Values ¶ added in v0.2.14
func (m InputFormModel) Values() map[string]string
Values returns the collected values as a map. Returns nil if the form was canceled.
func (InputFormModel) View ¶ added in v0.2.14
func (m InputFormModel) View() string
View renders the input form.
type InputFormStyles ¶ added in v0.2.14
type InputFormStyles struct {
Title lipgloss.Style
Label lipgloss.Style
LabelFocused lipgloss.Style
Help lipgloss.Style
Cursor lipgloss.Style
}
InputFormStyles holds styling configuration for the input form.
func DefaultInputFormStyles ¶ added in v0.2.14
func DefaultInputFormStyles() InputFormStyles
DefaultInputFormStyles returns the default styling for the input form.
func NoColorInputFormStyles ¶ added in v0.2.14
func NoColorInputFormStyles() InputFormStyles
NoColorInputFormStyles returns styles without colors.
type Item ¶
type Item interface {
// FilterValue returns the string used for fuzzy matching
FilterValue() string
// Title returns the main display text
Title() string
// Description returns secondary text (displayed dimmed)
Description() string
// String returns formatted string for display: [index] title description
String() string
}
Item interface for selectable items
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the Bubbletea model for the selector
func (Model) SelectedIndex ¶
SelectedIndex returns the original index of the selected item, or -1 if cancelled
type Styles ¶
type Styles struct {
Title lipgloss.Style
SelectedItem lipgloss.Style
NormalItem lipgloss.Style
MatchedChars lipgloss.Style
Cursor lipgloss.Style
Help lipgloss.Style
NoResults lipgloss.Style
SearchPrompt lipgloss.Style
MethodGET lipgloss.Style
MethodPOST lipgloss.Style
MethodPUT lipgloss.Style
MethodDELETE lipgloss.Style
MethodPATCH lipgloss.Style
MethodDefault lipgloss.Style
Description lipgloss.Style
Index lipgloss.Style
SelectedIndex lipgloss.Style
}
Styles holds the styling configuration for the selector
func DefaultStyles ¶
func DefaultStyles() Styles
DefaultStyles returns the default styling for the selector
func NoColorStyles ¶
func NoColorStyles() Styles
NoColorStyles returns styles without colors for non-color mode