Trait TextBuffer

Source
pub trait TextBuffer {
    // Required methods
    fn width(&self) -> usize;
    fn height(&self) -> usize;
    fn read(&self, row: usize, col: usize) -> Cell;
    fn write(&mut self, row: usize, col: usize, cell: Cell);

    // Provided methods
    fn delete(&mut self, row: usize, col: usize) { ... }
    fn new_line(&mut self, cell: Cell) { ... }
    fn clear(&mut self, cell: Cell) { ... }
}
Expand description

A 2D array of Cell to render on screen

Required Methods§

Source

fn width(&self) -> usize

Columns

Source

fn height(&self) -> usize

Rows

Source

fn read(&self, row: usize, col: usize) -> Cell

Read the character at (row, col)

Avoid use this because it’s usually very slow on real hardware.

Source

fn write(&mut self, row: usize, col: usize, cell: Cell)

Write a character ch at (row, col)

Provided Methods§

Source

fn delete(&mut self, row: usize, col: usize)

Delete one character at (row, col).

Source

fn new_line(&mut self, cell: Cell)

Insert one blank line at the bottom, and scroll up one line.

The default method does single read and write for each pixel. Usually it needs rewrite for better performance.

Source

fn clear(&mut self, cell: Cell)

Clear the buffer

Implementors§