spinner

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 4 Imported by: 509

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Line = Spinner{
		Frames: []string{"|", "/", "-", "\\"},
		FPS:    time.Second / 10,
	}
	Dot = Spinner{
		Frames: []string{"⣾ ", "⣽ ", "⣻ ", "⢿ ", "⡿ ", "⣟ ", "⣯ ", "⣷ "},
		FPS:    time.Second / 10,
	}
	MiniDot = Spinner{
		Frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"},
		FPS:    time.Second / 12,
	}
	Jump = Spinner{
		Frames: []string{"⢄", "⢂", "⢁", "⡁", "⡈", "⡐", "⡠"},
		FPS:    time.Second / 10,
	}
	Pulse = Spinner{
		Frames: []string{"█", "▓", "▒", "░"},
		FPS:    time.Second / 8,
	}
	Points = Spinner{
		Frames: []string{"∙∙∙", "●∙∙", "∙●∙", "∙∙●"},
		FPS:    time.Second / 7,
	}
	Globe = Spinner{
		Frames: []string{"🌍", "🌎", "🌏"},
		FPS:    time.Second / 4,
	}
	Moon = Spinner{
		Frames: []string{"🌑", "🌒", "🌓", "🌔", "🌕", "🌖", "🌗", "🌘"},
		FPS:    time.Second / 8,
	}
	Monkey = Spinner{
		Frames: []string{"🙈", "🙉", "🙊"},
		FPS:    time.Second / 3,
	}
	Meter = Spinner{
		Frames: []string{
			"▱▱▱",
			"▰▱▱",
			"▰▰▱",
			"▰▰▰",
			"▰▰▱",
			"▰▱▱",
			"▱▱▱",
		},
		FPS: time.Second / 7,
	}
	Hamburger = Spinner{
		Frames: []string{"☱", "☲", "☴", "☲"},
		FPS:    time.Second / 3,
	}
	Ellipsis = Spinner{
		Frames: []string{"", ".", "..", "..."},
		FPS:    time.Second / 3,
	}
)

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

View Source
var NewModel = New

NewModel returns a model with default values.

Deprecated: use New instead.

Functions

func Tick deprecated

func Tick() tea.Msg

Tick is the command used to advance the spinner one frame. Use this command to effectively start the spinner.

Deprecated: Use Model.Tick instead.

Types

type Model

type Model struct {
	// Spinner settings to use. See type Spinner.
	Spinner Spinner

	// Style sets the styling for the spinner. Most of the time you'll just
	// want foreground and background coloring, and potentially some padding.
	//
	// For an introduction to styling with Lip Gloss see:
	// https://github.com/charmbracelet/lipgloss
	Style lipgloss.Style
	// contains filtered or unexported fields
}

Model contains the state for the spinner. Use New to create new models rather than using Model as a struct literal.

func New added in v0.10.0

func New(opts ...Option) Model

New returns a model with default values.

func (Model) ID added in v0.10.0

func (m Model) ID() int

ID returns the spinner's unique ID.

func (Model) Tick added in v0.10.0

func (m Model) Tick() tea.Msg

Tick is the command used to advance the spinner one frame. Use this command to effectively start the spinner.

func (Model) Update added in v0.7.4

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

Update is the Tea update function.

func (Model) View added in v0.7.4

func (m Model) View() string

View renders the model's view.

type Option added in v0.13.0

type Option func(*Model)

Option is used to set options in New. For example:

spinner := New(WithSpinner(Dot))

func WithSpinner added in v0.13.0

func WithSpinner(spinner Spinner) Option

WithSpinner is an option to set the spinner.

func WithStyle added in v0.13.0

func WithStyle(style lipgloss.Style) Option

WithStyle is an option to set the spinner style.

type Spinner

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

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

type TickMsg

type TickMsg struct {
	Time time.Time

	ID int
	// contains filtered or unexported fields
}

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