mirror of
https://github.com/Atsukoro1/ponyfetch.git
synced 2024-11-23 12:47:59 +01:00
feat: 🎸 Enabling ansi code support in windows terminals
This commit is contained in:
parent
4f6e76fc54
commit
58b059bcbf
2 changed files with 13 additions and 4 deletions
|
@ -11,3 +11,6 @@ include = [
|
|||
"Cargo.toml",
|
||||
"ponies/*"
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
ansi_term = "0.12.1"
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue