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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
use std::fmt;
use std::fmt::Display;
use cluColor;
macro_rules! build_type_colored {
( $( $color:tt | $color_byte:tt | $name:ident )+ ) => {
build_type_colored!( $( $color | $color_byte | $name, stringify!($name) )+ );
};
( $( $color:tt | $color_byte:tt | $name:ident, $doc_name:expr )+ ) => {
$(
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[doc = "Color Type `"]
#[doc = $doc_name]
#[doc = "`."]
pub enum $name {}
impl cluColor for $name {
#[doc = "Return \""]
#[doc = $color]
#[inline(always)]
fn raw_color<'a>() -> &'a str {
$color
}
#[doc = "Return b\""]
#[doc = $color]
#[doc = "\""]
#[inline(always)]
fn raw_color_b<'a>() -> &'a [u8] {
$color_byte
}
#[doc = "Return \""]
#[doc = $doc_name]
#[doc = "\""]
#[inline(always)]
fn name<'a>() -> &'a str {
$doc_name
}
}
impl Display for $name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", Self::name())
}
}
)+
};
}
build_type_colored! (
"30" | b"30" | Black
"31" | b"31" | Red
"32" | b"32" | Green
"33" | b"33" | Yellow
"34" | b"34" | Blue
"35" | b"35" | Magenta
"36" | b"36" | Cyan
"37" | b"37" | White
"90" | b"90" | BrightBlack
"91" | b"91" | BrightRed
"92" | b"92" | BrightGreen
"93" | b"93" | BrightYellow
"94" | b"94" | BrightBlue
"95" | b"95" | BrightMagenta
"96" | b"96" | BrightCyan
"97" | b"97" | BrightWhite
);