list

package
v20.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package list provides a generic list implementation to be used inside BubbleTea-based dialog components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComparableStringer

type ComparableStringer interface {
	comparable
	fmt.Stringer
}

narrower type needed to use the NewEntries convenience function

type Entries

type Entries[S comparable] []Entry[S]

Entries provides methods for a collection of Entry instances.

func NewEntries

func NewEntries[S ComparableStringer](records ...S) Entries[S]

creates an Entries instance containing the given records

func (Entries[S]) AllDisabled

func (self Entries[S]) AllDisabled() bool

indicates whether all entries in this list are disabled

func (Entries[S]) IndexOf

func (self Entries[S]) IndexOf(needle S) int

provides the position of the given needle in this list

func (Entries[S]) IndexOfFunc

func (self Entries[S]) IndexOfFunc(needle S, equalFn func(a, b S) bool) int

provides the position of the given needle in this list

type Entry

type Entry[S comparable] struct {
	Data     S
	Disabled bool `exhaustruct:"optional"`
	Text     string
}

Entry is an entry in a List instance.

type List

type List[S comparable] struct {
	Colors       colors.DialogColors // colors to use for help text
	Cursor       int                 // index of the currently selected row
	Entries      Entries[S]          // the entries to select from
	EntryNumber  string              // the manually entered entry number
	MaxDigits    int                 // how many digits make up an entry number
	NumberFormat string              // template for formatting the entry number
	Status       Status
}

List contains elements and operations common to all BubbleTea-based list implementations.

func NewList

func NewList[S comparable](entries Entries[S], cursor int) List[S]

func (*List[S]) Aborted

func (self *List[S]) Aborted() bool

Aborted indicates whether the user has Aborted this components.

func (*List[S]) EntryNumberStr

func (self *List[S]) EntryNumberStr(number int) string

EntryNumberStr provides a colorized string to print the given entry number.

func (*List[S]) HandleKey

func (self *List[S]) HandleKey(key tea.KeyMsg) (bool, tea.Cmd)

HandleKey handles keypresses that are common for all bubbleLists.

func (*List[S]) MoveCursorDown

func (self *List[S]) MoveCursorDown()

func (*List[S]) MoveCursorUp

func (self *List[S]) MoveCursorUp()

func (*List[S]) MovePageDown

func (self *List[S]) MovePageDown()

func (*List[S]) MovePageUp

func (self *List[S]) MovePageUp()

func (List[S]) SelectedData

func (self List[S]) SelectedData() S

func (List[S]) SelectedEntry

func (self List[S]) SelectedEntry() Entry[S]

type Status

type Status int
const (
	StatusActive  Status = iota // the user is currently entering data into the dialog
	StatusDone                  // the user has made a selection
	StatusAborted               // the user has aborted the dialog
)

Jump to

Keyboard shortcuts

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