Crate terminal_trx

Source
Expand description

Provides a handle to the terminal of the current process that is both readable and writable.

§Example: Read and Write

 use terminal_trx::terminal;
 use std::io::{BufReader, BufRead as _, Write as _};

 let mut terminal = terminal().unwrap();

 write!(terminal, "hello world").unwrap();

 let mut reader = BufReader::new(&mut terminal);
 let mut line = String::new();
 reader.read_line(&mut line).unwrap();

§Example: Enable Raw Mode

use terminal_trx::terminal;

let mut tty = terminal().unwrap();
let mut lock = tty.lock();
let mut raw_mode = lock.enable_raw_mode().unwrap();

// You can now perform read and write operations using `raw_mode`.

Structs§

RawModeGuard
Guard for raw mode on the terminal, disables raw mode on drop. Can be crated using TerminalLock::enable_raw_mode.
Terminal
A readable and writable handle to the terminal (or TTY), created using terminal(). You can read and write data using the io::Read and io::Write implementations respectively.
TerminalLock
Guard for exclusive read- and write access to the terminal. Can be created using Terminal::lock.

Traits§

Transceive
A trait for objects that are both io::Read and io::Write.

Functions§

terminal
Creates a readable and writable handle to the terminal (or TTY) if available.