components

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 32 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InputDefaultRequired            = false
	InputDefaultRequiredMsg         = style.New().Fg(color.Red).Render("please input text!")
	InputDefaultRequiredMsgKeepTime = time.Second * 3
	InputDefaultStatus              = Focus
	InputDefaultPrompt              = "> "
	InputDefaultValue               = strx.Empty
	InputDefaultBlinkSpeed          = time.Millisecond * 530
	InputDefaultEchoMode            = EchoNormal
	InputDefaultEchoCharacter       = '*'
	InputDefaultCharLimit           = 0
	InputDefaultPlaceholderStyle    = style.New().Fg(color.Gray)
	InputDefaultPromptStyle         = style.New()
	InputDefaultTextStyle           = style.New()
	InputDefaultCursorStyle         = style.New()
)
View Source
var (
	PrefixFatal = style.New().Fg(color.Red).Render("FATAL ")
	PrefixError = style.New().Fg(color.RedPink).Render("ERROR ")
	PrefixWarn  = style.New().Fg(color.Orange).Render("WARN ")
	PrefixInfo  = style.New().Fg(color.Special).Render("INFO ")
	PrefixDebug = style.New().Fg(color.Gray).Render("DEBUG ")

	PrefixSuccess = style.New().Fg(color.Special).Render("SUCCESS ")
	PrefixFailed  = style.New().Fg(color.Red).Render("FAILED ")
)

default prefix

View Source
var (
	ProgressDefaultTotal           int64 = 100
	ProgressDefaultCurrent         int64 = 0
	ProgressDefaultPercentAgeFunc        = DefaultPercentAgeFunc
	ProgressDefaultPercentAgeStyle       = style.New().Inline()
	ProgressDefaultWidth                 = 45
	ProgressDefaultFull                  = '█'
	ProgressDefaultFullColor             = "#7571F9"
	ProgressDefaultEmpty                 = '░'
	ProgressDefaultEmptyColor            = "#606060"
	ProgressDefaultShowPercentage        = true
	ProgressDefaultShowCost              = true
	ProgressDefaultPrevAmount      int64 = 0
	ProgressDefaultCostView              = DefaultCostView
	ProgressDefaultTickCostDelay         = time.Millisecond * 100
)
View Source
var (
	SelectionDefaultCursorSymbol        = ">"
	SelectionDefaultUnCursorSymbol      = " "
	SelectionDefaultCursorSymbolStyle   = theme.DefaultTheme.CursorSymbolStyle
	SelectionDefaultChoiceTextStyle     = theme.DefaultTheme.ChoiceTextStyle
	SelectionDefaultPrompt              = "Please Selection your options:"
	SelectionDefaultPromptStyle         = style.New().Bold().Fg(color.White)
	SelectionDefaultHintSymbol          = "✓"
	SelectionDefaultHintSymbolStyle     = theme.DefaultTheme.MultiSelectedHintSymbolStyle
	SelectionDefaultUnHintSymbol        = "✗"
	SelectionDefaultUnHintSymbolStyle   = theme.DefaultTheme.UnHintSymbolStyle
	SelectionDefaultDisableOutPutResult = false
	SelectionDefaultPageSize            = 5
	SelectionDefaultHelp                = help.New()
	SelectionDefaultRowRender           = DefaultRowRender
	SelectionDefaultEnableFilter        = true
	SelectionDefaultFilterInput         = NewInput()
	SelectionDefaultFilterFunc          = DefaultFilterFunc
	SelectionDefaultShowHelp            = true
)
View Source
var (
	Line = Shape{
		Frames: []string{"|", "/", "-", "\\"},
		FPS:    time.Second / 10,
	}
	Dot = Shape{
		Frames: []string{"⣾ ", "⣽ ", "⣻ ", "⢿ ", "⡿ ", "⣟ ", "⣯ ", "⣷ "},
		FPS:    time.Second / 10,
	}
	MiniDot = Shape{
		Frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"},
		FPS:    time.Second / 12,
	}
	Jump = Shape{
		Frames: []string{"⢄", "⢂", "⢁", "⡁", "⡈", "⡐", "⡠"},
		FPS:    time.Second / 10,
	}
	Pulse = Shape{
		Frames: []string{"█", "▓", "▒", "░"},
		FPS:    time.Second / 8,
	}
	Points = Shape{
		Frames: []string{"∙∙∙", "●∙∙", "∙●∙", "∙∙●"},
		FPS:    time.Second / 7,
	}
	Globe = Shape{
		Frames: []string{"🌍", "🌎", "🌏"},
		FPS:    time.Second / 4,
	}
	Moon = Shape{
		Frames: []string{"🌑", "🌒", "🌓", "🌔", "🌕", "🌖", "🌗", "🌘"},
		FPS:    time.Second / 8,
	}
	Monkey = Shape{
		Frames: []string{"🙈", "🙉", "🙊"},
		FPS:    time.Second / 3,
	}
	Meter = Shape{
		Frames: []string{
			"▱▱▱",
			"▰▱▱",
			"▰▰▱",
			"▰▰▰",
			"▰▰▱",
			"▰▱▱",
			"▱▱▱",
		},
		FPS: time.Second / 7,
	}
	Hamburger = Shape{
		Frames: []string{"☱", "☲", "☴", "☲"},
		FPS:    time.Second / 3,
	}
	Running = Shape{
		Frames: []string{emoji.Walking, emoji.Running},
		FPS:    time.Second / 6,
	}
)

