list

package
v1.55.8 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InlineList

type InlineList struct {
	Items SliceView[ListItem]

	Paginator paginator.Model
	// contains filtered or unexported fields
}

func NewInlineList

func NewInlineList(args InlineListArgs) InlineList

func (InlineList) Choice

func (m InlineList) Choice() string

func (InlineList) Init

func (m InlineList) Init() tea.Cmd

func (InlineList) IsPaginationVisible added in v1.54.7

func (m InlineList) IsPaginationVisible() bool

func (*InlineList) SetChoice

func (m *InlineList) SetChoice(choice string)

func (*InlineList) SetMaxDisplayedItems added in v1.54.7

func (m *InlineList) SetMaxDisplayedItems(maxDisplayedItems int)

func (*InlineList) SetMinimized added in v1.54.7

func (m *InlineList) SetMinimized(minimized bool)

func (InlineList) Update

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

func (InlineList) UpdateInlineList

func (m InlineList) UpdateInlineList(msg tea.Msg) (InlineList, tea.Cmd)

UpdateInlineList does the same thing as Update, without erasing the component's type.

useful when composing this model into another model

func (InlineList) View

func (m InlineList) View() string

type InlineListArgs

type InlineListArgs struct {
	Items             []ListItem
	Minimized         bool
	MaxDisplayedItems int
}

type ListItem

type ListItem interface {
	GetItemValue() string
	GetItemDescription() string
}

func StringsToListItems

func StringsToListItems(strings []string) []ListItem

type SliceView added in v1.54.7

type SliceView[T any] struct {
	// contains filtered or unexported fields
}

SliceView sliding window view of a list of items e.g. a list of items that can be displayed in a terminal window, but not all at once It keeps track of the cursor position and the view window, ensuring the cursor is always visible in the sub-slice of items

func NewSliceView added in v1.54.7

func NewSliceView[T any](items []T) SliceView[T]

func (SliceView[T]) All added in v1.54.7

func (m SliceView[T]) All() []T

All returns all items

func (SliceView[T]) Choice added in v1.54.7

func (m SliceView[T]) Choice() T

Choice returns the currently selected item

func (SliceView[T]) Cursor added in v1.54.7

func (m SliceView[T]) Cursor() int

Cursor returns the index of the currently selected item

func (*SliceView[T]) CursorBack added in v1.54.7

func (m *SliceView[T]) CursorBack()

CursorUp moves the cursor up, wrapping around if it reaches the top it also updates the view to ensure the cursor is always visible

func (*SliceView[T]) CursorNext added in v1.54.7

func (m *SliceView[T]) CursorNext()

CursorDown moves the cursor down, wrapping around if it reaches the bottom it also updates the view to ensure the cursor is always visible

func (SliceView[T]) IsChoice added in v1.54.7

func (m SliceView[T]) IsChoice(i int) bool

IsChoice returns true if the index is the currently selected item

func (SliceView[T]) IsChoiceRelative added in v1.54.7

func (m SliceView[T]) IsChoiceRelative(relativeI int) bool

IsChoiceRelative returns true if the index is the currently selected item where the index is relative to the view sub-slice

func (*SliceView[T]) IsInView added in v1.54.7

func (m *SliceView[T]) IsInView(i int) bool

func (SliceView[T]) MaxDisplayedItems added in v1.54.7

func (m SliceView[T]) MaxDisplayedItems() int

MaxDisplayedItems returns the maximum number of items to display Use NumDisplayed to get the actual number of items that will be displayed

func (SliceView[T]) NumDisplayed added in v1.54.7

func (m SliceView[T]) NumDisplayed() int

NumDisplayed is the number of items that will be displayed based on max and total number of items

func (*SliceView[T]) SetCursor added in v1.54.7

func (m *SliceView[T]) SetCursor(cursor int)

SetCursor sets the cursor to the specified index, updating the view as needed if the cursor is out of bounds, it will wrap around

func (*SliceView[T]) SetMaxDisplayedItems added in v1.54.7

func (m *SliceView[T]) SetMaxDisplayedItems(max int)

SetMaxDisplayedItems sets the maximum number of items to display if max is 0 or less, it will display all items

func (*SliceView[T]) UpdateItems added in v1.54.7

func (m *SliceView[T]) UpdateItems(items []T)

func (SliceView[T]) View added in v1.54.7

func (m SliceView[T]) View() []T

View returns the items that should be displayed

func (SliceView[T]) ViewBounds added in v1.54.7

func (m SliceView[T]) ViewBounds() (int, int)

ViewBounds returns the start and end index of the view

func (SliceView[T]) ViewOffset added in v1.54.7

func (m SliceView[T]) ViewOffset() int

ViewOffset returns the index of the first item displayed in the view

type StringItem

type StringItem struct {
	Value string
}

func (StringItem) GetItemDescription

func (s StringItem) GetItemDescription() string

func (StringItem) GetItemValue

func (s StringItem) GetItemValue() string

type UpdateListItemsMsg

type UpdateListItemsMsg []ListItem

Jump to

Keyboard shortcuts

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