widgetlist

package
v0.0.0-...-839ffb1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilterState

type FilterState int

FilterState Taken from github.com/charmbracelet/bubbles/list/list.go FilterState describes the current filtering state on the model.

const (
	Unfiltered    FilterState = iota // no filter set
	Filtering                        // user is actively setting a filter
	FilterApplied                    // a filter is applied and user is not editing filter
)

Possible filter states.

func (FilterState) String

func (f FilterState) String() string

String returns a human-readable string of the current filter state.

type FilteredItem

type FilteredItem struct {
	Index int // corresponding global index
}

type FilteredItems

type FilteredItems []FilteredItem

func BasicFilter

func BasicFilter[T any](items *[]ListItem[T], s string) FilteredItems

func FuzzyFilter

func FuzzyFilter[T any](items *[]ListItem[T], s string) FilteredItems

type ItemConstructor

type ItemConstructor[T any] func(T) ListItem[T]

ItemConstructor defines the signature of the item constructor. T type represents the type of the item data.

type ListFilter

type ListFilter[T any] func(items *[]ListItem[T], s string) FilteredItems

type ListItem

type ListItem[T any] interface {
	orvyn.Focusable
	orvyn.Renderable
	FilterValue() string
	UpdateData(data T)
	GetData() T
}

func SimpleListItemConstructor

func SimpleListItemConstructor(value string) ListItem[string]

type SimpleListItem

type SimpleListItem struct {
	orvyn.BaseWidget
	orvyn.BaseFocusable
	// contains filtered or unexported fields
}

func (*SimpleListItem) FilterValue

func (s *SimpleListItem) FilterValue() string

func (*SimpleListItem) GetData

func (s *SimpleListItem) GetData() string

func (*SimpleListItem) Render

func (s *SimpleListItem) Render() string

func (*SimpleListItem) Resize

func (s *SimpleListItem) Resize(size orvyn.Size)

func (*SimpleListItem) UpdateData

func (s *SimpleListItem) UpdateData(value string)

type Widget

type Widget[T any] struct {
	orvyn.BaseWidget
	orvyn.BaseFocusable

	InfiniteScroll   bool
	AutoFocusNewItem bool

	CursorMovingCallback func(int)
	CursorMovedCallback  func(int)

	Filter ListFilter[T]
	// contains filtered or unexported fields
}

Widget defines a widgetlist widget. T type represents the type of the item data.

func New

func New[T any](itemConstructor ItemConstructor[T]) *Widget[T]

New creates a new *Widget widgetlist and takes an itemConstructor as parameter. T type represents the type of the item data.

func (*Widget[T]) AppendItem

func (w *Widget[T]) AppendItem(data T)

func (*Widget[T]) BlurCurrent

func (w *Widget[T]) BlurCurrent()

func (*Widget[T]) FilterState

func (w *Widget[T]) FilterState() FilterState

func (*Widget[T]) FocusFirst

func (w *Widget[T]) FocusFirst()

func (*Widget[T]) GetGlobalIndex

func (w *Widget[T]) GetGlobalIndex() int

func (*Widget[T]) GetItem

func (w *Widget[T]) GetItem(index int) T

func (*Widget[T]) GetItems

func (w *Widget[T]) GetItems() []T

func (*Widget[T]) GetSelectedItem

func (w *Widget[T]) GetSelectedItem() T

func (*Widget[T]) Init

func (w *Widget[T]) Init() tea.Cmd

func (*Widget[T]) InsertItem

func (w *Widget[T]) InsertItem(index int, data T)

func (*Widget[T]) IsInputting

func (w *Widget[T]) IsInputting() bool

func (*Widget[T]) Length

func (w *Widget[T]) Length() int

Length returns the count of items in the list.

func (*Widget[T]) MoveItem

func (w *Widget[T]) MoveItem(startIndex, destIndex int)

func (*Widget[T]) NextItem

func (w *Widget[T]) NextItem()

NextItem manages the focus of the next item.

func (*Widget[T]) OnBlur

func (w *Widget[T]) OnBlur()

func (*Widget[T]) OnFocus

func (w *Widget[T]) OnFocus()

func (*Widget[T]) PreviousItem

func (w *Widget[T]) PreviousItem()

PreviousItem manages the focus of the previous item.

func (*Widget[T]) RemoveItem

func (w *Widget[T]) RemoveItem(index int)

func (*Widget[T]) Render

func (w *Widget[T]) Render() string

func (*Widget[T]) Resize

func (w *Widget[T]) Resize(size orvyn.Size)

func (*Widget[T]) SetCursorMovementKeybinds

func (w *Widget[T]) SetCursorMovementKeybinds(cursorUp, cursorDown key.Binding)

func (*Widget[T]) SetFilterPlaceholder

func (w *Widget[T]) SetFilterPlaceholder(s string)

func (*Widget[T]) SetFilterable

func (w *Widget[T]) SetFilterable(filterable bool)

func (*Widget[T]) SetItem

func (w *Widget[T]) SetItem(index int, data T)

func (*Widget[T]) SetItems

func (w *Widget[T]) SetItems(items []T)

SetItems takes a []T (slice of data) and instantiate all items based on it.

func (*Widget[T]) Update

func (w *Widget[T]) Update(msg tea.Msg) tea.Cmd

Jump to

Keyboard shortcuts

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