blob: 27b7869f15d91c3036af4208b149f722988500e7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<!--
yt - A fully featured command line YouTube client
Copyright (C) 2025 softprops <d.tangren@gmail.com>
SPDX-License-Identifier: MIT
This file is part of Yt.
You should have received a copy of the License along with this program.
If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
-->
# termsize
[](https://github.com/softprops/termsize/actions/workflows/ci.yml)
[](https://crates.io/crates/termsize)
> 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)](http://man7.org/linux/man-pages/man1/stty.1.html) program, requesting the terminal size.
## [Documentation](https://softprops.github.com/termsize)
## install
run `cargo add termsize` in your terminal or add the following to your `Cargo.toml` file
```toml
[dependencies]
termsize = "0.1"
```
## usage
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.
```rust
pub fn main() {
termsize::get().map(|{ rows, cols }| {
println!("rows {} cols {}", size.rows, size.cols)
});
}
```
Doug Tangren (softprops) 2015-2024
|