Library
Module
Module type
Parameter
Class
Class type
Segment
contains a DSL for defining custom progress bars.
val bar :
mode:[ `ASCII | `UTF8 ] ->
?width:[ `Fixed of int | `Expand ] ->
('a -> float) ->
'a t
bar ~width f
is a progress bar of the form:
[#######################################................]
which occupies width
-many columns and uses f
to determine the proportion of the bar that is filled.
If ~width:`Expand
is passed – which is the default – this segment must be contained inside a box that determines its size.
val const : string -> _ t
const s
is the segment that always displays s
. s
must not contain any newline characters.
val const_fmt : width:int -> (Format.formatter -> unit) -> _ t
val of_pp : width:int -> (Format.formatter -> 'a -> unit) -> 'a t
of_pp ~width pp
is a segment that uses the supplied fixed-width pretty-printer to render the value. The pretty-printer must never emit newline characters.
periodic n s
has the same output format as s
, but only passes reported values down to s
on every n
-th call. This is useful when progress is being reported from a hot-loop, where the cost of rendering is non-negligible.
accumulator combine zero s
has the same output format s
.
stateful f
is a segment that behaves as f ()
for any given render, allowing f
to initialise any display state at the start of the rendering process.
Certain segments can have their size determined dynamically by being wrapped inside one of the following boxes:
box w
is a box that wraps a dynamically-sized segment and sets it to have size w ()
on each tick.
A box that takes on the current size of the terminal (or fallback
if stdout is not attached to a terminal.)
Horizontally join a list of segments, with a given separator. sep
defaults to const " "
.
Horizontally join a pair of segments consuming different reported values into a single segment that consumes a pair.