diff options
Diffstat (limited to 'src/ansi')
| -rw-r--r-- | src/ansi/colors.rs | 28 | ||||
| -rw-r--r-- | src/ansi/mod.rs | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/ansi/colors.rs b/src/ansi/colors.rs new file mode 100644 index 0000000..d14dc81 --- /dev/null +++ b/src/ansi/colors.rs @@ -0,0 +1,28 @@ +macro_rules! color { + ($($name: ident = $num:expr ;)*) => { + $( + #[allow(unused)] + pub const $name: &str = concat!("\x1b[", stringify!($num), "m"); + )* + }; +} + +color! { + RESET = 0; + BLACK_FG = 30; + BLACK_BG = 40; + RED_FG = 31; + RED_BG = 41; + GREEN_FG = 32; + GREEN_BG = 42; + YELLOW_FG = 33; + YELLOW_BG = 43; + BLUE_FG = 34; + BLUE_BG = 44; + MAGENTA_FG = 35; + MAGENTA_BG = 45; + CYAN_FG = 36; + CYAN_BG = 46; + WHITE_FG = 37; + WHITE_BG = 47; +} diff --git a/src/ansi/mod.rs b/src/ansi/mod.rs index 7a38ae4..d7e2ab3 100644 --- a/src/ansi/mod.rs +++ b/src/ansi/mod.rs @@ -1,5 +1,7 @@ use std::{collections::BTreeMap, io::Read, sync::RwLock}; +pub mod colors; + fn read1() -> Option<u8> { let mut buf = [0]; match std::io::stdin().lock().read_exact(&mut buf) { |
