1pub const MOON_EMOJI: &str = "🌙";
2
3const RAMADAN_GREEN_RGB: &str = "\u{1b}[38;2;128;240;151m";
4const ANSI_GREEN: &str = "\u{1b}[32m";
5const ANSI_RESET: &str = "\u{1b}[0m";
6
7fn is_color_supported() -> bool {
8 use std::io::IsTerminal;
9
10 if std::env::var_os("NO_COLOR").is_some() {
11 return false;
12 }
13
14 let term = std::env::var("TERM")
15 .unwrap_or_default()
16 .to_ascii_lowercase();
17 if term == "dumb" {
18 return false;
19 }
20
21 std::io::stdout().is_terminal()
22}
23
24fn supports_true_color() -> bool {
25 let color_term = std::env::var("COLORTERM")
26 .unwrap_or_default()
27 .to_lowercase();
28 color_term.contains("truecolor") || color_term.contains("24bit")
29}
30
31pub fn ramadan_green(value: &str) -> String {
32 if !is_color_supported() {
33 return value.to_string();
34 }
35
36 if !supports_true_color() {
37 return format!("{ANSI_GREEN}{value}{ANSI_RESET}");
38 }
39
40 format!("{RAMADAN_GREEN_RGB}{value}{ANSI_RESET}")
41}