]>
Commit | Line | Data |
---|---|---|
f035d41b XL |
1 | //! A simple utility for getting the size of a terminal. |
2 | //! | |
3 | //! Supports both Linux and Windows, but help is needed to test other platforms | |
4 | //! | |
5 | //! Tested on Rust Stable (1.4), Beta (1.5), and Nightly (1.6) | |
6 | //! | |
7 | //! # Example | |
8 | //! | |
9 | //! ``` | |
10 | //! use terminal_size::{Width, Height, terminal_size}; | |
11 | //! | |
12 | //! let size = terminal_size(); | |
13 | //! if let Some((Width(w), Height(h))) = size { | |
14 | //! println!("Your terminal is {} cols wide and {} lines tall", w, h); | |
15 | //! } else { | |
16 | //! println!("Unable to get terminal size"); | |
17 | //! } | |
18 | //! ``` | |
19 | //! | |
20 | ||
21 | #[derive(Debug)] | |
22 | pub struct Width(pub u16); | |
23 | #[derive(Debug)] | |
24 | pub struct Height(pub u16); | |
25 | ||
26 | #[cfg(unix)] | |
27 | mod unix; | |
28 | #[cfg(unix)] | |
29 | pub use crate::unix::{terminal_size, terminal_size_using_fd}; | |
30 | ||
31 | #[cfg(windows)] | |
32 | mod windows; | |
33 | #[cfg(windows)] | |
34 | pub use windows::terminal_size; |