Struct syntect::highlighting::Highlighter
[−]
[src]
pub struct Highlighter<'a> { /* fields omitted */ }
Basically a wrapper around a Theme
preparing it to be used for highlighting.
This is part of the API to preserve the possibility of caching
matches of the selectors of the theme on various scope paths
or setting up some kind of accelerator structure.
So for now this does very little but eventually if you keep it around between highlighting runs it will preserve its cache.
Methods
impl<'a> Highlighter<'a>
[src]
fn new(theme: &'a Theme) -> Highlighter<'a>
fn get_default(&self) -> Style
The default style in the absence of any matched rules. Basically what plain text gets highlighted as.
fn get_style(&self, path: &[Scope]) -> StyleModifier
Figures out which scope selector in the theme best matches this scope stack. It only returns any changes to the style that should be applied when the top element is pushed on to the stack. These actually aren't guaranteed to be different than the current style. Basically what this means is that you have to gradually apply styles starting with the default and working your way up the stack in order to get the correct style.
Don't worry if this sounds complex, you shouldn't need to use this method. It's only public because I default to making things public for power users unless I have a good argument nobody will ever need to use the method.
fn get_new_style(&self, path: &[Scope]) -> StyleModifier
Like get_style but only guarantees returning any new style
if the last element of path
was just pushed on to the stack.
Panics if path
is empty.
fn style_for_stack(&self, stack: &[Scope]) -> Style
Returns the fully resolved style for the given stack.
This operation is convenient but expensive. For reasonable performance, the caller should be caching results.
fn style_mod_for_stack(&self, stack: &[Scope]) -> StyleModifier
Returns a StyleModifier
which, if applied to the default style,
would generate the fully resolved style for this stack.
This is made available to applications that are using syntect styles in combination with style information from other sources.
This operation is convenient but expensive. For reasonable performance, the caller should be caching results.