Skip to content

Commit d64f98e

Browse files
committed
feat: export pretty printer for colors
1 parent 83db5e6 commit d64f98e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
* chore: drop dune as a dependency to fix .opam files
1010

11+
* feat: create colors from RGB tuples
12+
13+
* feat: pretty print colors
14+
1115
## 0.0.1
1216

1317
Initial release, including:

tty/color.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
type t = RGB of int * int * int | ANSI of int | ANSI256 of int | No_color
22

3+
let pp fmt t =
4+
match t with
5+
| RGB (r, g, b) -> Format.fprintf fmt "RGB(%d,%d,%d)" r g b
6+
| ANSI i -> Format.fprintf fmt "ANSI(%d)" i
7+
| ANSI256 i -> Format.fprintf fmt "ANSI256(%d)" i
8+
| No_color -> Format.fprintf fmt "No_color"
9+
310
exception Invalid_color of string
411
exception Invalid_color_param of string
512
exception Invalid_color_num of string * int

tty/color.mli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ type t = private
55
| No_color
66

77
val make : string -> t
8-
val of_rgb : (int * int * int) -> t
8+
val of_rgb : int * int * int -> t
9+
val pp : Format.formatter -> t -> unit
910

1011
exception Invalid_color of string
1112
exception Invalid_color_param of string

0 commit comments

Comments
 (0)