[−][src]Struct syntect::highlighting::HighlightState
Keeps a stack of scopes and styles as state between highlighting different lines. If you are highlighting an entire file you create one of these at the start and use it all the way to the end.
Caching
One reason this is exposed is that since it implements Clone
you can actually cache
these (probably along with a ParseState
) and only re-start highlighting from the point of a change.
You could also do something fancy like only highlight a bit past the end of a user's screen and resume
highlighting when they scroll down on large files.
Alternatively you can save space by caching only the path
field of this struct
then re-create the HighlightState
when needed by passing that stack as the initial_stack
parameter to the new
method. This takes less space but a small amount of time to re-create the style stack.
Note: Caching is for advanced users who have tons of time to maximize performance or want to do so eventually. It is not recommended that you try caching the first time you implement highlighting.
Fields
path: ScopeStack
Methods
impl HighlightState
[src]
pub fn new(
highlighter: &Highlighter,
initial_stack: ScopeStack
) -> HighlightState
[src]
highlighter: &Highlighter,
initial_stack: ScopeStack
) -> HighlightState
Note that the Highlighter
is not stored, it is used to construct the initial
stack of styles. Most of the time you'll want to pass an empty stack as initial_stack
but see the docs for HighlightState
for discussion of advanced caching use cases.
Trait Implementations
impl Clone for HighlightState
[src]
fn clone(&self) -> HighlightState
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for HighlightState
[src]
impl Eq for HighlightState
[src]
impl PartialEq<HighlightState> for HighlightState
[src]
fn eq(&self, other: &HighlightState) -> bool
[src]
fn ne(&self, other: &HighlightState) -> bool
[src]
impl StructuralEq for HighlightState
[src]
impl StructuralPartialEq for HighlightState
[src]
Auto Trait Implementations
impl RefUnwindSafe for HighlightState
impl Send for HighlightState
impl Sync for HighlightState
impl Unpin for HighlightState
impl UnwindSafe for HighlightState
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,