Some spinners to choose from. You could also make your own.

View Source
var (
	SpinnerDefaultModel               = spinner.New()
	SpinnerDefaultShape               = Line
	SpinnerDefaultShapeStyle          = theme.DefaultTheme.SpinnerShapeStyle
	SpinnerDefaultPrompt              = "Loading..."
	SpinnerDefaultDisableOutPutResult = false
	SpinnerDefaultStatus              = Normal
)
View Source
var (
	InterruptKey = key.NewBinding(
		key.WithKeys("ctrl+c"),
		key.WithHelp("^C", "kill program"),
	)
)

Functions

func BlurCmd

func BlurCmd() tea.Msg

func DefaultCostView added in v0.5.1

func DefaultCostView(cost time.Duration, total, current, prevAmount int64) string

func DefaultPercentAgeFunc

func DefaultPercentAgeFunc(total, current int64, percent float64) string

func DefaultRowRender

func DefaultRowRender(cursorSymbol string, hintSymbol string, choice string) string

func FinishCmd added in v0.7.5

func FinishCmd() tea.Msg

func FocusCmd

func FocusCmd() tea.Msg

func IsFinish added in v0.8.1

func IsFinish(status Status) bool

IsFinish status == Finish ?

func NewLineSuggestionRender added in v0.6.1

func NewLineSuggestionRender(suggestionItems []string, a *Autocomplete) string

func QuitCmd

func QuitCmd() tea.Msg

func TabSuggestionRender added in v0.6.1

func TabSuggestionRender(suggestionItems []string, a *Autocomplete) string

Types

type Autocomplete added in v0.5.1

type Autocomplete struct {
	/* custom */
	Input                *Input
	Suggester            Suggester
	Completer            Completer
	KeyMap               AutocompleteKeyMap
	SelectionCreator     func(options []string, a *Autocomplete) *Selection
	SuggestionViewRender func(suggestionItems []string, a *Autocomplete) string

	Padding int
	Program *tea.Program
	*PrintHelper
	Selection          *Selection
	ShowSelection      bool
	ShouldNewSelection bool
}

func NewAutocomplete added in v0.5.1

func NewAutocomplete(suggester Suggester) *Autocomplete

NewAutocomplete constructor

func (*Autocomplete) Init added in v0.5.1

func (a *Autocomplete) Init() tea.Cmd

func (*Autocomplete) SetProgram added in v0.5.1

func (a *Autocomplete) SetProgram(program *tea.Program)

func (*Autocomplete) Update added in v0.5.1

func (a *Autocomplete) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Autocomplete) Value added in v0.5.1

func (a *Autocomplete) Value() string

Value get user Input

func (*Autocomplete) View added in v0.5.1

func (a *Autocomplete) View() string

func (*Autocomplete) WithCompleter added in v0.5.2

func (a *Autocomplete) WithCompleter(completer Completer) *Autocomplete

WithCompleter DefaultCompleter

func (*Autocomplete) WithInput added in v0.5.1

