about summary refs log tree commit diff stats
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/termsize/Cargo.toml5
-rw-r--r--crates/termsize/README.md16
-rw-r--r--crates/termsize/src/lib.rs5
-rw-r--r--crates/termsize/src/nix.rs11
4 files changed, 19 insertions, 18 deletions
diff --git a/crates/termsize/Cargo.toml b/crates/termsize/Cargo.toml
index 940f7aa..10ab7ed 100644
--- a/crates/termsize/Cargo.toml
+++ b/crates/termsize/Cargo.toml
@@ -10,7 +10,10 @@
 
 [package]
 name = "termsize"
-authors = ["softprops <d.tangren@gmail.com>"]
+authors = [
+  "softprops <d.tangren@gmail.com>",
+  "Benedikt Peetz <benedikt.peetz@b-peetz.de>",
+]
 description = "Retrieves terminal size"
 repository = "https://github.com/softprops/termsize"
 homepage = "https://github.com/softprops/termsize"
diff --git a/crates/termsize/README.md b/crates/termsize/README.md
index 27b7869..305669b 100644
--- a/crates/termsize/README.md
+++ b/crates/termsize/README.md
@@ -17,15 +17,17 @@ If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 
 > 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.
-
+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
+run `cargo add termsize` in your terminal or add the following to your
+`Cargo.toml` file
 
 ```toml
 [dependencies]
@@ -35,8 +37,8 @@ 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.
+exposing two fields: `rows` and `cols` representing the number of rows and
+columns a a terminal's stdout supports.
 
 ```rust
 pub fn main() {
@@ -46,4 +48,4 @@ pub fn main() {
 }
 ```
 
-Doug Tangren (softprops) 2015-2024
\ No newline at end of file
+Doug Tangren (softprops) 2015-2024
diff --git a/crates/termsize/src/lib.rs b/crates/termsize/src/lib.rs
index e037176..69e7b78 100644
--- a/crates/termsize/src/lib.rs
+++ b/crates/termsize/src/lib.rs
@@ -1,5 +1,4 @@
 #![deny(missing_docs)]
-
 // yt - A fully featured command line YouTube client
 //
 // Copyright (C) 2025 softprops <d.tangren@gmail.com>
@@ -21,7 +20,7 @@
 //! ```
 
 /// Container for number of rows and columns
-#[derive(Debug)]
+#[derive(Debug, Clone, Copy)]
 pub struct Size {
     /// number of rows
     pub rows: u16,
@@ -48,6 +47,6 @@ mod tests {
     use super::get;
     #[test]
     fn test_get() {
-        assert!(get().is_some())
+        assert!(get().is_some());
     }
 }
diff --git a/crates/termsize/src/nix.rs b/crates/termsize/src/nix.rs
index 77fa574..e35aa6b 100644
--- a/crates/termsize/src/nix.rs
+++ b/crates/termsize/src/nix.rs
@@ -8,19 +8,15 @@
 // 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>.
 
-extern crate libc;
-
 use std::io::IsTerminal;
 
-use self::{
-    super::Size,
-    libc::{c_ushort, ioctl, STDOUT_FILENO, TIOCGWINSZ},
-};
+use self::super::Size;
+use libc::{c_ushort, ioctl, STDOUT_FILENO, TIOCGWINSZ};
 
 /// A representation of the size of the current terminal
 #[repr(C)]
 #[derive(Debug)]
-pub struct UnixSize {
+struct UnixSize {
     /// number of rows
     pub rows: c_ushort,
     /// number of columns
@@ -30,6 +26,7 @@ pub struct UnixSize {
 }
 
 /// Gets the current terminal size
+#[must_use]
 pub fn get() -> Option<Size> {
     // http://rosettacode.org/wiki/Terminal_control/Dimensions#Library:_BSD_libc
     if !std::io::stdout().is_terminal() {