Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Some spinners to choose from. You could also make your own. Line = Spinner([]string{"|", "/", "-", "\\"}) Dot = Spinner([]string{"⣾ ", "⣽ ", "⣻ ", "⢿ ", "⡿ ", "⣟ ", "⣯ ", "⣷ "}) )
Functions ¶
Types ¶
type Model ¶
type Model struct { // Type is the set of frames to use. See Spinner. Frames Spinner // FPS is the speed at which the ticker should tick. FPS time.Duration // ForegroundColor sets the background color of the spinner. It can be a // hex code or one of the 256 ANSI colors. If the terminal emulator can't // doesn't support the color specified it will automatically degrade // (per github.com/muesli/termenv). ForegroundColor string // BackgroundColor sets the background color of the spinner. It can be a // hex code or one of the 256 ANSI colors. If the terminal emulator can't // doesn't support the color specified it will automatically degrade // (per github.com/muesli/termenv). BackgroundColor string // MinimumLifetime is the minimum amount of time the spinner can run. Any // logic around this can be implemented in view that implements this // spinner. If HideFor is set MinimumLifetime will be added on top of // HideFor. In other words, if HideFor is 100ms and MinimumLifetime is // 200ms then MinimumLifetime will expire after 300ms. // // MinimumLifetime is optional. // // This is considered experimental and may not appear in future versions of // this library. MinimumLifetime time.Duration // HideFor can be used to wait to show the spinner until a certain amount // of time has passed. This can be useful for preventing flicking when load // times are very fast. // Optional. // // This is considered experimental and may not appear in future versions of // this library. HideFor time.Duration // contains filtered or unexported fields }
Model contains the state for the spinner. Use NewModel to create new models rather than using Model as a struct literal.
func Update ¶
Update is the Tea update function. This will advance the spinner one frame every time it's called, regardless the message passed, so be sure the logic is setup so as not to call this Update needlessly.
func (*Model) Start ¶ added in v0.6.0
func (m *Model) Start()
Start resets resets the spinner start time. For use with MinimumLifetime and MinimumStartTime. Optional.
This is considered experimental and may not appear in future versions of this library.
func (Model) Visible ¶ added in v0.6.0
Visible returns whether or not the view should be rendered. Works in conjunction with Model.HideFor and Model.MinimumLifetimeReached. You should use this message directly to determine whether or not to render this view in the parent view and whether to continue sending spin messaging in the parent update function.
Also note that using this function is optional and generally considered for advanced use only. Most of the time your application logic will determine whether or not this view should be used.
This is considered experimental and may not appear in future versions of this library.