pub trait TerminalBackend {
    type DisplayError: Debug;

    // Required methods
    fn screen_size(&self) -> ScreenSize;
    fn update_screen_size(&mut self, new_size: ScreenSize);
    fn display(
        &mut self,
        display_action: DisplayAction,
        scrollback_buffer: &ScrollbackBuffer,
        previous_style: Option<Style>
    ) -> Result<ScreenPoint, Self::DisplayError>;
    fn move_cursor_to(&mut self, new_position: ScreenPoint) -> ScreenPoint;
    fn move_cursor_by(&mut self, num_columns: i32, num_rows: i32) -> ScreenPoint;
    fn set_insert_mode(&mut self, mode: InsertMode);
    fn reset_screen(&mut self);
    fn clear_screen(&mut self);
    fn write_bytes(&mut self, bytes: &[u8]);
}

Required Associated Types§

source

type DisplayError: Debug

The Error type returned by the TerminalBackend::display() function if it returns a Result::Err variant.

Required Methods§

source

fn screen_size(&self) -> ScreenSize

Returns the screen size of the terminal.

source

fn update_screen_size(&mut self, new_size: ScreenSize)

Resizes the terminal screen. TODO: perform a full reflow of the contents currently displayed on screen.

source

fn display( &mut self, display_action: DisplayAction, scrollback_buffer: &ScrollbackBuffer, previous_style: Option<Style> ) -> Result<ScreenPoint, Self::DisplayError>

Displays the given range of Units in the scrollback buffer by writing them to this terminal’s backend.

The Unit at the scrollback_start point will be displayed at screen_start, and all Units up until the given scrollback_end point will be written to successive points on the screen.

Returns the new position of the screen cursor.

source

fn move_cursor_to(&mut self, new_position: ScreenPoint) -> ScreenPoint

Moves the on-screen cursor to the given position.

The cursor’s position will be clipped (not wrapped) to the actual size of the screen, in both the column (x) the row (y) dimensions.

Returns the new position of the on-screen cursor.

source

fn move_cursor_by(&mut self, num_columns: i32, num_rows: i32) -> ScreenPoint

Moves the on-screen cursor by the given number of rows and columns, in which a value of 0 indicates no movement in that dimension.

The cursor’s position will be clipped (not wrapped) to the actual size of the screen, in both the column (x) the row (y) dimensions.

Returns the new position of the on-screen cursor.

source

fn set_insert_mode(&mut self, mode: InsertMode)

TODO: change this to support any arbitrary terminal mode

source

fn reset_screen(&mut self)

Fully reset the terminal screen to its initial default state.

source

fn clear_screen(&mut self)

Clears the entire terminal screen.

source

fn write_bytes(&mut self, bytes: &[u8])

A temporary hack to allow direct writing to the backend’s output stream. This is only relevant for TtyBackends.

Implementors§

source§

impl<Output: Write> TerminalBackend for TtyBackend<Output>

§

type DisplayError = Error