Skip to main content

TermLike

Trait TermLike 

Source
pub trait TermLike:
    Debug
    + Send
    + Sync {
    // Required methods
    fn width(&self) -> u16;
    fn move_cursor_up(&self, n: usize) -> Result<()>;
    fn move_cursor_down(&self, n: usize) -> Result<()>;
    fn move_cursor_right(&self, n: usize) -> Result<()>;
    fn move_cursor_left(&self, n: usize) -> Result<()>;
    fn write_line(&self, s: &str) -> Result<()>;
    fn write_str(&self, s: &str) -> Result<()>;
    fn clear_line(&self) -> Result<()>;
    fn flush(&self) -> Result<()>;

    // Provided method
    fn height(&self) -> u16 { ... }
}
Expand description

A trait for minimal terminal-like behavior.

Anything that implements this trait can be used a draw target via ProgressDrawTarget::term_like.

Required Methods§

Source

fn width(&self) -> u16

Return the terminal width

Source

fn move_cursor_up(&self, n: usize) -> Result<()>

Move the cursor up by n lines

Source

fn move_cursor_down(&self, n: usize) -> Result<()>

Move the cursor down by n lines

Source

fn move_cursor_right(&self, n: usize) -> Result<()>

Move the cursor right by n chars

Source

fn move_cursor_left(&self, n: usize) -> Result<()>

Move the cursor left by n chars

Source

fn write_line(&self, s: &str) -> Result<()>

Write a string and add a newline.

Source

fn write_str(&self, s: &str) -> Result<()>

Write a string

Source

fn clear_line(&self) -> Result<()>

Clear the current line and reset the cursor to beginning of the line

Source

fn flush(&self) -> Result<()>

Provided Methods§

Source

fn height(&self) -> u16

Return the terminal height

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl TermLike for Term

Implementors§