mirror of
https://github.com/Atsukoro1/ponyfetch.git
synced 2024-11-27 06:17: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
|
@ -10,4 +10,7 @@ include = [
|
||||||
"**/*.rs",
|
"**/*.rs",
|
||||||
"Cargo.toml",
|
"Cargo.toml",
|
||||||
"ponies/*"
|
"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] = [
|
pub const COLORS : [(&str, &str); 34] = [
|
||||||
("black", "\u{001b}[30m"),
|
("black", "\u{001b}[30m"),
|
||||||
("red", "\u{001b}[31m"),
|
("red", "\u{001b}[31m"),
|
||||||
|
@ -36,10 +37,15 @@ pub const COLORS : [(&str, &str); 34] = [
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn print(text: &str, inline: bool, color: &str) {
|
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;
|
#[cfg(windows)]
|
||||||
let color = COLORS.iter().find(|(name, _)| name == &color).unwrap().1;
|
{
|
||||||
|
use ansi_term::enable_ansi_support;
|
||||||
|
enable_ansi_support().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
if inline {
|
if inline {
|
||||||
print!("{}{}", color, text);
|
print!("{}{}", color, text);
|
||||||
|
|
Loading…
Reference in a new issue