Module B0.Tty

module Tty: sig .. end
ANSI terminal interaction.


Terminal kind and capabilities


type kind = 
| No_tty
| Dumb
| Term of string
The type for terminals.
val kind : out:Unix.file_descr -> kind
kind out determines the kind of terminal by consulting the the TERM environment variable and using Unix.isatty on out.
type cap = 
| Ansi
| None
The type for terminal capabilities. Either ANSI terminal or none.
val cap : kind -> cap
cap kind determines capabilities according to kind.
val strip_escapes : string -> string
strip_escapes s removes ANSI escapes from s.

ANSI styling


type color = [ `Black
| `Blue
| `Cyan
| `Default
| `Green
| `Magenta
| `Red
| `White
| `Yellow ]
The type for ANSI colors.
type style = [ `Bg of color
| `Blink of [ `Rapid | `Slow ]
| `Bold
| `Faint
| `Fg of color
| `Italic
| `Reverse
| `Underline ]
The type for ANSI styles.
val str_cap : cap -> style list -> string -> string
str_cap cap styles s styles s according to styles and cap.

Global styling specification


val set_styling_cap : cap -> unit
set_styling_cap c sets the global styling capabilities to c. Affects the output of B0.Tty.str, B0.Tty.pp and B0.Tty.pp_str.
val styling_cap : unit -> cap
styling_cap () is the global styling capability.
val str : style list -> string -> string
str styles s styles s according to styles and the value of B0.Tty.styling_cap.
val pp_str : style list -> string B0.Fmt.t
pp_str styles ppf s prints s on ppf according to styles and the value of B0.Tty.styling_cap.
val pp : style list -> 'a B0.Fmt.t -> 'a B0.Fmt.t
pp styles pp_v ppf v prints v with pp_v on ppf according to styles and the value of B0.Tty.styling_cap.