listbox

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item interface {
	Display() string // what will be displayed
	ID() string      // unique identifier
}

Item is the minimal interface the list needs.

type ListModel

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

ListModel represents a scrollable list component

func New

func New(maxVisible int) ListModel

New creates a new ListModel with the specified maximum visible items

func (ListModel) Cursor

func (m ListModel) Cursor() int

Cursor returns the current cursor position

func (ListModel) Init

func (m ListModel) Init() tea.Cmd

Init initializes the model

func (ListModel) Selected

func (m ListModel) Selected() Item

Selected returns the currently selected item, or nil if there are no items

func (*ListModel) SetItems

func (m *ListModel) SetItems(items []Item) tea.Cmd

SetItems updates the items in the list

func (*ListModel) SetPointer

func (m *ListModel) SetPointer(pointer string)

SetPointer changes the pointer rune used to indicate selection

func (ListModel) Update

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

Update handles incoming messages and updates the model accordingly

func (ListModel) View

func (m ListModel) View() string

View renders the list

type SelectedMsg

type SelectedMsg struct {
	Item Item
}

SelectedMsg is emitted when an item is selected

Jump to

Keyboard shortcuts

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