pub struct SyntaxLines { /* private fields */ }Expand description
Feeds a CodeEditor its colors with a SyntaxHighlighter. It keeps
the parser state every SyntaxLines::STEP lines, so any visible line is highlighted by
re-parsing at most that many lines before it, and edits only drop what follows them.
Implementations§
Source§impl SyntaxLines
impl SyntaxLines
pub const STEP: usize = 16
pub fn new(highlighter: SyntaxHighlighter) -> Self
Sourcepub fn for_path(path: &str) -> Option<Self>
pub fn for_path(path: &str) -> Option<Self>
For a file name’s extension, or None when there is no grammar for it.
Sourcepub fn tokens<'a>(
&mut self,
line: usize,
text: impl Fn(usize) -> &'a str,
) -> Vec<(Range<usize>, TokenKind)>
pub fn tokens<'a>( &mut self, line: usize, text: impl Fn(usize) -> &'a str, ) -> Vec<(Range<usize>, TokenKind)>
The tokens of line, given a way to read any line of the text.
Sourcepub fn invalidate(&mut self, from_line: usize)
pub fn invalidate(&mut self, from_line: usize)
The text changed from from_line on.
Trait Implementations§
Source§impl LineHighlighter for SyntaxLines
impl LineHighlighter for SyntaxLines
Source§fn highlight_line(
&mut self,
buffer: &CodeBuffer,
line: usize,
cx: &App,
) -> LineHighlights
fn highlight_line( &mut self, buffer: &CodeBuffer, line: usize, cx: &App, ) -> LineHighlights
Highlights of line
line of buffer. Ranges are clipped to character boundaries.Source§fn invalidate(&mut self, from_line: usize)
fn invalidate(&mut self, from_line: usize)
The text changed from
from_line on: forget what was computed for it and later lines.Auto Trait Implementations§
impl Forget for SyntaxLines
impl Freeze for SyntaxLines
impl Move for SyntaxLines
impl RefUnwindSafe for SyntaxLines
impl Send for SyntaxLines
impl Sync for SyntaxLines
impl Unpin for SyntaxLines
impl UnsafeUnpin for SyntaxLines
impl UnwindSafe for SyntaxLines
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&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> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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