use crate::{ColorInAPlane, Flag, Style, StyleSet, color::Color};
pub trait StyleElement {
#[must_use]
fn add_to_style(self, style: Style) -> Style;
}
pub trait ToStyleSet: Sized {
type StyleSet: StyleSet;
#[must_use]
fn bold(self) -> Self::StyleSet {
self.flag(Flag::Bold)
}
#[must_use]
fn faint(self) -> Self::StyleSet {
self.flag(Flag::Faint)
}
#[must_use]
fn italic(self) -> Self::StyleSet {
self.flag(Flag::Italic)
}
#[must_use]
fn underline(self) -> Self::StyleSet {
self.flag(Flag::Underline)
}
#[must_use]
fn slow_blink(self) -> Self::StyleSet {
self.flag(Flag::SlowBlink)
}
#[must_use]
fn rapid_blink(self) -> Self::StyleSet {
self.flag(Flag::RapidBlink)
}
#[must_use]
fn reverse(self) -> Self::StyleSet {
self.flag(Flag::Reverse)
}
#[must_use]
fn conceal(self) -> Self::StyleSet {
self.flag(Flag::Conceal)
}
#[must_use]
fn crossed_out(self) -> Self::StyleSet {
self.flag(Flag::CrossedOut)
}
#[must_use]
fn double_underline(self) -> Self::StyleSet {
self.flag(Flag::DoubleUnderline)
}
#[must_use]
fn overline(self) -> Self::StyleSet {
self.flag(Flag::Overline)
}
#[must_use]
fn flag(self, flag: Flag) -> Self::StyleSet {
self.add(flag)
}
#[must_use]
fn fg(self, color: impl Into<Color>) -> Self::StyleSet {
self.color(ColorInAPlane::new_in_fg(color))
}
#[must_use]
fn bg(self, color: impl Into<Color>) -> Self::StyleSet {
self.color(ColorInAPlane::new_in_bg(color))
}
#[must_use]
fn color(self, color_in_a_plane: ColorInAPlane) -> Self::StyleSet {
self.add(color_in_a_plane)
}
#[must_use]
fn add(self, element: impl StyleElement) -> Self::StyleSet {
self.to_style_set().add(element)
}
#[must_use]
fn to_style_set(self) -> Self::StyleSet;
}