Skip to content

pending

fn new_spinner #

fn new_spinner(config SpinnerConfig) Spinner

new_spinner creates a Spinner instance

type SpinnerFrames #

type SpinnerFrames = []rune | []string

enum SpinnerTarget #

enum SpinnerTarget {
	stdout
	stderr
}

struct Spinner #

struct Spinner {
// the state of this Spinner
	state shared SpinnerState
// the channel to send and receive (e)println contents
	ch chan SpinnerMessage
// the thread spawned when this Spinner is created
	handle thread
pub:
// the config used to create this Spinner
	config SpinnerConfig
}

see new_spinner, SpinnerConfig, SpinnerState

fn (Spinner) get_state #

fn (s Spinner) get_state() SpinnerState

get_state returns (a clone of) the current spinner state

fn (Spinner) pause #

fn (s Spinner) pause()

pause pauses the spinner

fn (Spinner) start #

fn (s Spinner) start()

start starts the spinner

fn (Spinner) stop #

fn (s Spinner) stop()

stop stops the spinner

the spinner is unusable after calling this

fn (Spinner) stopped #

fn (s Spinner) stopped() bool

stopped returns true if the spinner is already stopped

fn (Spinner) set_prefix #

fn (s Spinner) set_prefix(ss string)

set_prefix sets the prefix of the Spinner

fn (Spinner) set_suffix #

fn (s Spinner) set_suffix(ss string)

set_suffix sets the suffix of the spinner

fn (Spinner) println #

fn (s Spinner) println(ss string)

println is a helper method to println above the spinner

fn (Spinner) eprintln #

fn (s Spinner) eprintln(ss string)

eprintln is a helper method to eprintln above the spinner

fn (Spinner) set_line_above #

fn (s Spinner) set_line_above(ss []string)

set_line_above sets the line above the spinner

fn (Spinner) set_line_above_at #

fn (s Spinner) set_line_above_at(i int, ss string)

set_line_above_at sets the line above the spinner at specific index

fn (Spinner) set_line_below #

fn (s Spinner) set_line_below(ss []string)

set_line_below sets the line below the spinner

fn (Spinner) set_line_below_at #

fn (s Spinner) set_line_below_at(i int, ss string)

set_line_below_at sets the line below the spinner at specific index

struct SpinnerConfig #

struct SpinnerConfig {
	frames   SpinnerFrames [required]
	interval time.Duration [required]
// where to print the spinner
	target SpinnerTarget = .stderr
// used to map (read: modify) the frame before it gets printed
// by default it will print the frame as-is
	map_frame     fn (frame string) string = default_map_frame
	initial_state SpinnerState
}

you can get some cool spinners here

struct SpinnerState #

struct SpinnerState {
pub mut:
// newline separated strings printed ABOVE the spinner
	line_above []string
// newline separated strings printed BELOW the spinner
	line_below []string
// string printed BEFORE the spinner in the same line
	prefix string
// string printed AFTER the spinner in the same line
	suffix string
// whether the spinner is paused
// paused spinner won't print anything
	paused bool
// whether the spinner is stopped
// stopped spinner is unusable and can't be _restarted_
	stopped bool
}

fn (SpinnerState) clone #

fn (s SpinnerState) clone() SpinnerState

clone clones this spinner state