Trait linefeed::terminal::Terminal [] [src]

pub trait Terminal: Sized {
    type PrepareGuard;
    fn new() -> Result<Self>;
fn eof_char(&self) -> char;
fn literal_char(&self) -> char;
fn erase_char(&self) -> char;
fn word_erase_char(&self) -> char;
fn kill_char(&self) -> char;
fn delete_seq(&self) -> &str;
fn insert_seq(&self) -> &str;
fn name(&self) -> Option<&str>;
fn size(&self) -> Result<Size>;
fn clear_screen(&self) -> Result<()>;
fn clear_to_screen_end(&self) -> Result<()>;
fn move_up(&self, n: usize) -> Result<()>;
fn move_down(&self, n: usize) -> Result<()>;
fn move_left(&self, n: usize) -> Result<()>;
fn move_right(&self, n: usize) -> Result<()>;
fn move_to_first_col(&self) -> Result<()>;
fn set_cursor_mode(&self, mode: CursorMode) -> Result<()>;
fn wait_for_input(&self, timeout: Option<Duration>) -> Result<bool>;
fn prepare(
        &self,
        catch_signals: bool,
        report_signals: SignalSet
    ) -> Result<Self::PrepareGuard>;
fn get_signal(&self) -> Option<Signal>;
fn take_signal(&self) -> Option<Signal>;
fn read_signals(&self) -> Result<Self::PrepareGuard>;
fn read(&self, buf: &mut Vec<u8>) -> Result<usize>;
fn write(&self, s: &str) -> Result<()>; }

Defines a low-level interface to the terminal

Associated Types

Returned by prepare and read_signals. When dropped, the prior terminal state will be restored.

Required Methods

Initialize the terminal interface

Returns the character that indicates end-of-file

Returns the character that indicates literal quoting sequence

Returns the character that indicates backward character erase

Returns the character that indicates backward word erase

Returns the character that indicates backward kill line

Returns the key sequence that indicates forward delete character

Returns the key sequence that indicates switching to insert mode

Returns the name of the terminal, if one has been supplied

Returns the size of the terminal window

Presents a clear terminal screen, with cursor at first row, first column.

If the terminal possesses a scrolling window over a buffer, this shall have the effect of moving the visible window down such that it shows an empty view of the buffer, preserving some or all of existing buffer contents, where possible.

Clears characters on the line occupied by the cursor, beginning with the cursor and ending at the end of the line. Also clears all characters on all lines after the cursor.

Moves the cursor up n cells; n may be zero.

Moves the cursor down n cells; n may be zero.

Moves the cursor left n cells; n may be zero.

Moves the cursor right n cells; n may be zero.

Moves the cursor to the first column of the current line

Set the current cursor mode

Waits timeout for user input. If timeout is None, waits indefinitely.

Returns Ok(true) if input becomes available within the given timeout or if a signal is received.

Returns Ok(false) if the timeout expires before input becomes available.

Prepares the terminal for line reading and editing operations.

When the returned value is dropped, the terminal will be restored to its state prior to calling prepare.

If catch_signals is true, signal handlers will be registered. These are also restored when the guard value is dropped.

The set of signals caught should include those contained in report_signals.

If the process received a signal since the last call to take_signal, return it. Otherwise, return None.

If the process received a signal since the last call to take_signal, consume and return it. Otherwise, return None.

Configures the terminal to interpret signal-inducing characters as input without raising a signal.

When the returned value is dropped, the terminal will be restored to its state prior to calling read_signals.

Reads some input from the terminal and appends it to the given buffer.

Returns the number of bytes read. Ok(0) may be returned to indicate that no bytes can be read at this time.

Writes output to the terminal and immediately flushes it to the device.

For each newline '\n' written to the terminal, the cursor should be moved to the first column of the following line.

The terminal interface shall not automatically move the cursor to the next line when write causes a character to be written to the final column.

Implementors