list

package
v14.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 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 Entries

type Entries[S fmt.Stringer] []Entry[S]

Entries provides methods for a collection of Entry instances.

func NewEntries

func NewEntries[S fmt.Stringer](records ...S) Entries[S]

NewEnabledListEntries creates Entries for the given data types.

func (Entries[S]) AllDisabled

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

AllDisabled indicates whether all entries in this list are disabled.

func (Entries[S]) IndexWithText

func (self Entries[S]) IndexWithText(text string) (found bool, index int)

IndexWithText provides the index of the element with the given text.

func (Entries[S]) IndexWithTextOr

func (self Entries[S]) IndexWithTextOr(text string, defaultIndex int) int

IndexWithTextOr provides the index of the element with the given text or the given default index if the element isn't in this collection.

type Entry

type Entry[S fmt.Stringer] struct {
	Data    S
	Enabled bool
	Text    string
}

Entry is an entry in a List instance.

func (Entry[S]) String

func (self Entry[S]) String() string

implement fmt.Stringer interface

type List

type List[S fmt.Stringer] 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 fmt.Stringer](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