[][src]Module crossterm::terminal

A functionality to work with the terminal.

Terminal

The terminal module provides a functionality to work with the terminal.

This documentation does not contain a lot of examples. The reason is that it's fairly obvious how to use this crate. Although, we do provide examples repository to demonstrate the capabilities.

Examples

use crossterm::{Result, Terminal};

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

    // Do something with the terminal
    terminal.set_size(10, 10)?;
    terminal.scroll_up(5)?;

    // Be a good citizen, cleanup
    terminal.set_size(cols, rows)
}

Commands:

use std::io::{stdout, Write};
use crossterm::{execute, Result, ScrollUp, SetSize, Terminal};

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

    // Do something with the terminal
    execute!(
        stdout(),
        SetSize(10, 10),
        ScrollUp(5)
    )?;

    // Be a good citizen, cleanup
    terminal.set_size(cols, rows)
}

Structs

Clear

A command to clear the terminal.

ScrollDown

A command to scroll the terminal given rows down.

ScrollUp

A command to scroll the terminal given rows up.

SetSize

A command to set the terminal size (rows, columns).

Terminal

A terminal.

Enums

ClearType

Represents different options how to clear the terminal.

Functions

terminal

Creates a new Terminal.