mirror of
https://github.com/Atsukoro1/ponyfetch.git
synced 2024-11-23 20:57:59 +01:00
feat: 🎸 Colors
This commit is contained in:
parent
c16a99c456
commit
4f8f46df21
2 changed files with 30 additions and 9 deletions
|
@ -1,5 +1,4 @@
|
|||
// make const with color names and match them with unicode symbol for color
|
||||
const COLORS : [(&str, &str); 17] = [
|
||||
const COLORS : [(&str, &str); 34] = [
|
||||
("black", "\u{001b}[30m"),
|
||||
("red", "\u{001b}[31m"),
|
||||
("green", "\u{001b}[32m"),
|
||||
|
@ -17,6 +16,23 @@ const COLORS : [(&str, &str); 17] = [
|
|||
("bright_cyan", "\u{001b}[96m"),
|
||||
("bright_white", "\u{001b}[97m"),
|
||||
("cyan_bold", "\u{001b}[36m\u{001b}[1m"),
|
||||
("bright_cyan_bold", "\u{001b}[96m\u{001b}[1m"),
|
||||
("reset", "\u{001b}[0m"),
|
||||
("bold", "\u{001b}[1m"),
|
||||
("black_bold", "\u{001b}[30m\u{001b}[1m"),
|
||||
("red_bold", "\u{001b}[31m\u{001b}[1m"),
|
||||
("green_bold", "\u{001b}[32m\u{001b}[1m"),
|
||||
("yellow_bold", "\u{001b}[33m\u{001b}[1m"),
|
||||
("blue_bold", "\u{001b}[34m\u{001b}[1m"),
|
||||
("magenta_bold", "\u{001b}[35m\u{001b}[1m"),
|
||||
("white_bold", "\u{001b}[37m\u{001b}[1m"),
|
||||
("bright_black_bold", "\u{001b}[90m\u{001b}[1m"),
|
||||
("bright_red_bold", "\u{001b}[91m\u{001b}[1m"),
|
||||
("bright_green_bold", "\u{001b}[92m\u{001b}[1m"),
|
||||
("bright_yellow_bold", "\u{001b}[93m\u{001b}[1m"),
|
||||
("bright_blue_bold", "\u{001b}[94m\u{001b}[1m"),
|
||||
("bright_magenta_bold", "\u{001b}[95m\u{001b}[1m"),
|
||||
("bright_white_bold", "\u{001b}[97m\u{001b}[1m"),
|
||||
];
|
||||
|
||||
pub fn print(text: &str, inline: bool, color: &str) {
|
||||
|
@ -33,4 +49,6 @@ pub fn print(text: &str, inline: bool, color: &str) {
|
|||
} else {
|
||||
println!("{}{}", color, text);
|
||||
}
|
||||
|
||||
print!("{}", COLORS[18].1);
|
||||
}
|
|
@ -6,24 +6,27 @@ pub fn print_detail(title: &str, value: String, atype: ActionType, color: &str)
|
|||
|
||||
match atype {
|
||||
ActionType::Details => {
|
||||
helpers::colors::print(&title, true, color);
|
||||
print(&title, true, &(color.to_owned() + "_bold"));
|
||||
for _ in 0..(10 - title.len()) {
|
||||
print!(" ");
|
||||
}
|
||||
|
||||
helpers::colors::print(" : ", true, "white");
|
||||
helpers::colors::print(" : ", true, "white_bold");
|
||||
|
||||
print!("{}", &value);
|
||||
},
|
||||
ActionType::Delimiter => {
|
||||
print("-----------------------------", true, "white");
|
||||
print("-----------------------------", true, "white_bold");
|
||||
},
|
||||
ActionType::HostInfo => {
|
||||
print(&format!(
|
||||
"{}@{}",
|
||||
title,
|
||||
value
|
||||
), true, color);
|
||||
title.to_owned(),
|
||||
value.to_owned()
|
||||
),
|
||||
true,
|
||||
&(color.to_owned() + "_bold")
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue