Crates.io | termsize |
lib.rs | termsize |
version | 0.1.9 |
source | src |
created_at | 2015-11-15 05:54:18.407317 |
updated_at | 2024-07-22 14:16:18.945084 |
description | Retrieves terminal size |
homepage | https://github.com/softprops/termsize |
repository | https://github.com/softprops/termsize |
max_upload_size | |
id | 3425 |
size | 14,887 |
because terminal size matters
Termsize is a rust crate providing a multi-platform interface for resolving your terminal's current size in rows and columns. On most unix systems, this is similar invoking the stty(1) program, requesting the terminal size.
run cargo add termsize
in your terminal or add the following to your Cargo.toml
file
[dependencies]
termsize = "0.1"
Termize provides one function, get
, which returns a termsize::Size
struct
exposing two fields: rows
and cols
representing the number of rows and columns
a a terminal's stdout supports.
pub fn main() {
termsize::get().map(|{ rows, cols }| {
println!("rows {} cols {}", size.rows, size.cols)
});
}
Doug Tangren (softprops) 2015-2024