Documentation
¶
Index ¶
- Constants
- Variables
- func Color256(n int) string
- func ColorPulse(start, end int, duration time.Duration) func() string
- func GreyPulse(interval time.Duration) func() string
- func SpeedupInterval(start, end, duration time.Duration) func() time.Duration
- func WithColor(color string) func(*Spinner)
- func WithColorFunc(f func() string) func(*Spinner)
- func WithHideCursor(hide bool) func(*Spinner)
- func WithIntervalFunc(f func() time.Duration) func(*Spinner)
- type Option
- type Spinner
Examples ¶
Constants ¶
View Source
const ( Black = "\033[38;5;0m" Green = "\033[38;5;2m" Olive = "\033[38;5;3m" Teal = "\033[38;5;6m" Silver = "\033[38;5;7m" Grey = "\033[38;5;8m" Red = "\033[38;5;9m" Lime = "\033[38;5;10m" Yellow = "\033[38;5;11m" Blue = "\033[38;5;12m" Aqua = "\033[38;5;14m" White = "\033[38;5;15m" Reset = "\033[0m" )
Variables ¶
View Source
var ( Dots1 = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"} Dots2 = []string{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"} Dots3 = []string{"⠋", "⠙", "⠚", "⠞", "⠖", "⠦", "⠴", "⠲", "⠳", "⠓"} Dots4 = []string{"⠄", "⠆", "⠇", "⠋", "⠙", "⠸", "⠰", "⠠", "⠰", "⠸", "⠙", "⠋", "⠇", "⠆"} Dots5 = []string{"⠋", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋"} Dots6 = []string{"⠁", "⠉", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠤", "⠄", "⠄", "⠤", "⠴", "⠲", "⠒", "⠂", "⠂", "⠒", "⠚", "⠙", "⠉", "⠁"} Dots7 = []string{"⠈", "⠉", "⠋", "⠓", "⠒", "⠐", "⠐", "⠒", "⠖", "⠦", "⠤", "⠠", "⠠", "⠤", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋", "⠉", "⠈"} Dots8 = []string{"⠁", "⠁", "⠉", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠤", "⠄", "⠄", "⠤", "⠠", "⠠", "⠤", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋", "⠉", "⠈", "⠈"} Dots9 = []string{"⢹", "⢺", "⢼", "⣸", "⣇", "⡧", "⡗", "⡏"} Dots10 = []string{"⢄", "⢂", "⢁", "⡁", "⡈", "⡐", "⡠"} Dots11 = []string{"⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈"} Dots12 = []string{"⢀⠀", "⡀⠀", "⠄⠀", "⢂⠀", "⡂⠀", "⠅⠀", "⢃⠀", "⡃⠀", "⠍⠀", "⢋⠀", "⡋⠀", "⠍⠁", "⢋⠁", "⡋⠁", "⠍⠉", "⠋⠉", "⠋⠉", "⠉⠙", "⠉⠙", "⠉⠩", "⠈⢙", "⠈⡙", "⢈⠩", "⡀⢙", "⠄⡙", "⢂⠩", "⡂⢘", "⠅⡘", "⢃⠨", "⡃⢐", "⠍⡐", "⢋⠠", "⡋⢀", "⠍⡁", "⢋⠁", "⡋⠁", "⠍⠉", "⠋⠉", "⠋⠉", "⠉⠙", "⠉⠙", "⠉⠩", "⠈⢙", "⠈⡙", "⠈⠩", "⠀⢙", "⠀⡙", "⠀⠩", "⠀⢘", "⠀⡘", "⠀⠨", "⠀⢐", "⠀⡐", "⠀⠠", "⠀⢀", "⠀⡀"} Line = []string{"-", "\\", "|", "/"} Pipe = []string{"┤", "┘", "┴", "└", "├", "┌", "┬", "┐"} SimpleDots = []string{". ", ".. ", "...", " "} SimpleDotsScrolling = []string{". ", ".. ", "...", " ..", " .", " "} Star = []string{"✶", "✸", "✹", "✺", "✹", "✷"} Flip = []string{"_", "_", "_", "-", "`", "`", "'", "´", "-", "_", "_", "_"} Hamburger = []string{"☱", "☲", "☴"} GrowVertical = []string{"▁", "▃", "▄", "▅", "▆", "▇", "▆", "▅", "▄", "▃"} GrowHorizontal = []string{"▏", "▎", "▍", "▌", "▋", "▊", "▉", "▊", "▋", "▌", "▍", "▎"} Balloon = []string{" ", ".", "o", "O", "@", "*", " "} Noise = []string{"▓", "▒", "░"} Bounce = []string{"⠁", "⠂", "⠄", "⠂"} BoxBounce = []string{"▖", "▘", "▝", "▗"} BoxBounce2 = []string{"▌", "▀", "▐", "▄"} Triangle = []string{"◢", "◣", "◤", "◥"} Arc = []string{"◜", "◠", "◝", "◞", "◡", "◟"} Circle = []string{"◡", "⊙", "◠"} SquareCorners = []string{"◰", "◳", "◲", "◱"} CircleQuarters = []string{"◴", "◷", "◶", "◵"} CircleHalves = []string{"◐", "◓", "◑", "◒"} Moon = []string{"🌑", "🌒", "🌓", "🌔", "🌕", "🌖", "🌗", "🌘"} Smiley = []string{"😄 ", "😝 "} Monkey = []string{"🙈 ", "🙈 ", "🙉 ", "🙊 "} Hearts = []string{"💛 ", "💙 ", "💜 ", "💚 ", "❤️ "} Clock = []string{"🕛 ", "🕐 ", "🕑 ", "🕒 ", "🕓 ", "🕔 ", "🕕 ", "🕖 ", "🕗 ", "🕘 ", "🕙 ", "🕚 "} Earth = []string{"🌍 ", "🌎 ", "🌏 "} Material = []string{"█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", "██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", "███▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", "████▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", "██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁", "██████▁▁▁▁▁▁▁▁▁▁▁▁▁▁", "███████▁▁▁▁▁▁▁▁▁▁▁▁▁", "████████▁▁▁▁▁▁▁▁▁▁▁▁", "█████████▁▁▁▁▁▁▁▁▁▁▁", "█████████▁▁▁▁▁▁▁▁▁▁▁", "██████████▁▁▁▁▁▁▁▁▁▁", "███████████▁▁▁▁▁▁▁▁▁", "█████████████▁▁▁▁▁▁▁", "██████████████▁▁▁▁▁▁", "██████████████▁▁▁▁▁▁", "▁██████████████▁▁▁▁▁", "▁██████████████▁▁▁▁▁", "▁██████████████▁▁▁▁▁", "▁▁██████████████▁▁▁▁", "▁▁▁██████████████▁▁▁", "▁▁▁▁█████████████▁▁▁", "▁▁▁▁██████████████▁▁", "▁▁▁▁██████████████▁▁", "▁▁▁▁▁██████████████▁", "▁▁▁▁▁██████████████▁", "▁▁▁▁▁██████████████▁", "▁▁▁▁▁▁██████████████", "▁▁▁▁▁▁██████████████", "▁▁▁▁▁▁▁█████████████", "▁▁▁▁▁▁▁█████████████", "▁▁▁▁▁▁▁▁████████████", "▁▁▁▁▁▁▁▁████████████", "▁▁▁▁▁▁▁▁▁███████████", "▁▁▁▁▁▁▁▁▁███████████", "▁▁▁▁▁▁▁▁▁▁██████████", "▁▁▁▁▁▁▁▁▁▁██████████", "▁▁▁▁▁▁▁▁▁▁▁▁████████", "▁▁▁▁▁▁▁▁▁▁▁▁▁███████", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁██████", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████", "█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████", "██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███", "██▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███", "███▁▁▁▁▁▁▁▁▁▁▁▁▁▁███", "████▁▁▁▁▁▁▁▁▁▁▁▁▁▁██", "█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█", "█████▁▁▁▁▁▁▁▁▁▁▁▁▁▁█", "██████▁▁▁▁▁▁▁▁▁▁▁▁▁█", "████████▁▁▁▁▁▁▁▁▁▁▁▁", "█████████▁▁▁▁▁▁▁▁▁▁▁", "█████████▁▁▁▁▁▁▁▁▁▁▁", "█████████▁▁▁▁▁▁▁▁▁▁▁", "█████████▁▁▁▁▁▁▁▁▁▁▁", "███████████▁▁▁▁▁▁▁▁▁", "████████████▁▁▁▁▁▁▁▁", "████████████▁▁▁▁▁▁▁▁", "██████████████▁▁▁▁▁▁", "██████████████▁▁▁▁▁▁", "▁██████████████▁▁▁▁▁", "▁██████████████▁▁▁▁▁", "▁▁▁█████████████▁▁▁▁", "▁▁▁▁▁████████████▁▁▁", "▁▁▁▁▁████████████▁▁▁", "▁▁▁▁▁▁███████████▁▁▁", "▁▁▁▁▁▁▁▁█████████▁▁▁", "▁▁▁▁▁▁▁▁█████████▁▁▁", "▁▁▁▁▁▁▁▁▁█████████▁▁", "▁▁▁▁▁▁▁▁▁█████████▁▁", "▁▁▁▁▁▁▁▁▁▁█████████▁", "▁▁▁▁▁▁▁▁▁▁▁████████▁", "▁▁▁▁▁▁▁▁▁▁▁████████▁", "▁▁▁▁▁▁▁▁▁▁▁▁███████▁", "▁▁▁▁▁▁▁▁▁▁▁▁███████▁", "▁▁▁▁▁▁▁▁▁▁▁▁▁███████", "▁▁▁▁▁▁▁▁▁▁▁▁▁███████", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█████", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁████", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁███", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁", "▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁"} )
Spinner styles
Functions ¶
func SpeedupInterval ¶ added in v0.1.1
func WithColorFunc ¶
func WithHideCursor ¶
func WithIntervalFunc ¶
Types ¶
type Option ¶
type Option func(*Spinner)
func WithFrames ¶
func WithInterval ¶
func WithPosition ¶ added in v0.1.2
func WithWriter ¶
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Example (Basic) ¶
package main
import (
"time"
"github.com/tmc/spinner"
)
func main() {
s := spinner.New()
s.Start()
time.Sleep(time.Second)
s.Stop()
}
Example (WithAdvancedOptions) ¶
package main
import (
"time"
"github.com/tmc/spinner"
)
func main() {
s := spinner.New(
spinner.WithFrames(spinner.Dots8),
spinner.WithIntervalFunc(
spinner.SpeedupInterval(90*time.Millisecond, 40*time.Millisecond, time.Second*5),
),
spinner.WithColorFunc(spinner.GreyPulse(15*time.Millisecond)),
)
s.Start()
time.Sleep(5 * time.Second)
s.Stop()
}
Example (WithCustomFrames) ¶
package main
import (
"time"
"github.com/tmc/spinner"
)
func main() {
s := spinner.New(spinner.WithFrames(spinner.Dots12))
s.Start()
time.Sleep(3 * time.Second)
s.Stop()
}
Example (WithCustomFramesAllDots) ¶
package main
import (
"fmt"
"os"
"time"
"github.com/tmc/spinner"
)
func main() {
for i, f := range [][]string{
spinner.Dots1,
spinner.Dots2,
spinner.Dots3,
spinner.Dots4,
spinner.Dots5,
spinner.Dots6,
spinner.Dots7,
spinner.Dots8,
spinner.Dots9,
spinner.Dots10,
spinner.Dots11,
spinner.Dots12,
} {
s := spinner.New(spinner.WithFrames(f))
fmt.Fprintf(os.Stderr, "spinner.Dots%v\n", i+1)
s.Start()
time.Sleep(2 * time.Second)
s.Stop()
fmt.Fprintf(os.Stderr, "\n")
}
}
Click to show internal directories.
Click to hide internal directories.