use crate::Style;
#[derive(Debug, PartialEq, Eq, Copy, Clone, PartialOrd, Ord, Hash)]
pub enum Attribute {
Bold,
Dim,
Italic,
Underline,
Blink,
RapidBlink,
Invert,
Conceal,
Strike,
}
#[derive(Debug, PartialEq, Eq, Copy, Clone, PartialOrd, Ord, Hash)]
pub enum Quirk {
Mask,
Wrap,
Linger,
#[deprecated(
since = "1.0.1",
note = "renamed to `Resetting` due to builder method conflicts with `Vec::clear()`.\n\
`Quirk::Clear` will be removed in a future release."
)]
Clear,
Resetting,
Bright,
OnBright,
}
set_enum! {
Attribute { Bold, Dim, Italic, Underline, Blink, RapidBlink, Invert, Conceal, Strike }
}
set_enum! {
Quirk { Mask, Wrap, Linger, Clear, Resetting, Bright, OnBright }
}
impl Attribute {
pub(crate) fn fmt(&self, f: &mut dyn core::fmt::Write) -> core::fmt::Result {
write!(f, "{}", match self {
Attribute::Bold => 1,
Attribute::Dim => 2,
Attribute::Italic => 3,
Attribute::Underline => 4,
Attribute::Blink => 5,
Attribute::RapidBlink => 6,
Attribute::Invert => 7,
Attribute::Conceal => 8,
Attribute::Strike => 9,
})
}
pub const fn style(self) -> Style {
Style::new().attr(self)
}
}
impl Quirk {
pub const fn style(self) -> Style {
Style::new().quirk(self)
}
}
impl From<Attribute> for crate::Style {
fn from(attr: Attribute) -> Self {
attr.style()
}
}
impl From<Quirk> for crate::Style {
fn from(quirk: Quirk) -> Self {
quirk.style()
}
}