diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-02-16 10:10:07 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-02-16 10:10:07 +0100 |
commit | 9da970f1f44f19432680e255f91f73fbb8fbe3c8 (patch) | |
tree | 7bf2e5ded6d81b4ae76a080eaa5f80418343a5a9 /crates/termsize/src/lib.rs | |
parent | refactor(treewide): Remove all references of the now obsolete update_raw.py (diff) | |
download | yt-9da970f1f44f19432680e255f91f73fbb8fbe3c8.zip |
chore(crates/termsize): Vendor
Diffstat (limited to 'crates/termsize/src/lib.rs')
-rw-r--r-- | crates/termsize/src/lib.rs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/crates/termsize/src/lib.rs b/crates/termsize/src/lib.rs new file mode 100644 index 0000000..e037176 --- /dev/null +++ b/crates/termsize/src/lib.rs @@ -0,0 +1,53 @@ +#![deny(missing_docs)] + +// 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 is a tiny crate that provides a simple +//! interface for retrieving the current +//! [terminal interface](http://www.manpagez.com/man/4/tty/) size +//! +//! ```rust +//! extern crate termsize; +//! +//! termsize::get().map(|size| println!("rows {} cols {}", size.rows, size.cols)); +//! ``` + +/// Container for number of rows and columns +#[derive(Debug)] +pub struct Size { + /// number of rows + pub rows: u16, + /// number of columns + pub cols: u16, +} + +#[cfg(unix)] +#[path = "nix.rs"] +mod imp; + +#[cfg(windows)] +#[path = "win.rs"] +mod imp; + +#[cfg(not(any(unix, windows)))] +#[path = "other.rs"] +mod imp; + +pub use imp::get; + +#[cfg(test)] +mod tests { + use super::get; + #[test] + fn test_get() { + assert!(get().is_some()) + } +} |