item

package
v0.0.61 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Cursor     = "x"
	Prompt     = "> "
	Selected   = "x"
	Unselected = " "
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Choice

type Choice map[string]string

Choice is a map[string]string for a single choice

func (Choice) Key

func (c Choice) Key() string

Key returns the key or label

func (Choice) Set

func (c Choice) Set(v string) Choice

Set sets the value

func (Choice) Value

func (c Choice) Value() string

Value returns the string value

type Choices

type Choices []Choice

Choices is a slice of string maps to satisfy the fuzzy.Source interface

func MapToChoices

func MapToChoices[K comparable, V any, M ~map[K]V](c []M) Choices

MapToChoices converts a slice of maps to Choices. Only the first item in the map is collected.

func SliceToChoices

func SliceToChoices[E any](c []E) Choices

SliceToChoices converts a generic slice to Choices. Values are converted to a string using fmt.Sprint and the key is the zero value.

func (Choices) Filter

func (c Choices) Filter(s string) []Item

Filter fuzzy matches items in the list

func (Choices) Len

func (c Choices) Len() int

Len satisfies the fuzzy.Source interface

func (Choices) Set

func (c Choices) Set(idx int, val string)

Set sets the value for an item in the slice

func (Choices) String

func (c Choices) String(i int) string

String satisfies the fuzzy.Source interface

type Item

type Item struct {
	fuzzy.Match

	Label    string
	Current  bool
	Selected bool
	Style    Style
	// contains filtered or unexported fields
}

func ChoicesToItems

func ChoicesToItems(options Choices) []Item

func New

func New() Item

func (*Item) Exec

func (i *Item) Exec(cmd *exec.Cmd)

func (Item) Render

func (i Item) Render(w, h int) string

func (*Item) SetIndex

func (i *Item) SetIndex(idx int) *Item

func (*Item) SetLabel

func (i *Item) SetLabel(l string) *Item

func (*Item) SetMatch

func (i *Item) SetMatch(m fuzzy.Match) *Item

func (*Item) SetValue

func (i *Item) SetValue(val string) *Item

type Style

type Style struct {
	Selected   lipgloss.Style
	Unselected lipgloss.Style
	Cursor     lipgloss.Style
	Match      lipgloss.Style
	Label      lipgloss.Style
}

func DefaultStyle

func DefaultStyle() Style

Jump to

Keyboard shortcuts

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