This crate provides utilities for working with terminals.
rust
let size = terminal_utils::size().unwrap();
println!("The terminal is {}x{} characters.", size.width, size.height);
```rust let rawmodeguard = terminalutils::enableraw_mode().unwrap(); println!("Raw mode is enabled.");
let israwmodeenabled = terminalutils::israwmodeenabled().unwrap(); assert!(israwmodeenabled);
// Previous terminal mode is restored when the guard is dropped. drop(rawmodeguard); println!("Raw mode is disabled."); ```
This feature is only available with the tokio
feature. It is enabled by default.
```rust let mut resizerx = terminalutils::onresize().unwrap(); tokio::spawn(async move { loop { resizerx.changed().await.unwrap();
let size = resize_rx.borrow();
println!("terminal size changed: {:?}", size);
}
}); ```