list

package
v0.0.0-...-8079059 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Showcase

func Showcase()

Showcase demonstrates all features of the Model component by creating a list model with some items and running an interactive example in the terminal.

Types

type Item

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

Item represents an item in the list.

func NewItem

func NewItem(title, desc string) *Item

NewItem returns a new item.

func (*Item) Description

func (i *Item) Description() string

Description returns the description of the list item.

func (*Item) FilterValue

func (i *Item) FilterValue() string

FilterValue returns the value used for filtering the list item.

func (*Item) Title

func (i *Item) Title() string

Title returns the title of the list item.

type Items

type Items []*Item

Items represents an array of items.

type Model

type Model struct {
	List list.Model // List is the list model.
	// contains filtered or unexported fields
}

Model represents the list model.

func New

func New(items ...*Item) *Model

New creates and returns a new Model with default settings.

func (*Model) Canceled

func (m *Model) Canceled() bool

Canceled returns the canceled flag.

func (*Model) Init

func (m *Model) Init() tea.Cmd

Init initializes the Model and returns a nil command.

func (*Model) Quit

func (m *Model) Quit() bool

Quit returns the quit flag.

func (*Model) SelectedItem

func (m *Model) SelectedItem() *Item

SelectedItem returns the selected item.

func (*Model) Update

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

Update handles user input and updates the list state by processing key messages and updating the selected item accordingly.

func (Model) View

func (m Model) View() string

View renders the list as a string, displaying the list items with their respective styles.

func (*Model) WithCancel

func (m *Model) WithCancel(cancelable bool) *Model

WithCancel sets the cancelable flag and returns a new Model with the updated flag.

func (*Model) WithItems

func (m *Model) WithItems(items ...list.Item) *Model

WithItems sets the list items and returns a new Model with the updated items.

func (*Model) WithQuit

func (m *Model) WithQuit(quitable bool) *Model

WithQuit sets the quitable flag and returns a new Model with the updated flag.

func (*Model) WithSelectedIndex

func (m *Model) WithSelectedIndex(i int) *Model

WithSelectedIndex sets the index of the initially selected item and returns a new Model with the updated selected index.

Jump to

Keyboard shortcuts

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