Skip to main content

Backend

Trait Backend 

Source
pub trait Backend: DisplayBackend {
    // Required methods
    fn enable_raw_mode(&mut self) -> Result<()>;
    fn disable_raw_mode(&mut self) -> Result<()>;
    fn hide_cursor(&mut self) -> Result<()>;
    fn show_cursor(&mut self) -> Result<()>;
    fn get_cursor_pos(&mut self) -> Result<(u16, u16)>;
    fn move_cursor_to(&mut self, x: u16, y: u16) -> Result<()>;
    fn scroll(&mut self, dist: i16) -> Result<()>;
    fn clear(&mut self, clear_type: ClearType) -> Result<()>;
    fn size(&self) -> Result<Size>;

    // Provided method
    fn move_cursor(&mut self, direction: MoveDirection) -> Result<()> { ... }
}
Expand description

A trait to represent a terminal that can be rendered to in an interactive manner.

Required Methods§

Source

fn enable_raw_mode(&mut self) -> Result<()>

Enables raw mode.

Source

fn disable_raw_mode(&mut self) -> Result<()>

Disables raw mode.

Source

fn hide_cursor(&mut self) -> Result<()>

Hides the cursor.

Source

fn show_cursor(&mut self) -> Result<()>

Shows the cursor.

Source

fn get_cursor_pos(&mut self) -> Result<(u16, u16)>

Gets the cursor position as (col, row). The top-left cell is (0, 0).

Source

fn move_cursor_to(&mut self, x: u16, y: u16) -> Result<()>

Moves the cursor to given position. The top-left cell is (0, 0).

Source

fn scroll(&mut self, dist: i16) -> Result<()>

Scrolls the terminal the given number of rows.

A negative number means the terminal scrolls upwards, while a positive number means the terminal scrolls downwards.

Source

fn clear(&mut self, clear_type: ClearType) -> Result<()>

Clears the cells given by clear_type

Source

fn size(&self) -> Result<Size>

Gets the size of the terminal in rows and columns.

Provided Methods§

Source

fn move_cursor(&mut self, direction: MoveDirection) -> Result<()>

Moves the cursor relative to the current position as per the direction.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<B: Backend> Backend for &mut B

Source§

fn enable_raw_mode(&mut self) -> Result<()>

Source§

fn disable_raw_mode(&mut self) -> Result<()>

Source§

fn hide_cursor(&mut self) -> Result<()>

Source§

fn show_cursor(&mut self) -> Result<()>

Source§

fn get_cursor_pos(&mut self) -> Result<(u16, u16)>

Source§

fn move_cursor_to(&mut self, x: u16, y: u16) -> Result<()>

Source§

fn move_cursor(&mut self, direction: MoveDirection) -> Result<()>

Source§

fn scroll(&mut self, dist: i16) -> Result<()>

Source§

fn clear(&mut self, clear_type: ClearType) -> Result<()>

Source§

fn size(&self) -> Result<Size>

Implementors§

Source§

impl Backend for TestBackend

Source§

impl<W: Write + AsFd> Backend for TermionBackend<W>

Available on crate feature termion only.
Source§

impl<W: Write> Backend for CrosstermBackend<W>

Available on crate feature crossterm only.