Module Line.Internals
Exposes the underlying implementation of line segments for testing. This API is unstable, unsafe and mostly undocumented; here be dragons etc.
module Line_buffer : sig ... endval noop : unit -> _ Line.Internals.tval theta :
width:int ->
(Progress_engine__.Line_buffer.t -> Line.Internals.event -> unit) ->
_ Line.Internals.tval alpha :
width:int ->
initial:[ `Theta of Progress_engine__.Line_buffer.t -> unit | `Val of 'a ] ->
(Progress_engine__.Line_buffer.t -> Line.Internals.event -> 'a -> unit) ->
'a Line.Internals.tval alpha_unsized :
initial:
[ `Theta of width:(unit -> int) -> Progress_engine__.Line_buffer.t -> int
| `Val of 'a ] ->
(width:(unit -> int) ->
Progress_engine__.Line_buffer.t ->
Line.Internals.event ->
'a ->
int) ->
'a Line.Internals.tval array : 'a Line.Internals.t array -> 'a Line.Internals.tval pair :
?sep:unit Line.Internals.t ->
'a Line.Internals.t ->
'b Line.Internals.t ->
('a * 'b) Line.Internals.tval contramap : f:('a -> 'b) -> 'b Line.Internals.t -> 'a Line.Internals.tval on_finalise : 'a -> 'a Line.Internals.t -> 'a Line.Internals.tval of_pp :
width:int ->
initial:'a ->
(Stdlib.Format.formatter -> Line.Internals.event -> 'a -> unit) ->
'a Line.Internals.tof_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.
val conditional : ('a -> bool) -> 'a Line.Internals.t -> 'a Line.Internals.tconditional pred s has the same output format as s, but is only passes reported values down to s when they satisfy pred.
Stateful segments
val periodic : int -> 'a Line.Internals.t -> 'a Line.Internals.tperiodic 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.
val accumulator :
('a -> 'a -> 'a) ->
'a ->
'a Line.Internals.t ->
'a Line.Internals.taccumulator combine zero s has the same output format s.
val stateful : (unit -> 'a Line.Internals.t) -> 'a Line.Internals.tstateful 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.
Dynamically-sized segments
Certain segments can have their size determined dynamically by being wrapped inside one of the following boxes:
val box_dynamic :
?pad:[ `left | `right | `none ] ->
(unit -> int) ->
'a Line.Internals.t ->
'a Line.Internals.tbox w is a box that wraps a dynamically-sized segment and sets it to have size w () on each tick.
val box_fixed :
?pad:[ `left | `right | `none ] ->
int ->
'a Line.Internals.t ->
'a Line.Internals.tbox-fixed n s fixes the size of the dynamic segment s to be n.
val box_winsize :
?max:int ->
?fallback:int ->
'a Line.Internals.t ->
'a Line.Internals.tA box that takes on the current size of the terminal (or fallback if stdout is not attached to a terminal).
val to_line : 'a Line.Internals.t -> 'a Line.t