From e1e987cc898aae741ae85ac8e311f7a204045b16 Mon Sep 17 00:00:00 2001 From: c-cube Date: Sat, 19 Mar 2022 23:00:53 +0000 Subject: [PATCH] deploy: 6fa4c1c7d261f0fa611cb0f4b1c2e812021ebfa6 --- dev/containers/CCFormat/index.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dev/containers/CCFormat/index.html b/dev/containers/CCFormat/index.html index bb758d24..64f10322 100644 --- a/dev/containers/CCFormat/index.html +++ b/dev/containers/CCFormat/index.html @@ -134,7 +134,13 @@ Format.printf f:( string -> 'b ) -> string -> ( 'a, t, unit, 'b ) Stdlib.format4 -> - 'a

with_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];;
module ANSI_codes : sig ... end

ANSI escape codes. This contains lower level functions for them.

IO

val output : t -> 'a printer -> 'a -> unit
val to_string : 'a printer -> 'a -> string
val of_chan : Stdlib.out_channel -> t

Alias to Format.formatter_of_out_channel.

  • since 1.2
val with_out_chan : Stdlib.out_channel -> ( t -> 'a ) -> 'a

with_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 : t
val stderr : t
val tee : t -> t -> t

tee a b makes a new formatter that writes in both a and b.

  • since 1.0
val sprintf : ( 'a, t, unit, string ) Stdlib.format4 -> 'a

Print 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 -> 'a

Like sprintf but never prints colors.

  • since 0.16
val sprintf_dyn_color : + 'a

with_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 ... end

ANSI escape codes. This contains lower level functions for them.

val styling : ANSI_codes.style list -> 'a printer -> 'a printer

styling st p is the same printer as p, except it locally sets the style st.

Example:

open CCFormat;
+set_color_default true;
+sprintf
+  "what is your %a? %a! No, %a! Ahhhhhhh@."
+  (styling [`FG `White; `Bold] string) "favorite color"
+  (styling [`FG `Blue] string) "blue"
+  (styling [`FG `Red] string) "red"

Available only on OCaml >= 4.08.

  • since NEXT_RELEASE
val with_styling : ANSI_codes.style list -> t -> ( unit -> 'a ) -> 'a

with_styling style fmt f sets the given style on fmt, calls f(), then restores the previous style. It is useful in imperative-style printers (a sequence of "print a; print b; …").

Available only on OCaml >= 4.08.

  • since NEXT_RELEASE

IO

val output : t -> 'a printer -> 'a -> unit
val to_string : 'a printer -> 'a -> string
val of_chan : Stdlib.out_channel -> t

Alias to Format.formatter_of_out_channel.

  • since 1.2
val with_out_chan : Stdlib.out_channel -> ( t -> 'a ) -> 'a

with_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 : t
val stderr : t
val tee : t -> t -> t

tee a b makes a new formatter that writes in both a and b.

  • since 1.0
val sprintf : ( 'a, t, unit, string ) Stdlib.format4 -> 'a

Print 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 -> 'a

Like sprintf but never prints colors.

  • since 0.16
val sprintf_dyn_color : colors:bool -> ( 'a, t, unit, string ) Stdlib.format4 -> 'a

Like sprintf but enable/disable colors depending on colors.

Example:

(* with colors *)