use crate::escape;
macro_rules! do_style {
( $( $style:ident: $code:tt ),+ ) => {
$(
#[doc = concat!(stringify!($style), ".")]
pub fn $style() {
escape(concat!(stringify!($code), "m"));
}
)+
};
}
do_style!(bold: 1, faint: 2, italic: 3, underline: 4, strike: 9);
pub mod de {
use crate::escape;
macro_rules! de_style {
( $( $style:ident: $code:tt ),+ ) => {
$(
#[doc = concat!(stringify!($style), ".")]
pub fn $style() {
escape(concat!(stringify!($code), "m"));
}
)+
pub fn all() {
$($style();)+
weight();
}
};
}
de_style!(italic: 23, underline: 24, strike: 29);
pub fn weight() {
escape("22m");
}
}
pub mod with {
macro_rules! with_style {
( $( $style:ident: $de:ident ),+ ) => {
$(
#[doc = concat!(stringify!($style), ",")]
pub fn $style(f: impl FnOnce()) {
super::$style();
(f)();
super::de::$de();
}
)+
};
}
with_style![
bold: weight,
faint: weight,
italic: italic,
underline: underline,
strike: strike
];
}