#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum AnsiColor {
#[default]
Default,
Indexed(u8),
Rgb(u8, u8, u8),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum AnsiIntensity {
#[default]
Normal,
Bold,
Faint,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum UnderlineStyle {
#[default]
None,
Single,
Double,
Curly,
Dotted,
Dashed,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct AnsiStyle {
pub foreground: AnsiColor,
pub background: AnsiColor,
pub underline_color: Option<AnsiColor>,
pub intensity: AnsiIntensity,
pub italic: bool,
pub underline: UnderlineStyle,
pub strikethrough: bool,
pub reverse: bool,
pub hidden: bool,
}
impl AnsiStyle {
pub(crate) fn reset(&mut self) {
*self = Self::default();
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AnsiSpan {
pub text: String,
pub style: AnsiStyle,
}
impl AnsiSpan {
#[must_use]
pub fn new(text: impl Into<String>, style: AnsiStyle) -> Self {
Self {
text: text.into(),
style,
}
}
}