use owo_colors::Style;
use crate::SourceSpan;
#[derive(Copy, Clone, PartialEq, Debug)]
pub(super) enum LabelRenderMode {
SingleLine,
BlockFirst,
BlockRest,
}
#[derive(Debug, Clone)]
pub(super) struct FancySpan<'a> {
label: Option<&'a str>,
span: SourceSpan,
pub(super) style: Style,
}
impl PartialEq for FancySpan<'_> {
fn eq(&self, other: &Self) -> bool {
self.label == other.label && self.span == other.span
}
}
impl<'a> FancySpan<'a> {
pub(super) fn new(label: Option<&'a str>, span: SourceSpan, style: Style) -> Self {
FancySpan { label, span, style }
}
pub(super) fn has_label(&self) -> bool {
self.label.is_some()
}
pub(super) fn label(&self) -> Option<&str> {
self.label
}
pub(super) fn offset(&self) -> usize {
self.span.offset() as usize
}
pub(super) fn len(&self) -> usize {
self.span.len() as usize
}
}