Trait text_terminal::TerminalBackend
source · 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§
sourcetype DisplayError: Debug
type DisplayError: Debug
The Error type returned by the TerminalBackend::display()
function
if it returns a Result::Err
variant.
Required Methods§
sourcefn screen_size(&self) -> ScreenSize
fn screen_size(&self) -> ScreenSize
Returns the screen size of the terminal.
sourcefn update_screen_size(&mut self, new_size: ScreenSize)
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.
sourcefn display(
&mut self,
display_action: DisplayAction,
scrollback_buffer: &ScrollbackBuffer,
previous_style: Option<Style>
) -> Result<ScreenPoint, Self::DisplayError>
fn display( &mut self, display_action: DisplayAction, scrollback_buffer: &ScrollbackBuffer, previous_style: Option<Style> ) -> Result<ScreenPoint, Self::DisplayError>
Displays the given range of Unit
s 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 Unit
s up until the given scrollback_end
point will be written to
successive points on the screen.
Returns the new position of the screen cursor.
sourcefn move_cursor_to(&mut self, new_position: ScreenPoint) -> ScreenPoint
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.
sourcefn move_cursor_by(&mut self, num_columns: i32, num_rows: i32) -> ScreenPoint
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.
sourcefn set_insert_mode(&mut self, mode: InsertMode)
fn set_insert_mode(&mut self, mode: InsertMode)
TODO: change this to support any arbitrary terminal mode
sourcefn reset_screen(&mut self)
fn reset_screen(&mut self)
Fully reset the terminal screen to its initial default state.
sourcefn clear_screen(&mut self)
fn clear_screen(&mut self)
Clears the entire terminal screen.
sourcefn write_bytes(&mut self, bytes: &[u8])
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.