func (a *Autocomplete) WithInput(input *Input) *Autocomplete

func (*Autocomplete) WithKeyMap added in v0.5.1

func (a *Autocomplete) WithKeyMap(keyMap AutocompleteKeyMap) *Autocomplete

WithKeyMap DefaultAutocompleteKeyMap

func (*Autocomplete) WithSelectionCreator added in v0.5.1

func (a *Autocomplete) WithSelectionCreator(f func(suggester []string, a *Autocomplete) *Selection) *Autocomplete

WithSelectionCreator DefaultSelectionCreator

func (*Autocomplete) WithSuggestionViewRender added in v0.6.1

func (a *Autocomplete) WithSuggestionViewRender(f func(suggestionItems []string, a *Autocomplete) string) *Autocomplete

WithSuggestionViewRender Two implementations are provided by default: NewLineSuggestionRender or TabSuggestionRender, of course you can also choose to implement your own `render`

type AutocompleteKeyMap added in v0.5.1

type AutocompleteKeyMap struct {
	Quit           key.Binding
	CloseSelection key.Binding
	Up             key.Binding
	Down           key.Binding
	Complete       key.Binding
	GotoEnd        key.Binding
}

func DefaultAutocompleteKeyMap added in v0.5.1

func DefaultAutocompleteKeyMap() AutocompleteKeyMap

type AutocompleteValCtx added in v0.5.2

type AutocompleteValCtx struct {
	Cursor int
	Value  string
	// contains filtered or unexported fields
}

func (AutocompleteValCtx) CursorVal added in v0.5.2

func (a AutocompleteValCtx) CursorVal() string

CursorVal a.Value[:a.Cursor]

func (AutocompleteValCtx) CursorWord added in v0.5.2

func (a AutocompleteValCtx) CursorWord() string

CursorWord current word

type Completer added in v0.5.2

type Completer func(valCtx AutocompleteValCtx, choiceWord string) (newVal string, newCursor int)

Completer result (newValue,newCursor) DefaultCompleter

func DefaultCompleter added in v0.5.2

func DefaultCompleter() Completer

type Components

type Components interface {
	tea.Model

	// SetProgram this method will be called back when the tea.Program starts.
	// please keep passing this method
	SetProgram(program *tea.Program)
}

Components, You can use these components directly:

  1. Input
  2. Selection
  3. Spinner
  4. Autocomplete
  5. Progress

Or use them inline in your custom component, for how to embed them, you can refer to the implementation of `Confirm`.

type CursorMode

type CursorMode int

CursorMode describes the behavior of the cursor.

const (
	CursorBlink CursorMode = iota
	CursorStatic
	CursorHide
)

func (CursorMode) Map

func (c CursorMode) Map() cursor.Mode

func (CursorMode) String

func (c CursorMode) String() string

String returns the cursor mode in a human-readable format. This method is provisional and for informational purposes only.

type EchoMode

type EchoMode int

EchoMode sets the Input behavior of the text Input field.

const (
	// EchoNormal displays text as is. This is the default behavior.
	EchoNormal EchoMode = iota
	// EchoPassword displays the EchoCharacter mask instead of actual
	// characters.  This is commonly used for password fields.
	EchoPassword
	// EchoNone displays nothing as characters are entered. This is commonly
	// seen for password fields on the command line.
	EchoNone
)

type Input

type Input struct {
	Model textinput.Model

	FocusPrompt   string
	UnFocusPrompt string

	OutputResult             bool
	Required                 bool
	RequiredMsg              string
	RequiredMsgKeepAliveTime time.Duration

	BlinkSpeed    time.Duration
	Status        Status
	EchoMode      EchoMode
	EchoCharacter rune
	// CharLimit is the maximum amount of characters this Input element will
	// accept. If 0 or less, there's no limit.
	CharLimit int

	Prompt       string
	DefaultValue string

	PromptStyle       *style.Style
	DefaultValueStyle *style.Style

	FocusSymbol     string
	UnFocusSymbol   string
	FocusInterval   string
	UnFocusInterval string

	FocusSymbolStyle     *style.Style
	UnFocusSymbolStyle   *style.Style
	FocusIntervalStyle   *style.Style
	UnFocusIntervalStyle *style.Style

	TextStyle   *style.Style
	CursorStyle *style.Style
	KeyMap      InputKeyMap
	// contains filtered or unexported fields
}

