clucolor/
colors.rs

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			/*impl Debug for $name {
59				fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
60					f.debug_struct(Self::name()).finish()
61				}
62			}*/
63			
64		)+
65
66	};
67}
68
69//Generation of colors at compile time
70build_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	/*"30" |		b"30"		|	BoldBlack
81	"31" |		b"31"		|	BoldRed
82	"32" |		b"32"		|	BoldGreen
83	"33" |		b"33"		|	BoldYellow
84	"34" |		b"34"		|	BoldBlue
85	"35" |		b"35"		|	BoldMagenta
86	"36" |		b"36"		|	BoldCyan
87	"37" |		b"37"		|	BoldWhite*/
88	
89	
90	"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	/*"90" |		b"90"		|	BoldBrightBlack
100	"91" |		b"91"		|	BoldBrightRed
101	"92" |		b"92"		|	BoldBrightGreen
102	"93" |		b"93"		|	BoldBrightYellow
103	"94" |		b"94"		|	BoldBrightBlue
104	"95" |		b"95"		|	BoldBrightMagenta
105	"96" |		b"96"		|	BoldBrightCyan
106	"97" |		b"97"		|	BoldBrightWhite*/
107);
108