components

package
v12.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package dialog contains shared components to build full dialog screens out of.

Index

Constants

View Source
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
)
View Source
const TestInputKey = "GITTOWN_DIALOG_INPUT"

TestInputKey specifies the name of environment variables containing input for dialogs in end-to-end tests.

View Source
const WindowSize = 9

how many elements to display in the dialog

Variables

This section is empty.

Functions

func FormattedSecret

func FormattedSecret(secret string, aborted bool) string

FormattedToken provides the given API token in a printable format.

func FormattedSelection

func FormattedSelection(selection string, aborted bool) string

FormattedSelection provides the given dialog choice in a printable format.

func FormattedToken

func FormattedToken(token string, aborted bool) string

FormattedToken provides the given API token in a printable format.

func RadioList

func RadioList[S fmt.Stringer](entries []S, cursor int, title, help string, inputs TestInput) (selected S, aborted bool, err error)

RadioList lets the user select a new main branch for this repo.

func Red added in v12.1.0

func Red() termenv.Style

func SendInputs added in v12.1.0

func SendInputs(inputs TestInput, program *tea.Program)

SendInputs sends the given keystrokes to the given bubbletea program.

func TextDisplay

func TextDisplay(title, text string, inputs TestInput) (bool, error)

func TextField

func TextField(args TextFieldArgs) (string, bool, error)

Types

type BubbleList

type BubbleList[S fmt.Stringer] struct {
	Colors       dialogColors  // colors to use for help text
	Cursor       int           // index of the currently selected row
	Dim          termenv.Style // style for dim output
	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
}

BubbleList contains common elements of BubbleTea list implementations.

func NewBubbleList

func NewBubbleList[S fmt.Stringer](entries []S, cursor int) BubbleList[S]

func (*BubbleList[S]) Aborted

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

Aborted indicates whether the user has Aborted this components.

func (*BubbleList[S]) EntryNumberStr

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

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

func (*BubbleList[S]) HandleKey

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

HandleKey handles keypresses that are common for all bubbleLists.

func (BubbleList[S]) SelectedEntry

func (self BubbleList[S]) SelectedEntry() S

type TestInput

type TestInput []tea.Msg

TestInput contains the input for a single dialog in an end-to-end test.

func ParseTestInput

func ParseTestInput(envData string) TestInput

ParseTestInput converts the given input data in the environment variable format into the format understood by Git Town's dialogs.

type TestInputs

type TestInputs []TestInput

TestInputs contains the input for all dialogs in an end-to-end test.

func LoadTestInputs

func LoadTestInputs(environmenttVariables []string) TestInputs

LoadTestInputs provides the TestInputs to use in an end-to-end test, taken from the given environment variable snapshot.

func (*TestInputs) Next

func (self *TestInputs) Next() TestInput

Next provides the TestInput for the next dialog in an end-to-end test.

type TextFieldArgs

type TextFieldArgs struct {
	ExistingValue string
	Help          string
	Prompt        string
	TestInput     TestInput
	Title         string
}

Jump to

Keyboard shortcuts

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