#[derive(Clone, Debug, PartialEq, Eq)]
pub enum HighlightEvent {
Start {
scope_index: usize,
language: String,
},
Source { start: usize, end: usize },
End,
}
impl HighlightEvent {
pub fn scope(&self) -> Option<&'static str> {
match self {
Self::Start { scope_index, .. } => crate::highlights::HIGHLIGHT_NAMES
.get(*scope_index)
.copied(),
Self::Source { .. } | Self::End => None,
}
}
pub fn language(&self) -> Option<&str> {
match self {
Self::Start { language, .. } => Some(language),
Self::Source { .. } | Self::End => None,
}
}
}