Struct floem_cosmic_text::TextLayoutLine
source · pub struct TextLayoutLine { /* private fields */ }
Expand description
A line (or paragraph) of text that is shaped and laid out
Implementations§
source§impl TextLayoutLine
impl TextLayoutLine
sourcepub fn new<T: Into<String>>(
text: T,
attrs_list: AttrsList,
start_index: usize,
tab_width: usize
) -> Self
pub fn new<T: Into<String>>( text: T, attrs_list: AttrsList, start_index: usize, tab_width: usize ) -> 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> + Into<String>>(
&mut self,
text: T,
attrs_list: AttrsList
) -> bool
pub fn set_text<T: AsRef<str> + Into<String>>( &mut self, text: T, 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 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_wrap(&mut self, wrap: Wrap) -> bool
pub fn set_wrap(&mut self, wrap: Wrap) -> bool
Set wrapping setting (wrap by characters/words or no wrapping)
Will reset shape and layout if it differs from current wrapping setting. 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 shape and 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 start_index(&self) -> usize
pub fn start_index(&self) -> usize
The start index in the original overarching line.
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_layout(&mut self)
pub fn reset_layout(&mut self)
Reset only layout information
sourcepub fn layout(&mut self, width: f32, wrap: Wrap) -> &[LayoutLine]
pub fn layout(&mut self, width: f32, wrap: Wrap) -> &[LayoutLine]
Layout line, will cache results
sourcepub fn layout_opt(&self) -> &Option<Vec<LayoutLine>>
pub fn layout_opt(&self) -> &Option<Vec<LayoutLine>>
Get line layout cache
Trait Implementations§
source§impl Clone for TextLayoutLine
impl Clone for TextLayoutLine
source§fn clone(&self) -> TextLayoutLine
fn clone(&self) -> TextLayoutLine
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more