1macro_rules! xterm_colors {
2 ($(
3 $xterm_num:literal $name:ident ($r:literal, $g:literal, $b:literal)
4 )*) => {
5
6 pub(crate) mod dynamic {
7 use core::fmt;
8
9 #[allow(unused_imports)]
10 use crate::OwoColorize;
11
12 /// Available Xterm colors for use with [`OwoColorize::color`](OwoColorize::color)
13 /// or [`OwoColorize::on_color`](OwoColorize::on_color)
14 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
15 pub enum XtermColors {
16 $(
17 #[allow(missing_docs)]
18 $name,
19 )*
20 }
21
22 impl crate::DynColor for XtermColors {
23 fn fmt_ansi_fg(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 let color = match self {
25 $(
26 XtermColors::$name => concat!("\x1b[38;5;", stringify!($xterm_num), "m"),
27 )*
28 };
29
30 f.write_str(color)
31 }
32
33 fn fmt_ansi_bg(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34 let color = match self {
35 $(
36 XtermColors::$name => concat!("\x1b[48;5;", stringify!($xterm_num), "m"),
37 )*
38 };
39
40 f.write_str(color)
41 }
42
43 fn fmt_raw_ansi_fg(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44 let color = match self {
45 $(
46 XtermColors::$name => concat!("38;5;", stringify!($xterm_num)),
47 )*
48 };
49
50 f.write_str(color)
51 }
52
53 fn fmt_raw_ansi_bg(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54 let color = match self {
55 $(
56 XtermColors::$name => concat!("48;5;", stringify!($xterm_num)),
57 )*
58 };
59
60 f.write_str(color)
61 }
62
63 #[doc(hidden)]
64 fn get_dyncolors_fg(&self) -> crate::DynColors {
65 crate::DynColors::Xterm(*self)
66 }
67
68 #[doc(hidden)]
69 fn get_dyncolors_bg(&self) -> crate::DynColors {
70 crate::DynColors::Xterm(*self)
71 }
72 }
73
74 impl From<u8> for XtermColors {
75 fn from(x: u8) -> Self {
76 match x {
77 $(
78 $xterm_num => XtermColors::$name,
79 )*
80 }
81 }
82 }
83
84 impl From<XtermColors> for u8 {
85 fn from(color: XtermColors) -> Self {
86 match color {
87 $(
88 XtermColors::$name => $xterm_num,
89 )*
90 }
91 }
92 }
93 }
94
95 $(
96 #[allow(missing_docs)]
97 pub struct $name;
98
99 impl crate::Color for $name {
100 const ANSI_FG: &'static str = concat!("\x1b[38;5;", stringify!($xterm_num), "m");
101 const ANSI_BG: &'static str = concat!("\x1b[48;5;", stringify!($xterm_num), "m");
102
103 const RAW_ANSI_BG: &'static str = concat!("48;5;", stringify!($xterm_num));
104 const RAW_ANSI_FG: &'static str = concat!("48;5;", stringify!($xterm_num));
105
106 #[doc(hidden)]
107 type DynEquivelant = dynamic::XtermColors;
108
109 #[doc(hidden)]
110 const DYN_EQUIVELANT: Self::DynEquivelant = dynamic::XtermColors::$name;
111
112 #[doc(hidden)]
113 fn into_dyncolors() -> crate::DynColors {
114 crate::DynColors::Xterm(dynamic::XtermColors::$name)
115 }
116 }
117 )*
118 };
119}
120
121xterm_colors! {
122 0 UserBlack (0,0,0)
123 1 UserRed (128,0,0)
124 2 UserGreen (0,128,0)
125 3 UserYellow (128,128,0)
126 4 UserBlue (0,0,128)
127 5 UserMagenta (128,0,128)
128 6 UserCyan (0,128,128)
129 7 UserWhite (192,192,192)
130 8 UserBrightBlack (128,128,128)
131 9 UserBrightRed (255,0,0)
132 10 UserBrightGreen (0,255,0)
133 11 UserBrightYellow (255,255,0)
134 12 UserBrightBlue (0,0,255)
135 13 UserBrightMagenta (255,0,255)
136 14 UserBrightCyan (0,255,255)
137 15 UserBrightWhite (255,255,255)
138 16 Black (0,0,0)
139 17 StratosBlue (0,0,95)
140 18 NavyBlue (0,0,135)
141 19 MidnightBlue (0,0,175)
142 20 DarkBlue (0,0,215)
143 21 Blue (0,0,255)
144 22 CamaroneGreen (0,95,0)
145 23 BlueStone (0,95,95)
146 24 OrientBlue (0,95,135)
147 25 EndeavourBlue (0,95,175)
148 26 ScienceBlue (0,95,215)
149 27 BlueRibbon (0,95,255)
150 28 JapaneseLaurel (0,135,0)
151 29 DeepSeaGreen (0,135,95)
152 30 Teal (0,135,135)
153 31 DeepCerulean (0,135,175)
154 32 LochmaraBlue (0,135,215)
155 33 AzureRadiance (0,135,255)
156 34 LightJapaneseLaurel (0,175,0)
157 35 Jade (0,175,95)
158 36 PersianGreen (0,175,135)
159 37 BondiBlue (0,175,175)
160 38 Cerulean (0,175,215)
161 39 LightAzureRadiance (0,175,255)
162 40 DarkGreen (0,215,0)
163 41 Malachite (0,215,95)
164 42 CaribbeanGreen (0,215,135)
165 43 LightCaribbeanGreen (0,215,175)
166 44 RobinEggBlue (0,215,215)
167 45 Aqua (0,215,255)
168 46 Green (0,255,0)
169 47 DarkSpringGreen (0,255,95)
170 48 SpringGreen (0,255,135)
171 49 LightSpringGreen (0,255,175)
172 50 BrightTurquoise (0,255,215)
173 51 Cyan (0,255,255)
174 52 Rosewood (95,0,0)
175 53 PompadourMagenta (95,0,95)
176 54 PigmentIndigo (95,0,135)
177 55 DarkPurple (95,0,175)
178 56 ElectricIndigo (95,0,215)
179 57 ElectricPurple (95,0,255)
180 58 VerdunGreen (95,95,0)
181 59 ScorpionOlive (95,95,95)
182 60 Lilac (95,95,135)
183 61 ScampiIndigo (95,95,175)
184 62 Indigo (95,95,215)
185 63 DarkCornflowerBlue (95,95,255)
186 64 DarkLimeade (95,135,0)
187 65 GladeGreen (95,135,95)
188 66 JuniperGreen (95,135,135)
189 67 HippieBlue (95,135,175)
190 68 HavelockBlue (95,135,215)
191 69 CornflowerBlue (95,135,255)
192 70 Limeade (95,175,0)
193 71 FernGreen (95,175,95)
194 72 SilverTree (95,175,135)
195 73 Tradewind (95,175,175)
196 74 ShakespeareBlue (95,175,215)
197 75 DarkMalibuBlue (95,175,255)
198 76 DarkBrightGreen (95,215,0)
199 77 DarkPastelGreen (95,215,95)
200 78 PastelGreen (95,215,135)
201 79 DownyTeal (95,215,175)
202 80 Viking (95,215,215)
203 81 MalibuBlue (95,215,255)
204 82 BrightGreen (95,255,0)
205 83 DarkScreaminGreen (95,255,95)
206 84 ScreaminGreen (95,255,135)
207 85 DarkAquamarine (95,255,175)
208 86 Aquamarine (95,255,215)
209 87 LightAquamarine (95,255,255)
210 88 Maroon (135,0,0)
211 89 DarkFreshEggplant (135,0,95)
212 90 LightFreshEggplant (135,0,135)
213 91 Purple (135,0,175)
214 92 ElectricViolet (135,0,215)
215 93 LightElectricViolet (135,0,255)
216 94 Brown (135,95,0)
217 95 CopperRose (135,95,95)
218 96 StrikemasterPurple (135,95,135)
219 97 DelugePurple (135,95,175)
220 98 DarkMediumPurple (135,95,215)
221 99 DarkHeliotropePurple (135,95,255)
222 100 Olive (135,135,0)
223 101 ClayCreekOlive (135,135,95)
224 102 DarkGray (135,135,135)
225 103 WildBlueYonder (135,135,175)
226 104 ChetwodeBlue (135,135,215)
227 105 SlateBlue (135,135,255)
228 106 LightLimeade (135,175,0)
229 107 ChelseaCucumber (135,175,95)
230 108 BayLeaf (135,175,135)
231 109 GulfStream (135,175,175)
232 110 PoloBlue (135,175,215)
233 111 LightMalibuBlue (135,175,255)
234 112 Pistachio (135,215,0)
235 113 LightPastelGreen (135,215,95)
236 114 DarkFeijoaGreen (135,215,135)
237 115 VistaBlue (135,215,175)
238 116 Bermuda (135,215,215)
239 117 DarkAnakiwaBlue (135,215,255)
240 118 ChartreuseGreen (135,255,0)
241 119 LightScreaminGreen (135,255,95)
242 120 DarkMintGreen (135,255,135)
243 121 MintGreen (135,255,175)
244 122 LighterAquamarine (135,255,215)
245 123 AnakiwaBlue (135,255,255)
246 124 BrightRed (175,0,0)
247 125 DarkFlirt (175,0,95)
248 126 Flirt (175,0,135)
249 127 LightFlirt (175,0,175)
250 128 DarkViolet (175,0,215)
251 129 BrightElectricViolet (175,0,255)
252 130 RoseofSharonOrange (175,95,0)
253 131 MatrixPink (175,95,95)
254 132 TapestryPink (175,95,135)
255 133 FuchsiaPink (175,95,175)
256 134 MediumPurple (175,95,215)
257 135 Heliotrope (175,95,255)
258 136 PirateGold (175,135,0)
259 137 MuesliOrange (175,135,95)
260 138 PharlapPink (175,135,135)
261 139 Bouquet (175,135,175)
262 140 Lavender (175,135,215)
263 141 LightHeliotrope (175,135,255)
264 142 BuddhaGold (175,175,0)
265 143 OliveGreen (175,175,95)
266 144 HillaryOlive (175,175,135)
267 145 SilverChalice (175,175,175)
268 146 WistfulLilac (175,175,215)
269 147 MelroseLilac (175,175,255)
270 148 RioGrandeGreen (175,215,0)
271 149 ConiferGreen (175,215,95)
272 150 Feijoa (175,215,135)
273 151 PixieGreen (175,215,175)
274 152 JungleMist (175,215,215)
275 153 LightAnakiwaBlue (175,215,255)
276 154 Lime (175,255,0)
277 155 GreenYellow (175,255,95)
278 156 LightMintGreen (175,255,135)
279 157 Celadon (175,255,175)
280 158 AeroBlue (175,255,215)
281 159 FrenchPassLightBlue (175,255,255)
282 160 GuardsmanRed (215,0,0)
283 161 RazzmatazzCerise (215,0,95)
284 162 MediumVioletRed (215,0,135)
285 163 HollywoodCerise (215,0,175)
286 164 DarkPurplePizzazz (215,0,215)
287 165 BrighterElectricViolet (215,0,255)
288 166 TennOrange (215,95,0)
289 167 RomanOrange (215,95,95)
290 168 CranberryPink (215,95,135)
291 169 HopbushPink (215,95,175)
292 170 Orchid (215,95,215)
293 171 LighterHeliotrope (215,95,255)
294 172 MangoTango (215,135,0)
295 173 Copperfield (215,135,95)
296 174 SeaPink (215,135,135)
297 175 CanCanPink (215,135,175)
298 176 LightOrchid (215,135,215)
299 177 BrightHeliotrope (215,135,255)
300 178 DarkCorn (215,175,0)
301 179 DarkTachaOrange (215,175,95)
302 180 TanBeige (215,175,135)
303 181 ClamShell (215,175,175)
304 182 ThistlePink (215,175,215)
305 183 Mauve (215,175,255)
306 184 Corn (215,215,0)
307 185 TachaOrange (215,215,95)
308 186 DecoOrange (215,215,135)
309 187 PaleGoldenrod (215,215,175)
310 188 AltoBeige (215,215,215)
311 189 FogPink (215,215,255)
312 190 ChartreuseYellow (215,255,0)
313 191 Canary (215,255,95)
314 192 Honeysuckle (215,255,135)
315 193 ReefPaleYellow (215,255,175)
316 194 SnowyMint (215,255,215)
317 195 OysterBay (215,255,255)
318 196 Red (255,0,0)
319 197 DarkRose (255,0,95)
320 198 Rose (255,0,135)
321 199 LightHollywoodCerise (255,0,175)
322 200 PurplePizzazz (255,0,215)
323 201 Fuchsia (255,0,255)
324 202 BlazeOrange (255,95,0)
325 203 BittersweetOrange (255,95,95)
326 204 WildWatermelon (255,95,135)
327 205 DarkHotPink (255,95,175)
328 206 HotPink (255,95,215)
329 207 PinkFlamingo (255,95,255)
330 208 FlushOrange (255,135,0)
331 209 Salmon (255,135,95)
332 210 VividTangerine (255,135,135)
333 211 PinkSalmon (255,135,175)
334 212 DarkLavenderRose (255,135,215)
335 213 BlushPink (255,135,255)
336 214 YellowSea (255,175,0)
337 215 TexasRose (255,175,95)
338 216 Tacao (255,175,135)
339 217 Sundown (255,175,175)
340 218 CottonCandy (255,175,215)
341 219 LavenderRose (255,175,255)
342 220 Gold (255,215,0)
343 221 Dandelion (255,215,95)
344 222 GrandisCaramel (255,215,135)
345 223 Caramel (255,215,175)
346 224 CosmosSalmon (255,215,215)
347 225 PinkLace (255,215,255)
348 226 Yellow (255,255,0)
349 227 LaserLemon (255,255,95)
350 228 DollyYellow (255,255,135)
351 229 PortafinoYellow (255,255,175)
352 230 Cumulus (255,255,215)
353 231 White (255,255,255)
354 232 DarkCodGray (8,8,8)
355 233 CodGray (18,18,18)
356 234 LightCodGray (28,28,28)
357 235 DarkMineShaft (38,38,38)
358 236 MineShaft (48,48,48)
359 237 LightMineShaft (58,58,58)
360 238 DarkTundora (68,68,68)
361 239 Tundora (78,78,78)
362 240 ScorpionGray (88,88,88)
363 241 DarkDoveGray (98,98,98)
364 242 DoveGray (108,108,108)
365 243 Boulder (118,118,118)
366 244 Gray (128,128,128)
367 245 LightGray (138,138,138)
368 246 DustyGray (148,148,148)
369 247 NobelGray (158,158,158)
370 248 DarkSilverChalice (168,168,168)
371 249 LightSilverChalice (178,178,178)
372 250 DarkSilver (188,188,188)
373 251 Silver (198,198,198)
374 252 DarkAlto (208,208,208)
375 253 Alto (218,218,218)
376 254 Mercury (228,228,228)
377 255 GalleryGray (238,238,238)
378}
379