Buffer

Struct Buffer 

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

A rectangular grid of terminal cells.

Stores styled text content for rendering to a terminal. Use set_string and set_style to modify the buffer contents.

Implementations§

Source§

impl Buffer

Source

pub fn scroll_up(&mut self, amount: u16)

Scrolls content up by the given number of lines.

Lines shifted off the top are discarded; new lines at the bottom are filled with empty cells.

Source

pub fn scroll_down(&mut self, amount: u16)

Scrolls content down by the given number of lines.

Lines shifted off the bottom are discarded; new lines at the top are filled with empty cells.

Source

pub fn width(&self) -> u16

Returns the buffer width in cells.

Source

pub fn height(&self) -> u16

Returns the buffer height in cells.

Source

pub fn new(width: u16, height: u16) -> Buffer

Creates a new buffer with the given dimensions.

Source

pub fn get_mut(&mut self, x: u16, y: u16) -> Option<&mut Cell>

Returns a mutable reference to the cell at the given position.

Source

pub fn row_remaining_mut(&mut self, x: u16, y: u16) -> Option<&mut [Cell]>

Returns a mutable slice of cells from position (x, y) to the end of the row.

Source

pub fn set_style(&mut self, area: Rect, style: Style)

Source

pub fn set_string( &mut self, x: u16, y: u16, string: &str, style: Style, ) -> (u16, u16)

Writes a styled string at the given position.

Returns the cursor position after writing.

Source

pub fn set_stringn( &mut self, x: u16, y: u16, string: &str, max_width: usize, style: Style, ) -> (u16, u16)

Writes a styled string with a maximum width.

Returns the cursor position after writing.

Auto Trait Implementations§

§

impl Freeze for Buffer

§

impl RefUnwindSafe for Buffer

§

impl Send for Buffer

§

impl Sync for Buffer

§

impl Unpin for Buffer

§

impl UnwindSafe for Buffer

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