pub struct RichText { /* private fields */ }Expand description
Rich text container that holds styled text spans, plus the URL table that link spans index into.
Implementations§
Source§impl RichText
impl RichText
pub fn new() -> Self
Sourcepub fn add_link(&mut self, url: impl Into<SharedString>) -> u32
pub fn add_link(&mut self, url: impl Into<SharedString>) -> u32
Register a link destination, returning the index for
InlineStyle::link on the spans that carry its text.
Sourcepub fn links(&self) -> &[SharedString]
pub fn links(&self) -> &[SharedString]
The registered link destinations, in registration order.
Sourcepub fn link_ranges(&self) -> Vec<(Range<usize>, SharedString)>
pub fn link_ranges(&self) -> Vec<(Range<usize>, SharedString)>
Byte ranges of the flattened text that are links, with their destinations — the input for an interactive text element’s clickable ranges. Adjacent spans of the same link merge into one range.
pub fn push(&mut self, text: impl Into<String>, style: InlineStyle)
pub fn push_plain(&mut self, text: impl Into<String>)
pub fn is_empty(&self) -> bool
pub fn clear(&mut self)
pub fn to_plain_text(&self) -> String
pub fn to_highlights(&self) -> (String, Vec<(Range<usize>, HighlightStyle)>)
pub fn to_highlights_with( &self, palette: &InlinePalette, ) -> (String, Vec<(Range<usize>, HighlightStyle)>)
pub fn spans(&self) -> &[TextSpan]
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RichText
impl RefUnwindSafe for RichText
impl Send for RichText
impl Sync for RichText
impl Unpin for RichText
impl UnsafeUnpin for RichText
impl UnwindSafe for RichText
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
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>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().