Crates.io | terminal-utils |
lib.rs | terminal-utils |
version | 0.1.0 |
source | src |
created_at | 2023-08-28 16:06:06.497189 |
updated_at | 2023-08-28 16:06:06.497189 |
description | A collection of utilities for working with the terminal. |
homepage | https://github.com/atrox/terminal-utils |
repository | https://github.com/atrox/terminal-utils |
max_upload_size | |
id | 957138 |
size | 15,581 |
This crate provides utilities for working with terminals.
let size = terminal_utils::size().unwrap();
println!("The terminal is {}x{} characters.", size.width, size.height);
let raw_mode_guard = terminal_utils::enable_raw_mode().unwrap();
println!("Raw mode is enabled.");
let is_raw_mode_enabled = terminal_utils::is_raw_mode_enabled().unwrap();
assert!(is_raw_mode_enabled);
// Previous terminal mode is restored when the guard is dropped.
drop(raw_mode_guard);
println!("Raw mode is disabled.");
This feature is only available with the tokio
feature. It is enabled by default.
let mut resize_rx = terminal_utils::on_resize().unwrap();
tokio::spawn(async move {
loop {
resize_rx.changed().await.unwrap();
let size = resize_rx.borrow();
println!("terminal size changed: {:?}", size);
}
});