[][src]Trait termwiz::terminal::Terminal

pub trait Terminal {
    fn set_raw_mode(&mut self) -> Result<(), Error>;
fn set_cooked_mode(&mut self) -> Result<()>;
fn enter_alternate_screen(&mut self) -> Result<(), Error>;
fn exit_alternate_screen(&mut self) -> Result<(), Error>;
fn get_screen_size(&mut self) -> Result<ScreenSize, Error>;
fn set_screen_size(&mut self, size: ScreenSize) -> Result<(), Error>;
fn render(&mut self, changes: &[Change]) -> Result<(), Error>;
fn flush(&mut self) -> Result<(), Error>;
fn poll_input(
        &mut self,
        wait: Option<Duration>
    ) -> Result<Option<InputEvent>, Error>;
fn waker(&self) -> TerminalWaker; }

Terminal abstracts over some basic terminal capabilities. If the set_raw_mode or set_cooked_mode functions are used in any combination, the implementation is required to restore the terminal mode that was in effect when it was created.

Required methods

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

Raw mode disables input line buffering, allowing data to be read as the user presses keys, disables local echo, so keys pressed by the user do not implicitly render to the terminal output, and disables canonicalization of unix newlines to CRLF.

fn set_cooked_mode(&mut self) -> Result<()>

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

Enter the alternate screen. The alternate screen will be left automatically when the Terminal is dropped.

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

Exit the alternate screen.

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

Queries the current screen size, returning width, height.

fn set_screen_size(&mut self, size: ScreenSize) -> Result<(), Error>

Sets the current screen size

fn render(&mut self, changes: &[Change]) -> Result<(), Error>

Render a series of changes to the terminal output

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

Flush any buffered output

fn poll_input(
    &mut self,
    wait: Option<Duration>
) -> Result<Option<InputEvent>, Error>

Check for a parsed input event. wait indicates the behavior in the case that no input is immediately available. If wait is None then poll_input will not return until an event is available. If wait is Some(duration) then poll_input will wait up to the given duration for an event before returning with a value of Ok(None). If wait is Some(Duration::new(0, 0)) then the poll is non-blocking.

The possible values returned as InputEvents depend on the mode of the terminal. Most values are not returned unless the terminal is set to raw mode.

fn waker(&self) -> TerminalWaker

Loading content...

Implementors

impl Terminal for UnixTerminal[src]

Loading content...