diff --git a/Cargo.toml b/Cargo.toml index 94a8097..fef10f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,4 +10,7 @@ include = [ "**/*.rs", "Cargo.toml", "ponies/*" -] \ No newline at end of file +] + +[dependencies] +ansi_term = "0.12.1" \ No newline at end of file diff --git a/src/helpers/colors.rs b/src/helpers/colors.rs index 2e23a58..b3ddd54 100644 --- a/src/helpers/colors.rs +++ b/src/helpers/colors.rs @@ -1,3 +1,4 @@ +// #[cfg(any(target_os = "linux", target_os = "macos"))] pub const COLORS : [(&str, &str); 34] = [ ("black", "\u{001b}[30m"), ("red", "\u{001b}[31m"), @@ -36,10 +37,15 @@ pub const COLORS : [(&str, &str); 34] = [ ]; pub fn print(text: &str, inline: bool, color: &str) { - let color = color; + let color = COLORS.iter().find( + |(name, _)| name == &color + ).unwrap().1; - let color = color; - let color = COLORS.iter().find(|(name, _)| name == &color).unwrap().1; + #[cfg(windows)] + { + use ansi_term::enable_ansi_support; + enable_ansi_support().unwrap(); + } if inline { print!("{}{}", color, text);