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§

source

fn writer(&mut self) -> &mut T

Returns a mutable reference to the writer. e.g. &mut std::io::Stderr.

source

fn size(&self) -> Result<TermSize, Error>

Returns the terminal size.

source

fn enable_raw(&mut self) -> Result<(), Error>

Enables raw mode.

source

fn disable_raw(&mut self) -> Result<(), Error>

Disables raw mode.

source

fn cursor_show(&mut self) -> Result<(), Error>

Shows the cursor.

source

fn cursor_hide(&mut self) -> Result<(), Error>

Hides the cursor.

source

fn cursor_pos(&self) -> Result<CursorPosition, Error>

Returns the cursor position.

source

fn move_to(&mut self, col: u16, row: u16) -> Result<(), Error>

Moves the cursor to the specified position.

source

fn move_column(&mut self, to: u16) -> Result<(), Error>

Moves the cursor to the specified column.

source

fn move_next_line(&mut self, to: u16) -> Result<(), Error>

Moves the cursor to the next line.

source

fn move_previous_line(&mut self, to: u16) -> Result<(), Error>

Moves the cursor to the previous line.

source

fn scroll_up(&mut self, row: u16) -> Result<(), Error>

Scrolls the terminal up.

source

fn scroll_down(&mut self, row: u16) -> Result<(), Error>

Scrolls the terminal down.

source

fn clear(&mut self) -> Result<(), Error>

Clears the terminal screen.

source

fn clear_purge(&mut self) -> Result<(), Error>

Clears the terminal screen from the cursor position downwards.

source

fn clear_current_line(&mut self) -> Result<(), Error>

Clears the current line.

source

fn clear_cursor_up(&mut self) -> Result<(), Error>

Clears the terminal screen from the cursor position upwards.

source

fn clear_cursor_down(&mut self) -> Result<(), Error>

Clears the terminal screen from the cursor position downwards.

source

fn write(&mut self, value: &str) -> Result<(), Error>

Writes the specified value to the terminal.

source

fn writeln(&mut self, value: &str) -> Result<(), Error>

Writes the specified value to the terminal and appends a newline.

source

fn flush(&mut self) -> Result<(), Error>

Flushes all change queues.

source

fn read_key(&mut self) -> Result<(KeyCode, KeyModifiers), Error>

Reads a key from the terminal.

Implementors§

source§

impl<T: Write> Terminal<T> for Term<T>