list

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 3 Imported by: 3 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package list renders a cursor-and-scroll list over pre-rendered row blocks.

Rows arrive as Items whose Block text is already styled and wrapped; the model owns only selection and viewport state. It is not a tea model — deck views and CLI panes drive it by calling Move/Scroll and printing View.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	Block      string
	Key        string
	Selectable bool
	GapStem    string
	// Payload carries the caller's domain value for the row, handed back by
	// Selected and selection callbacks so callers need no key→value side table.
	Payload any
}

Item is one list row. Block is the pre-rendered (possibly multi-line) body; Key identifies the row to the caller; unselectable rows are skipped by the cursor. GapStem, when set, is repeated in the blank line drawn after the row so tree rules survive the gap.

type Model

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

Model is the list state: rows plus cursor, scroll offset, size, and focus. Callers mutate it with SetItems/Move/Scroll and render it with View; it is not a Bubble Tea model and has no Update loop.

func New

func New() Model

New returns an empty model with no selection.

func (*Model) EnsureVisible added in v0.1.17

func (m *Model) EnsureVisible()

EnsureVisible scrolls just enough to bring the selected row into view.

func (*Model) Height added in v0.1.7

func (m *Model) Height() int

Height returns the viewport height set by SetSize.

func (*Model) Move

func (m *Model) Move(delta int)

Move steps the cursor by delta over selectable rows, scrolling as needed; with no selectable rows it scrolls the viewport instead.

func (*Model) Scroll

func (m *Model) Scroll(delta int)

Scroll shifts the viewport by delta lines and drags the cursor along so it stays on a visible row.

func (*Model) Selectable

func (m *Model) Selectable() bool

Selectable reports whether any row currently holds the cursor.

func (*Model) Selected

func (m *Model) Selected() (Item, bool)

Selected returns the row under the cursor, if any.

func (*Model) SetFocused

func (m *Model) SetFocused(f bool)

SetFocused switches the cursor glyph between focused and dimmed styles.

func (*Model) SetItems

func (m *Model) SetItems(items []Item)

SetItems replaces the rows and resets cursor and scroll to the top.

func (*Model) SetItemsKeepingCursor added in v0.1.13

func (m *Model) SetItemsKeepingCursor(items []Item)

SetItemsKeepingCursor replaces the rows while trying to keep the current selection: first by Key, then by index, falling back to the first selectable row.

func (*Model) SetSize

func (m *Model) SetSize(w, h int)

SetSize sets the viewport dimensions in cells; height bounds View's output.

func (*Model) SetTheme added in v0.2.2

func (m *Model) SetTheme(t theme.Theme)

SetTheme pins the theme View renders with; unset, the process default applies.

func (*Model) View

func (m *Model) View() string

View renders the visible window of rows as a plain string.

Jump to

Keyboard shortcuts

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