simplelist

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeymap = Keymap{
	Open: key.NewBinding(
		key.WithKeys("enter"),
		key.WithHelp("Enter", "Open"),
	),
	Up: key.NewBinding(
		key.WithKeys("up", "k"),
		key.WithHelp("↑/k", "Move up"),
	),
	Down: key.NewBinding(
		key.WithKeys("down", "j"),
		key.WithHelp("↓/j", "Move down"),
	),
	PageUp: key.NewBinding(
		key.WithKeys("shift+up", "K"),
		key.WithHelp("shift+↑/K", "Page up"),
	),
	PageDown: key.NewBinding(
		key.WithKeys("shift+down", "J"),
		key.WithHelp("shift+↓/J", "Page down"),
	),
	QuickSelect: key.NewBinding(
		key.WithKeys("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"),
		key.WithHelp("0-9", "Quick select"),
	),
}

DefaultKeymap is the default keymap for the list

Functions

This section is empty.

Types

type Item

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

Item is an item in the list

func NewItem

func NewItem(title, desc string) Item

NewItem creates a new item

func (Item) Description

func (i Item) Description() string

Description returns the description of the item

func (Item) FilterValue

func (i Item) FilterValue() string

FilterValue returns the title of the item

func (Item) Title

func (i Item) Title() string

Title returns the title of the item

type Keymap

type Keymap struct {
	Open        key.Binding
	Up          key.Binding
	Down        key.Binding
	PageUp      key.Binding
	PageDown    key.Binding
	QuickSelect key.Binding
}

Keymap is the Keymap for the list

type Model

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

Model contains state of the list

func New

func New(colors *theme.Colors, title string, height int, showDesc bool) Model

New creates a new list

func (Model) FullHelp

func (m Model) FullHelp() [][]key.Binding

FullHelp returns the full help for the list

func (Model) GetItem

func (m Model) GetItem(text string) (list.Item, bool)

GetItem checks if the list has an item and returns it

func (Model) Index

func (m Model) Index() int

Index returns the index of the selected item

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the tab

func (*Model) IsEmpty

func (m *Model) IsEmpty() bool

IsEmpty checks if the list is empty

func (Model) Items

func (m Model) Items() []list.Item

Items returns the items in the list

func (Model) SelectedItem

func (m Model) SelectedItem() list.Item

SelectedItem returns the selected item

func (*Model) SetHeight

func (m *Model) SetHeight(height int)

SetHeight sets the height of the list

func (*Model) SetIndex

func (m *Model) SetIndex(index int)

SetIndex sets the index of the selected item

func (*Model) SetItems

func (m *Model) SetItems(items []list.Item)

SetItems sets the items in the list

func (Model) ShortHelp

func (m Model) ShortHelp() []key.Binding

ShortHelp returns the short help for the list

func (Model) Update

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

Update updates the model

func (Model) View

func (m Model) View() string

View returns the view of the list

Jump to

Keyboard shortcuts

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