Documentation ¶
Index ¶
- type Item
- type ItemDelegate
- type KeyMap
- type Model
- func (m Model) Cursor() int
- func (m *Model) CursorDown()
- func (m *Model) CursorLeft()
- func (m *Model) CursorRight()
- func (m *Model) CursorUp()
- func (m Model) FullHelp() [][]key.Binding
- func (m Model) GetOffset() int
- func (m Model) Height() int
- func (m Model) Index() int
- func (m Model) Items() []Item
- func (m Model) SelectedItem() Item
- func (m *Model) SetDelegate(d ItemDelegate)
- func (m *Model) SetHeight(v int)
- func (m *Model) SetItems(i []Item) tea.Cmd
- func (m *Model) SetShowPagination(v bool)
- func (m *Model) SetShowTitle(v bool)
- func (m *Model) SetSize(width, height int)
- func (m *Model) SetWidth(v int)
- func (m Model) ShortHelp() []key.Binding
- func (m *Model) ShowPagination() bool
- func (m Model) ShowTitle() bool
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- func (m Model) VisibleItems() []Item
- func (m Model) Width() int
- type Styles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item interface { // FilterValue is the value we use when filtering against this item when // we're filtering the list. FilterValue() string }
Item is an item that appears in the list.
type ItemDelegate ¶
type ItemDelegate interface { // Render renders the item's view. Render(w io.Writer, m Model, index int, item Item) // Height is the height of the list item. Height() int // Spacing is the size of the horizontal gap between list items in cells. Spacing() int // Update is the update loop for items. All messages in the list's update // loop will pass through here except when the user is setting a filter. // Use this method to perform item-level updates appropriate to this // delegate. Update(msg tea.Msg, m *Model) tea.Cmd }
ItemDelegate encapsulates the general functionality for all list items. The benefit to separating this logic from the item itself is that you can change the functionality of items without changing the actual items themselves.
Note that if the delegate also implements help.KeyMap delegate-related help items will be added to the help view.
type KeyMap ¶
type KeyMap struct { // Keybindings used when browsing the list. CursorUp key.Binding CursorDown key.Binding CursorLeft key.Binding CursorRight key.Binding NextPage key.Binding PrevPage key.Binding GoToStart key.Binding GoToEnd key.Binding // The quit keybinding. This won't be caught when filtering. Quit key.Binding // The quit-no-matter-what keybinding. This will be caught when filtering. ForceQuit key.Binding }
KeyMap defines keybindings. It satisfies to the help.KeyMap interface, which is used to render the menu.
func DefaultKeyMap ¶
func DefaultKeyMap() KeyMap
DefaultKeyMap returns a default set of keybindings.
type Model ¶
type Model struct { ItemNamePlural string Title string Styles Styles // Key mappings for navigating the list. KeyMap KeyMap Paginator paginator.Model Help help.Model // contains filtered or unexported fields }
Model contains the state of this component.
func New ¶
func New(items []Item, delegate ItemDelegate, width, height int) Model
New returns a new model with sensible defaults.
func (*Model) CursorDown ¶
func (m *Model) CursorDown()
CursorDown moves the cursor down. This can also advance the state to the next page.
func (*Model) CursorLeft ¶
func (m *Model) CursorLeft()
func (*Model) CursorRight ¶
func (m *Model) CursorRight()
func (*Model) CursorUp ¶
func (m *Model) CursorUp()
CursorUp moves the cursor up. This can also move the state to the previous page.
func (Model) Index ¶
Index returns the index of the currently selected item as it appears in the entire slice of items.
func (Model) SelectedItem ¶
SelectedItem returns the current selected item in the list.
func (*Model) SetDelegate ¶
func (m *Model) SetDelegate(d ItemDelegate)
SetDelegate sets the item delegate.
func (*Model) SetShowPagination ¶
SetShowPagination hides or shows the paginator. Note that pagination will still be active, it simply won't be displayed.
func (*Model) SetShowTitle ¶
SetShowTitle shows or hides the title bar.
func (*Model) ShowPagination ¶
ShowPagination returns whether the pagination is visible.
func (Model) VisibleItems ¶
VisibleItems returns the total items available to be shown.
type Styles ¶
type Styles struct { TitleBar lipgloss.Style Title lipgloss.Style NoItems lipgloss.Style PaginationStyle lipgloss.Style HelpStyle lipgloss.Style // Styled characters. ActivePaginationDot lipgloss.Style InactivePaginationDot lipgloss.Style ArabicPagination lipgloss.Style DividerDot lipgloss.Style }
Styles contains style definitions for this list component. By default, these values are generated by DefaultStyles.
func DefaultStyles ¶
func DefaultStyles() (s Styles)
DefaultStyles returns a set of default style definitions for this list component.