termsize/
lib.rs

1#![deny(missing_docs)]
2
3//! Termsize is a tiny crate that provides a simple
4//! interface for retrieving the current
5//! [terminal interface](http://www.manpagez.com/man/4/tty/) size
6//!
7//! ```rust
8//! extern crate termsize;
9//!
10//! termsize::get().map(|size| println!("rows {} cols {}", size.rows, size.cols));
11//! ```
12
13/// Container for number of rows and columns
14#[derive(Debug)]
15pub struct Size {
16    /// number of rows
17    pub rows: u16,
18    /// number of columns
19    pub cols: u16,
20}
21
22#[cfg(unix)]
23#[path = "nix.rs"]
24mod imp;
25
26#[cfg(windows)]
27#[path = "win.rs"]
28mod imp;
29
30#[cfg(not(any(unix, windows)))]
31#[path = "other.rs"]
32mod imp;
33
34pub use imp::get;
35
36#[cfg(test)]
37mod tests {
38    use super::get;
39    #[test]
40    fn test_get() {
41        assert!(get().is_some())
42    }
43}