pub struct ShapedLine {
pub text: SharedString,
/* private fields */
}Expand description
A line of text that has been shaped and decorated.
Fields§
§text: SharedStringThe text that was shaped for this line.
Implementations§
Source§impl ShapedLine
impl ShapedLine
Sourcepub fn cursor(&self) -> ShapedLineCursor<'_>
pub fn cursor(&self) -> ShapedLineCursor<'_>
Returns a forward-only cursor for this shaped line.
Sourcepub fn width(&self) -> Pixels
pub fn width(&self) -> Pixels
The width of the shaped line in pixels.
This is the glyph advance width computed by the text shaping system and is useful for incrementally advancing a “pen” when painting multiple fragments on the same row.
Sourcepub fn with_len(self, len: usize) -> ShapedLine
pub fn with_len(self, len: usize) -> ShapedLine
Override the len, useful if you’re rendering text a as text b (e.g. rendering invisibles).
Sourcepub fn paint(
&self,
origin: Point<Pixels>,
line_height: Pixels,
align: TextAlign,
align_width: Option<Pixels>,
window: &mut Window,
cx: &mut App,
) -> Result<(), Error>
pub fn paint( &self, origin: Point<Pixels>, line_height: Pixels, align: TextAlign, align_width: Option<Pixels>, window: &mut Window, cx: &mut App, ) -> Result<(), Error>
Paint the line of text to the window.
Sourcepub fn paint_with_underline_handler(
&self,
origin: Point<Pixels>,
line_height: Pixels,
align: TextAlign,
align_width: Option<Pixels>,
window: &mut Window,
cx: &mut App,
paint_underline: impl FnMut(Range<usize>, Point<Pixels>, Pixels, &UnderlineStyle, &mut Window),
) -> Result<(), Error>
pub fn paint_with_underline_handler( &self, origin: Point<Pixels>, line_height: Pixels, align: TextAlign, align_width: Option<Pixels>, window: &mut Window, cx: &mut App, paint_underline: impl FnMut(Range<usize>, Point<Pixels>, Pixels, &UnderlineStyle, &mut Window), ) -> Result<(), Error>
Paint the line with a handler for each underline.
Sourcepub fn paint_background(
&self,
origin: Point<Pixels>,
line_height: Pixels,
align: TextAlign,
align_width: Option<Pixels>,
window: &mut Window,
cx: &mut App,
) -> Result<(), Error>
pub fn paint_background( &self, origin: Point<Pixels>, line_height: Pixels, align: TextAlign, align_width: Option<Pixels>, window: &mut Window, cx: &mut App, ) -> Result<(), Error>
Paint the background of the line to the window.
Sourcepub fn split_at(&self, byte_index: usize) -> (ShapedLine, ShapedLine)
pub fn split_at(&self, byte_index: usize) -> (ShapedLine, ShapedLine)
Split this shaped line at a byte index, returning (prefix, suffix).
prefixcontains glyphs for bytes[0, byte_index)with original positions. Its width equals the x-advance up to the split point.suffixcontains glyphs for bytes[byte_index, len)with positions shifted left so the first glyph starts at x=0, and byte indices rebased to 0.- Decoration runs are partitioned at the boundary; a run that straddles it is split into two with adjusted lengths.
font_size,ascent, anddescentare copied to both halves.
Trait Implementations§
Source§impl Clone for ShapedLine
impl Clone for ShapedLine
Source§fn clone(&self) -> ShapedLine
fn clone(&self) -> ShapedLine
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ShapedLine
impl Debug for ShapedLine
Source§impl Default for ShapedLine
impl Default for ShapedLine
Source§fn default() -> ShapedLine
fn default() -> ShapedLine
Returns the “default value” for a type. Read more
Source§impl Deref for ShapedLine
impl Deref for ShapedLine
Source§impl DerefMut for ShapedLine
impl DerefMut for ShapedLine
Auto Trait Implementations§
impl Forget for ShapedLine
impl Freeze for ShapedLinewhere
*const ArcInner<LineLayout> is !null: Freeze,
PhantomData<ArcInner<LineLayout>>: Freeze,
&'static str: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const DecorationRun is !null: Freeze,
PhantomData<DecorationRun>: Freeze,
impl Move for ShapedLine
impl RefUnwindSafe for ShapedLine
impl Send for ShapedLine
impl Sync for ShapedLinewhere
Arc<LineLayout>: Sync,
Arc<str>: Sync,
SmallVecData<[DecorationRun; 32]>: Sync,
DecorationRun: Sync,
impl Unpin for ShapedLinewhere
Arc<LineLayout>: Unpin,
&'static str: Unpin,
Arc<str>: Unpin,
*const DecorationRun is !null: Unpin,
DecorationRun: Unpin,
impl UnsafeUnpin for ShapedLinewhere
*const ArcInner<LineLayout> is !null: UnsafeUnpin,
PhantomData<ArcInner<LineLayout>>: UnsafeUnpin,
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const DecorationRun is !null: UnsafeUnpin,
PhantomData<DecorationRun>: UnsafeUnpin,
impl UnwindSafe for ShapedLinewhere
Arc<LineLayout>: UnwindSafe,
&'static str: UnwindSafe,
Arc<str>: UnwindSafe,
NonNull<DecorationRun>: UnwindSafe,
DecorationRun: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
Source§type NoneType = T
type NoneType = T
The type of the none-equivalent value that
NoneValue::null_value produces.Source§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.
Source§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>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().