chromakitx 1.0.2

A comprehensive color manipulation library for Rust
Documentation
// SPDX-FileCopyrightText: 2023 CELESTIFYX Team
// SPDX-License-Identifier: GPL-3.0-or-later

use super::EnumColor;

use crate::{
    ColorFormattable,
    define_text_styles
};

define_text_styles! {
    Reset = 0,
    Bold = 1,
    Dim = 2,
    Italic = 3,
    Underline = 4,
    Blink = 5,
    BlinkRapid = 6,
    Reverse = 7,
    Hidden = 8,
    Strikethrough = 9
}

impl ColorFormattable for TextStyle {
    fn format(&self, _: bool) -> String {
        format!("\x1B[{}m", self.code())
    }
}

impl EnumColor for TextStyle {
    fn from_name(name: &str) -> Option<Self> {
        Self::from_str(name).ok()
    }
}