1
2use std::fmt;
3use std::fmt::Display;
4
5use cluColor;
6
7
8macro_rules! build_type_colored {
9
10 ( $( $color:tt | $color_byte:tt | $name:ident )+ ) => {
11 build_type_colored!( $( $color | $color_byte | $name, stringify!($name) )+ );
12 };
13
14
15
16 ( $( $color:tt | $color_byte:tt | $name:ident, $doc_name:expr )+ ) => {
17 $(
18 #[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
19
20 #[doc = "Color Type `"]
21 #[doc = $doc_name]
22 #[doc = "`."]
23 pub enum $name {}
24
25 impl cluColor for $name {
26
27 #[doc = "Return \""]
28 #[doc = $color]
29 #[inline(always)]
30 fn raw_color<'a>() -> &'a str {
31 $color
32 }
33
34 #[doc = "Return b\""]
35 #[doc = $color]
36 #[doc = "\""]
37 #[inline(always)]
38 fn raw_color_b<'a>() -> &'a [u8] {
39 $color_byte
40 }
41
42
43 #[doc = "Return \""]
44 #[doc = $doc_name]
45 #[doc = "\""]
46 #[inline(always)]
47 fn name<'a>() -> &'a str {
48 $doc_name
49 }
50 }
51
52 impl Display for $name {
53 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
54 write!(f, "{}", Self::name())
55 }
56 }
57
58 )+
65
66 };
67}
68
69build_type_colored! (
71 "30" | b"30" | Black
72 "31" | b"31" | Red
73 "32" | b"32" | Green
74 "33" | b"33" | Yellow
75 "34" | b"34" | Blue
76 "35" | b"35" | Magenta
77 "36" | b"36" | Cyan
78 "37" | b"37" | White
79
80 "90" | b"90" | BrightBlack
91 "91" | b"91" | BrightRed
92 "92" | b"92" | BrightGreen
93 "93" | b"93" | BrightYellow
94 "94" | b"94" | BrightBlue
95 "95" | b"95" | BrightMagenta
96 "96" | b"96" | BrightCyan
97 "97" | b"97" | BrightWhite
98
99 );
108