Skip to content

popoppo/clojure-spinners

Repository files navigation

Test Clojars Project

clojure-spinners

Various spinners for Clojure.
The built-in spinners are coming from cli-spinners and the implementation is designed to be (somewhat) compatible with clj-commons/spinner

Usage

The following 3 steps are needed to run spinners.

  • create a spinner instance by create!
  • start the spinner by start!
  • stop it by stop!

Here is a simple example.

(let [opts {:spinner :hearts
            :text "Hearts!!"}
      s (create! opts)]
  (start! s)
  (Thread/sleep 2000)
  (stop! s))

That can also be done with spin!.

(spin! {:text "Spin with spin!"}
       (Thread/sleep 2000))

You can find more examples here.

Character width

You can use any unicode chars.
The width of them are calculated based on the following document.

https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt
(Top page: https://www.unicode.org/reports/tr11/)

Note that

  • all chars defined as "Ambiguous" are handled as half width characters.
    Basically you don't need to care about it, but might get unexpected output with them.
  • In this library, all emoji characters are handled as wide characters even if you add "\ufe0e" (Variation Selector-15).

Related

  • cli-spinners - Spinners for use in the terminal.
  • ora - Elegant terminal spinners in JavaScript.
  • halo - Elegant terminal spinners for terminal, IPython and Jupyter.
  • spinner - Simple ANSI text spinner for command line Clojure apps.

I'd like to thank all related works!!

About

Various spinners for Clojure

Resources

License

Stars

Watchers

Forks

Packages

No packages published