tableselect

package
v0.20.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// MaxColumnWidth caps how wide a non-rank column can be.
	MaxColumnWidth = 30
	// MinTableHeightRows ensures the viewport is never too small to render properly.
	MinTableHeightRows = 2
)

Variables

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

Functions

func Run

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

Run executes the numeric selection UI.

Types

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
	NumericBuf string
	Ctx        context.Context
	Aborted    bool
	// contains filtered or unexported fields
}

Model represents the UI state for numeric 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