list

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package list provides virtualized list rendering for large datasets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListItem

type ListItem interface {
	ID() string
	Render(width int) string
}

ListItem represents an item in the virtual list.

type ScrollableList

type ScrollableList struct {
	*VirtualList
	// contains filtered or unexported fields
}

ScrollableList provides smooth scrolling with animation.

func NewScrollableList

func NewScrollableList() *ScrollableList

NewScrollableList creates a new scrollable list.

func (*ScrollableList) ScrollDown

func (l *ScrollableList) ScrollDown()

ScrollDown scrolls down by one item.

func (*ScrollableList) ScrollToIndex

func (l *ScrollableList) ScrollToIndex(index int, animate bool)

ScrollToIndex scrolls to the given index with optional animation.

func (*ScrollableList) ScrollUp

func (l *ScrollableList) ScrollUp()

ScrollUp scrolls up by one item.

type VirtualList

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

VirtualList provides efficient rendering of large lists by only rendering visible items.

func NewVirtualList

func NewVirtualList() *VirtualList

NewVirtualList creates a new virtual list.

func (*VirtualList) ItemCount

func (l *VirtualList) ItemCount() int

ItemCount returns the number of items.

func (*VirtualList) ScrollBy

func (l *VirtualList) ScrollBy(delta int)

ScrollBy scrolls by the given number of items.

func (*VirtualList) ScrollTo

func (l *VirtualList) ScrollTo(index int)

ScrollTo scrolls to make the given item visible.

func (*VirtualList) ScrollToBottom

func (l *VirtualList) ScrollToBottom()

ScrollToBottom scrolls to the bottom of the list.

func (*VirtualList) Select

func (l *VirtualList) Select(index int)

Select selects the item at the given index.

func (*VirtualList) SelectedIndex

func (l *VirtualList) SelectedIndex() int

SelectedIndex returns the currently selected item index.

func (*VirtualList) SetEstimatedHeight

func (l *VirtualList) SetEstimatedHeight(h int)

SetEstimatedHeight sets the estimated item height for items not yet measured.

func (*VirtualList) SetItemHeight

func (l *VirtualList) SetItemHeight(id string, height int)

SetItemHeight updates the measured height for an item.

func (*VirtualList) SetItems

func (l *VirtualList) SetItems(items []ListItem)

SetItems sets the list items.

func (*VirtualList) SetViewport

func (l *VirtualList) SetViewport(height, width int)

SetViewport sets the viewport dimensions.

func (*VirtualList) TotalHeight

func (l *VirtualList) TotalHeight() int

TotalHeight returns the total height of all items.

func (*VirtualList) VisibleItems

func (l *VirtualList) VisibleItems() []VisibleItem

VisibleItems returns the items visible in the current viewport.

type VisibleItem

type VisibleItem struct {
	Index       int
	Item        ListItem
	Y           int // Y position in viewport
	Height      int // Visible height (may be clipped)
	OffsetY     int // Y offset within item (for partial visibility)
	IsSelected  bool
	TotalHeight int // Total height of the item
}

VisibleItem represents an item visible in the viewport.

Jump to

Keyboard shortcuts

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