module CCFormat:sig
..end
type'a
sequence =('a -> unit) -> unit
typet =
Format.formatter
type'a
printer =t -> 'a -> unit
val silent : 'a printer
val unit : unit printer
val int : int printer
val string : string printer
val bool : bool printer
val float3 : float printer
val float : float printer
val char : char printer
val int32 : int32 printer
val int64 : int64 printer
val nativeint : nativeint printer
val string_quoted : string printer
CCString.print
.val list : ?start:string ->
?stop:string ->
?sep:string -> 'a printer -> 'a list printer
val array : ?start:string ->
?stop:string ->
?sep:string -> 'a printer -> 'a array printer
val arrayi : ?start:string ->
?stop:string ->
?sep:string -> (int * 'a) printer -> 'a array printer
val seq : ?start:string ->
?stop:string ->
?sep:string -> 'a printer -> 'a sequence printer
val opt : 'a printer -> 'a option printer
opt pp
prints options as follows:
Some x
will become "some foo" if pp x ---> "foo"
None
will become "none"sep
argument is only availableval pair : ?sep:string ->
'a printer -> 'b printer -> ('a * 'b) printer
val triple : ?sep:string ->
'a printer ->
'b printer -> 'c printer -> ('a * 'b * 'c) printer
val quad : ?sep:string ->
'a printer ->
'b printer ->
'c printer ->
'd printer -> ('a * 'b * 'c * 'd) printer
val within : string -> string -> 'a printer -> 'a printer
within a b p
wraps p
inside the strings a
and b
. Convenient,
for instances, for brackets, parenthesis, quotes, etc.val map : ('a -> 'b) -> 'b printer -> 'a printer
val vbox : ?i:int -> 'a printer -> 'a printer
i
: level of indentation within the box (default 0)val hvbox : ?i:int -> 'a printer -> 'a printer
i
: level of indentation within the box (default 0)val hovbox : ?i:int -> 'a printer -> 'a printer
i
: level of indentation within the box (default 0)val hbox : 'a printer -> 'a printer
Use ANSI escape codes https://en.wikipedia.org/wiki/ANSI_escape_code to put some colors on the terminal.
This uses tags in format strings to specify the style. Current styles are the following:
Example:
set_color_default true;;
Format.printf
"what is your @{<White>favorite color@}? @{<blue>blue@}! No, @{<red>red@}! Ahhhhhhh@.";;
status: experimental
val set_color_tag_handling : t -> unit
val set_color_default : bool -> unit
set_color_default b
enables color handling on the standard formatters
(stdout, stderr) if b = true
as well as on CCFormat.sprintf
formatters;
it disables the color handling if b = false
.val with_color : string -> 'a printer -> 'a printer
with_color "Blue" pp
behaves like the printer pp
, but with the given
style.
status: experimentalval with_colorf : string -> t -> ('a, t, unit, unit) Pervasives.format4 -> 'a
with_colorf "Blue" out "%s %d" "yolo" 42
will behave like Format.fprintf
,
but wrapping the content with the given style
status: experimentalval output : t -> 'a printer -> 'a -> unit
val to_string : 'a printer -> 'a -> string
val stdout : t
val stderr : t
val sprintf : ('a, t, unit, string) Pervasives.format4 -> 'a
CCFormat.fprintf
. Similar to Format.asprintf
.val sprintf_no_color : ('a, t, unit, string) Pervasives.format4 -> 'a
val fprintf : t -> ('a, t, unit) Pervasives.format -> 'a
Format.fprintf
val ksprintf : f:(string -> 'b) -> ('a, Format.formatter, unit, 'b) Pervasives.format4 -> 'a
ksprintf fmt ~f
formats using fmt
, in a way similar to CCFormat.sprintf
,
and then calls f
on the resulting string.val to_file : string -> ('a, t, unit, unit) Pervasives.format4 -> 'a