tui

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 7 Imported by: 0

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

View Source
var ErrCancelled = errors.ErrCanceled

ErrCancelled is returned when the user cancels the selection

Functions

This section is empty.

Types

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
}

Item interface for selectable items

func Run

func Run(items []Item, useColors bool) (Item, int, error)

Run runs the selector and returns the selected item and its original index Returns nil, -1, ErrCancelled if user cancelled, or nil, -1, error for other errors

type Model

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

Model is the Bubbletea model for the selector

func NewModel

func NewModel(items []Item, useColors bool) Model

NewModel creates a new selector model

func (Model) Cancelled

func (m Model) Cancelled() bool

Cancelled returns true if the selection was cancelled

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model

func (Model) Selected

func (m Model) Selected() Item

Selected returns the selected item, or nil if cancelled

func (Model) SelectedIndex

func (m Model) SelectedIndex() int

SelectedIndex returns the original index of the selected item, or -1 if cancelled

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages and updates the model

func (Model) View

func (m Model) View() string

View renders the selector

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

Jump to

Keyboard shortcuts

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