cosmic_text

Struct 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

source

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

source

pub fn reset_new<T: Into<String>>( &mut self, text: T, ending: LineEnding, attrs_list: AttrsList, shaping: Shaping, )

Resets the current line with new internal values.

Avoids deallocating internal caches so they can be reused.

source

pub fn text(&self) -> &str

Get current text

source

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

source

pub fn into_text(self) -> String

Consume this line, returning only its text contents as a String.

source

pub fn ending(&self) -> LineEnding

Get line ending

source

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

source

pub fn attrs_list(&self) -> &AttrsList

Get attributes list

source

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

source

pub fn align(&self) -> Option<Align>

Get the Text alignment

source

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

source

pub fn append(&mut self, other: Self)

Append line at end of this line

The wrap setting of the appended line will be lost

source

pub fn split_off(&mut self, index: usize) -> Self

Split off new line at index

source

pub fn reset(&mut self)

Reset shaping, layout, and metadata caches

source

pub fn reset_shaping(&mut self)

Reset shaping and layout caches

source

pub fn reset_layout(&mut self)

Reset only layout cache

source

pub fn shape( &mut self, font_system: &mut FontSystem, tab_width: u16, ) -> &ShapeLine

Shape line, will cache results

source

pub fn shape_opt(&self) -> Option<&ShapeLine>

Get line shaping cache

source

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

source

pub fn layout_opt(&self) -> Option<&Vec<LayoutLine>>

Get line layout cache

source

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

source

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

source§

fn clone(&self) -> BufferLine

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for BufferLine

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.