Input the Input component.

func NewInput

func NewInput() *Input

NewInput constructor

func (i *Input) Blink() bool

Blink returns whether or not to draw the cursor.

func (*Input) Blur

func (i *Input) Blur()

Blur removes the Focus state on the model. When the model is blurred it can not receive keyboard Input and the cursor will be hidden.

func (*Input) Cursor

func (i *Input) Cursor() int

Cursor returns the cursor position. deprecated: use Position() instead.

func (*Input) CursorEnd

func (i *Input) CursorEnd()

CursorEnd moves the cursor to the end of the Input field.

func (*Input) CursorMode

func (i *Input) CursorMode() CursorMode

CursorMode returns the model's cursor mode. For available cursor modes, see type CursorMode.

func (*Input) CursorStart

func (i *Input) CursorStart()

CursorStart moves the cursor to the start of the Input field.

func (*Input) Focus

func (i *Input) Focus()

Focus sets the Focus state on the model. When the model is in Focus it can receive keyboard Input and the cursor will be hidden.

func (*Input) Focused

func (i *Input) Focused() bool

Focused returns the focus state on the model.

func (*Input) Init

func (i *Input) Init() tea.Cmd

func (*Input) Position added in v0.10.0

func (i *Input) Position() int

func (*Input) Reset

func (i *Input) Reset()

Reset sets the Input to its default state with no Input. Returns whether or not the cursor blink should reset.

func (*Input) SetCursor

func (i *Input) SetCursor(pos int)

SetCursor moves the cursor to the given position. If the position is out of bounds the cursor will be moved to the start or end accordingly.

func (*Input) SetCursorMode

func (i *Input) SetCursorMode(model CursorMode)

SetCursorMode sets the model's cursor mode. This method returns a command.

For available cursor modes, see type CursorMode.

func (*Input) SetProgram

func (i *Input) SetProgram(program *tea.Program)

func (*Input) Update

func (i *Input) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Input) Value

func (i *Input) Value() string

Value returns the value of the text Input.

func (*Input) View

func (i *Input) View() string

type InputKeyMap added in v0.7.5

type InputKeyMap struct {
	Confirm key.Binding
	Quit    key.Binding
}

func InputDefaultKeyMap added in v0.7.5

func InputDefaultKeyMap() InputKeyMap

type PrintHelper added in v0.5.4

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

PrintHelper Used for thread-safe output when running the Components

func NewPrintHelper added in v0.5.4

func NewPrintHelper(program *tea.Program) *PrintHelper

NewPrintHelper constructor

func (PrintHelper) Center added in v0.5.4

func (p PrintHelper) Center(str string)

func (PrintHelper) Debug added in v0.5.4

func (p PrintHelper) Debug(format string, a ...any)

func (PrintHelper) Error added in v0.5.4

func (p PrintHelper) Error(format string, a ...any)

func (PrintHelper) Failed added in v0.5.4

func (p PrintHelper) Failed(format string, a ...any)

func (PrintHelper) Fatal added in v0.5.4

func (p PrintHelper) Fatal(format string, a ...any)

func (PrintHelper) GetProgram added in v0.7.5

func (p PrintHelper) GetProgram() *tea.Program

func (PrintHelper) Info added in v0.5.4

func (p PrintHelper) Info(format string, a ...any)

func (PrintHelper) Print added in v0.5.4

func (p PrintHelper) Print(str string)

func (PrintHelper) PrintWithPrefix added in v0.5.4

func (p PrintHelper) PrintWithPrefix(prefix, format string, a ...any)

func (PrintHelper) Success added in v0.5.4

func (p PrintHelper) Success(format string, a ...any)

func (PrintHelper) Warn added in v0.5.4

func (p PrintHelper) Warn(format string, a ...any)

type Progress

type Progress struct {
	*PrintHelper
	Id int
	// the progress total
	Total int64
	// Current amount
	Current int64

	// kill program
	Quit key.Binding
	// Total width of the progress bar, including percentage, if set.
	Width int

	// "Filled" sections of the progress bar.
	Full      rune
	FullColor string

	// "Empty" sections of progress bar.
	Empty      rune
	EmptyColor string

	ShowPercentage  bool
	PercentAgeFunc  func(total, current int64, percent float64) string
	PercentAgeStyle *style.Style

	ShowCost bool
	CostView func(cost time.Duration, total, current, prevAmount int64) string

	TickCostDelay time.Duration

	DoneView func() string

	TitleView func(done bool) string
	// contains filtered or unexported fields
}

