https://github.com/atrox/terminal-utils
🦀 A collection of utilities for working with the terminal in rust.
https://github.com/atrox/terminal-utils
Last synced: 10 months ago
JSON representation
🦀 A collection of utilities for working with the terminal in rust.
- Host: GitHub
- URL: https://github.com/atrox/terminal-utils
- Owner: Atrox
- License: mit
- Created: 2023-08-28T16:04:13.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-15T06:31:35.000Z (over 1 year ago)
- Last Synced: 2025-03-01T12:05:25.396Z (11 months ago)
- Language: Rust
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# terminal-utils
[](https://crates.io/crates/terminal-utils)
[](https://docs.rs/terminal-utils)
[](LICENSE)
This crate provides utilities for working with terminals.
## Terminal size
```rust
let size = terminal_utils::size().unwrap();
println!("The terminal is {}x{} characters.", size.width, size.height);
```
## Raw mode
```rust
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.");
```
## Resize signal
This feature is only available with the `tokio` feature. It is enabled by default.
```rust
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);
}
});
```