pub trait Terminal {
// Required methods
fn set_raw_mode(&mut self) -> Result<()>;
fn set_cooked_mode(&mut self) -> Result<()>;
fn enter_alternate_screen(&mut self) -> Result<()>;
fn exit_alternate_screen(&mut self) -> Result<()>;
fn get_screen_size(&mut self) -> Result<ScreenSize>;
fn set_screen_size(&mut self, size: ScreenSize) -> Result<()>;
fn render(&mut self, changes: &[Change]) -> Result<()>;
fn flush(&mut self) -> Result<()>;
fn poll_input(
&mut self,
wait: Option<Duration>,
) -> Result<Option<InputEvent>>;
fn waker(&self) -> TerminalWaker;
// Provided method
fn probe_capabilities(&mut self) -> Option<ProbeCapabilities<'_>> { ... }
}Expand description
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§
Sourcefn set_raw_mode(&mut self) -> Result<()>
fn set_raw_mode(&mut self) -> Result<()>
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<()>
Sourcefn enter_alternate_screen(&mut self) -> Result<()>
fn enter_alternate_screen(&mut self) -> Result<()>
Enter the alternate screen. The alternate screen will be left
automatically when the Terminal is dropped.
Sourcefn exit_alternate_screen(&mut self) -> Result<()>
fn exit_alternate_screen(&mut self) -> Result<()>
Exit the alternate screen.
Sourcefn get_screen_size(&mut self) -> Result<ScreenSize>
fn get_screen_size(&mut self) -> Result<ScreenSize>
Queries the current screen size, returning width, height.
Sourcefn set_screen_size(&mut self, size: ScreenSize) -> Result<()>
fn set_screen_size(&mut self, size: ScreenSize) -> Result<()>
Sets the current screen size
Sourcefn render(&mut self, changes: &[Change]) -> Result<()>
fn render(&mut self, changes: &[Change]) -> Result<()>
Render a series of changes to the terminal output
Sourcefn poll_input(&mut self, wait: Option<Duration>) -> Result<Option<InputEvent>>
fn poll_input(&mut self, wait: Option<Duration>) -> Result<Option<InputEvent>>
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::ZERO) 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
Provided Methods§
Sourcefn probe_capabilities(&mut self) -> Option<ProbeCapabilities<'_>>
fn probe_capabilities(&mut self) -> Option<ProbeCapabilities<'_>>
Returns a capability probing helper that will use escape sequences to attempt to probe information from the terminal