list

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 4 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[T interface{}] struct {
	// contains filtered or unexported fields
}

Item represents an item in the list

func NewItem

func NewItem[T interface{}](title, prefix string, data T) Item[T]

Create a new item

func (Item[T]) Data

func (i Item[T]) Data() T

Get data

func (Item[T]) Description

func (i Item[T]) Description() string

Get description

func (Item[T]) FilterValue

func (i Item[T]) FilterValue() string

Get value to filter by

func (Item[T]) Prefix

func (i Item[T]) Prefix() string

Get prefix

func (Item[T]) Title

func (i Item[T]) Title() string

Get title

type Model

type Model[T interface{}] struct {
	// contains filtered or unexported fields
}

The list model provides a base list component with the ability to filter

func InitialModel

func InitialModel[T interface{}](ctx *context.ProgramContext, title string) Model[T]

Get new list

func (*Model[T]) GetSelected

func (m *Model[T]) GetSelected() (*Item[T], bool)

Return the selected element

func (Model[T]) Init

func (m Model[T]) Init() tea.Cmd

Init list

func (*Model[T]) Resize

func (m *Model[T]) Resize(width, height int)

Set new with and height

func (*Model[T]) SetItems

func (m *Model[T]) SetItems(items []Item[T])

Set list items

func (Model[T]) Update

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

Update list

func (Model[T]) View

func (m Model[T]) View() string

Render list

Jump to

Keyboard shortcuts

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