Documentation
¶
Index ¶
- Constants
- Variables
- func BlurCmd() tea.Msg
- func DefaultPercentAgeFunc(total, current int64, percent float64) string
- func DefaultRowRender(cursorSymbol string, hintSymbol string, choice string) string
- func FocusCmd() tea.Msg
- func QuitCmd() tea.Msg
- type Components
- type CursorMode
- type EchoMode
- type Input
- func (in *Input) Blink() bool
- func (in *Input) Blur()
- func (in *Input) Cursor() int
- func (in *Input) CursorEnd()
- func (in *Input) CursorMode() CursorMode
- func (in *Input) CursorStart()
- func (in *Input) Focus()
- func (in *Input) Focused() bool
- func (in *Input) Init() tea.Cmd
- func (in *Input) Quit()
- func (in *Input) Reset() bool
- func (in *Input) SetCursor(pos int)
- func (in *Input) SetCursorMode(model CursorMode)
- func (in *Input) SetProgram(program *tea.Program)
- func (in *Input) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (in *Input) Value() string
- func (in *Input) View() string
- type Progress
- func (pro *Progress) Change(amount int64)
- func (pro *Progress) Cost() time.Duration
- func (pro *Progress) Decr(amount int64)
- func (pro *Progress) DecrOne()
- func (pro *Progress) Done()
- func (pro *Progress) Incr(amount int64)
- func (pro *Progress) IncrOne()
- func (pro *Progress) Init() tea.Cmd
- func (pro *Progress) Println(args ...interface{})
- func (pro *Progress) SetProgram(program *tea.Program)
- func (pro *Progress) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (pro *Progress) View() string
- func (pro *Progress) ViewAs(percent float64, refreshTime time.Time) string
- func (pro *Progress) WithCostView(f func(cost time.Duration, total, current, prevAmount int64) string) *Progress
- func (pro *Progress) WithDefaultGradient() *Progress
- func (pro *Progress) WithDefaultScaledGradient() *Progress
- func (pro *Progress) WithDisableCostView() *Progress
- func (pro *Progress) WithDisablePercentage() *Progress
- func (pro *Progress) WithDoneView(f func() string) *Progress
- func (pro *Progress) WithEmpty(empty rune) *Progress
- func (pro *Progress) WithEmptyColor(empty string) *Progress
- func (pro *Progress) WithFull(full rune) *Progress
- func (pro *Progress) WithFullColor(full string) *Progress
- func (pro *Progress) WithGradient(colorA, colorB string) *Progress
- func (pro *Progress) WithPercentAgeFunc(f func(total int64, current int64, percent float64) string) *Progress
- func (pro *Progress) WithPercentAgeStyle(sty *style.Style) *Progress
- func (pro *Progress) WithScaledGradient(colorA, colorB string) *Progress
- func (pro *Progress) WithSolidFill(color string) *Progress
- func (pro *Progress) WithTitleView(f func() string) *Progress
- func (pro *Progress) WithTotal(total int64) *Progress
- func (pro *Progress) WithWidth(w int) *Progress
- type ProgressMsg
- type RefreshPromptMsg
- type Selection
- type SelectionItem
- type Shape
- type Spinner
- type StartUp
- type Status
Constants ¶
const (
DefaultBlinkSpeed = time.Millisecond * 530
)
Variables ¶
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.
Functions ¶
func DefaultPercentAgeFunc ¶
func DefaultRowRender ¶
Types ¶
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:
- Input
- Selection
- Spinner
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() textinput.CursorMode
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 /* option start */ Status Status Prompt string Placeholder string BlinkSpeed time.Duration EchoMode EchoMode EchoCharacter rune PromptStyle *style.Style TextStyle *style.Style BackgroundStyle *style.Style PlaceholderStyle *style.Style CursorStyle *style.Style // default is disable QuitKey key.Binding // CharLimit is the maximum amount of characters this input element will // accept. If 0 or less, there's no limit. CharLimit int // contains filtered or unexported fields }
Input the input component.
func (*Input) Blur ¶
func (in *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) CursorEnd ¶
func (in *Input) CursorEnd()
CursorEnd moves the cursor to the end of the input field.
func (*Input) CursorMode ¶
func (in *Input) CursorMode() CursorMode
CursorMode returns the model's cursor mode. For available cursor modes, see type CursorMode.
func (*Input) CursorStart ¶
func (in *Input) CursorStart()
CursorStart moves the cursor to the start of the input field.
func (*Input) Focus ¶
func (in *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) Reset ¶
Reset sets the input to its default state with no input. Returns whether or not the cursor blink should reset.
func (*Input) SetCursor ¶
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 (in *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 ¶
type Progress ¶
type Progress struct { Id int // the progress total Total int64 // Current amount Current int64 // 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 DoneView func() string TitleView func() string // contains filtered or unexported fields }
func NewProgress ¶
func NewProgress() *Progress
func (*Progress) Cost ¶ added in v0.4.1
Cost the progress cost. plz make sure Progress.end and Progress.start are not null
func (*Progress) Done ¶ added in v0.4.1
func (pro *Progress) Done()
Done progress, will output DoneView
func (*Progress) SetProgram ¶
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 ¶
WithDefaultGradient sets a gradient fill with default colors.
func (*Progress) WithDefaultScaledGradient ¶
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
WithDisableCostView disable cost view
func (*Progress) WithDisablePercentage ¶
WithDisablePercentage disable output percentage.
func (*Progress) WithDoneView ¶ added in v0.4.1
WithDoneView when Group is done, will callback this func.
func (*Progress) WithEmptyColor ¶
WithEmptyColor default "#606060"
func (*Progress) WithFullColor ¶
WithFullColor default "#7571F9"
func (*Progress) WithGradient ¶
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 ¶
WithPercentAgeStyle replace percentage style
func (*Progress) WithScaledGradient ¶
WithScaledGradient scales the gradient to fit the width of the filled portion of the progress bar.
func (*Progress) WithSolidFill ¶
WithSolidFill sets the progress to use a solid fill with the given color.
func (*Progress) WithTitleView ¶ added in v0.4.1
WithTitleView append title view.
type ProgressMsg ¶
type RefreshPromptMsg ¶
type RefreshPromptMsg string
type Selection ¶
type Selection struct { // result Selected map[int]struct{} /* options start */ Choices []SelectionItem // how many options to display at a time PageSize int DisableOutPutResult bool // key binding Keymap selection.KeyMap // key Help text Help help.Model Prompt 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(string, string, string) string EnableFilter bool FilterInput *Input FilterFunc func(input string, items []SelectionItem) []SelectionItem // contains filtered or unexported fields }
func (*Selection) SetProgram ¶
type SelectionItem ¶
type SelectionItem struct {
// contains filtered or unexported fields
}
func DefaultFilterFunc ¶
func DefaultFilterFunc(input string, items []SelectionItem) []SelectionItem
type Spinner ¶
type Spinner struct { Model spinner.Model /* options start */ Shape Shape ShapeStyle *style.Style Prompt string DisableOutPutResult bool Status Status // contains filtered or unexported fields }
func (*Spinner) RefreshPrompt ¶
RefreshPrompt refresh prompt.
func (*Spinner) SetProgram ¶
type StartUp ¶
func NewStartUp ¶
func NewStartUp(c Components, ops ...tea.ProgramOption) *StartUp
NewStartUp new StartUp