[][src]Struct crossterm_terminal::Terminal

pub struct Terminal { /* fields omitted */ }

A terminal.

The Terminal instance is stateless and does not hold any data. You can create as many instances as you want and they will always refer to the same terminal.

Examples

Basic usage:

use crossterm_terminal::{Result, Terminal};

fn main() -> Result<()> {
    let terminal = Terminal::new();
    let (cols, rows) = terminal.size()?;

    terminal.set_size(10, 10)?;
    terminal.scroll_up(5)?;

    terminal.set_size(cols, rows)
}

Methods

impl Terminal[src]

pub fn new() -> Terminal[src]

Creates a new Terminal.

pub fn clear(&self, clear_type: ClearType) -> Result<()>[src]

Clears the terminal.

See the ClearType enum to learn about all ways how the terminal can be cleared.

pub fn size(&self) -> Result<(u16, u16)>[src]

Returns the terminal size ((columns, rows)).

pub fn scroll_up(&self, row_count: u16) -> Result<()>[src]

Scrolls the terminal row_count rows up.

pub fn scroll_down(&self, row_count: u16) -> Result<()>[src]

Scrolls the terminal row_count rows down.

pub fn set_size(&self, columns: u16, rows: u16) -> Result<()>[src]

Sets the terminal size.

pub fn exit(&self)[src]

Exits the current process.

Platform-specific Behavior

std::process::exit is called internally with platform specific exit codes.

Unix: exit code 0.

Windows: exit code 256.

pub fn write<D: Display>(&self, value: D) -> Result<usize>[src]

Writes any displayable content to the current terminal and flushes the standard output.

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]