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

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

Implementations

Create a new interface for the specified device.

Examples
use tty_interface::Interface;

let interface = Interface::new(&mut device)?;

When finished using this interface, uninitialize its terminal configuration.

Examples
use tty_interface::Interface;

let interface = Interface::new(&mut device)?;
interface.exit()?;

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::new(&mut device)?;
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, Style, Position, pos};

let mut interface = Interface::new(&mut device)?;
interface.set_styled(pos!(1, 1), "Hello, world!", Style::default().set_bold(true));

Clear all text on the specified line. Changes are staged until applied.

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

let mut interface = Interface::new(&mut device)?;

// Write "Hello," and "world!" on two different lines
interface.set(pos!(0, 0), "Hello,");
interface.set(pos!(0, 1), "world!");
interface.apply()?;

// Clear the second line, "world!"
interface.clear_line(1);
interface.apply()?;

Update the interface’s cursor to the specified position, or hide it if unspecified.

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

let mut interface = Interface::new(&mut device)?;
interface.set_cursor(Some(pos!(1, 2)));

Applies staged changes to the terminal.

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

let mut interface = Interface::new(&mut device)?;
interface.set(pos!(1, 1), "Hello, world!");
interface.apply()?;

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.