Trait promptuity::Terminal
source · pub trait Terminal<T: Write> {
Show 22 methods
// Required methods
fn writer(&mut self) -> &mut T;
fn size(&self) -> Result<TermSize, Error>;
fn enable_raw(&mut self) -> Result<(), Error>;
fn disable_raw(&mut self) -> Result<(), Error>;
fn cursor_show(&mut self) -> Result<(), Error>;
fn cursor_hide(&mut self) -> Result<(), Error>;
fn cursor_pos(&self) -> Result<CursorPosition, Error>;
fn move_to(&mut self, col: u16, row: u16) -> Result<(), Error>;
fn move_column(&mut self, to: u16) -> Result<(), Error>;
fn move_next_line(&mut self, to: u16) -> Result<(), Error>;
fn move_previous_line(&mut self, to: u16) -> Result<(), Error>;
fn scroll_up(&mut self, row: u16) -> Result<(), Error>;
fn scroll_down(&mut self, row: u16) -> Result<(), Error>;
fn clear(&mut self) -> Result<(), Error>;
fn clear_purge(&mut self) -> Result<(), Error>;
fn clear_current_line(&mut self) -> Result<(), Error>;
fn clear_cursor_up(&mut self) -> Result<(), Error>;
fn clear_cursor_down(&mut self) -> Result<(), Error>;
fn write(&mut self, value: &str) -> Result<(), Error>;
fn writeln(&mut self, value: &str) -> Result<(), Error>;
fn flush(&mut self) -> Result<(), Error>;
fn read_key(&mut self) -> Result<(KeyCode, KeyModifiers), Error>;
}
Expand description
A trait to represent a terminal.
The Terminal
trait includes the APIs necessary for building prompts, and the specific implementation provided by Promptuity is Term
.
Since the expected terminal is defined as a trait, it allows for switching to any implementation. For example, an implementation for a different terminal library or for testing purposes.
Required Methods§
sourcefn writer(&mut self) -> &mut T
fn writer(&mut self) -> &mut T
Returns a mutable reference to the writer. e.g. &mut std::io::Stderr
.
sourcefn enable_raw(&mut self) -> Result<(), Error>
fn enable_raw(&mut self) -> Result<(), Error>
Enables raw mode.
sourcefn disable_raw(&mut self) -> Result<(), Error>
fn disable_raw(&mut self) -> Result<(), Error>
Disables raw mode.
sourcefn cursor_show(&mut self) -> Result<(), Error>
fn cursor_show(&mut self) -> Result<(), Error>
Shows the cursor.
sourcefn cursor_hide(&mut self) -> Result<(), Error>
fn cursor_hide(&mut self) -> Result<(), Error>
Hides the cursor.
sourcefn cursor_pos(&self) -> Result<CursorPosition, Error>
fn cursor_pos(&self) -> Result<CursorPosition, Error>
Returns the cursor position.
sourcefn move_to(&mut self, col: u16, row: u16) -> Result<(), Error>
fn move_to(&mut self, col: u16, row: u16) -> Result<(), Error>
Moves the cursor to the specified position.
sourcefn move_column(&mut self, to: u16) -> Result<(), Error>
fn move_column(&mut self, to: u16) -> Result<(), Error>
Moves the cursor to the specified column.
sourcefn move_previous_line(&mut self, to: u16) -> Result<(), Error>
fn move_previous_line(&mut self, to: u16) -> Result<(), Error>
Moves the cursor to the previous line.
sourcefn clear_purge(&mut self) -> Result<(), Error>
fn clear_purge(&mut self) -> Result<(), Error>
Clears the terminal screen from the cursor position downwards.
sourcefn clear_current_line(&mut self) -> Result<(), Error>
fn clear_current_line(&mut self) -> Result<(), Error>
Clears the current line.
sourcefn clear_cursor_up(&mut self) -> Result<(), Error>
fn clear_cursor_up(&mut self) -> Result<(), Error>
Clears the terminal screen from the cursor position upwards.
sourcefn clear_cursor_down(&mut self) -> Result<(), Error>
fn clear_cursor_down(&mut self) -> Result<(), Error>
Clears the terminal screen from the cursor position downwards.
sourcefn write(&mut self, value: &str) -> Result<(), Error>
fn write(&mut self, value: &str) -> Result<(), Error>
Writes the specified value to the terminal.