@@ -43,115 +43,8 @@ static KINDS: [(&str, &str); NUM_KINDS] = [
4343 #[ cfg( feature = "bin_kinds" ) ] ( "Custom" , "" ) ,
4444] ;
4545
46- // Build up a list of 256 ANSI colors, naming the ones we can.
47- static COLORS : [ & str ; 256 ] = [
48- "Black" ,
49- "Red" ,
50- "Green" ,
51- "Yellow" ,
52- "Blue" ,
53- "Magenta" ,
54- "Cyan" ,
55- "LightGrey" ,
56- "DarkGrey" ,
57- "LightRed" ,
58- "LightGreen" ,
59- "LightYellow" ,
60- "LightBlue" ,
61- "LightMagenta" ,
62- "LightCyan" ,
63- "White" ,
64- "Misc016" ,
65- "NavyBlue" ,
66- "DarkBlue" ,
67- "Misc019" , "Misc020" , "Misc021" ,
68- "DarkGreen" ,
69- "Misc023" , "Misc024" , "Misc025" , "Misc026" , "Misc027" , "Misc028" , "Misc029" ,
70- "Misc030" , "Misc031" , "Misc032" , "Misc033" , "Misc034" , "Misc035" ,
71- "DarkCyan" ,
72- "LightSeaGreen" ,
73- "Misc038" , "Misc039" , "Misc040" , "Misc041" , "Misc042" , "Misc043" ,
74- "DarkTurquoise" ,
75- "Misc045" , "Misc046" , "Misc047" , "Misc048" ,
76- "MediumSpringGreen" ,
77- "Misc050" , "Misc051" , "Misc052" , "Misc053" , "Misc054" , "Misc055" , "Misc056" ,
78- "BlueViolet" ,
79- "Misc058" , "Misc059" , "Misc060" , "Misc061" , "Misc062" , "Misc063" , "Misc064" ,
80- "Misc065" , "Misc066" ,
81- "SteelBlue" ,
82- "Misc068" ,
83- "CornflowerBlue" ,
84- "Misc070" , "Misc071" , "Misc072" , "Misc073" , "Misc074" , "Misc075" , "Misc076" ,
85- "Misc077" , "Misc078" , "Misc079" ,
86- "MediumTurquoise" ,
87- "Misc081" , "Misc082" , "Misc083" , "Misc084" , "Misc085" , "Misc086" , "Misc087" ,
88- "Misc088" , "Misc089" , "Misc090" , "Misc091" , "Misc092" , "Misc093" , "Misc094" ,
89- "Misc095" , "Misc096" , "Misc097" , "Misc098" , "Misc099" , "Misc100" , "Misc101" ,
90- "Misc102" ,
91- "LightSlateGrey" ,
92- "MediumPurple" ,
93- "LightSlateBlue" ,
94- "Misc106" , "Misc107" ,
95- "DarkSeaGreen" ,
96- "Misc109" , "Misc110" , "Misc111" , "Misc112" , "Misc113" , "Misc114" , "Misc115" ,
97- "Misc116" , "Misc117" , "Misc118" , "Misc119" , "Misc120" , "Misc121" , "Misc122" ,
98- "Misc123" , "Misc124" , "Misc125" ,
99- "MediumVioletRed" ,
100- "Misc127" , "Misc128" , "Misc129" , "Misc130" , "Misc131" , "Misc132" , "Misc133" ,
101- "Misc134" , "Misc135" ,
102- "DarkGoldenrod" ,
103- "Misc137" ,
104- "RosyBrown" ,
105- "Misc139" , "Misc140" , "Misc141" , "Misc142" ,
106- "DarkKhaki" ,
107- "Misc144" , "Misc145" , "Misc146" ,
108- "LightSteelBlue" ,
109- "Misc148" , "Misc149" , "Misc150" , "Misc151" , "Misc152" , "Misc153" ,
110- "GreenYellow" ,
111- "Misc155" , "Misc156" , "Misc157" , "Misc158" , "Misc159" , "Misc160" , "Misc161" ,
112- "Misc162" , "Misc163" , "Misc164" , "Misc165" , "Misc166" , "Misc167" , "Misc168" ,
113- "Misc169" ,
114- "Orchid" ,
115- "Misc171" , "Misc172" , "Misc173" , "Misc174" , "Misc175" , "Misc176" ,
116- "Violet" ,
117- "Misc178" , "Misc179" ,
118- "Tan" ,
119- "Misc181" , "Misc182" , "Misc183" , "Misc184" , "Misc185" , "Misc186" , "Misc187" ,
120- "Misc188" , "Misc189" , "Misc190" , "Misc191" , "Misc192" , "Misc193" , "Misc194" ,
121- "Misc195" , "Misc196" , "Misc197" , "Misc198" , "Misc199" , "Misc200" , "Misc201" ,
122- "Misc202" , "Misc203" , "Misc204" , "Misc205" , "Misc206" , "Misc207" ,
123- "DarkOrange" ,
124- "Misc209" ,
125- "LightCoral" ,
126- "Misc211" , "Misc212" , "Misc213" , "Misc214" ,
127- "SandyBrown" ,
128- "Misc216" , "Misc217" , "Misc218" , "Misc219" , "Misc220" , "Misc221" , "Misc222" ,
129- "Misc223" , "Misc224" , "Misc225" , "Misc226" , "Misc227" , "Misc228" , "Misc229" ,
130- "Misc230" , "Misc231" , "Misc232" , "Misc233" , "Misc234" , "Misc235" , "Misc236" ,
131- "Misc237" , "Misc238" , "Misc239" , "Misc240" , "Misc241" , "Misc242" , "Misc243" ,
132- "Misc244" , "Misc245" , "Misc246" , "Misc247" , "Misc248" , "Misc249" , "Misc250" ,
133- "Misc251" , "Misc252" , "Misc253" , "Misc254" , "Misc255" ,
134- ] ;
135-
136- /// # ANSI-to-Web Conversion Table.
137- static HEX : [ & str ; 256 ] = [
138- "#000000" , "#800000" , "#008000" , "#808000" , "#000080" , "#800080" , "#008080" , "#c0c0c0" , "#808080" , "#ff0000" , "#00ff00" , "#ffff00" , "#0000ff" , "#ff00ff" , "#00ffff" , "#ffffff" ,
139- "#000000" , "#00005f" , "#000087" , "#0000af" , "#0000d7" , "#0000ff" , "#005f00" , "#005f5f" , "#005f87" , "#005faf" , "#005fd7" , "#005fff" , "#008700" , "#00875f" , "#008787" , "#0087af" ,
140- "#0087d7" , "#0087ff" , "#00af00" , "#00af5f" , "#00af87" , "#00afaf" , "#00afd7" , "#00afff" , "#00d700" , "#00d75f" , "#00d787" , "#00d7af" , "#00d7d7" , "#00d7ff" , "#00ff00" , "#00ff5f" ,
141- "#00ff87" , "#00ffaf" , "#00ffd7" , "#00ffff" , "#5f0000" , "#5f005f" , "#5f0087" , "#5f00af" , "#5f00d7" , "#5f00ff" , "#5f5f00" , "#5f5f5f" , "#5f5f87" , "#5f5faf" , "#5f5fd7" , "#5f5fff" ,
142- "#5f8700" , "#5f875f" , "#5f8787" , "#5f87af" , "#5f87d7" , "#5f87ff" , "#5faf00" , "#5faf5f" , "#5faf87" , "#5fafaf" , "#5fafd7" , "#5fafff" , "#5fd700" , "#5fd75f" , "#5fd787" , "#5fd7af" ,
143- "#5fd7d7" , "#5fd7ff" , "#5fff00" , "#5fff5f" , "#5fff87" , "#5fffaf" , "#5fffd7" , "#5fffff" , "#870000" , "#87005f" , "#870087" , "#8700af" , "#8700d7" , "#8700ff" , "#875f00" , "#875f5f" ,
144- "#875f87" , "#875faf" , "#875fd7" , "#875fff" , "#878700" , "#87875f" , "#878787" , "#8787af" , "#8787d7" , "#8787ff" , "#87af00" , "#87af5f" , "#87af87" , "#87afaf" , "#87afd7" , "#87afff" ,
145- "#87d700" , "#87d75f" , "#87d787" , "#87d7af" , "#87d7d7" , "#87d7ff" , "#87ff00" , "#87ff5f" , "#87ff87" , "#87ffaf" , "#87ffd7" , "#87ffff" , "#af0000" , "#af005f" , "#af0087" , "#af00af" ,
146- "#af00d7" , "#af00ff" , "#af5f00" , "#af5f5f" , "#af5f87" , "#af5faf" , "#af5fd7" , "#af5fff" , "#af8700" , "#af875f" , "#af8787" , "#af87af" , "#af87d7" , "#af87ff" , "#afaf00" , "#afaf5f" ,
147- "#afaf87" , "#afafaf" , "#afafd7" , "#afafff" , "#afd700" , "#afd75f" , "#afd787" , "#afd7af" , "#afd7d7" , "#afd7ff" , "#afff00" , "#afff5f" , "#afff87" , "#afffaf" , "#afffd7" , "#afffff" ,
148- "#d70000" , "#d7005f" , "#d70087" , "#d700af" , "#d700d7" , "#d700ff" , "#d75f00" , "#d75f5f" , "#d75f87" , "#d75faf" , "#d75fd7" , "#d75fff" , "#d78700" , "#d7875f" , "#d78787" , "#d787af" ,
149- "#d787d7" , "#d787ff" , "#d7af00" , "#d7af5f" , "#d7af87" , "#d7afaf" , "#d7afd7" , "#d7afff" , "#d7d700" , "#d7d75f" , "#d7d787" , "#d7d7af" , "#d7d7d7" , "#d7d7ff" , "#d7ff00" , "#d7ff5f" ,
150- "#d7ff87" , "#d7ffaf" , "#d7ffd7" , "#d7ffff" , "#ff0000" , "#ff005f" , "#ff0087" , "#ff00af" , "#ff00d7" , "#ff00ff" , "#ff5f00" , "#ff5f5f" , "#ff5f87" , "#ff5faf" , "#ff5fd7" , "#ff5fff" ,
151- "#ff8700" , "#ff875f" , "#ff8787" , "#ff87af" , "#ff87d7" , "#ff87ff" , "#ffaf00" , "#ffaf5f" , "#ffaf87" , "#ffafaf" , "#ffafd7" , "#ffafff" , "#ffd700" , "#ffd75f" , "#ffd787" , "#ffd7af" ,
152- "#ffd7d7" , "#ffd7ff" , "#ffff00" , "#ffff5f" , "#ffff87" , "#ffffaf" , "#ffffd7" , "#ffffff" , "#080808" , "#121212" , "#1c1c1c" , "#262626" , "#303030" , "#3a3a3a" , "#444444" , "#4e4e4e" ,
153- "#585858" , "#626262" , "#6c6c6c" , "#767676" , "#808080" , "#8a8a8a" , "#949494" , "#9e9e9e" , "#a8a8a8" , "#b2b2b2" , "#bcbcbc" , "#c6c6c6" , "#d0d0d0" , "#dadada" , "#e4e4e4" , "#eeeeee" ,
154- ] ;
46+ // COLORS: [(name, hex)].
47+ include ! ( "skel/ansi256.rs" ) ;
15548
15649
15750
@@ -198,7 +91,7 @@ fn build_ansi_color() {
19891pub enum AnsiColor {{" ,
19992 AnsiTable
20093 ) . unwrap ( ) ;
201- for ( k, ( v, h) ) in COLORS . iter ( ) . zip ( HEX . iter ( ) ) . enumerate ( ) {
94+ for ( k, ( v, h) ) in COLORS . iter ( ) . enumerate ( ) {
20295 // Give it a title.
20396 if v. starts_with ( "Misc" ) {
20497 writeln ! ( & mut out, "\t /// # Color #{k}." ) . unwrap ( ) ;
@@ -246,7 +139,7 @@ impl AnsiColor {\n");
246139 /// ```
247140 pub const fn from_u8(num: u8) -> Self {
248141 match num {\n " ) ;
249- for ( k, v) in COLORS . iter ( ) . enumerate ( ) {
142+ for ( k, v) in COLORS . iter ( ) . map ( | ( v , _ ) | v ) . enumerate ( ) {
250143 writeln ! ( & mut out, "\t \t \t {k} => Self::{v}," ) . unwrap ( ) ;
251144 }
252145 out. push_str ( "\t \t }\n \t }\n " ) ;
@@ -270,7 +163,7 @@ impl AnsiColor {\n");
270163 /// ```
271164 pub const fn as_str(self) -> &'static str {
272165 match self {\n " ) ;
273- for ( k, v) in COLORS . iter ( ) . enumerate ( ) {
166+ for ( k, v) in COLORS . iter ( ) . map ( | ( v , _ ) | v ) . enumerate ( ) {
274167 writeln ! ( & mut out, "\t \t \t Self::{v} => fyi_ansi::csi!({k})," ) . unwrap ( ) ;
275168 }
276169 out. push_str ( "\t \t }\n \t }\n " ) ;
@@ -283,7 +176,7 @@ impl AnsiColor {\n");
283176 /// slice, bolded.
284177 pub(crate) const fn as_str_bold(self) -> &'static str {
285178 match self {\n " ) ;
286- for ( k, v) in COLORS . iter ( ) . enumerate ( ) {
179+ for ( k, v) in COLORS . iter ( ) . map ( | ( v , _ ) | v ) . enumerate ( ) {
287180 writeln ! ( & mut out, "\t \t \t Self::{v} => fyi_ansi::csi!(bold, {k})," ) . unwrap ( ) ;
288181 }
289182 out. push_str ( "\t \t }\n \t }\n " ) ;
@@ -311,7 +204,7 @@ fn build_msg_kinds() {
311204 /// # Hidden Kinds.
312205 const HIDDEN : [ & str ; 2 ] = [ "Blank" , "Custom" ] ;
313206
314- let mut out = String :: with_capacity ( 2048 ) ;
207+ let mut out = String :: with_capacity ( 8192 ) ;
315208 out. push_str ( r#"#[expect(missing_docs, reason = "Redudant.")]
316209#[derive(Debug, Copy, Clone, Eq, Hash, PartialEq)]
317210/// # Message Kind.
@@ -471,11 +364,10 @@ struct AnsiTable;
471364impl fmt:: Display for AnsiTable {
472365 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
473366 f. write_str ( r##"<div style="display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: stretch; color: #fff; font-size: 13px; font-weight: bold; text-align: center; line-height: 40px;">"## ) ?;
474- for ( k, color ) in HEX . iter ( ) . enumerate ( ) {
367+ for ( k, ( name , hex ) ) in COLORS . iter ( ) . enumerate ( ) {
475368 write ! (
476369 f,
477- r##"<div style="width: 40px; height: 40px; margin: 0 1px 1px 0; background: {color}" title="{} ({k:03})">{k:03}</div>"## ,
478- COLORS [ k] ,
370+ r##"<div style="width: 40px; height: 40px; margin: 0 1px 1px 0; background: {hex}" title="{name} ({k:03})">{k:03}</div>"## ,
479371 ) . unwrap ( ) ;
480372 }
481373 f. write_str ( "</div>" )
0 commit comments