pub struct SyntaxHighlighter {
pub theme_name: String,
pub syntax_name: String,
/* private fields */
}Fields§
§theme_name: String§syntax_name: StringImplementations§
Source§impl SyntaxHighlighter
impl SyntaxHighlighter
pub fn new() -> Self
pub fn for_path(path: &Path) -> Self
pub fn plain() -> Self
pub fn with_theme(self, theme_name: &str) -> Self
pub fn with_syntax(self, syntax_name: &str) -> Self
Sourcepub fn snapshot_state(&self) -> HighlighterState
pub fn snapshot_state(&self) -> HighlighterState
Extract a HighlighterState snapshot of the highlighter’s configuration
and accumulated checkpoints.
IMPORTANT: This snapshot contains ParseState / HighlightState values
from syntect which are not guaranteed to be thread-safe. Do NOT send
the resulting HighlighterState across threads. For background-workers
use the theme/syntax names and the buffer lines to reconstruct a
SyntaxHighlighter inside the worker (see app.rs worker changes).
Sourcepub fn from_state(state: HighlighterState) -> Self
pub fn from_state(state: HighlighterState) -> Self
Reconstruct a SyntaxHighlighter from a previously snapshotted state.
The resulting highlighter has an empty per-line cache but inherits all accumulated checkpoints, so highlighting resumes cheaply.
pub fn clear_cache(&self)
pub fn invalidate_from(&self, from_line: usize)
pub fn highlight_line_at( &self, lines: &[String], line: usize, version: Version, ) -> Arc<Vec<Token>>
pub fn highlight_range( &self, all_lines: &[String], version: Version, start_row: usize, count: usize, ) -> Vec<Vec<StyledSpan>>
pub fn highlight_tokens( &self, all_lines: &[String], version: Version, start_line: usize, count: usize, ) -> Vec<Arc<Vec<Token>>>
Sourcepub fn highlight_tokens_cancellable(
&self,
all_lines: &[String],
version: Version,
start_line: usize,
count: usize,
cancelled: &AtomicBool,
) -> Vec<Arc<Vec<Token>>>
pub fn highlight_tokens_cancellable( &self, all_lines: &[String], version: Version, start_line: usize, count: usize, cancelled: &AtomicBool, ) -> Vec<Arc<Vec<Token>>>
Cancellable variant of highlight_tokens that checks cancelled between
lines and returns early if cancellation is requested. Useful for aborting
long-running background highlight tasks.
pub fn tokens_to_spans(&self, _line: &str, tokens: &[Token]) -> Vec<StyledSpan>
Trait Implementations§
Source§impl Clone for SyntaxHighlighter
impl Clone for SyntaxHighlighter
Source§impl Debug for SyntaxHighlighter
impl Debug for SyntaxHighlighter
Auto Trait Implementations§
impl !Freeze for SyntaxHighlighter
impl !RefUnwindSafe for SyntaxHighlighter
impl Send for SyntaxHighlighter
impl !Sync for SyntaxHighlighter
impl Unpin for SyntaxHighlighter
impl UnsafeUnpin for SyntaxHighlighter
impl UnwindSafe for SyntaxHighlighter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more