picker

package
v0.270.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package picker is a small vertical single-select list with per-row descriptions. It is the chooser `ofga init` and the `ofga mappings` workspace use for short, fixed sets of options, where bubbles' filterable list would be more machinery than the choice deserves.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clamp

func Clamp(s string, w int) string

Clamp truncates s to w display cells, marking the cut with an ellipsis. A non-positive width leaves s alone.

Types

type Item

type Item struct {
	Title string
	Desc  string
	Value string
}

Item is one row: a title, an optional description line, and the value the caller switches on once it is selected.

type Picker

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

Picker holds the rows and the cursor.

func New

func New(items []Item) *Picker

New builds a picker over items, with the first row selected.

func (*Picker) Cursor

func (p *Picker) Cursor() int

Cursor returns the highlighted row index.

func (*Picker) Len

func (p *Picker) Len() int

Len returns the number of rows.

func (*Picker) Move

func (p *Picker) Move(d int)

Move advances the cursor by d rows, wrapping at both ends.

func (*Picker) Selected

func (p *Picker) Selected() Item

Selected returns the highlighted item, or the zero Item when there are none.

func (*Picker) SetCursor

func (p *Picker) SetCursor(i int)

SetCursor highlights row i, clamped into range. Used to pre-select the row matching a value carried in from a flag or an existing document.

func (*Picker) View

func (p *Picker) View(width int) string

View renders the rows stacked, the selected one marked and bolded.

Jump to

Keyboard shortcuts

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