Skip to content

Commit

Permalink
feat: Add Formatter struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Syaw0 committed Nov 4, 2024
1 parent a322ef4 commit 4d0647d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,33 @@ pub enum PaintType {
BG,
}

#[derive(Debug, Clone)]
struct Formatter {
n: u8,
}

impl Stylify for Formatter {
fn make_styles(&self, _paint_type: Option<&PaintType>) -> String {
format!("{}", self.n)
}
}

pub const RESET: Styles = Styles::StyleFormatter(Formatter { n: 0 });
pub const BOLD: Styles = Styles::StyleFormatter(Formatter { n: 1 });
pub const FAINT: Styles = Styles::StyleFormatter(Formatter { n: 2 });
pub const ITALIC: Styles = Styles::StyleFormatter(Formatter { n: 3 });
pub const UNDERLINE: Styles = Styles::StyleFormatter(Formatter { n: 4 });
pub const SLOW_BLINK: Styles = Styles::StyleFormatter(Formatter { n: 5 });
pub const RAPID_BLINK: Styles = Styles::StyleFormatter(Formatter { n: 6 });
pub const OVERLINE: Styles = Styles::StyleFormatter(Formatter { n: 53 });

#[derive(Debug, Clone)]
pub enum Styles {
StyleRgb(Rgb),
StyleBasicColor(BasicColor),
StylePaletteColor(PaletteColor),
StylePaintType(PaintType),
StyleFormatter(Formatter),
}

impl Styles {
Expand All @@ -22,6 +43,7 @@ impl Styles {
Styles::StylePaintType(c) => c.make_styles(paint_type),
Styles::StylePaletteColor(c) => c.make_styles(paint_type),
Styles::StyleRgb(c) => c.make_styles(paint_type),
Styles::StyleFormatter(c) => c.make_styles(paint_type),
}
}
}
Expand Down

0 comments on commit 4d0647d

Please sign in to comment.