Documentation
¶
Index ¶
- type ExpandCollapse
- type ItemAdded
- type ItemDeleted
- type ItemWrapper
- type KeyMap
- type ListItem
- func (i *ListItem[T]) Add(item T, index int) ListItem[T]
- func (i *ListItem[T]) AddMulti(index int, items ...T)
- func (i ListItem[T]) Expanded() bool
- func (r ListItem[T]) FilterValue() string
- func (r ListItem[T]) Flatten() []ListItem[T]
- func (r ListItem[T]) GetChildren() []ListItem[T]
- func (r ListItem[T]) GetParent() *ListItem[T]
- func (r ListItem[T]) IndexWithinParent() int
- func (i ListItem[T]) Point() *ListItem[T]
- func (r ListItem[T]) RModify(fnn func(ListItem[T]))
- func (i *ListItem[T]) SetExpanded(v bool) tea.Cmd
- func (r ListItem[T]) TotalBeneath() int
- func (r *ListItem[T]) Value() *T
- type ListOptions
- type Model
- func (m *Model[T]) AddToRoot(argument ...T)
- func (m *Model[T]) Flatten() (tea.Cmd, []list.Item)
- func (m Model[T]) Init() tea.Cmd
- func (m *Model[T]) NewItem(item T) ListItem[T]
- func (m *Model[T]) SetSize(w, h int)
- func (m Model[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m Model[T]) View() string
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExpandCollapse ¶
type ExpandCollapse[T ItemWrapper[T]] struct { Affected ListItem[T] Collapsed bool }
type ItemDeleted ¶
type ItemDeleted struct {
DeletedIndex int
}
type ItemWrapper ¶
type ItemWrapper[T any] interface { list.Item // finds and returns the index of the child // within the current element's children Find(T) int // should find and return the index of the // current element within its parent IndexWithinParent() int // should return this item's children GetChildren() []T // overwrites the value's children with the given argument. SetChildren([]T) // should return the current element's parent. GetParent() *T // should set the item's parent to the argument. SetParent(*T) // since `value` is not exported from the `ListItem`, // we need a wrapper function to access it. Value() *T // returns how deeply nested the current node is, as an int. // i'd recommend calculating this by checking that `Parent` // is not null in a for loop. Lvl() int // adds an element to this item's children. Add(int, T) // same as Add() but can receive more than one argument! AddMulti(int, ...T) // Removes child at specified index and returns it Remove(int) T // Returns a string representation of this item. ToString() string }
type ListItem ¶
type ListItem[T ItemWrapper[T]] struct { ParentModel *Model[T] // this is a recursive struct, meaning that it can // have 0 or more child elements, which can have 0 // or more child elements, and so on Children *[]ListItem[T] // if it is a top level item, this field will be `nil`. // otherwise contains the element that contains the // current item Parent *ListItem[T] // contains filtered or unexported fields }
func (ListItem[T]) FilterValue ¶
func (ListItem[T]) GetChildren ¶
func (ListItem[T]) IndexWithinParent ¶
func (ListItem[T]) TotalBeneath ¶
type ListOptions ¶
type Model ¶
type Model[T ItemWrapper[T]] struct { List list.Model Options Options // contains filtered or unexported fields }
func New ¶
func New[T ItemWrapper[T]](items []T, delegate list.ItemDelegate, options Options) Model[T]
type Options ¶
type Options struct { ClosedPrefix string OpenPrefix string ListOptions ListOptions Expandable bool Width int Height int Keymap KeyMap }
var DefaultOptions Options = Options{ ClosedPrefix: ">", OpenPrefix: "⌵", Width: 600, Height: 250, Expandable: true, Keymap: DefaultKeys, }
func (*Options) SetExpandable ¶
Click to show internal directories.
Click to hide internal directories.