termsize_alt/
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| {
11//!   println!("rows {} cols {}", size.rows, size.cols)
12//! });
13//! ```
14
15/// Container for number of rows and columns
16#[derive(Debug)]
17pub struct Size {
18    /// number of rows
19    pub rows: u16,
20    /// number of columns
21    pub cols: u16,
22}
23
24#[cfg(unix)]
25#[path = "nix.rs"]
26mod imp;
27
28#[cfg(windows)]
29#[path = "win.rs"]
30mod imp;
31
32#[cfg(not(any(unix, windows)))]
33#[path = "other.rs"]
34mod imp;
35
36pub use imp::get;
37
38#[cfg(test)]
39mod tests {
40    use super::get;
41    #[test]
42    fn test_get() {
43        assert!(get().is_some())
44    }
45}