use super::{BOLD, Color, DIM, ITALIC, REVERSE, Style, UNDERLINE};
impl Style {
#[must_use]
pub const fn fg(mut self, color: Color) -> Self {
self.fg = Some(color);
self
}
#[must_use]
pub const fn bg(mut self, color: Color) -> Self {
self.bg = Some(color);
self
}
#[must_use]
pub const fn bold(self) -> Self {
self.with(BOLD)
}
#[must_use]
pub const fn dim(self) -> Self {
self.with(DIM)
}
#[must_use]
pub const fn italic(self) -> Self {
self.with(ITALIC)
}
#[must_use]
pub const fn underline(self) -> Self {
self.with(UNDERLINE)
}
#[must_use]
pub const fn reverse(self) -> Self {
self.with(REVERSE)
}
const fn with(mut self, bit: u8) -> Self {
self.attributes |= bit;
self
}
#[must_use]
pub const fn inherit(mut self, other: Self) -> Self {
if self.fg.is_none() {
self.fg = other.fg;
}
if self.bg.is_none() {
self.bg = other.bg;
}
self.attributes |= other.attributes;
self
}
#[must_use]
pub const fn plain(mut self) -> Self {
self.frame = Self::new().frame;
self
}
}