package ocolor

  1. Overview
  2. Docs

Basic types and values

Types

Color types

type color4 = {
  1. r4 : bool;
  2. g4 : bool;
  3. b4 : bool;
  4. intensity4 : bool;
}

The type of 4-bits colors. They are informally rgb colors where each component is in a scale from 0 to 1, with an additionnal intensity bit.

type cube6 = {
  1. r6 : int;
  2. g6 : int;
  3. b6 : int;
}

The type of rgb colors with each component in [0; 5]. This is used to encode the 6*6*6 color cube of 8-bits colors?

type color8 =
  1. | Standard of color4
  2. | Cube6 of cube6
  3. | Grayscale of int

The type of a 8-bits color. Such a color is either a standard color, a 6*6*6 rgb color or some kind of grey on a 24-steps grayscale. Thus, the paramter of Grayscale should be in [0; 23]

type color24 = {
  1. r24 : int;
  2. g24 : int;
  3. b24 : int;
}

The type of 24-bits colors. Each component belongs to [0; 255].

type color =
  1. | C4 of color4
  2. | C8 of color8
  3. | C24 of color24

The type of a color that can be a 4-, 8- or 24-bits color.

Style types

type style =
  1. | Reset
  2. | Bold
  3. | Faint
  4. | Faint_bold_off
  5. | Italic
  6. | Italic_fraktur_off
  7. | Fraktur
  8. | DoubleUnderlined
  9. | Underlined
  10. | Underlined_off
  11. | Reverse_video
  12. | Reverse_video_off
  13. | Conceal
  14. | Conceal_off
  15. | Crossed_out
  16. | Crossed_out_off
  17. | Framed
  18. | Framed_encircled_off
  19. | Encircled
  20. | Overlined
  21. | Overlined_off
  22. | Default_font
  23. | Font of int
  24. | Fg of color
  25. | Default_fg
  26. | Bg of color
  27. | Default_bg

All style sequences that are implemented.

Helpers and values

Iterators on finite (small) color space

val fold_color4 : (color4 -> 'acc -> 'acc0) -> 'acc1 -> 'acc2
val fold_cube6 : (cube6 -> 'acc -> 'acc0) -> 'acc1 -> 'acc2
val fold_greyscale : (int -> 'acc -> 'acc0) -> 'acc1 -> 'acc2
val fold_color8 : (color8 -> 'acc -> 'acc0) -> 'acc1 -> 'acc2

Useful names for 4-bits colors

Standard 3-bits colors
val black : color4
val red : color4
val green : color4
val blue : color4
val yellow : color4
val magenta : color4
val cyan : color4
val white : color4
High intensity 4-bits colors
val hi_black : color4
val hi_red : color4
val hi_green : color4
val hi_blue : color4
val hi_yellow : color4
val hi_magenta : color4
val hi_cyan : color4
val hi_white : color4

Standard palettes types

type rgb = int * int * int
module Color4Map : sig ... end
module Color8Map : sig ... end
type color_palette =
  1. | VGA
  2. | CMD
  3. | Terminal_app
  4. | PuTTY
  5. | MIRC
  6. | Xterm
  7. | X
  8. | Ubuntu
  9. | Custom_palette of rgb Color4Map.t

The kind of palette the terminal uses. It is used to match a 4-bits color to a rgb color. This is useful to find the clostest 4-bits color to a rgb color, according to the actual colors.

module ColorPaletteMap : sig ... end