Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into ci2
Browse files Browse the repository at this point in the history
  • Loading branch information
Morganamilo committed Oct 31, 2023
2 parents 9817ee6 + 67cc6f4 commit 2a8c30c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
20 changes: 10 additions & 10 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.152", features = ["derive"] }
serde_json = "1.0.91"
smart-default = "0.7.1"
tempfile = "3.3.0"
term_size = "0.3.2"
terminal_size = "0.3.0"
tokio = { version = "1.24.2", features = [
"process",
"macros",
Expand Down
3 changes: 2 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::args::Args;
use crate::devel::save_devel_info;
use crate::exec::{self, Status};
use crate::fmt::color_repo;
use crate::info::get_terminal_width;
use crate::pkgbuild::{PkgbuildRepos, RepoSource};
use crate::util::{get_provider, reopen_stdin};
use crate::{alpm_debug_enabled, help, printtr, repo};
Expand Down Expand Up @@ -608,7 +609,7 @@ impl Config {
let state_dir = state;

let color = Colors::from("never");
let cols = term_size::dimensions_stdout().map(|v| v.0);
let cols = get_terminal_width();

let mut config = Self {
cols,
Expand Down
17 changes: 13 additions & 4 deletions src/info.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
use std::collections::HashMap;
use std::os::fd::AsRawFd;
use std::path::PathBuf;

use crate::config::{Colors, Config};
use crate::download::cache_info_with_warnings;
use crate::exec;
Expand All @@ -10,8 +14,8 @@ use anyhow::Error;

use globset::GlobSet;
use raur::ArcPackage as Package;
use srcinfo::ArchVec;
use term_size::dimensions_stdout;
use srcinfo::{ArchVec, Srcinfo};
use terminal_size::terminal_size_using_fd;
use tr::tr;
use unicode_width::UnicodeWidthStr;

Expand Down Expand Up @@ -150,7 +154,7 @@ pub fn print_pkgbuild_info(
len: usize,
) -> Result<(), Error> {
let color = conf.color;
let cols = dimensions_stdout().map(|x| x.0);
let cols = get_terminal_width();
let print = |k: &str, v: &str| print(color, len, cols, k, v);
let print_list = |k: &str, v: &[_]| print_list(color, len, cols, k, v);
let print_arch_list = |k: &str, v: &[ArchVec]| {
Expand Down Expand Up @@ -215,7 +219,7 @@ pub fn print_aur_info(
len: usize,
) -> Result<(), Error> {
let color = conf.color;
let cols = dimensions_stdout().map(|x| x.0);
let cols = get_terminal_width();
let print = |k: &str, v: &str| print(color, len, cols, k, v);
let print_list = |k: &str, v: &[_]| print_list(color, len, cols, k, v);
let no = tr!("No");
Expand Down Expand Up @@ -296,3 +300,8 @@ fn print_info<'a>(
let sep = if list { " " } else { " " };
print_indent(Style::new(), indent, indent, cols, sep, value)
}

#[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)
}

0 comments on commit 2a8c30c

Please sign in to comment.