add CCFormat.{h,v,hov,hv}box printer combinators

This commit is contained in:
Simon Cruanes 2016-02-24 20:01:18 +01:00
parent cb9dc59567
commit 33b61e8bab
2 changed files with 40 additions and 1 deletions

View file

@ -89,6 +89,26 @@ let map f pp fmt x =
pp fmt (f x);
()
let vbox ?(i=0) pp out x =
Format.pp_open_vbox out i;
pp out x;
Format.pp_close_box out ()
let hovbox ?(i=0) pp out x =
Format.pp_open_hovbox out i;
pp out x;
Format.pp_close_box out ()
let hvbox ?(i=0) pp out x =
Format.pp_open_hvbox out i;
pp out x;
Format.pp_close_box out ()
let hbox pp out x =
Format.pp_open_hbox out ();
pp out x;
Format.pp_close_box out ()
(** {2 IO} *)
let output fmt pp x = pp fmt x

View file

@ -44,7 +44,26 @@ val quad : 'a printer -> 'b printer -> 'c printer -> 'd printer -> ('a * 'b * 'c
val map : ('a -> 'b) -> 'b printer -> 'a printer
(** {2 ASCII codes}
val vbox : ?i:int -> 'a printer -> 'a printer
(** Wrap the printer in a vertical box
@param i level of indentation within the box (default 0)
@since NEXT_RELEASE *)
val hvbox : ?i:int -> 'a printer -> 'a printer
(** Wrap the printer in a horizontal/vertical box
@param i level of indentation within the box (default 0)
@since NEXT_RELEASE *)
val hovbox : ?i:int -> 'a printer -> 'a printer
(** Wrap the printer in a horizontal or vertical box
@param i level of indentation within the box (default 0)
@since NEXT_RELEASE *)
val hbox : 'a printer -> 'a printer
(** Wrap the printer in an horizontal box
@since NEXT_RELEASE *)
(** {2 ANSI codes}
Use ANSI escape codes https://en.wikipedia.org/wiki/ANSI_escape_code
to put some colors on the terminal.