pub struct Text {
pub text: String,
pub marks: Vec<MarkSpan>,
}Expand description
Inline content: a string, plus marks over byte ranges of it.
Marks are a separate list rather than flags on a run because an editor has
to map them through insertions and deletions, and because run flags lose
nesting order — under flags **_x_** and _**x**_ are the same value.
Here they differ by the order of the two spans, and both survive a round
trip.
A newline in text is a line break within the block (markdown’s soft or
hard break, which this model does not distinguish — neither does Notion).
Whether it paints as a break or a space is a rendering decision.
Fields§
§text: String§marks: Vec<MarkSpan>Outermost first. Ranges may overlap and may be identical.
Implementations§
Source§impl Text
impl Text
Sourcepub fn insert(&mut self, at: usize, s: &str)
pub fn insert(&mut self, at: usize, s: &str)
Insert at a byte offset, moving the marks with it.
Sourcepub fn remove(&mut self, range: Range<usize>)
pub fn remove(&mut self, range: Range<usize>)
Remove a byte range, collapsing any mark that covered it.
Sourcepub fn toggle(&mut self, range: Range<usize>, mark: Mark)
pub fn toggle(&mut self, range: Range<usize>, mark: Mark)
Add mark over range, or take it away if the whole range has it.
Sourcepub fn covered_by(&self, range: &Range<usize>, mark: &Mark) -> bool
pub fn covered_by(&self, range: &Range<usize>, mark: &Mark) -> bool
Whether every byte of range already carries mark.
Trait Implementations§
impl Eq for Text
impl StructuralPartialEq for Text
Auto Trait Implementations§
impl Freeze for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnsafeUnpin for Text
impl UnwindSafe for Text
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().