minimo 0.5.42

terminal ui library combining alot of things from here and there and making it slightly easier to play with
Documentation
use super::*;

/// # hex! macro
/// to convert hex color to ansi color
/// example: hex!(#0099FF) -> "\x1b[38;2;0;99;255m"
#[macro_export]
macro_rules! hex {
($hex:expr) => {
    {
        let hex = $hex.trim_start_matches("#");
        let r = u8::from_str_radix(&hex[0..2], 16).unwrap();
        let g = u8::from_str_radix(&hex[2..4], 16).unwrap();
        let b = u8::from_str_radix(&hex[4..6], 16).unwrap();
        format!("\x1b[38;2;{};{};{}m", r, g, b)
    }
};
}

///hexbg! macro to convert hex color to ansi background color
/// example: hexbg!(#0099FF) -> "\x1b[48;2;0;99;255m\x1b[30m"
/// example: hexbg!(#0099FF, 255) -> "\x1b[48;2;0;99;255m\x1b[30m"
/// example: hexbg!(#0099FF, 255, 255, 255) -> "\x1b[48;2;0;99;255m\x1b[30m"
#[macro_export]
macro_rules! hexbg {
($hex:expr) => {
    {
        let hex = $hex.trim_start_matches("#");
        let r = u8::from_str_radix(&hex[0..2], 16).unwrap();
        let g = u8::from_str_radix(&hex[2..4], 16).unwrap();
        let b = u8::from_str_radix(&hex[4..6], 16).unwrap();
        format!("\x1b[48;2;{};{};{}m\x1b[30m", r, g, b)
    }
};
($hex:expr, $r:expr) => {
    {
        let hex = $hex.trim_start_matches("#");
        let r = u8::from_str_radix(&hex[0..2], 16).unwrap();
        let g = u8::from_str_radix(&hex[2..4], 16).unwrap();
        let b = u8::from_str_radix(&hex[4..6], 16).unwrap();
        format!("\x1b[48;2;{};{};{}m\x1b[30m", r, g, b)
    }
};
($hex:expr, $r:expr, $g:expr, $b:expr) => {
    {
        let hex = $hex.trim_start_matches("#");
        let r = u8::from_str_radix(&hex[0..2], 16).unwrap();
        let g = u8::from_str_radix(&hex[2..4], 16).unwrap();
        let b = u8::from_str_radix(&hex[4..6], 16).unwrap();
        format!("\x1b[48;2;{};{};{}m\x1b[30m", r, g, b)
    }
};
}