forked from angelakis/Edsger-Compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNicePrint.ml
35 lines (26 loc) · 945 Bytes
/
NicePrint.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(******************************)
(* Colored Printing Functions *)
(******************************)
(* Supported Colors *)
type color =
| Normal
| Green
| Red;;
(********************************************************************)
(* If you want to add additional colors, please adjust 'type color' *)
(* and add the corresponding code in the following function. More: *)
(* https://en.wikipedia.org/wiki/ANSI_escape_code *)
(********************************************************************)
let colortxt = function
| Normal -> "\x1B[0m"
| Green -> "\x1B[32m"
| Red -> "\x1B[31m"
(* These Functions Print on Standard Error *)
let eprintf_color color =
prerr_string @@ colortxt color;
Printf.eprintf;;
let eclear () = prerr_string @@ colortxt Normal
let printf_color color =
print_string @@ colortxt color;
Printf.printf;;
let clear () = print_string @@ colortxt Normal