diff --git a/Cargo.lock b/Cargo.lock index 908b231a..4f246b7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2183,12 +2183,12 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9" dependencies = [ "rustix", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index c61db934..74f6975c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ serde = { version = "1.0.215", features = ["derive"] } serde_json = "1.0.132" smart-default = "0.7.1" tempfile = "3.14.0" -terminal_size = "0.3.0" +terminal_size = "0.4.1" tokio = { version = "1.41.1", features = [ "process", "macros", diff --git a/src/info.rs b/src/info.rs index 318c7a49..15d0b787 100644 --- a/src/info.rs +++ b/src/info.rs @@ -1,4 +1,4 @@ -use std::os::fd::AsRawFd; +use std::os::fd::{AsRawFd, BorrowedFd}; use crate::config::{Colors, Config}; use crate::download::cache_info_with_warnings; @@ -13,7 +13,7 @@ use anyhow::Error; use globset::GlobSet; use raur::ArcPackage as Package; use srcinfo::ArchVec; -use terminal_size::terminal_size_using_fd; +use terminal_size::terminal_size_of; use tr::tr; use unicode_width::UnicodeWidthStr; @@ -301,5 +301,7 @@ fn print_info<'a>( #[must_use] pub fn get_terminal_width() -> Option { - terminal_size_using_fd(std::io::stdout().as_raw_fd()).map(|(w, _h)| w.0 as usize) + let stdout_fd = std::io::stdout().as_raw_fd(); + let borrowed_fd = unsafe { BorrowedFd::borrow_raw(stdout_fd) }; + terminal_size_of(borrowed_fd).map(|(w, _h)| w.0 as usize) }