From 4f8f46df21ada7e58b542fc603c62f56f9331ffe Mon Sep 17 00:00:00 2001 From: Atsukoro1 Date: Thu, 1 Dec 2022 22:06:04 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Colors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/helpers/colors.rs | 24 +++++++++++++++++++++--- src/helpers/print.rs | 15 +++++++++------ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/helpers/colors.rs b/src/helpers/colors.rs index 9e65d7a..bbffca9 100644 --- a/src/helpers/colors.rs +++ b/src/helpers/colors.rs @@ -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) { @@ -27,10 +43,12 @@ pub fn print(text: &str, inline: bool, color: &str) { let color = color; let color = COLORS.iter().find(|(name, _)| name == &color).unwrap().1; - + if inline { print!("{}{}", color, text); } else { println!("{}{}", color, text); } + + print!("{}", COLORS[18].1); } \ No newline at end of file diff --git a/src/helpers/print.rs b/src/helpers/print.rs index 36c53c0..bd5d2e7 100644 --- a/src/helpers/print.rs +++ b/src/helpers/print.rs @@ -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") + ); } }; }