class Term::Spinner

Defined in:

spinner/formats.cr
spinner/multi.cr
spinner/version.cr
term-spinner.cr

Constant Summary

CROSS = "✖"
ECMA_CSI = "\e["
FORMATS = {"classic" => {interval: 10, frames: ["|", "/", "-", "\\"]}, "spin" => {interval: 10, frames: ["◴", "◷", "◶", "◵"] of ::String}, "spin_2" => {interval: 10, frames: ["◐", "◓", "◑", "◒"] of ::String}, "spin_3" => {interval: 10, frames: ["◰", "◳", "◲", "◱"] of ::String}, "spin_4" => {interval: 10, frames: ["╫", "╪"] of ::String}, "pulse" => {interval: 10, frames: ["⎺", "⎻", "⎼", "⎽", "⎼", "⎻"] of ::String}, "pulse_2" => {interval: 15, frames: ["▁", "▃", "▅", "▆", "▇", "█", "▇", "▆", "▅", "▃"] of ::String}, "pulse_3" => {interval: 20, frames: ["▉", "▊", "▋", "▌", "▍", "▎", "▏", "▎", "▍", "▌", "▋", "▊", "▉"] of ::String}, "dots" => {interval: 10, frames: ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] of ::String}, "dots_2" => {interval: 10, frames: ["⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"] of ::String}, "dots_3" => {interval: 10, frames: ["⠋", "⠙", "⠚", "⠞", "⠖", "⠦", "⠴", "⠲", "⠳", "⠓"] of ::String}, "dots_4" => {interval: 10, frames: ["⠄", "⠆", "⠇", "⠋", "⠙", "⠸", "⠰", "⠠", "⠰", "⠸", "⠙", "⠋", "⠇", "⠆"] of ::String}, "dots_5" => {interval: 10, frames: ["⠋", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋"] of ::String}, "dots_6" => {interval: 10, frames: ["⠁", "⠉", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠤", "⠄", "⠄", "⠤", "⠴", "⠲", "⠒", "⠂", "⠂", "⠒", "⠚", "⠙", "⠉", "⠁"] of ::String}, "dots_7" => {interval: 10, frames: ["⠈", "⠉", "⠋", "⠓", "⠒", "⠐", "⠐", "⠒", "⠖", "⠦", "⠤", "⠠", "⠠", "⠤", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋", "⠉", "⠈"] of ::String}, "dots_8" => {interval: 10, frames: ["⠁", "⠁", "⠉", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠤", "⠄", "⠄", "⠤", "⠠", "⠠", "⠤", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋", "⠉", "⠈", "⠈"] of ::String}, "dots_9" => {interval: 10, frames: ["⢹", "⢺", "⢼", "⣸", "⣇", "⡧", "⡗", "⡏"] of ::String}, "dots_10" => {interval: 10, frames: ["⢄", "⢂", "⢁", "⡁", "⡈", "⡐", "⡠"] of ::String}, "dots_11" => {interval: 10, frames: ["⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈"] of ::String}, "arrow" => {interval: 10, frames: ["←", "↖", "↑", "↗", "→", "↘", "↓", "↙"] of ::String}, "arrow_pulse" => {interval: 10, frames: ["▹▹▹▹▹", "▸▹▹▹▹", "▹▸▹▹▹", "▹▹▸▹▹", "▹▹▹▸▹", "▹▹▹▹▸"]}, "triangle" => {interval: 10, frames: ["◢", "◣", "◤", "◥"] of ::String}, "arc" => {interval: 10, frames: ["◜", "◠", "◝", "◞", "◡", "◟"] of ::String}, "pipe" => {interval: 10, frames: ["┤", "┘", "┴", "└", "├", "┌", "┬", "┐"] of ::String}, "bouncing" => {interval: 10, frames: ["[ ]", "[ =]", "[ ==]", "[ ===]", "[====]", "[=== ]", "[== ]", "[= ]"]}, "bouncing_ball" => {interval: 10, frames: ["( ● )", "( ● )", "( ● )", "( ● )", "( ●)", "( ● )", "( ● )", "( ● )", "( ● )", "(● )"]}, "bounce" => {interval: 10, frames: ["⠁", "⠂", "⠄", "⠂"] of ::String}, "box_bounce" => {interval: 10, frames: ["▌", "▀", "▐", "▄"] of ::String}, "box_bounce_2" => {interval: 10, frames: ["▖", "▘", "▝", "▗"] of ::String}, "star" => {interval: 10, frames: ["✶", "✸", "✹", "✺", "✹", "✷"] of ::String}, "toggle" => {interval: 10, frames: ["■", "□", "▪", "▫"] of ::String}, "balloon" => {interval: 10, frames: [".", "o", "O", "@", "*"] of ::String}, "balloon_2" => {interval: 10, frames: [".", "o", "O", "°", "O", "o", "."] of ::String}, "flip" => {interval: 10, frames: ["-", "◡", "⊙", "-", "◠"] of ::String}, "burger" => {interval: 6, frames: ["☱", "☲", "☴"] of ::String}, "dance" => {interval: 10, frames: [">))'>", " >))'>", " >))'>", " >))'>", " >))'>", " <'((<", " <'((<", " <'((<"]}, "shark" => {interval: 10, frames: ["▐|\\____________▌", "▐_|\\___________▌", "▐__|\\__________▌", "▐___|\\_________▌", "▐____|\\________▌", "▐_____|\\_______▌", "▐______|\\______▌", "▐_______|\\_____▌", "▐________|\\____▌", "▐_________|\\___▌", "▐__________|\\__▌", "▐___________|\\_▌", "▐____________|\\▌", "▐____________/|▌", "▐___________/|_▌", "▐__________/|__▌", "▐_________/|___▌", "▐________/|____▌", "▐_______/|_____▌", "▐______/|______▌", "▐_____/|_______▌", "▐____/|________▌", "▐___/|_________▌", "▐__/|__________▌", "▐_/|___________▌", "▐/|____________▌"]}, "pong" => {interval: 10, frames: ["▐⠂ ▌", "▐⠈ ▌", "▐ ⠂ ▌", "▐ ⠠ ▌", "▐ ⡀ ▌", "▐ ⠠ ▌", "▐ ⠂ ▌", "▐ ⠈ ▌", "▐ ⠂ ▌", "▐ ⠠ ▌", "▐ ⡀ ▌", "▐ ⠠ ▌", "▐ ⠂ ▌", "▐ ⠈ ▌", "▐ ⠂▌", "▐ ⠠▌", "▐ ⡀▌", "▐ ⠠ ▌", "▐ ⠂ ▌", "▐ ⠈ ▌", "▐ ⠂ ▌", "▐ ⠠ ▌", "▐ ⡀ ▌", "▐ ⠠ ▌", "▐ ⠂ ▌", "▐ ⠈ ▌", "▐ ⠂ ▌", "▐ ⠠ ▌", "▐ ⡀ ▌", "▐⠠ ▌"]}}
MATCHER = /:spinner/
TICK = "✔"
VERSION = "0.1.0"

Constructors

Instance Method Summary

Constructor Detail

def self.new(*args, **options) #

[View source]

Instance Method Detail

def attach_to(multispinner : Multi) #

Notifies the Spinner that it is running under a multispinner


[View source]
def auto_spin #

Start automatic spinning animation


[View source]
def clear_line #

Clear the current line


[View source]
def done? : Bool #

Whether the spinner has completed spinning


[View source]
def duration #

Duration of the spinning animation


[View source]
def error(stop_message = "") #

Finish spinning and set state to :error


[View source]
def error? #

Whether the spinner is in the error state. This is only true temporarily while it is being marked with a failure mark.


[View source]
def execute_job #

Execute this spinner job


[View source]
def execute_on_line(&) #

[View source]
def first_run? : Bool #

Whether this is the first time this spinner has ran


[View source]
def frames : Array(String) #

The animation frames


[View source]
def hide_cursor : Bool #

Whether to show or hide the cursor


[View source]
def interval : Time::Span #

The animation interval


[View source]
def job(&work : Spinner -> ) #

Add job to the spinner


[View source]
def job : Term::Spinner -> Nil? #

Get the current job


[View source]
def job? #

Check if this spinner has a scheduled job


[View source]
def message : String #

The message to print before the spinner


[View source]
def multispinner : Multi | Nil #

[View source]
def next_char #

Retrieve next character


[View source]
def on(name, &block : Spinner -> ) #

Register a callback


[View source]
def output : IO::FileDescriptor #

The object that responds to print call defaulting to stderr


[View source]
def pause #

Pause the spinner


[View source]
def paused? #

Whether the spinner is paused


[View source]
def redraw_indent #

Redraw the indent for this spinner, if it exists


[View source]
def reset #

[View source]
def resume #

Resume spinner


[View source]
def row : Int32 | Nil #

The current row inside a multi spinner


[View source]
def run(stop_message = "", &block : Spinner -> ) #

Runspinner while executing job


[View source]
def spin #

Perform a spin


[View source]
def spinning? #

Whether the spinner is spinning


[View source]
def start #

Start timer and unlock spinner


[View source]
def state : Symbol #

The current spinner state


[View source]
def stop(stop_message = "") #

Stop the running spinner


[View source]
def stopped? #

Whether spinner is stopped


[View source]
def success(stop_message = "") #

Finish spinning and set state to :success


[View source]
def success? #

Whether the spinner is in the success state. When true the spinner is marked with a success mark.


[View source]
def tokens : Hash(String, String) #

Tokens for the message


[View source]
def tty? #

[View source]
def update(**tokens) #

Update string formatting tokens


[View source]