package terminal

  1. Overview
  2. Docs
Basic utilities for interacting with terminals

Install

dune-project
 Dependency

Authors

Maintainers

Sources

progress-0.5.0.tbz
sha256=7f87f0597363928c45ba859ae5a1430f6aa3c29e251ff1a53cf786ed0e045961
sha512=45dee4fe2ae0b7fc3ca675f6e854d738873eb608ef9155ea5d7edac4639c183ae1f512847a1b43bdfc1f4c459e7d5b44d03ee809455797e680f890b33d531367

doc/terminal.ansi/Terminal_ansi/Color/index.html

Module Terminal_ansi.ColorSource

Sourcetype t

The type of colours that can be rendered to a terminal.

4-bit ANSI colours

Colours built using ansi will be rendered using the standard 4-bit ANSI escape codes for terminals. The actual colours displayed to the user depend on their terminal configuration / theme, ensuring that they look natural in context.

Sourcetype plain = [
  1. | `black
  2. | `blue
  3. | `cyan
  4. | `green
  5. | `magenta
  6. | `red
  7. | `white
  8. | `yellow
]
Sourceval ansi : [ plain | `bright of plain ] -> t

24-bit RGB colours

Most modern terminals offer support for full 24-bit RGB colour (called "true colour") in addition to the 16 original ANSI colours. These colours are rendered exactly as requested, offering greater flexibility at the risk of clashing with the user's theming.

Sourceval rgb : int -> int -> int -> t

rgb r g b is the RGB24 colour with the given red, green and blue colour components respectively. Raises Invalid_argument if any of the components are outside the range [0, 255].

Sourceval hex : string -> t

hex s is the RGB24 colour given by the hex triplet s, which must start with #. Examples:

  • hex "#FF8C00" = rgb 0xFF 0x8C 0x00
  • hex "#fa0" = rgb 0xFF 0xAA 0x00

Raises Invalid_argument if the given string is not a #-prefixed hex triplet.

Sourceval pp_dump : Format.formatter -> t -> unit

Pretty-print a colour with an unspecified format.