ratatui::buffer

Struct Cell

Source
pub struct Cell {
    pub fg: Color,
    pub bg: Color,
    pub underline_color: Color,
    pub modifier: Modifier,
    pub skip: bool,
    /* private fields */
}
Expand description

A buffer cell

Fields§

§fg: Color

The foreground color of the cell.

§bg: Color

The background color of the cell.

§underline_color: Color

The underline color of the cell.

§modifier: Modifier

The modifier of the cell.

§skip: bool

Whether the cell should be skipped when copying (diffing) the buffer to the screen.

Implementations§

Source§

impl Cell

Source

pub const EMPTY: Self = _

An empty Cell

Source

pub const fn new(symbol: &'static str) -> Self

Creates a new Cell with the given symbol.

This works at compile time and puts the symbol onto the stack. Fails to build when the symbol doesnt fit onto the stack and requires to be placed on the heap. Use Self::default().set_symbol() in that case. See CompactString::const_new for more details on this.

Source

pub fn symbol(&self) -> &str

Gets the symbol of the cell.

Source

pub fn set_symbol(&mut self, symbol: &str) -> &mut Self

Sets the symbol of the cell.

Source

pub fn set_char(&mut self, ch: char) -> &mut Self

Sets the symbol of the cell to a single character.

Source

pub fn set_fg(&mut self, color: Color) -> &mut Self

Sets the foreground color of the cell.

Source

pub fn set_bg(&mut self, color: Color) -> &mut Self

Sets the background color of the cell.

Source

pub fn set_style<S: Into<Style>>(&mut self, style: S) -> &mut Self

Sets the style of the cell.

style accepts any type that is convertible to Style (e.g. Style, Color, or your own type that implements Into<Style>).

Source

pub const fn style(&self) -> Style

Returns the style of the cell.

Source

pub fn set_skip(&mut self, skip: bool) -> &mut Self

Sets the cell to be skipped when copying (diffing) the buffer to the screen.

This is helpful when it is necessary to prevent the buffer from overwriting a cell that is covered by an image from some terminal graphics protocol (Sixel / iTerm / Kitty …).

Source

pub fn reset(&mut self)

Resets the cell to the empty state.

Trait Implementations§

Source§

impl Clone for Cell

Source§

fn clone(&self) -> Cell

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 Cell

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Cell

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<char> for Cell

Source§

fn from(ch: char) -> Self

Converts to this type from the input type.
Source§

impl Hash for Cell

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Cell

Source§

fn eq(&self, other: &Cell) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Cell

Source§

impl StructuralPartialEq for Cell

Auto Trait Implementations§

§

impl Freeze for Cell

§

impl RefUnwindSafe for Cell

§

impl Send for Cell

§

impl Sync for Cell

§

impl Unpin for Cell

§

impl UnwindSafe for Cell

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 u8)

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> 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.