picker

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package picker provides reusable list picker components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildInstanceItems

func BuildInstanceItems(cfg *config.Config) []list.Item

BuildInstanceItems converts a config to a sorted slice of list items.

Types

type Config

type Config struct {
	Title  string
	Items  []list.Item
	Width  int
	Height int
}

Config holds configuration for creating a new picker.

type InstanceItem

type InstanceItem struct {
	Name     string
	Instance *config.Instance
	Current  bool
}

InstanceItem wraps a named Instance for display in a picker.

func (InstanceItem) Description

func (i InstanceItem) Description() string

func (InstanceItem) FilterValue

func (i InstanceItem) FilterValue() string

func (InstanceItem) Title

func (i InstanceItem) Title() string

type Item

type Item interface {
	list.Item
	Title() string
	Description() string
}

Item is the interface for items that can be displayed in a picker.

type ItemDelegate

type ItemDelegate struct{}

ItemDelegate renders items in the picker list.

func (ItemDelegate) Height

func (d ItemDelegate) Height() int

func (ItemDelegate) Render

func (d ItemDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item)

func (ItemDelegate) Spacing

func (d ItemDelegate) Spacing() int

func (ItemDelegate) Update

func (d ItemDelegate) Update(_ tea.Msg, _ *list.Model) tea.Cmd

type Model

type Model struct {
	List     list.Model
	Err      error
	Width    int
	Height   int
	Quitting bool
	Chosen   bool
}

Model is the Bubble Tea model for a generic picker.

func New

func New(cfg Config) Model

New creates a new picker Model.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the picker.

func (Model) SelectedItem

func (m Model) SelectedItem() list.Item

SelectedItem returns the currently selected item.

func (Model) Update

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

Update handles messages for the picker.

func (Model) View

func (m Model) View() string

View renders the picker.

Jump to

Keyboard shortcuts

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