func NewProgress

func NewProgress() *Progress

NewProgress constructor

func (*Progress) Change

func (pro *Progress) Change(amount int64)

Change current val, add or sub.

func (*Progress) Cost added in v0.4.1

func (pro *Progress) Cost() time.Duration

Cost the progress cost. plz make sure Progress.end and Progress.start are not null

func (*Progress) Decr

func (pro *Progress) Decr(amount int64)

Decr current val

func (*Progress) DecrOne

func (pro *Progress) DecrOne()

DecrOne decr one

func (*Progress) Done added in v0.4.1

func (pro *Progress) Done()

Done progress, will output DoneView

func (*Progress) Incr

func (pro *Progress) Incr(amount int64)

Incr current val

func (*Progress) IncrOne

func (pro *Progress) IncrOne()

IncrOne incr one

func (*Progress) Init

func (pro *Progress) Init() tea.Cmd

func (*Progress) Println added in v0.4.2

func (pro *Progress) Println(args ...interface{})

func (*Progress) SetProgram

func (pro *Progress) SetProgram(program *tea.Program)

func (*Progress) Update

func (pro *Progress) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Progress) View

func (pro *Progress) View() string

func (*Progress) ViewAs

func (pro *Progress) ViewAs(percent float64, now time.Time, done bool) string

func (*Progress) WithCostView added in v0.4.1

func (pro *Progress) WithCostView(f func(cost time.Duration, total, current, prevAmount int64) string) *Progress

WithCostView append cost view.

func (*Progress) WithDefaultGradient

func (pro *Progress) WithDefaultGradient() *Progress

WithDefaultGradient sets a gradient fill with default colors.

func (*Progress) WithDefaultScaledGradient

func (pro *Progress) WithDefaultScaledGradient() *Progress

WithDefaultScaledGradient sets a gradient with default colors, and scales the gradient to fit the filled portion of the ramp.

func (*Progress) WithDisableCostView added in v0.4.1

func (pro *Progress) WithDisableCostView() *Progress

WithDisableCostView disable cost view

func (*Progress) WithDisablePercentage

func (pro *Progress) WithDisablePercentage() *Progress

WithDisablePercentage disable output percentage.

func (*Progress) WithDoneView added in v0.4.1

func (pro *Progress) WithDoneView(f func() string) *Progress

WithDoneView when Group is done, will callback this func.

func (*Progress) WithEmpty

func (pro *Progress) WithEmpty(empty rune) *Progress

WithEmpty default '░'

func (*Progress) WithEmptyColor

func (pro *Progress) WithEmptyColor(empty string) *Progress

WithEmptyColor default "#606060"

func (*Progress) WithFull

func (pro *Progress) WithFull(full rune) *Progress

WithFull default '█'

func (*Progress) WithFullColor

func (pro *Progress) WithFullColor(full string) *Progress

WithFullColor default "#7571F9"

func (*Progress) WithGradient

func (pro *Progress) WithGradient(colorA, colorB string) *Progress

WithGradient sets a gradient fill blending between two colors.

func (*Progress) WithPercentAgeFunc

func (pro *Progress) WithPercentAgeFunc(f func(total int64, current int64, percent float64) string) *Progress

WithPercentAgeFunc default DefaultPercentAgeFunc

func (*Progress) WithPercentAgeStyle

func (pro *Progress) WithPercentAgeStyle(sty *style.Style) *Progress

WithPercentAgeStyle replace percentage style

func (*Progress) WithQuitKey added in v0.7.5

func (pro *Progress) WithQuitKey(key key.Binding) *Progress

WithQuitKey replace `Quit` key, user interrupt, kill program.

func (*Progress) WithScaledGradient

func (pro *Progress) WithScaledGradient(colorA, colorB string) *Progress

WithScaledGradient scales the gradient to fit the width of the filled portion of the progress bar.

func (*Progress) WithSolidFill

