Skip to main content

Text

Struct Text 

Source
pub struct Text { /* private fields */ }
Expand description

A run of styled spans, word-wrapped at the render width. Newlines inside span content start new lines.

Implementations§

Source§

impl Text

Source

pub fn style(self, style: Style) -> Self

Style the most recently added span (the initial one if none added).

Source

pub fn span(self, content: impl Into<String>, style: Style) -> Self

Append a styled span.

Trait Implementations§

Source§

impl Element for Text

Source§

fn height(&self, width: u16) -> u16

Rows needed at the given width. Exact, cheap, no side effects.
Source§

fn render(&self, area: Rect, buf: &mut Buffer)

Draw into area of buf. area is sized by the caller from height (possibly clamped at the buffer edge).
Source§

fn animated(&self) -> Option<Duration>

Frame interval if self-animating (e.g. a live spinner). The runtime re-presents the tail at the smallest returned interval while any animated element is present.
Source§

fn cursor(&self, _area: Rect) -> Option<(u16, u16)>

Hardware cursor position relative to area, when this element is focused. None hides the cursor.

Auto Trait Implementations§

§

impl Freeze for Text

§

impl RefUnwindSafe for Text

§

impl Send for Text

§

impl Sync for Text

§

impl Unpin for Text

§

impl UnsafeUnpin for Text

§

impl UnwindSafe for Text

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<E> ElementExt for E
where E: Element,

Source§

fn any<'a>(self) -> AnyElement<'a>
where Self: 'a,

Type-erase, for heterogeneous branches.
Source§

fn pad_left(self, cols: u16) -> Padded<Self>

Offset by cols columns of left padding.
Source§

fn pad_top(self, rows: u16) -> Padded<Self>

Offset by rows rows of top padding.
Source§

impl<T> Fluent for T

Source§

fn when(self, cond: bool, f: impl FnOnce(Self) -> Self) -> Self

Apply f only when cond holds.
Source§

fn when_some<T>(self, value: Option<T>, f: impl FnOnce(Self, T) -> Self) -> Self

Apply f with the value when present.
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, 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.