A modular, clean and powerful extension of the OCaml standard library
Library containers
Module CCFormat . ANSI_codes
type color = [
| `Black
| `Red
| `Yellow
| `Green
| `Blue
| `Magenta
| `Cyan
| `White

An ANSI color

type style = [
| `FG of color(*


| `BG of color(*


| `Bold
| `Reset

A style. Styles can be composed in a list.

val clear_line : string

clear_line is an escape code to clear the current line. It is very useful for progress bars; for example:

let pp_progress i =
  Printf.printf "%sprogress at %d%!" ANSI_codes.clear_line i

if called repeatedly this will print successive progress messages on a single line.

val reset : string

The escape code to reset style (colors, bold, etc.)

val string_of_style : style -> string

string_of_style st is an escape code to set the current style to st. It can be printed as is on any output that is a compatible terminal.

val string_of_style_list : style list -> string

string_of_style_list styles is an escape code for multiple styles at once. For example string_of_style_list ANSI_codes.([`FG `Red; `BG `Green; `Bold]) is a very shiny style.