package epictetus

  1. Overview
  2. Docs

A default ALIGNER in which contents are pretty-printers with the expected output size. Especially useful when using semantic tags or when printing ANSI escape sequences. The size is computed by calling the pretty-printer. It would better be pure!

type contents = Stdlib.Format.formatter -> unit
type _tree_contents =
  1. | Leaf of contents
  2. | Node of tree_contents list
and tree_contents = {
  1. node : _tree_contents;
  2. fill_with : char;
  3. align : Alignment.alignment;
}
val leaf : ?fill_with:char -> ?align:Alignment.alignment -> contents -> tree_contents
val node : ?fill_with:char -> ?align:Alignment.alignment -> tree_contents list -> tree_contents
val tree_size : tree_contents -> Size_tree.t

Compute the tree_size of a tree_contents.

val tree_size_of_list : tree_contents list -> Size_tree.t option

Compute the tree_size of a list of tree_contents. Return None if the list is empty.

val print_tree_with_size : ?trailing_whitespaces:bool -> Size_tree.t -> Stdlib.Format.formatter -> tree_contents -> unit

Print a tree_contents with respect to a given tree_size. This tree_size must be bigger than the tree_size corresponding to the tree_contents. Otherwise the behavior is undefined. Be careful.

trailing_whitespaces: whether to print trailing whitespaces. False by default.

val print_table : ?trailing_whitespaces:bool -> Stdlib.Format.formatter -> tree_contents list -> unit

Print a list of tree_contents in a consistent way: it uses the smallest tree_size computed by joining all tree_size. This function must compute and merge all tree_size before starting. This is a good entrypoint.

trailing_whitespaces: whether to print trailing whitespaces. False by default.

val kprint_table : ?trailing_whitespaces:bool -> (Stdlib.Format.formatter -> unit) -> Stdlib.Format.formatter -> tree_contents list -> unit

Like print_table but call the first parameter at the end of each line.

trailing_whitespaces: whether to print trailing whitespaces. False by default.

val stringify_table : ?trailing_whitespaces:bool -> tree_contents list -> string list

Print in a list of string a list of tree_contents in a consistent way: it uses the smallest tree_size computed by joining all tree_size. This function must compute and merge all tree_size before starting. This is a good entrypoint.

trailing_whitespaces: whether to print trailing whitespaces. False by default.

val pp_of_table : ?trailing_whitespaces:bool -> tree_contents list -> (Stdlib.Format.formatter -> unit) list