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.
Click to show internal directories.
Click to hide internal directories.