pub struct Highlighter<'a> { /* private fields */ }
Expand description

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.

Implementations§

source§

impl<'a> Highlighter<'a>

source

pub fn new(theme: &'a Theme) -> Highlighter<'a>

source

pub fn get_default(&self) -> Style

The default style in the absence of any matched rules. Basically what plain text gets highlighted as.

source

pub 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.

source

pub fn style_mod_for_stack(&self, path: &[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. It’s likely slower than style_for_stack.

Trait Implementations§

source§

impl<'a> Debug for Highlighter<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Highlighter<'a>

§

impl<'a> Send for Highlighter<'a>

§

impl<'a> Sync for Highlighter<'a>

§

impl<'a> Unpin for Highlighter<'a>

§

impl<'a> UnwindSafe for Highlighter<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.