Struct cosmic_text::BufferLine
source · pub struct BufferLine { /* private fields */ }
Expand description
A line (or paragraph) of text that is shaped and laid out
Implementations§
source§impl BufferLine
impl BufferLine
sourcepub fn new<T: Into<String>>(
text: T,
ending: LineEnding,
attrs_list: AttrsList,
shaping: Shaping,
) -> Self
pub fn new<T: Into<String>>( text: T, ending: LineEnding, attrs_list: AttrsList, shaping: Shaping, ) -> Self
Create a new line with the given text and attributes list
Cached shaping and layout can be done using the Self::shape
and
Self::layout
functions
sourcepub fn set_text<T: AsRef<str>>(
&mut self,
text: T,
ending: LineEnding,
attrs_list: AttrsList,
) -> bool
pub fn set_text<T: AsRef<str>>( &mut self, text: T, ending: LineEnding, attrs_list: AttrsList, ) -> bool
Set text and attributes list
Will reset shape and layout if it differs from current text and attributes list. Returns true if the line was reset
sourcepub fn into_text(self) -> String
pub fn into_text(self) -> String
Consume this line, returning only its text contents as a String.
sourcepub fn ending(&self) -> LineEnding
pub fn ending(&self) -> LineEnding
Get line ending
sourcepub fn set_ending(&mut self, ending: LineEnding) -> bool
pub fn set_ending(&mut self, ending: LineEnding) -> bool
Set line ending
Will reset shape and layout if it differs from current line ending. Returns true if the line was reset
sourcepub fn attrs_list(&self) -> &AttrsList
pub fn attrs_list(&self) -> &AttrsList
Get attributes list
sourcepub fn set_attrs_list(&mut self, attrs_list: AttrsList) -> bool
pub fn set_attrs_list(&mut self, attrs_list: AttrsList) -> bool
Set attributes list
Will reset shape and layout if it differs from current attributes list. Returns true if the line was reset
sourcepub fn set_align(&mut self, align: Option<Align>) -> bool
pub fn set_align(&mut self, align: Option<Align>) -> bool
Set the text alignment
Will reset layout if it differs from current alignment.
Setting to None will use Align::Right
for RTL lines, and Align::Left
for LTR lines.
Returns true if the line was reset
sourcepub fn append(&mut self, other: Self)
pub fn append(&mut self, other: Self)
Append line at end of this line
The wrap setting of the appended line will be lost
sourcepub fn reset_shaping(&mut self)
pub fn reset_shaping(&mut self)
Reset shaping and layout caches
sourcepub fn reset_layout(&mut self)
pub fn reset_layout(&mut self)
Reset only layout cache
sourcepub fn shape(
&mut self,
font_system: &mut FontSystem,
tab_width: u16,
) -> &ShapeLine
pub fn shape( &mut self, font_system: &mut FontSystem, tab_width: u16, ) -> &ShapeLine
Shape line, will cache results
sourcepub fn shape_in_buffer(
&mut self,
scratch: &mut ShapeBuffer,
font_system: &mut FontSystem,
tab_width: u16,
) -> &ShapeLine
pub fn shape_in_buffer( &mut self, scratch: &mut ShapeBuffer, font_system: &mut FontSystem, tab_width: u16, ) -> &ShapeLine
Shape a line using a pre-existing shape buffer, will cache results
sourcepub fn layout(
&mut self,
font_system: &mut FontSystem,
font_size: f32,
width_opt: Option<f32>,
wrap: Wrap,
match_mono_width: Option<f32>,
tab_width: u16,
) -> &[LayoutLine]
pub fn layout( &mut self, font_system: &mut FontSystem, font_size: f32, width_opt: Option<f32>, wrap: Wrap, match_mono_width: Option<f32>, tab_width: u16, ) -> &[LayoutLine]
Layout line, will cache results
sourcepub fn layout_in_buffer(
&mut self,
scratch: &mut ShapeBuffer,
font_system: &mut FontSystem,
font_size: f32,
width_opt: Option<f32>,
wrap: Wrap,
match_mono_width: Option<f32>,
tab_width: u16,
) -> &[LayoutLine]
pub fn layout_in_buffer( &mut self, scratch: &mut ShapeBuffer, font_system: &mut FontSystem, font_size: f32, width_opt: Option<f32>, wrap: Wrap, match_mono_width: Option<f32>, tab_width: u16, ) -> &[LayoutLine]
Layout a line using a pre-existing shape buffer, will cache results
sourcepub fn layout_opt(&self) -> &Option<Vec<LayoutLine>>
pub fn layout_opt(&self) -> &Option<Vec<LayoutLine>>
Get line layout cache
sourcepub fn metadata(&self) -> Option<usize>
pub fn metadata(&self) -> Option<usize>
Get line metadata. This will be None if BufferLine::set_metadata
has not been called
after the last reset of shaping and layout caches
sourcepub fn set_metadata(&mut self, metadata: usize)
pub fn set_metadata(&mut self, metadata: usize)
Set line metadata. This is stored until the next line reset
Trait Implementations§
source§impl Clone for BufferLine
impl Clone for BufferLine
source§fn clone(&self) -> BufferLine
fn clone(&self) -> BufferLine
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for BufferLine
impl RefUnwindSafe for BufferLine
impl Send for BufferLine
impl Sync for BufferLine
impl Unpin for BufferLine
impl UnwindSafe for BufferLine
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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 more