pub mod ansi;
pub mod markdown;
use crate::theme::Style;
use crate::utils::span::{IndexedSpan, Span, SpannedString};
pub type StyledString = SpannedString<Style>;
pub type StyledIndexedSpan = IndexedSpan<Style>;
pub type StyledSpan<'a> = Span<'a, Style>;
impl SpannedString<Style> {
pub fn plain<S>(content: S) -> Self
where
S: Into<String>,
{
Self::styled(content, Style::none())
}
pub fn styled<S, T>(content: S, style: T) -> Self
where
S: Into<String>,
T: Into<Style>,
{
let content = content.into();
let style = style.into();
Self::single_span(content, style)
}
pub fn append_plain<S>(&mut self, text: S)
where
S: Into<String>,
{
self.append(Self::plain(text));
}
pub fn append_styled<S, T>(&mut self, text: S, style: T)
where
S: Into<String>,
T: Into<Style>,
{
self.append(Self::styled(text, style));
}
}