pub struct SourceText { /* private fields */ }Expand description
A source text and what render_source reads off it every frame: its
lines, a hash of each, and its highlight spans.
SourceText::new walks and highlights the whole text.
SourceText::edit redoes only the lines an edit touched and shifts the
spans around it; the SpanJob it answers highlights the new text in full,
on any thread, for SourceText::set_spans.
Implementations§
Source§impl SourceText
impl SourceText
pub fn new(code: impl Into<Arc<str>>, cx: &App) -> Self
pub fn text(&self) -> &str
Sourcepub fn line_of(&self, offset: usize) -> usize
pub fn line_of(&self, offset: usize) -> usize
The line holding byte offset; past the end, the last line.
Sourcepub fn spans(&self) -> Option<&[(Range<usize>, HighlightKind)]>
pub fn spans(&self) -> Option<&[(Range<usize>, HighlightKind)]>
The highlight spans, in bytes and in order. Between an Self::edit
and the Self::set_spans that follows it, the spans from before the
edit, shifted past it, and none over the bytes it replaced.
Auto Trait Implementations§
impl !Freeze for SourceText
impl !RefUnwindSafe for SourceText
impl !Send for SourceText
impl !Sync for SourceText
impl Unpin for SourceText
impl UnsafeUnpin for SourceText
impl UnwindSafe for SourceText
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> 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