Module Text_block
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
val nil : t
the empty block. a left and right unit to both
hcat
andvcat
val fill : char -> width:int -> height:int -> t
fill
andspace
assume width and height are non-negative
val space : width:int -> height:int -> t
val text : ?align:halign -> ?max_width:int -> string -> t
a basic block of text, split on newlines and horizontally aligned as specified.
If
max_width
is provided, split on whitespace and wrap words to respect the request. So long as no words are longer thanmax_width
, the resulting text block will be no wider thanmax_width
val textf : ?align:halign -> ?max_width:int -> ('r, unit, string, t) Core_kernel.format4 -> 'r
val vcat : ?align:halign -> ?sep:t -> t list -> t
vertical and horizontal concatenation with alignment
val height : t -> int
val valign : valign -> t list -> t list
vertical and horizontal sequence alignment. Both
valign
andhalign
return a list of the same length as the input, with the corresponding elements padded to the appropriate alignment.If you have a list of a statically known length, using
With_static_lengths.valign
orWith_static_lengths.halign
below will let the type checker know that the length of the returned list is equal to the length of the input list.
val halign : halign -> t list -> t list
val hstrut : int -> t
empty blocks with either horizontal or vertical extent -- useful for specifying a minimum width or height in conjunction with valign or halign, respectively
val vstrut : int -> t
val ansi_escape : ?prefix:string -> ?suffix:string -> t -> t
wrap a block with an ANSI escape sequence. The
prefix
andsuffix
arguments should render with zero width and height.
val render : t -> string
render a block of text as a string
val table : ?sep_width:int -> [ `Cols of (t list * halign) list ] -> [ `Rows of t list ]
val compress_table_header : ?sep_width:int -> [ `Cols of (t * t list * halign) list ] -> [ `Header of t ] * [ `Rows of t list ]
compress table header according to column widths. Input: a list of columns of the form (title, values, column alignment). Output: one header block and row sequence. Raises: if the
values
lists are not the same length in each column. Example:first name age first name last name age | last name | | | ==> | | | 30 sue smith 30 sue smith 18 bill rodriguez 18 bill rodriguez 76 rick jones 76 rick jones
val vsep : t
vsep = vstrut 1
val hsep : t
hsep = hstrut 1
val sexp : ('a -> Core_kernel.Sexp.t) -> 'a -> t
sexp sexp_of_a a = sexp_of_a a |> Sexp.to_string |> text
module With_static_lengths : sig ... end
Provide versions of halign and valign with the invariant about list length encoded into the types.