Skip to main content

ScreenBuffer

Struct ScreenBuffer 

Source
pub struct ScreenBuffer {
    pub width: usize,
    pub height: usize,
    /* private fields */
}

Fields§

§width: usize§height: usize

Implementations§

Source§

impl ScreenBuffer

Source

pub fn new(width: usize, height: usize, style: Option<Style>) -> Self

Source

pub fn get(&self, x: usize, y: usize) -> &Cell

Source

pub fn get_mut(&mut self, x: usize, y: usize) -> &mut Cell

Source

pub fn as_plain_lines(&self) -> Vec<String>

Source

pub fn from_renderable( console: &Console, options: &ConsoleOptions, renderable: &dyn Renderable, style: Option<Style>, ) -> Self

Render a renderable to a ScreenBuffer.

This uses Console::render_lines and then converts the rendered lines to cells.

Source

pub fn from_lines( lines: &[Vec<Segment>], width: usize, height: usize, default_style: Option<Style>, ) -> Self

Build a ScreenBuffer from pre-rendered lines.

The caller is expected to provide lines already padded/cropped to width × height.

Source

pub fn blit_lines( &mut self, x: usize, y: usize, width: usize, lines: &[Vec<Segment>], )

Blit pre-rendered lines into the buffer at an offset.

Lines should be padded/cropped to the region width. This method will clip to the screen bounds.

Source

pub fn to_styled_lines(&self) -> Vec<Vec<Segment>>

Convert the buffer to styled lines (no newlines).

Source

pub fn diff_to_segments(&self, previous: &ScreenBuffer) -> Segments

Compute an update sequence that transforms previous into self.

The returned segments:

  • Start with Home (cursor to 0,0)
  • Use cursor controls (no \n) for positioning
  • Emit styled text for changed spans
Source

pub fn diff_to_segments_from_origin(&self, previous: &ScreenBuffer) -> Segments

Compute an update sequence relative to the current cursor origin.

Unlike diff_to_segments, this does not emit Home and is intended for embedding in larger cursor-positioned render flows (e.g. Live updates).

Trait Implementations§

Source§

impl Clone for ScreenBuffer

Source§

fn clone(&self) -> ScreenBuffer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ScreenBuffer

Source§

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

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

impl Eq for ScreenBuffer

Source§

impl PartialEq for ScreenBuffer

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ScreenBuffer

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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

Checks if this value is equivalent to the given key. 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> 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.