[][src]Struct crossterm::Terminal

pub struct Terminal { /* fields omitted */ }

Allows you to preform actions on the terminal.

Features:

  • Clearing (all lines, current line, from cursor down and up, until new line)
  • Scrolling (Up, down)
  • Get the size of the terminal
  • Set the size of the terminal
  • Alternate screen
  • Raw screen
  • Exit the current process

Check /examples/ in the library for more specific examples.

Methods

impl Terminal[src]

pub fn new() -> Terminal[src]

Create new terminal instance whereon terminal related actions can be performed.

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

Clear the current cursor by specifying the ClearType.

Example

let mut term = terminal();

// clear all cells in terminal.
term.clear(crossterm::ClearType::All);
// clear all cells from the cursor position downwards in terminal.
term.clear(crossterm::ClearType::FromCursorDown);
// clear all cells from the cursor position upwards in terminal.
term.clear(crossterm::ClearType::FromCursorUp);
// clear current line cells in terminal.
term.clear(crossterm::ClearType::CurrentLine);
// clear all cells from cursor position until new line in terminal.
term.clear(crossterm::ClearType::UntilNewLine);

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

Get the terminal size (x,y).

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

Scroll n lines up in the current terminal.

Parameter

  • count: the number of rows should be shifted up.

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

Scroll n lines down in the current terminal.

Parameter

  • count: the number of rows should be shifted down.

pub fn set_size(&self, width: u16, height: u16) -> Result<(), ErrorKind>[src]

Set the terminal size. Note that not all terminals can be set to a very small scale.

let mut term = terminal();

// Set of the size to X: 10 and Y: 10
let size = term.set_size(10,10);

pub fn exit(&self)[src]

Exit the current process.

let mut term = terminal();

let size = term.exit();

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

Write any displayable content to the current terminal screen.

let mut term = terminal();

let size = term.write("Some text \n Some text on new line");

This will also flush the standard output.

Auto Trait Implementations

impl Send for Terminal

impl Sync for Terminal

impl Unpin for Terminal

impl !UnwindSafe for Terminal

impl !RefUnwindSafe for Terminal

Blanket Implementations

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

impl<T, U> Into<U> for T where
    U: From<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]