mirror of
https://github.com/xvxx/phd
synced 2024-11-04 18:00:22 +00:00
little color module
This commit is contained in:
parent
0b386249ec
commit
b9393ea625
25
src/color.rs
Normal file
25
src/color.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use std::fmt;
|
||||
|
||||
macro_rules! color {
|
||||
($t:ident, $code:expr) => {
|
||||
pub struct $t;
|
||||
impl fmt::Display for $t {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "\x1b[{}m", $code)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
color!(Black, 90);
|
||||
color!(Red, 91);
|
||||
color!(Green, 92);
|
||||
color!(Yellow, 93);
|
||||
color!(Blue, 94);
|
||||
color!(Magenta, 95);
|
||||
color!(Cyan, 96);
|
||||
color!(White, 97);
|
||||
|
||||
color!(Reset, 0);
|
||||
color!(Bold, 1);
|
||||
color!(Underline, 4);
|
@ -1,3 +1,4 @@
|
||||
pub mod color;
|
||||
pub mod request;
|
||||
pub mod server;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user