picker

package
v0.10.11 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCancelled = errors.New("tui picker: selection cancelled")
	ErrNonTTY    = errors.New("tui picker: requires a TTY on stdin and stderr")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Title         string
	Help          string
	Items         []Item
	InitialFilter string
}

type Input

type Input struct {
	Key  Key
	Rune rune
}

type Item

type Item struct {
	ID         string
	Label      string
	Detail     string
	Meta       string
	FilterText string
}

func Run

func Run(input *os.File, screen *os.File, cfg Config) (Item, error)

type Key

type Key int
const (
	KeyRune Key = iota
	KeyUp
	KeyDown
	KeyPageUp
	KeyPageDown
	KeyHome
	KeyEnd
	KeyBackspace
	KeyEnter
	KeyCancel
)

type Model

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

func New

func New(items []Item, initialFilter string) *Model

func (*Model) Filter

func (m *Model) Filter() string

func (*Model) Selected

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

func (*Model) Update

func (m *Model) Update(in Input, pageSize int) Outcome

func (*Model) View

func (m *Model) View(height int) View

type Outcome

type Outcome int
const (
	OutcomeContinue Outcome = iota
	OutcomeAccept
	OutcomeCancel
)

type View

type View struct {
	Filter     string
	Total      int
	MatchCount int
	Offset     int
	Items      []ViewItem
}

type ViewItem

type ViewItem struct {
	Item     Item
	Selected bool
}

Jump to

Keyboard shortcuts

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