| 1 | (************************************************************************) |
| 2 | (* * The Rocq Prover / The Rocq Development Team *) |
| 3 | (* v * Copyright INRIA, CNRS and contributors *) |
| 4 | (* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 | (* \VV/ **************************************************************) |
| 6 | (* // * This file is distributed under the terms of the *) |
| 7 | (* * GNU Lesser General Public License Version 2.1 *) |
| 8 | (* * (see LICENSE file for the text of the license) *) |
| 9 | (************************************************************************) |
| 10 | |
| 11 | type color = [ |
| 12 | `DEFAULT |
| 13 | | `BLACK |
| 14 | | `RED |
| 15 | | `GREEN |
| 16 | | `YELLOW |
| 17 | | `BLUE |
| 18 | | `MAGENTA |
| 19 | | `CYAN |
| 20 | | `WHITE |
| 21 | | `LIGHT_BLACK |
| 22 | | `LIGHT_RED |
| 23 | | `LIGHT_GREEN |
| 24 | | `LIGHT_YELLOW |
| 25 | | `LIGHT_BLUE |
| 26 | | `LIGHT_MAGENTA |
| 27 | | `LIGHT_CYAN |
| 28 | | `LIGHT_WHITE |
| 29 | | `INDEX of int |
| 30 | | `RGB of (int * int * int) |
| 31 | ] |
| 32 | |
| 33 | type style = { |
| 34 | fg_color : color option; |
| 35 | bg_color : color option; |
| 36 | bold : bool option; |
| 37 | italic : bool option; |
| 38 | underline : bool option; |
| 39 | negative : bool option; |
| 40 | prefix : string option; |
| 41 | suffix : string option; |
| 42 | } |
| 43 | |
| 44 | val make : ?fg_color:color -> ?bg_color:color -> |
| 45 | ?bold:bool -> ?italic:bool -> ?underline:bool -> |
| 46 | ?negative:bool -> ?style:style -> |
| 47 | ?prefix:string -> ?suffix:string -> unit -> style |
| 48 | (** Create a style from the given flags. It is derived from the optional |
| 49 | [style] argument if given. *) |
| 50 | |
| 51 | val merge : style -> style -> style |
| 52 | (** [merge s1 s2] returns [s1] with all defined values of [s2] overwritten. *) |
| 53 | |
| 54 | val diff : style -> style -> style |
| 55 | (** [diff s1 s2] returns the differences between [s1] and [s2]. *) |
| 56 | |
| 57 | val repr : style -> int list |
| 58 | (** Generate the ANSI code representing the given style. *) |
| 59 | |
| 60 | val eval : style -> string |
| 61 | (** Generate an escape sequence from a style. *) |
| 62 | |
| 63 | val reset : string |
| 64 | (** This escape sequence resets all attributes. *) |
| 65 | |
| 66 | val reset_style : style |
| 67 | (** The default style *) |
| 68 | |
| 69 | val has_style : Unix.file_descr -> bool |
| 70 | (** Whether an output file descriptor handles styles. Very heuristic, only |
| 71 | checks it is a terminal. *) |
| 72 | |
| 73 | val parse : string -> (string * style) list |
| 74 | (** Parse strings describing terminal styles in the LS_COLORS syntax. For |
| 75 | robustness, ignore meaningless entries and drops undefined styles. *) |