Struct floem_cosmic_text::TextLayout

source ·
pub struct TextLayout {
    pub lines: Vec<TextLayoutLine>,
    /* private fields */
}
Expand description

A buffer of text that is shaped and laid out

Fields§

§lines: Vec<TextLayoutLine>

[BufferLine]s (or paragraphs) of text in the buffer

Implementations§

source§

impl TextLayout

source

pub fn new() -> Self

Create a new [Buffer] with the provided [FontSystem] and Metrics

§Panics

Will panic if metrics.line_height is zero.

source

pub fn shape_until(&mut self, lines: i32) -> i32

Pre-shape lines in the buffer, up to lines, return actual number of layout lines

source

pub fn shape_until_cursor(&mut self, cursor: Cursor)

Shape lines until cursor, also scrolling to include cursor in view

source

pub fn shape_until_scroll(&mut self)

Shape lines until scroll

source

pub fn layout_cursor(&self, cursor: &Cursor) -> LayoutCursor

source

pub fn line_shape(&mut self, line_i: usize) -> Option<&ShapeLine>

Shape the provided line index and return the result

source

pub fn line_layout(&mut self, line_i: usize) -> Option<&[LayoutLine]>

Lay out the provided line index and return the result

source

pub fn wrap(&self) -> Wrap

Get the current Wrap

source

pub fn set_wrap(&mut self, wrap: Wrap)

Set the current Wrap

source

pub fn size(&self) -> Size

source

pub fn set_size(&mut self, width: f32, height: f32)

Set the current buffer dimensions

source

pub fn scroll(&self) -> i32

Get the current scroll location

source

pub fn set_scroll(&mut self, scroll: i32)

Set the current scroll location

source

pub fn set_text(&mut self, text: &str, attrs: AttrsList)

Set text of buffer, using provided attributes for each line by default

source

pub fn set_tab_width(&mut self, tab_width: usize)

source

pub fn redraw(&self) -> bool

True if a redraw is needed

source

pub fn set_redraw(&mut self, redraw: bool)

Set redraw needed flag

source

pub fn layout_runs(&self) -> LayoutRunIter<'_>

Get the visible layout runs for rendering and other tasks

source

pub fn hit_point(&self, point: Point) -> HitPoint

source

pub fn line_col_position(&self, line: usize, col: usize) -> HitPosition

source

pub fn hit_position(&self, idx: usize) -> HitPosition

source

pub fn hit(&self, x: f32, y: f32) -> Option<Cursor>

Convert x, y position to Cursor (hit detection)

source

pub fn draw<F>(&self, cache: &mut SwashCache, color: Color, f: F)
where F: FnMut(i32, i32, u32, u32, Color),

Draw the buffer

Trait Implementations§

source§

impl Clone for TextLayout

source§

fn clone(&self) -> TextLayout

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

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more