use std::fmt::{Debug, Formatter};
use internship::IStr;
use serde::{Deserialize, Serialize};
use code_span::CodeView;
mod convert;
mod der;
pub mod iter;
mod ser;
#[derive(Clone, Eq, PartialEq)]
pub struct ColorView {
span: CodeView<IStr>,
}
#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct ColorSpan {
pub text: String,
pub color: IStr,
}
impl ColorView {
#[inline]
pub fn new(text: impl Into<String>) -> ColorView {
Self { span: CodeView::blank(text) }
}
pub fn text(&self) -> &str {
self.span.get_text()
}
pub fn dye_position(&mut self, start: usize, end: usize, color: &str) {
let color = match color {
"" => None,
_ => Some(IStr::new(color)),
};
self.span.mark_position(start, end, color)
}
pub fn dye_offset(&mut self, start: usize, end: usize, color: &str) {
let color = match color {
"" => None,
_ => Some(IStr::new(color)),
};
self.span.mark_offset(start, end, color)
}
}