use std::fmt;
sequence!(
struct ResetAttributes => sgr!("0")
);
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub enum Attribute {
Bold = 1,
Faint = 2,
Normal = 22,
Italic = 3,
ItalicOff = 23,
Underline = 4,
UnderlineOff = 24,
Blink = 5,
BlinkOff = 25,
Reverse = 7,
ReverseOff = 27,
Conceal = 8,
ConcealOff = 28,
Crossed = 9,
CrossedOff = 29,
}
impl fmt::Display for Attribute {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", *self as i32)
}
}
sequence!(
struct SetAttribute(Attribute) =>
|this, f| write!(f, sgr!("{}"), this.0)
);
#[cfg(test)]
test_sequences!(
set_attribute(
SetAttribute(Attribute::Bold) => "\x1B[1m",
SetAttribute(Attribute::Faint) => "\x1B[2m",
SetAttribute(Attribute::Normal) => "\x1B[22m",
SetAttribute(Attribute::Italic) => "\x1B[3m",
SetAttribute(Attribute::ItalicOff) => "\x1B[23m",
SetAttribute(Attribute::Underline) => "\x1B[4m",
SetAttribute(Attribute::UnderlineOff) => "\x1B[24m",
SetAttribute(Attribute::Blink) => "\x1B[5m",
SetAttribute(Attribute::BlinkOff) => "\x1B[25m",
SetAttribute(Attribute::Reverse) => "\x1B[7m",
SetAttribute(Attribute::ReverseOff) => "\x1B[27m",
SetAttribute(Attribute::Conceal) => "\x1B[8m",
SetAttribute(Attribute::ConcealOff) => "\x1B[28m",
SetAttribute(Attribute::Crossed) => "\x1B[9m",
SetAttribute(Attribute::CrossedOff) => "\x1B[29m",
),
reset_attributes(
ResetAttributes => "\x1B[0m",
)
);