Skip to content

Commit

Permalink
update terminal-size
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Stingler committed Dec 16, 2024
1 parent c9c4a23 commit 716f3d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 5 additions & 3 deletions src/info.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -301,5 +301,7 @@ fn print_info<'a>(

#[must_use]
pub fn get_terminal_width() -> Option<usize> {
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)
}

0 comments on commit 716f3d6

Please sign in to comment.