picker

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HelpHint

type HelpHint struct {
	Key  string
	Desc string
}

HelpHint defines a key/description pair for the footer.

type Model

type Model struct {
	Rows     []Row
	Cursor   int
	Values   []int
	Defaults []int
	Locked   []bool
	IsReset  []bool
	Styles   Styles
	Hints    []HelpHint
}

Model holds the state for an options picker overlay.

func New

func New(rows []Row, values, defaults []int, locked, isReset []bool, styles Styles) Model

New creates a picker Model with the given rows and initial values. defaults, locked, and isReset slices must have the same length as rows.

func (*Model) Cycle

func (m *Model) Cycle()

Cycle advances to the next choice, wrapping around to the first.

func (*Model) Down

func (m *Model) Down()

Down moves the cursor down one row.

func (*Model) Left

func (m *Model) Left()

Left selects the previous choice in the current row (clamped).

func (*Model) Reset

func (m *Model) Reset()

Reset restores the current row to its default value.

func (*Model) Right

func (m *Model) Right()

Right selects the next choice in the current row (clamped).

func (*Model) Up

func (m *Model) Up()

Up moves the cursor up one row.

func (*Model) View

func (m *Model) View() string

View renders the picker overlay as a styled string.

type Row

type Row struct {
	Label   string
	Choices []string
}

Row defines a single option row with a label and selectable choices.

type Styles

type Styles struct {
	Box            lg.Style // outer box style
	Cursor         string   // prefix for the cursor row (e.g. "❯ ")
	CursorLineBG   string   // raw ANSI background escape for cursor row (optional)
	CursorPad      string   // prefix for non-cursor rows (e.g. "  ")
	Default        lg.Style // default (but not selected) choice
	HelpKey        lg.Style // key hint style in footer
	HelpText       lg.Style // text hint style in footer
	Inactive       lg.Style // unselected choices
	Label          lg.Style // regular label style
	LockedInactive lg.Style // unselected choices on locked rows
	LockedLabel    lg.Style // label style for locked rows
	LockedSuffix   string   // text appended to locked rows (e.g. "  (CLI)")
	Selected       lg.Style // currently selected choice
}

Styles controls the visual appearance of the picker overlay.

Jump to

Keyboard shortcuts

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