func (pro *Progress) WithSolidFill(color string) *Progress

WithSolidFill sets the progress to use a solid fill with the given color.

func (*Progress) WithTickCostDelay added in v0.6.1

func (pro *Progress) WithTickCostDelay(delay time.Duration) *Progress

WithTickCostDelay defaultTicKCostDelay the interval time between each refresh cost time

func (*Progress) WithTitleView added in v0.4.1

func (pro *Progress) WithTitleView(f func(done bool) string) *Progress

WithTitleView append title view.

func (*Progress) WithTotal

func (pro *Progress) WithTotal(total int64) *Progress

WithTotal default 100

func (*Progress) WithWidth

func (pro *Progress) WithWidth(w int) *Progress

WithWidth sets the initial width of the progress bar. Note that you can also set the width via the Width property, which can come in handy if you're waiting for a tea.WindowSizeMsg.

type ProgressMsg

type ProgressMsg struct {
	Id     int
	Amount int64
}

type RefreshPromptMsg

type RefreshPromptMsg string

type Selection

type Selection struct {
	// result
	Selected map[int]bool

	ShowPaginator bool // default true
	Paginator     paginator.Model
	Choices       []SelectionItem

	Validators []Validator

	DisableOutPutResult bool

	// key binding
	Keymap SelectionKeyMap
	// key Help text
	Help     help.Model
	ShowHelp bool

	Prompt         string
	Header         string
	CursorSymbol   string
	UnCursorSymbol string
	HintSymbol     string
	UnHintSymbol   string

	PromptStyle       *style.Style
	CursorSymbolStyle *style.Style
	HintSymbolStyle   *style.Style
	UnHintSymbolStyle *style.Style
	ChoiceTextStyle   *style.Style

	// RowRender output options
	// CursorSymbol,HintSymbol,choice
	RowRender func(CursorSymbol string, HintSymbol string, choice string) string

	EnableFilter bool
	FilterInput  *Input
	FilterFunc   func(input string, items []SelectionItem) []SelectionItem

	FocusSymbol          string
	UnFocusSymbol        string
	FocusInterval        string
	UnFocusInterval      string
	FocusSymbolStyle     *style.Style
	UnFocusSymbolStyle   *style.Style
	FocusIntervalStyle   *style.Style
	UnFocusIntervalStyle *style.Style
	ValueStyle           *style.Style
	// contains filtered or unexported fields
}

func DefaultSelectionCreator added in v0.5.1

func DefaultSelectionCreator(suggester []string, a *Autocomplete) *Selection

func NewSelection

func NewSelection(choices []string) *Selection

NewSelection constructor

func (*Selection) Init

func (s *Selection) Init() tea.Cmd

func (*Selection) RefreshChoices added in v0.12.0

func (s *Selection) RefreshChoices()

RefreshChoices refresh Choices

func (*Selection) RenderColor

func (s *Selection) RenderColor()

RenderColor set color to text

func (*Selection) SetPageSize added in v0.12.0

func (s *Selection) SetPageSize(pageSize int)

SetPageSize set page size

func (*Selection) SetProgram

func (s *Selection) SetProgram(program *tea.Program)

func (*Selection) Update

func (s *Selection) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Selection) Value

func (s *Selection) Value() []int

Value get all Selected

func (*Selection) View

func (s *Selection) View() string

type SelectionItem

type SelectionItem struct {
	Idx int
	Val string
}

func DefaultFilterFunc

func DefaultFilterFunc(input string, items []SelectionItem) []SelectionItem

type SelectionKeyMap added in v0.5.1

type SelectionKeyMap struct {
	Up        key.Binding
	Down      key.Binding
	Choice    key.Binding
	Confirm   key.Binding
	SelectAll key.Binding // 全选
	Flip      key.Binding // 反选
	// kill program
	Quit     key.Binding
	NextPage key.Binding
	PrevPage key.Binding
}

func DefaultMultiKeyMap added in v0.5.1

func DefaultMultiKeyMap() SelectionKeyMap

func DefaultSingleKeyMap added in v0.5.1

func DefaultSingleKeyMap() SelectionKeyMap

func (SelectionKeyMap) FullHelp added in v0.5.1

func (k SelectionKeyMap) FullHelp() [][]key.Binding

