progress.indeterminate
Indeterminate progress indicator (aka a “spinner”), for the case where the progress of a long-running task cannot be determined.
animate!
macro
(animate! & body)
Wraps the given forms in an indeterminate progress indicator. If the first form is the keyword :opts
, the second form must be a map, containing any/all of these keys:
:frames
- the frames (a sequence ofString
s) to use for the indeterminate progress indicator (default is(:ascii-spinner styles)
):delay-in-ms
- the delay (in ms) between frames (default is100
ms):fg-colour
- the foregound colour of the indeterminate progress indicator (default is:default
) - see thejansi-clj
docs for allowed values, and prefix withbright-
to get the bright equivalent:bg-colour
- the background colour of the indeterminate progress indicator (default is:default
) - see thejansi-clj
docs for allowed values, and prefix withbright-
to get the bright equivalent:attributes
- the attributes of the indeterminate progress indicator (default is[:default]
) - see thejansi-clj
docs for allowed values
animatef!
(animatef! f)
(animatef! opts f)
Starts the indeterminate progress indicator, calls fn f
(a function of zero parameters), then stops the progress indicator. Returns the result of f
.
Note: the animate! macro is preferred over this function.
The optional opts
map may have an/all of these keys:
:frames
- the frames (a sequence ofString
s) to use for the indeterminate progress indicator (default is(:ascii-spinner styles)
):delay-in-ms
- the delay (in ms) between frames (default is100
ms):fg-colour
- the foregound colour of the indeterminate progress indicator (default is:default
) - see thejansi-clj
docs for allowed values, and prefix withbright-
to get the bright equivalent:bg-colour
- the background colour of the indeterminate progress indicator (default is:default
) - see thejansi-clj
docs for allowed values, and prefix withbright-
to get the bright equivalent:attributes
- the attributes of the indeterminate progress indicator (default is[:default]
) - see thejansi-clj
docs for allowed values
default-delay-ms
The default delay between frames (in milliseconds), if one isn’t specified.
default-style
The default indeterminate progress indicator style used, if one isn’t specified, as a keyword
that has an associated entry in styles. This style is known to function on all platforms.
(print & more)
Schedules the given values for printing (via clojure.core/print), since clojure.core/print and related output fns interfere with an active indeterminate progress indicator.
Notes:
- output is emitted in between ‘frames’ of the progress indicator, so may not appear immediately
- values are space delimited (as in clojure.core/print) - use clojure.core/str, clojure.core/format, etc. for finer control
- no newlines are inserted - if message(s) are to appear on new lines the caller needs to include
\n
in the value(s)
state
(state)
What state is the indeterminate progress indicator currently in? One of:
:inactive
:active
:shutting-down
styles
A selection of predefined styles of determinate progress indicators, represented as a map
. Only ASCII progress indicators are known to work reliably - other styles depend on the operating system, terminal font & encoding, phase of the moon, and how long since your dog last pooped.