From 4d0647dd8aa18dd1434448f4dd346c86d03b0a46 Mon Sep 17 00:00:00 2001 From: syaw0 Date: Mon, 4 Nov 2024 09:45:45 +0330 Subject: [PATCH] feat: Add Formatter struct --- src/colors.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/colors.rs b/src/colors.rs index 7b1a6e3..674f404 100644 --- a/src/colors.rs +++ b/src/colors.rs @@ -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 { @@ -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), } } }