tablepageselect

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxColumnWidth caps how wide a non-rank column can be.
	MaxColumnWidth = 100
	// MinTableHeightRows ensures the viewport is never too small to render properly.
	MinTableHeightRows = 2
	// DefaultPageSize limits visible rows per page.
	DefaultPageSize = 10
)

Variables

View Source
var (
	// ErrNoItems indicates there were no items to select from.
	ErrNoItems = eris.New("no items to select from")
)

Functions

func RunWithHotkeys

func RunWithHotkeys(
	ctx context.Context,
	prompt string,
	columns []string,
	rows [][]string,
	defaultIndex int,
	extraKeys []ExtraKey,
) (int, string, error)

RunWithHotkeys runs the picker with caller-defined shortcuts. It returns an action token when a shortcut closes the picker; an empty token means the user selected a row normally.

Errors: ErrNoItems for empty rows, context.Canceled on Ctrl+C, silent error on esc/abort, wrapped Bubble Tea errors otherwise.

Types

type ExtraKey

type ExtraKey struct {
	Binding key.Binding
	Action  string
	// Secondary hides the binding until the legend expands.
	Secondary bool
}

ExtraKey binds a shortcut to the action returned by the picker.

type Model

type Model struct {
	Prompt     string
	Columns    []string   // excludes the blank rank column
	Rows       [][]string // excludes the rank cell; rank is auto-generated
	Cursor     int        // global selected index across all rows
	NumericBuf string
	Ctx        context.Context
	Aborted    bool
	Canceled   bool

	// ExtraKeys close the picker and report their action through HotkeyAction.
	ExtraKeys    []ExtraKey
	HotkeyAction string

	PageSize int
	// contains filtered or unexported fields
}

Model represents the UI state for paginated selection with a table and prompt.

func InitialModel

func InitialModel(ctx context.Context, prompt string, columns []string, rows [][]string, defaultIndex int) *Model

InitialModel creates a new Model with the given columns, rows, context and default cursor.

func (*Model) Init

func (m *Model) Init() tea.Cmd

func (*Model) Update

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

Update handles user input and updates the model state accordingly.

func (*Model) View

func (m *Model) View() string

View renders the current state of the list and the numeric prompt.

Jump to

Keyboard shortcuts

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