Module B0_std.Tty

module Tty: sig .. end

ANSI terminal interaction.


Terminals

type t = [ `Dumb | `Term of string ] option 

The type for terminals. Either no terminal, a dumb one or a named terminal from the TERM environment variable.

val of_fd : Unix.file_descr -> t

of_fd fd determines the terminal for file descriptor fd by using Unix.isatty fd and consulting the TERM environment variable.

Capabilities

type cap = [ `Ansi | `None ] 

The type for terminal capabilities. Either no capability or ANSI capability.

val cap : t -> cap

cap tty determines tty's capabilities.

ANSI escapes and 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 styled_str : cap -> style list -> string -> string

styled_str cap styles s styles s according to styles and cap.

val strip_escapes : string -> string

strip_escapes s removes ANSI escapes from s.