Module CCFormat
Helpers for Format
- since
- 0.8
Documentation for the standard Format module
include module type of sig ... end
val pp_open_box : formatter -> int -> unitval open_box : int -> unitval pp_close_box : formatter -> unit -> unitval close_box : unit -> unitval pp_open_hbox : formatter -> unit -> unitval open_hbox : unit -> unitval pp_open_vbox : formatter -> int -> unitval open_vbox : int -> unitval pp_open_hvbox : formatter -> int -> unitval open_hvbox : int -> unitval pp_open_hovbox : formatter -> int -> unitval open_hovbox : int -> unitval pp_print_string : formatter -> string -> unitval print_string : string -> unitval pp_print_as : formatter -> int -> string -> unitval print_as : int -> string -> unitval pp_print_int : formatter -> int -> unitval print_int : int -> unitval pp_print_float : formatter -> float -> unitval print_float : float -> unitval pp_print_char : formatter -> char -> unitval print_char : char -> unitval pp_print_bool : formatter -> bool -> unitval print_bool : bool -> unitval pp_print_space : formatter -> unit -> unitval print_space : unit -> unitval pp_print_cut : formatter -> unit -> unitval print_cut : unit -> unitval pp_print_break : formatter -> int -> int -> unitval print_break : int -> int -> unitval pp_print_custom_break : formatter -> fits:(string * int * string) -> breaks:(string * int * string) -> unitval pp_force_newline : formatter -> unit -> unitval force_newline : unit -> unitval pp_print_if_newline : formatter -> unit -> unitval print_if_newline : unit -> unitval pp_print_flush : formatter -> unit -> unitval print_flush : unit -> unitval pp_print_newline : formatter -> unit -> unitval print_newline : unit -> unitval pp_set_margin : formatter -> int -> unitval set_margin : int -> unitval pp_get_margin : formatter -> unit -> intval get_margin : unit -> intval pp_set_max_indent : formatter -> int -> unitval set_max_indent : int -> unitval pp_get_max_indent : formatter -> unit -> intval get_max_indent : unit -> int
val check_geometry : geometry -> boolval pp_set_geometry : formatter -> max_indent:int -> margin:int -> unitval set_geometry : max_indent:int -> margin:int -> unitval pp_safe_set_geometry : formatter -> max_indent:int -> margin:int -> unitval safe_set_geometry : max_indent:int -> margin:int -> unitval pp_update_geometry : formatter -> (geometry -> geometry) -> unitval update_geometry : (geometry -> geometry) -> unitval pp_get_geometry : formatter -> unit -> geometryval get_geometry : unit -> geometryval pp_set_max_boxes : formatter -> int -> unitval set_max_boxes : int -> unitval pp_get_max_boxes : formatter -> unit -> intval get_max_boxes : unit -> intval pp_over_max_boxes : formatter -> unit -> boolval over_max_boxes : unit -> boolval pp_open_tbox : formatter -> unit -> unitval open_tbox : unit -> unitval pp_close_tbox : formatter -> unit -> unitval close_tbox : unit -> unitval pp_set_tab : formatter -> unit -> unitval set_tab : unit -> unitval pp_print_tab : formatter -> unit -> unitval print_tab : unit -> unitval pp_print_tbreak : formatter -> int -> int -> unitval print_tbreak : int -> int -> unitval pp_set_ellipsis_text : formatter -> string -> unitval set_ellipsis_text : string -> unitval pp_get_ellipsis_text : formatter -> unit -> stringval get_ellipsis_text : unit -> string
val pp_open_stag : formatter -> stag -> unitval open_stag : stag -> unitval pp_close_stag : formatter -> unit -> unitval close_stag : unit -> unitval pp_set_tags : formatter -> bool -> unitval set_tags : bool -> unitval pp_set_print_tags : formatter -> bool -> unitval set_print_tags : bool -> unitval pp_set_mark_tags : formatter -> bool -> unitval set_mark_tags : bool -> unitval pp_get_print_tags : formatter -> unit -> boolval get_print_tags : unit -> boolval pp_get_mark_tags : formatter -> unit -> boolval get_mark_tags : unit -> boolval pp_set_formatter_out_channel : formatter -> Stdlib.out_channel -> unitval set_formatter_out_channel : Stdlib.out_channel -> unitval pp_set_formatter_output_functions : formatter -> (string -> int -> int -> unit) -> (unit -> unit) -> unitval set_formatter_output_functions : (string -> int -> int -> unit) -> (unit -> unit) -> unitval pp_get_formatter_output_functions : formatter -> unit -> (string -> int -> int -> unit) * (unit -> unit)val get_formatter_output_functions : unit -> (string -> int -> int -> unit) * (unit -> unit)
type formatter_out_functions= Stdlib__format.formatter_out_functions={out_string : string -> int -> int -> unit;out_flush : unit -> unit;out_newline : unit -> unit;out_spaces : int -> unit;out_indent : int -> unit;}
val pp_set_formatter_out_functions : formatter -> formatter_out_functions -> unitval set_formatter_out_functions : formatter_out_functions -> unitval pp_get_formatter_out_functions : formatter -> unit -> formatter_out_functionsval get_formatter_out_functions : unit -> formatter_out_functions
type formatter_stag_functions= Stdlib__format.formatter_stag_functions={mark_open_stag : stag -> string;mark_close_stag : stag -> string;print_open_stag : stag -> unit;print_close_stag : stag -> unit;}
val pp_set_formatter_stag_functions : formatter -> formatter_stag_functions -> unitval set_formatter_stag_functions : formatter_stag_functions -> unitval pp_get_formatter_stag_functions : formatter -> unit -> formatter_stag_functionsval get_formatter_stag_functions : unit -> formatter_stag_functionsval formatter_of_out_channel : Stdlib.out_channel -> formatterval std_formatter : formatterval err_formatter : formatterval formatter_of_buffer : Stdlib.Buffer.t -> formatterval stdbuf : Stdlib.Buffer.tval str_formatter : formatterval flush_str_formatter : unit -> stringval make_formatter : (string -> int -> int -> unit) -> (unit -> unit) -> formatterval formatter_of_out_functions : formatter_out_functions -> formatter
type symbolic_output_item= Stdlib__format.symbolic_output_item=|Output_flush|Output_newline|Output_string of string|Output_spaces of int|Output_indent of inttype symbolic_output_buffer= Stdlib__format.symbolic_output_buffer
val make_symbolic_output_buffer : unit -> symbolic_output_bufferval clear_symbolic_output_buffer : symbolic_output_buffer -> unitval get_symbolic_output_buffer : symbolic_output_buffer -> symbolic_output_item listval flush_symbolic_output_buffer : symbolic_output_buffer -> symbolic_output_item listval add_symbolic_output_item : symbolic_output_buffer -> symbolic_output_item -> unitval formatter_of_symbolic_output_buffer : symbolic_output_buffer -> formatterval pp_print_list : ?pp_sep:(formatter -> unit -> unit) -> (formatter -> 'a -> unit) -> formatter -> 'a list -> unitval pp_print_seq : ?pp_sep:(formatter -> unit -> unit) -> (formatter -> 'a -> unit) -> formatter -> 'a Stdlib.Seq.t -> unitval pp_print_text : formatter -> string -> unitval pp_print_option : ?none:(formatter -> unit -> unit) -> (formatter -> 'a -> unit) -> formatter -> 'a option -> unitval pp_print_result : ok:(formatter -> 'a -> unit) -> error:(formatter -> 'e -> unit) -> formatter -> ('a, 'e) Stdlib.result -> unitval fprintf : formatter -> ('a, formatter, unit) Stdlib.format -> 'aval printf : ('a, formatter, unit) Stdlib.format -> 'aval eprintf : ('a, formatter, unit) Stdlib.format -> 'aval sprintf : ('a, unit, string) Stdlib.format -> 'aval asprintf : ('a, formatter, unit, string) Stdlib.format4 -> 'aval dprintf : ('a, formatter, unit, formatter -> unit) Stdlib.format4 -> 'aval ifprintf : formatter -> ('a, formatter, unit) Stdlib.format -> 'aval kfprintf : (formatter -> 'a) -> formatter -> ('b, formatter, unit, 'a) Stdlib.format4 -> 'bval kdprintf : ((formatter -> unit) -> 'a) -> ('b, formatter, unit, 'a) Stdlib.format4 -> 'bval ikfprintf : (formatter -> 'a) -> formatter -> ('b, formatter, unit, 'a) Stdlib.format4 -> 'bval ksprintf : (string -> 'a) -> ('b, unit, string, 'a) Stdlib.format4 -> 'bval kasprintf : (string -> 'a) -> ('b, formatter, unit, 'a) Stdlib.format4 -> 'bval bprintf : Stdlib.Buffer.t -> ('a, formatter, unit) Stdlib.format -> 'aval kprintf : (string -> 'a) -> ('b, unit, string, 'a) Stdlib.format4 -> 'bval set_all_formatter_output_functions : out:(string -> int -> int -> unit) -> flush:(unit -> unit) -> newline:(unit -> unit) -> spaces:(int -> unit) -> unitval get_all_formatter_output_functions : unit -> (string -> int -> int -> unit) * (unit -> unit) * (unit -> unit) * (int -> unit)val pp_set_all_formatter_output_functions : formatter -> out:(string -> int -> int -> unit) -> flush:(unit -> unit) -> newline:(unit -> unit) -> spaces:(int -> unit) -> unitval pp_get_all_formatter_output_functions : formatter -> unit -> (string -> int -> int -> unit) * (unit -> unit) * (unit -> unit) * (int -> unit)val pp_open_tag : formatter -> tag -> unitval open_tag : tag -> unitval pp_close_tag : formatter -> unit -> unitval close_tag : unit -> unit
type formatter_tag_functions= Stdlib__format.formatter_tag_functions={mark_open_tag : tag -> string;mark_close_tag : tag -> string;print_open_tag : tag -> unit;print_close_tag : tag -> unit;}
val pp_set_formatter_tag_functions : formatter -> formatter_tag_functions -> unitval set_formatter_tag_functions : formatter_tag_functions -> unitval pp_get_formatter_tag_functions : formatter -> unit -> formatter_tag_functionsval get_formatter_tag_functions : unit -> formatter_tag_functions
type t= Stdlib.Format.formattertype 'a printer= t -> 'a -> unit
Combinators
val silent : 'a printerPrints nothing.
val unit : unit printerPrints "()".
val int : int printerval string : string printerval bool : bool printerval float3 : float printerval float : float printerval exn : exn printerPrinter using
Printexc.to_string.- since
- 3.0
val space : unit printerAlias to
pp_print_space.- since
- 3.2
val cut : unit printerAlias to
pp_print_cut.- since
- 3.2
val break : (int * int) printerTuple-ized
printerform ofpp_print_break.- since
- 3.2
val newline : unit printerForce newline (see
Format.pp_force_newline).- since
- 1.2
val substring : (string * int * int) printersubstring (s,i,len)prints the substring(s,i,len), whereiis the offset insandlenthe number of bytes in the substring.- raises Invalid_argument
if the triple
(s,i,len)does not describe a proper substring.
- since
- 1.2
val text : string printerPrint string, but replacing spaces with breaks and newlines with
newline. Seepp_print_texton recent versions of OCaml.- since
- 1.2
val string_lines : string printerstring_lines out sprintsswith all newlines ('\n') replaced by a cut, in a vertical box. It does NOT insert breakable spaces in place of spaces, unliketext. This means an already formatted string can be displayed inside another formatter without mangling the indentation.- since
- 3.3
val char : char printer- since
- 0.14
val int32 : int32 printer- since
- 0.14
val int64 : int64 printer- since
- 0.14
val nativeint : nativeint printer- since
- 0.14
val flush : unit printerAlias to
Format.pp_print_flush.- since
- 1.2
val list : ?sep:unit printer -> 'a printer -> 'a list printerval array : ?sep:unit printer -> 'a printer -> 'a array printerval arrayi : ?sep:unit printer -> (int * 'a) printer -> 'a array printerval seq : ?sep:unit printer -> 'a printer -> 'a Stdlib.Seq.t printerval iter : ?sep:unit printer -> 'a printer -> 'a iter printerval opt : 'a printer -> 'a option printeropt ppprints options as follows:Some xwill become "some foo" ifpp x ---> "foo".Nonewill become "none".
val pair : ?sep:unit printer -> 'a printer -> 'b printer -> ('a * 'b) printerval triple : ?sep:unit printer -> 'a printer -> 'b printer -> 'c printer -> ('a * 'b * 'c) printerval quad : ?sep:unit printer -> 'a printer -> 'b printer -> 'c printer -> 'd printer -> ('a * 'b * 'c * 'd) printerval append : unit printer -> unit printer -> unit printerappend ppa ppbfirst printsppa (), then printsppb ().- since
- 3.2
val append_l : unit printer list -> unit printerappend_l ppsruns the printers inppssequentially.- since
- 3.2
val within : string -> string -> 'a printer -> 'a printerwithin a b pwrapspinside the stringsaandb. Convenient, for instances, for brackets, parenthesis, quotes, etc.- since
- 0.17
val map : ('a -> 'b) -> 'b printer -> 'a printerval vbox : ?i:int -> 'a printer -> 'a printerWrap the printer in a vertical box.
- parameter i
level of indentation within the box (default 0).
- since
- 0.16
val hvbox : ?i:int -> 'a printer -> 'a printerWrap the printer in a horizontal/vertical box.
- parameter i
level of indentation within the box (default 0).
- since
- 0.16
val hovbox : ?i:int -> 'a printer -> 'a printerWrap the printer in a horizontal or vertical box.
- parameter i
level of indentation within the box (default 0).
- since
- 0.16
val return : ('a, _, _, 'a) Stdlib.format4 -> unit printerreturn "some_format_string"takes a argument-less format string and returns a printer actionable by(). Examples:return ",@ "return "@{<Red>and then@}@,"return "@[<v>a@ b@]"
- since
- 1.0
val of_to_string : ('a -> string) -> 'a printerof_to_string fconverts its input to a string usingf, then prints the string.- since
- 1.0
val some : 'a printer -> 'a option printersome ppwill print options as follows:Some xis printed usingpponxNoneis not printed at all
- since
- 1.0
ANSI codes
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:
- "reset" resets style
- "black"
- "red"
- "green"
- "yellow"
- "blue"
- "magenta"
- "cyan"
- "white"
- "bold" bold font
- "Black" bold black
- "Red" bold red
- "Green" bold green
- "Yellow" bold yellow
- "Blue" bold blue
- "Magenta" bold magenta
- "Cyan" bold cyan
- "White" bold white
Example:
set_color_default true;;
+CCFormat (containers.CCFormat) Module CCFormat
Helpers for Format
- since
- 0.8
Documentation for the standard Format module
include module type of sig ... end
val pp_open_box : formatter -> int -> unitval open_box : int -> unitval pp_close_box : formatter -> unit -> unitval close_box : unit -> unitval pp_open_hbox : formatter -> unit -> unitval open_hbox : unit -> unitval pp_open_vbox : formatter -> int -> unitval open_vbox : int -> unitval pp_open_hvbox : formatter -> int -> unitval open_hvbox : int -> unitval pp_open_hovbox : formatter -> int -> unitval open_hovbox : int -> unitval pp_print_string : formatter -> string -> unitval print_string : string -> unitval pp_print_as : formatter -> int -> string -> unitval print_as : int -> string -> unitval pp_print_int : formatter -> int -> unitval print_int : int -> unitval pp_print_float : formatter -> float -> unitval print_float : float -> unitval pp_print_char : formatter -> char -> unitval print_char : char -> unitval pp_print_bool : formatter -> bool -> unitval print_bool : bool -> unitval pp_print_space : formatter -> unit -> unitval print_space : unit -> unitval pp_print_cut : formatter -> unit -> unitval print_cut : unit -> unitval pp_print_break : formatter -> int -> int -> unitval print_break : int -> int -> unitval pp_print_custom_break : formatter -> fits:(string * int * string) -> breaks:(string * int * string) -> unitval pp_force_newline : formatter -> unit -> unitval force_newline : unit -> unitval pp_print_if_newline : formatter -> unit -> unitval print_if_newline : unit -> unitval pp_print_flush : formatter -> unit -> unitval print_flush : unit -> unitval pp_print_newline : formatter -> unit -> unitval print_newline : unit -> unitval pp_set_margin : formatter -> int -> unitval set_margin : int -> unitval pp_get_margin : formatter -> unit -> intval get_margin : unit -> intval pp_set_max_indent : formatter -> int -> unitval set_max_indent : int -> unitval pp_get_max_indent : formatter -> unit -> intval get_max_indent : unit -> int
val check_geometry : geometry -> boolval pp_set_geometry : formatter -> max_indent:int -> margin:int -> unitval set_geometry : max_indent:int -> margin:int -> unitval pp_safe_set_geometry : formatter -> max_indent:int -> margin:int -> unitval safe_set_geometry : max_indent:int -> margin:int -> unitval pp_update_geometry : formatter -> (geometry -> geometry) -> unitval update_geometry : (geometry -> geometry) -> unitval pp_get_geometry : formatter -> unit -> geometryval get_geometry : unit -> geometryval pp_set_max_boxes : formatter -> int -> unitval set_max_boxes : int -> unitval pp_get_max_boxes : formatter -> unit -> intval get_max_boxes : unit -> intval pp_over_max_boxes : formatter -> unit -> boolval over_max_boxes : unit -> boolval pp_open_tbox : formatter -> unit -> unitval open_tbox : unit -> unitval pp_close_tbox : formatter -> unit -> unitval close_tbox : unit -> unitval pp_set_tab : formatter -> unit -> unitval set_tab : unit -> unitval pp_print_tab : formatter -> unit -> unitval print_tab : unit -> unitval pp_print_tbreak : formatter -> int -> int -> unitval print_tbreak : int -> int -> unitval pp_set_ellipsis_text : formatter -> string -> unitval set_ellipsis_text : string -> unitval pp_get_ellipsis_text : formatter -> unit -> stringval get_ellipsis_text : unit -> string
val pp_open_stag : formatter -> stag -> unitval open_stag : stag -> unitval pp_close_stag : formatter -> unit -> unitval close_stag : unit -> unitval pp_set_tags : formatter -> bool -> unitval set_tags : bool -> unitval pp_set_print_tags : formatter -> bool -> unitval set_print_tags : bool -> unitval pp_set_mark_tags : formatter -> bool -> unitval set_mark_tags : bool -> unitval pp_get_print_tags : formatter -> unit -> boolval get_print_tags : unit -> boolval pp_get_mark_tags : formatter -> unit -> boolval get_mark_tags : unit -> boolval pp_set_formatter_out_channel : formatter -> Stdlib.out_channel -> unitval set_formatter_out_channel : Stdlib.out_channel -> unitval pp_set_formatter_output_functions : formatter -> (string -> int -> int -> unit) -> (unit -> unit) -> unitval set_formatter_output_functions : (string -> int -> int -> unit) -> (unit -> unit) -> unitval pp_get_formatter_output_functions : formatter -> unit -> (string -> int -> int -> unit) * (unit -> unit)val get_formatter_output_functions : unit -> (string -> int -> int -> unit) * (unit -> unit)
type formatter_out_functions = Stdlib__format.formatter_out_functions = {out_string : string -> int -> int -> unit;out_flush : unit -> unit;out_newline : unit -> unit;out_spaces : int -> unit;out_indent : int -> unit;
}
val pp_set_formatter_out_functions : formatter -> formatter_out_functions -> unitval set_formatter_out_functions : formatter_out_functions -> unitval pp_get_formatter_out_functions : formatter -> unit -> formatter_out_functionsval get_formatter_out_functions : unit -> formatter_out_functions
type formatter_stag_functions = Stdlib__format.formatter_stag_functions = {mark_open_stag : stag -> string;mark_close_stag : stag -> string;print_open_stag : stag -> unit;print_close_stag : stag -> unit;
}
val pp_set_formatter_stag_functions : formatter -> formatter_stag_functions -> unitval set_formatter_stag_functions : formatter_stag_functions -> unitval pp_get_formatter_stag_functions : formatter -> unit -> formatter_stag_functionsval get_formatter_stag_functions : unit -> formatter_stag_functionsval formatter_of_out_channel : Stdlib.out_channel -> formatterval std_formatter : formatterval err_formatter : formatterval formatter_of_buffer : Stdlib.Buffer.t -> formatterval stdbuf : Stdlib.Buffer.tval str_formatter : formatterval flush_str_formatter : unit -> stringval make_formatter : (string -> int -> int -> unit) -> (unit -> unit) -> formatterval formatter_of_out_functions : formatter_out_functions -> formatter
type symbolic_output_item = Stdlib__format.symbolic_output_item = | Output_flush| Output_newline| Output_string of string| Output_spaces of int| Output_indent of int
type symbolic_output_buffer = Stdlib__format.symbolic_output_buffer
val make_symbolic_output_buffer : unit -> symbolic_output_bufferval clear_symbolic_output_buffer : symbolic_output_buffer -> unitval get_symbolic_output_buffer : symbolic_output_buffer -> symbolic_output_item listval flush_symbolic_output_buffer : symbolic_output_buffer -> symbolic_output_item listval add_symbolic_output_item : symbolic_output_buffer -> symbolic_output_item -> unitval formatter_of_symbolic_output_buffer : symbolic_output_buffer -> formatterval pp_print_list : ?pp_sep:(formatter -> unit -> unit) -> (formatter -> 'a -> unit) -> formatter -> 'a list -> unitval pp_print_seq : ?pp_sep:(formatter -> unit -> unit) -> (formatter -> 'a -> unit) -> formatter -> 'a Stdlib.Seq.t -> unitval pp_print_text : formatter -> string -> unitval pp_print_option : ?none:(formatter -> unit -> unit) -> (formatter -> 'a -> unit) -> formatter -> 'a option -> unitval pp_print_result : ok:(formatter -> 'a -> unit) -> error:(formatter -> 'e -> unit) -> formatter -> ('a, 'e) Stdlib.result -> unitval fprintf : formatter -> ('a, formatter, unit) Stdlib.format -> 'aval printf : ('a, formatter, unit) Stdlib.format -> 'aval eprintf : ('a, formatter, unit) Stdlib.format -> 'aval sprintf : ('a, unit, string) Stdlib.format -> 'aval asprintf : ('a, formatter, unit, string) Stdlib.format4 -> 'aval dprintf : ('a, formatter, unit, formatter -> unit) Stdlib.format4 -> 'aval ifprintf : formatter -> ('a, formatter, unit) Stdlib.format -> 'aval kfprintf : (formatter -> 'a) -> formatter -> ('b, formatter, unit, 'a) Stdlib.format4 -> 'bval kdprintf : ((formatter -> unit) -> 'a) -> ('b, formatter, unit, 'a) Stdlib.format4 -> 'bval ikfprintf : (formatter -> 'a) -> formatter -> ('b, formatter, unit, 'a) Stdlib.format4 -> 'bval ksprintf : (string -> 'a) -> ('b, unit, string, 'a) Stdlib.format4 -> 'bval kasprintf : (string -> 'a) -> ('b, formatter, unit, 'a) Stdlib.format4 -> 'bval bprintf : Stdlib.Buffer.t -> ('a, formatter, unit) Stdlib.format -> 'aval kprintf : (string -> 'a) -> ('b, unit, string, 'a) Stdlib.format4 -> 'bval set_all_formatter_output_functions : out:(string -> int -> int -> unit) -> flush:(unit -> unit) -> newline:(unit -> unit) -> spaces:(int -> unit) -> unitval get_all_formatter_output_functions : unit -> (string -> int -> int -> unit) * (unit -> unit) * (unit -> unit) * (int -> unit)val pp_set_all_formatter_output_functions : formatter -> out:(string -> int -> int -> unit) -> flush:(unit -> unit) -> newline:(unit -> unit) -> spaces:(int -> unit) -> unitval pp_get_all_formatter_output_functions : formatter -> unit -> (string -> int -> int -> unit) * (unit -> unit) * (unit -> unit) * (int -> unit)val pp_open_tag : formatter -> tag -> unitval open_tag : tag -> unitval pp_close_tag : formatter -> unit -> unitval close_tag : unit -> unit
type formatter_tag_functions = Stdlib__format.formatter_tag_functions = {mark_open_tag : tag -> string;mark_close_tag : tag -> string;print_open_tag : tag -> unit;print_close_tag : tag -> unit;
}
val pp_set_formatter_tag_functions : formatter -> formatter_tag_functions -> unitval set_formatter_tag_functions : formatter_tag_functions -> unitval pp_get_formatter_tag_functions : formatter -> unit -> formatter_tag_functionsval get_formatter_tag_functions : unit -> formatter_tag_functions
type t = Stdlib.Format.formattertype -'a printer = t -> 'a -> unit
Combinators
val silent : 'a printerPrints nothing.
val unit : unit printerPrints "()".
val int : int printerval string : string printerval bool : bool printerval float3 : float printerval float : float printerval exn : exn printerPrinter using Printexc.to_string.
- since
- 3.0
val space : unit printerAlias to pp_print_space.
- since
- 3.2
val cut : unit printerAlias to pp_print_cut.
- since
- 3.2
val break : (int * int) printerTuple-ized printer form of pp_print_break.
- since
- 3.2
val newline : unit printerForce newline (see Format.pp_force_newline).
- since
- 1.2
val substring : (string * int * int) printersubstring (s,i,len) prints the substring (s,i,len), where i is the offset in s and len the number of bytes in the substring.
- raises Invalid_argument
if the triple (s,i,len) does not describe a proper substring.
- since
- 1.2
val text : string printerPrint string, but replacing spaces with breaks and newlines with newline. See pp_print_text on recent versions of OCaml.
- since
- 1.2
val string_lines : string printerstring_lines out s prints s with all newlines ('\n') replaced by a cut, in a vertical box. It does NOT insert breakable spaces in place of spaces, unlike text. This means an already formatted string can be displayed inside another formatter without mangling the indentation.
- since
- 3.3
val char : char printer- since
- 0.14
val int32 : int32 printer- since
- 0.14
val int64 : int64 printer- since
- 0.14
val nativeint : nativeint printer- since
- 0.14
val flush : unit printerAlias to Format.pp_print_flush.
- since
- 1.2
val list : ?sep:unit printer -> 'a printer -> 'a list printerval array : ?sep:unit printer -> 'a printer -> 'a array printerval arrayi : ?sep:unit printer -> (int * 'a) printer -> 'a array printerval seq : ?sep:unit printer -> 'a printer -> 'a Stdlib.Seq.t printerval iter : ?sep:unit printer -> 'a printer -> 'a iter printerval opt : 'a printer -> 'a option printeropt pp prints options as follows:
Some x will become "some foo" if pp x ---> "foo".None will become "none".
val pair : ?sep:unit printer -> 'a printer -> 'b printer -> ('a * 'b) printerval triple : ?sep:unit printer -> 'a printer -> 'b printer -> 'c printer -> ('a * 'b * 'c) printerval quad : ?sep:unit printer -> 'a printer -> 'b printer -> 'c printer -> 'd printer -> ('a * 'b * 'c * 'd) printerval append : unit printer -> unit printer -> unit printerappend ppa ppb first prints ppa (), then prints ppb ().
- since
- 3.2
val append_l : unit printer list -> unit printerappend_l pps runs the printers in pps sequentially.
- since
- 3.2
val within : string -> string -> 'a printer -> 'a printerwithin a b p wraps p inside the strings a and b. Convenient, for instances, for brackets, parenthesis, quotes, etc.
- since
- 0.17
val map : ('a -> 'b) -> 'b printer -> 'a printerval vbox : ?i:int -> 'a printer -> 'a printerWrap the printer in a vertical box.
- parameter i
level of indentation within the box (default 0).
- since
- 0.16
val hvbox : ?i:int -> 'a printer -> 'a printerWrap the printer in a horizontal/vertical box.
- parameter i
level of indentation within the box (default 0).
- since
- 0.16
val hovbox : ?i:int -> 'a printer -> 'a printerWrap the printer in a horizontal or vertical box.
- parameter i
level of indentation within the box (default 0).
- since
- 0.16
val return : ('a, _, _, 'a) Stdlib.format4 -> unit printerreturn "some_format_string" takes a argument-less format string and returns a printer actionable by (). Examples:
return ",@ "return "@{<Red>and then@}@,"return "@[<v>a@ b@]"
- since
- 1.0
val of_to_string : ('a -> string) -> 'a printerof_to_string f converts its input to a string using f, then prints the string.
- since
- 1.0
val some : 'a printer -> 'a option printersome pp will print options as follows:
Some x is printed using pp on xNone is not printed at all
- since
- 1.0
val const_string : string -> 'a printerconst_string s is a printer that ignores its input and always prints s.
- since
- NEXT_RELEASE
val opaque : 'a printeropaque is const_string "opaque". The exact string used is not stable.
- since
- NEXT_RELEASE
ANSI codes
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:
- "reset" resets style
- "black"
- "red"
- "green"
- "yellow"
- "blue"
- "magenta"
- "cyan"
- "white"
- "bold" bold font
- "Black" bold black
- "Red" bold red
- "Green" bold green
- "Yellow" bold yellow
- "Blue" bold blue
- "Magenta" bold magenta
- "Cyan" bold cyan
- "White" bold white
Example:
set_color_default true;;
Format.printf
"what is your @{<White>favorite color@}? @{<blue>blue@}! No, @{<red>red@}! Ahhhhhhh@.";;
status: unstable
- since
- 0.15
val set_color_tag_handling : t -> unitAdd functions to support color tags to the given formatter.
- since
- 0.15
val set_color_default : bool -> unitset_color_default b enables color handling on the standard formatters (stdout, stderr) if b = true as well as on sprintf formatters; it disables the color handling if b = false.
val with_color : string -> 'a printer -> 'a printerwith_color "Blue" pp behaves like the printer pp, but with the given style.
status: unstable
- since
- 0.16
val with_colorf : string -> t -> ('a, t, unit, unit) Stdlib.format4 -> 'awith_colorf "Blue" out "%s %d" "yolo" 42 will behave like Format.fprintf, but wrapping the content with the given style.
status: unstable
- since
- 0.16
val with_color_sf : string -> ('a, t, unit, string) Stdlib.format4 -> 'awith_color_sf "Blue" out "%s %d" "yolo" 42 will behave like sprintf, but wrapping the content with the given style.
Example:
CCFormat.with_color_sf "red" "%a" CCFormat.Dump.(list int) [1;2;3] |> print_endline;;
status: unstable
- since
- 0.21
val with_color_ksf : f:(string -> 'b) -> string -> ('a, t, unit, 'b) Stdlib.format4 -> 'awith_color_ksf "Blue" ~f "%s %d" "yolo" 42 will behave like ksprintf, but wrapping the content with the given style.
Example: the following with raise Failure with a colored message
CCFormat.with_color_ksf "red" ~f:failwith "%a" CCFormat.Dump.(list int) [1;2;3];;
- since
- 1.2
module ANSI_codes : sig ... endANSI escape codes. This contains lower level functions for them.
IO
val output : t -> 'a printer -> 'a -> unitval to_string : 'a printer -> 'a -> stringval of_chan : Stdlib.out_channel -> tAlias to Format.formatter_of_out_channel.
- since
- 1.2
val with_out_chan : Stdlib.out_channel -> (t -> 'a) -> 'awith_out_chan oc f turns oc into a formatter fmt, and call f fmt. Behaves like f fmt from then on, but whether the call to f fails or returns, fmt is flushed before the call terminates.
- since
- 1.2
val stdout : tval stderr : tval tee : t -> t -> ttee a b makes a new formatter that writes in both a and b.
- since
- 1.0
val sprintf : ('a, t, unit, string) Stdlib.format4 -> 'aPrint into a string any format string that would usually be compatible with fprintf. Like Format.asprintf.
val sprintf_no_color : ('a, t, unit, string) Stdlib.format4 -> 'aLike sprintf but never prints colors.
- since
- 0.16
val sprintf_dyn_color : colors:bool -> ('a, t, unit, string) Stdlib.format4 -> 'aLike sprintf but enable/disable colors depending on colors.
Example:
(* with colors *)
diff --git a/dev/containers/CCUtf8_string/index.html b/dev/containers/CCUtf8_string/index.html
index e7b3a7a5..8e9ad1ab 100644
--- a/dev/containers/CCUtf8_string/index.html
+++ b/dev/containers/CCUtf8_string/index.html
@@ -1,2 +1,2 @@
-CCUtf8_string (containers.CCUtf8_string) Module CCUtf8_string
Unicode String, in UTF8
type uchar = Stdlib.Uchar.ttype 'a gen = unit -> 'a optiontype 'a iter = ('a -> unit) -> unitFast internal iterator.
- since
- 2.8
val equal : t -> t -> boolval hash : t -> intval compare : t -> t -> intval pp : Stdlib.Format.formatter -> t -> unitval to_string : t -> stringIdentity.
val to_gen : ?idx:int -> t -> uchar genGenerator of unicode codepoints.
- parameter idx
offset where to start the decoding.
val to_iter : ?idx:int -> t -> uchar iterIterator of unicode codepoints.
- parameter idx
offset where to start the decoding.
- since
- 2.8
val to_seq : ?idx:int -> t -> uchar Stdlib.Seq.tIter of unicode codepoints. Renamed from to_std_seq since 3.0.
- parameter idx
offset where to start the decoding.
- since
- 3.0
val to_list : ?idx:int -> t -> uchar listList of unicode codepoints.
- parameter idx
offset where to start the decoding.
val fold : ?idx:int -> ('a -> uchar -> 'a) -> 'a -> t -> 'aval iter : ?idx:int -> (uchar -> unit) -> t -> unitval n_chars : t -> intNumber of characters.
val n_bytes : t -> intNumber of bytes.
val map : (uchar -> uchar) -> t -> tval filter_map : (uchar -> uchar option) -> t -> tval flat_map : (uchar -> t) -> t -> tval append : t -> t -> tval concat : t -> t list -> tval of_seq : uchar Stdlib.Seq.t -> tBuild a string from unicode codepoints Renamed from of_std_seq since 3.0.
- since
- 3.0
val uchar_to_bytes : uchar -> char iterTranslate the unicode codepoint to a list of utf-8 bytes. This can be used, for example, in combination with Buffer.add_char on a pre-allocated buffer to add the bytes one by one (despite its name, Buffer.add_char takes individual bytes, not unicode codepoints).
- since
- 3.2
val of_gen : uchar gen -> tval of_list : uchar list -> tval of_string_exn : string -> tValidate string by checking it is valid UTF8.
- raises Invalid_argument
if the string is not valid UTF8.
val of_string : string -> t optionSafe version of of_string_exn.
val unsafe_of_string : string -> tConversion from a string without validating. CAUTION this is unsafe and can break all the other functions in this module. Use only if you're sure the string is valid UTF8. Upon iteration, if an invalid substring is met, Malformed will be raised.
\ No newline at end of file
+CCUtf8_string (containers.CCUtf8_string) Module CCUtf8_string
Unicode String, in UTF8
type uchar = Stdlib.Uchar.ttype 'a gen = unit -> 'a optiontype 'a iter = ('a -> unit) -> unitFast internal iterator.
- since
- 2.8
val equal : t -> t -> boolval hash : t -> intval compare : t -> t -> intval pp : Stdlib.Format.formatter -> t -> unitval to_string : t -> stringIdentity.
val to_gen : ?idx:int -> t -> uchar genGenerator of unicode codepoints.
- parameter idx
offset where to start the decoding.
val to_iter : ?idx:int -> t -> uchar iterIterator of unicode codepoints.
- parameter idx
offset where to start the decoding.
- since
- 2.8
val to_seq : ?idx:int -> t -> uchar Stdlib.Seq.tIter of unicode codepoints. Renamed from to_std_seq since 3.0.
- parameter idx
offset where to start the decoding.
- since
- 3.0
val to_list : ?idx:int -> t -> uchar listList of unicode codepoints.
- parameter idx
offset where to start the decoding.
val fold : ?idx:int -> ('a -> uchar -> 'a) -> 'a -> t -> 'aval iter : ?idx:int -> (uchar -> unit) -> t -> unitval n_chars : t -> intNumber of characters.
val n_bytes : t -> intNumber of bytes.
val map : (uchar -> uchar) -> t -> tval filter_map : (uchar -> uchar option) -> t -> tval flat_map : (uchar -> t) -> t -> tval empty : tEmpty string.
- since
- NEXT_RELEASE
val concat : t -> t list -> tconcat sep l concatenates each string in l, inserting sep in between each string. Similar to String.concat.
val of_seq : uchar Stdlib.Seq.t -> tBuild a string from unicode codepoints Renamed from of_std_seq since 3.0.
- since
- 3.0
val uchar_to_bytes : uchar -> char iterTranslate the unicode codepoint to a list of utf-8 bytes. This can be used, for example, in combination with Buffer.add_char on a pre-allocated buffer to add the bytes one by one (despite its name, Buffer.add_char takes individual bytes, not unicode codepoints).
- since
- 3.2
val of_gen : uchar gen -> tval of_list : uchar list -> tval of_string_exn : string -> tValidate string by checking it is valid UTF8.
- raises Invalid_argument
if the string is not valid UTF8.
val of_string : string -> t optionSafe version of of_string_exn.
val unsafe_of_string : string -> tConversion from a string without validating. CAUTION this is unsafe and can break all the other functions in this module. Use only if you're sure the string is valid UTF8. Upon iteration, if an invalid substring is met, Malformed will be raised.
\ No newline at end of file