pub struct Interface<'a> { /* private fields */ }
Expand description

A TTY-based user-interface providing optimized update rendering.

Implementations

Create a new interface for stdout.

Examples
use tty_interface::Interface;

let interface = Interface::for_stdout().expect("terminal size should be available");

Create a new interface for the specified writer.

Examples
use tty_interface::Interface;
use std::io::{Write, stdout};

let writer: &mut dyn Write = &mut stdout();
let interface = Interface::for_writer(writer).expect("terminal size should be available");

When finished using this interface, uninitialize its terminal configuration.

Update the interface’s text at the specified position. Changes are staged until applied.

Examples
use tty_interface::{Interface, Position, pos};

let mut interface = Interface::for_stdout().expect("terminal size should be available");
interface.set(pos!(1, 1), "Hello, world!");

Update the interface’s text at the specified position. Changes are staged until applied.

Examples
use tty_interface::{Interface, Position, pos, Style};

let mut interface = Interface::for_stdout().expect("terminal size should be available");
interface.set_styled(pos!(1, 1), "Hello, world!", Style::default().set_bold(true));

Applies staged changes to the terminal.

Examples
use tty_interface::{Interface, Position, pos};

let mut interface = Interface::for_stdout().expect("terminal size should be available");
interface.set(pos!(1, 1), "Hello, world!");
interface.apply().expect("updates should be valid");

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.