struct
include SmartPrint
let (%) = (^-^)
let s str =
let has_leading_space = String.get str ~index:0 = Some ' ' in
let has_ending_space = String.(get str ~index:(length str - 1)) = Some ' ' in
(if has_leading_space then space else empty)
% words str
% (if has_ending_space then space else empty)
let sp = space
let sf fmt = ksprintf s fmt
let i i = OCaml.int i
let f f = OCaml.float f
let n = newline
let verbatim s = string s
let exn e = s (Printexc.to_string e)
let option ~f = function
| Some o -> f o
| None -> empty
let escape c = ksprintf string "\027[%sm" c
let color c t = escape c % t % escape "0"
let bold_red t = color "1;31" t
let bold_yellow t = color "1;33" t
let bold_green t = color "1;32" t
let greyish t = color "37" t
let to_string ~line_width ~indent t =
SmartPrint.to_string line_width indent t
let to_list ~line_width ~indent t =
let res = ref [] in
let add c = res := c :: !res in
SmartPrint.to_something line_width indent
(fun c -> `Char c |> add)
(fun s -> `String s |> add)
(fun s ofs len -> `Sub_string (s, ofs, len) |> add)
t;
List.rev !res
end