ScreenBuffer

Struct ScreenBuffer 

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

A simple screen buffer for terminal content.

This provides basic screen buffer functionality. For full terminal emulation, use the screen feature which provides a more complete implementation.

Implementations§

Source§

impl ScreenBuffer

Source

pub fn new(dimensions: Dimensions) -> Self

Create a new screen buffer.

Source

pub const fn dimensions(&self) -> Dimensions

Get the screen dimensions.

Source

pub const fn cursor(&self) -> Position

Get the cursor position.

Source

pub fn set_cursor(&mut self, pos: Position)

Set the cursor position.

Source

pub fn move_cursor(&mut self, rows: isize, cols: isize)

Move the cursor.

Source

pub const fn save_cursor(&mut self)

Save the cursor position.

Source

pub const fn restore_cursor(&mut self)

Restore the cursor position.

Source

pub fn get(&self, row: usize, col: usize) -> Option<&Cell>

Get a cell at a position.

Source

pub fn get_mut(&mut self, row: usize, col: usize) -> Option<&mut Cell>

Get a mutable cell at a position.

Source

pub fn put_char(&mut self, c: char, attrs: CellAttributes)

Put a character at the cursor position.

Source

pub fn line(&self, row: usize) -> Option<String>

Get a line as a string.

Source

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

Get all lines as strings.

Source

pub fn content(&self) -> String

Get the screen content as a single string.

Source

pub fn region_text(&self, region: Region) -> String

Get text in a region.

Source

pub fn clear(&mut self)

Clear the screen.

Source

pub fn clear_region(&mut self, region: Region)

Clear a region.

Source

pub fn scroll_up(&mut self, n: usize)

Scroll the screen up by n lines.

Source

pub fn scroll_down(&mut self, n: usize)

Scroll the screen down by n lines.

Source

pub const fn set_scroll_region(&mut self, top: usize, bottom: usize)

Set the scroll region.

Source

pub fn resize(&mut self, dimensions: Dimensions)

Resize the screen.

Trait Implementations§

Source§

impl Debug for ScreenBuffer

Source§

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

Formats the value using the given formatter. 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, 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.
Source§

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

Source§

fn vzip(self) -> V