spinner

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: MIT Imports: 3 Imported by: 1,149

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Some spinners to choose from. You could also make your own.
	Line = Spinner([]string{"|", "/", "-", "\\"})
	Dot  = Spinner([]string{"⣾ ", "⣽ ", "⣻ ", "⢿ ", "⡿ ", "⣟ ", "⣯ ", "⣷ "})
)

Functions

func Tick

func Tick(m Model) tea.Cmd

Tick is the command used to advance the spinner one frame.

func View

func View(model Model) string

View renders the model's view.

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
	// 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 NewModel

func NewModel() Model

NewModel returns a model with default values.

func Update

func Update(msg tea.Msg, m Model) (Model, tea.Cmd)

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.

type Spinner

type Spinner = []string

Spinner is a set of frames used in animating the spinner.

type TickMsg

type TickMsg struct{}

TickMsg indicates that the timer has ticked and we should render a frame.

Jump to

Keyboard shortcuts

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