pub struct HighlightedText { /* private fields */ }Expand description
A run of text with some of it marked.
The current mark is a different treatment from the rest, not a stronger one: “which hit am I on” and “where are the other hits” are two questions, and one shade of the same colour answers neither clearly.
Implementations§
Source§impl HighlightedText
impl HighlightedText
pub fn new(text: impl Into<SharedString>) -> Self
Sourcepub fn id(self, ident: impl Into<Ident>) -> Self
pub fn id(self, ident: impl Into<Ident>) -> Self
Publishes a node under this id. Without one nothing is published, the
way a decorative Badge publishes nothing.
Sourcepub fn hits(self, hits: impl IntoIterator<Item = Range<usize>>) -> Self
pub fn hits(self, hits: impl IntoIterator<Item = Range<usize>>) -> Self
The ranges to mark, in byte offsets into the text this was given.
Sourcepub fn current(self, index: usize) -> Self
pub fn current(self, index: usize) -> Self
Which hit, by index into HighlightedText::hits, is the current one.
pub fn monospace(self, monospace: bool) -> Self
Sourcepub fn published_hits(&self) -> usize
pub fn published_hits(&self) -> usize
How many of the given ranges name text this string actually holds.
A caller whose offsets are wrong gets a smaller number than it handed in, which is how a broken boundary is noticed rather than guessed at.
Trait Implementations§
Source§impl Debug for HighlightedText
impl Debug for HighlightedText
Source§impl IntoElement for HighlightedText
impl IntoElement for HighlightedText
Source§type Element = ViewElement<HighlightedText>
type Element = ViewElement<HighlightedText>
The specific type of element into which the implementing type is converted.
Useful for converting other types into elements automatically, like Strings
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Convert self into a type that implements
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
Convert self into a dynamically-typed
AnyElement.Source§impl RenderOnce for HighlightedText
impl RenderOnce for HighlightedText
Source§fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement
Render this component into an element tree. Note that this method
takes ownership of self, as compared to
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl Freeze for HighlightedText
impl RefUnwindSafe for HighlightedText
impl Send for HighlightedText
impl Sync for HighlightedText
impl Unpin for HighlightedText
impl UnsafeUnpin for HighlightedText
impl UnwindSafe for HighlightedText
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Render this component or element with an animation
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<E> Flipping for Ewhere
E: IntoElement,
impl<E> Flipping for Ewhere
E: IntoElement,
Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Imperatively modify self with the given closure.
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Conditionally modify self with the given closure.
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
Conditionally modify self with the given closure.
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