func (SelectionKeyMap) ShortHelp added in v0.5.1

func (k SelectionKeyMap) ShortHelp() []key.Binding

type SelectionWithList added in v0.12.0

type SelectionWithList[T list.DefaultItem] struct {
	// should set before Init
	List   *list.Model
	KeyMap *SelectionWithListKeyMap
	// contains filtered or unexported fields
}

func NewSelectionWithList added in v0.12.0

func NewSelectionWithList[T list.DefaultItem](items []T) *SelectionWithList[T]

NewSelectionWithList WIP

func (*SelectionWithList[T]) Init added in v0.12.0

func (s *SelectionWithList[T]) Init() tea.Cmd

func (*SelectionWithList[T]) SetItems added in v0.12.0

func (s *SelectionWithList[T]) SetItems(items []T)

func (*SelectionWithList[T]) SetProgram added in v0.12.0

func (s *SelectionWithList[T]) SetProgram(program *tea.Program)

func (*SelectionWithList[T]) Update added in v0.12.0

func (s *SelectionWithList[T]) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*SelectionWithList[T]) Value added in v0.12.0

func (s *SelectionWithList[T]) Value() []T

func (*SelectionWithList[T]) View added in v0.12.0

func (s *SelectionWithList[T]) View() string

type SelectionWithListKeyMap added in v0.12.0

type SelectionWithListKeyMap struct {
	Choice key.Binding
}

type Shape

type Shape struct {
	Frames []string
	FPS    time.Duration
}

Shape the Spinner Shape

type Spinner

type Spinner struct {
	*PrintHelper
	Model spinner.Model
	// user interrupt, kill program.
	Quit                key.Binding
	Shape               Shape
	ShapeStyle          *style.Style
	Prompt              string
	DisableOutPutResult bool
	Status              Status
	// contains filtered or unexported fields
}

func NewSpinner

func NewSpinner() *Spinner

NewSpinner constructor

func (*Spinner) Finish added in v0.7.5

func (s *Spinner) Finish()

Finish spinner job is done

func (*Spinner) Finished added in v0.7.5

func (s *Spinner) Finished() bool

Finished get quit state.

func (*Spinner) Init

func (s *Spinner) Init() tea.Cmd

func (*Spinner) RefreshPrompt

func (s *Spinner) RefreshPrompt(str string)

RefreshPrompt refresh prompt.

func (*Spinner) SetProgram

func (s *Spinner) SetProgram(program *tea.Program)

func (*Spinner) Update

func (s *Spinner) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Spinner) View

func (s *Spinner) View() string

type StartUp

type StartUp struct {
	P *tea.Program
	// contains filtered or unexported fields
}

func NewStartUp

func NewStartUp(c Components, ops ...tea.ProgramOption) *StartUp

NewStartUp new StartUp

func (*StartUp) Kill

func (s *StartUp) Kill()

Kill Components

func (*StartUp) Quit added in v0.5.1

func (s *StartUp) Quit()

func (*StartUp) Run added in v0.9.0

func (s *StartUp) Run() (tea.Model, error)

Run Returns the final model.

func (*StartUp) Send

func (s *StartUp) Send(msg tea.Msg)

Send message to component

func (*StartUp) Start

func (s *StartUp) Start() error

Start Deprecated: please use StartUp.Run instead.

type Status

type Status int

Status About the state of the Component

const (
	// Focus only use Input
	Focus Status = iota
	// Blur only use Input
	Blur
	// Quit user interrupt, should kill program
	Quit
	// Finish indicates that a component has done its job
	Finish
	// Normal ignore it
	Normal
)

type Suggester added in v0.5.1

type Suggester func(valCtx AutocompleteValCtx) ([]string, bool)

Suggester get suggest options

type Validator added in v0.10.0

type Validator func(ans interface{}) error

Validator is a function passed to a Question after a user has provided a response. If the function returns an error, then the user will be prompted again for another response.

func MaxItems added in v0.10.0

func MaxItems(numberItems int) Validator

MaxItems requires that the List is no longer than the specified value

func MinItems added in v0.10.0

func MinItems(numberItems int) Validator

MinItems requires that the List is longer or equal in length to the specified value

Directories

Path Synopsis
input
selection

Jump to

Keyboard shortcuts

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