1use super::*;
2
3const CONSTANTS: [(&str, &str, &str); 27] = [
4 ("HEX", "0123456789abcdef", "1.27.0"),
5 ("HEXLOWER", "0123456789abcdef", "1.27.0"),
6 ("HEXUPPER", "0123456789ABCDEF", "1.27.0"),
7 ("CLEAR", "\x1bc", "master"),
8 ("NORMAL", "\x1b[0m", "master"),
9 ("BOLD", "\x1b[1m", "master"),
10 ("ITALIC", "\x1b[3m", "master"),
11 ("UNDERLINE", "\x1b[4m", "master"),
12 ("INVERT", "\x1b[7m", "master"),
13 ("HIDE", "\x1b[8m", "master"),
14 ("STRIKETHROUGH", "\x1b[9m", "master"),
15 ("BLACK", "\x1b[30m", "master"),
16 ("RED", "\x1b[31m", "master"),
17 ("GREEN", "\x1b[32m", "master"),
18 ("YELLOW", "\x1b[33m", "master"),
19 ("BLUE", "\x1b[34m", "master"),
20 ("MAGENTA", "\x1b[35m", "master"),
21 ("CYAN", "\x1b[36m", "master"),
22 ("WHITE", "\x1b[37m", "master"),
23 ("BG_BLACK", "\x1b[40m", "master"),
24 ("BG_RED", "\x1b[41m", "master"),
25 ("BG_GREEN", "\x1b[42m", "master"),
26 ("BG_YELLOW", "\x1b[43m", "master"),
27 ("BG_BLUE", "\x1b[44m", "master"),
28 ("BG_MAGENTA", "\x1b[45m", "master"),
29 ("BG_CYAN", "\x1b[46m", "master"),
30 ("BG_WHITE", "\x1b[47m", "master"),
31];
32
33pub fn constants() -> &'static HashMap<&'static str, &'static str> {
34 static MAP: OnceLock<HashMap<&str, &str>> = OnceLock::new();
35 MAP.get_or_init(|| {
36 CONSTANTS
37 .into_iter()
38 .map(|(name, value, _version)| (name, value))
39 .collect()
40 })
41}
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn readme_table() {
49 println!("| Name | Value |");
50 println!("|------|-------------|");
51 for (name, value, version) in CONSTANTS {
52 println!(
53 "| `{name}`<sup>{version}</sup> | `\"{}\"` |",
54 value.replace('\x1b', "\\e")
55 );
56 }
57 }
58}