Skip to content

Commit 341b942

Browse files
committed
remove unmaintained term_size dep
1 parent 382af21 commit 341b942

File tree

6 files changed

+14
-23
lines changed

6 files changed

+14
-23
lines changed

Cargo.lock

+1-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ regex = "1.10.3"
3232
serde = {version = "1", features = ["derive"]}
3333
serde_json = "1"
3434
serde_tuple = "0.5.0"
35-
term_size = "=1.0.0-beta.2"
35+
terminal_size = "0.3.0"
3636
thread_local = "1"
3737
time = "0.3.36"
3838
tinyvec = {version = "1", features = ["alloc", "serde"]}

src/grid_fmt.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::{
1010
algorithm::map::{EMPTY_NAN, TOMBSTONE_NAN},
1111
array::{Array, ArrayValue},
1212
boxed::Boxed,
13+
terminal_size,
1314
value::Value,
1415
Complex, Primitive, WILDCARD_CHAR, WILDCARD_NAN,
1516
};
@@ -419,7 +420,7 @@ impl<T: GridFmt + ArrayValue> GridFmt for Array<T> {
419420

420421
// Handle really big grid
421422
if self.rank() > 1 {
422-
let max_width = term_size::dimensions().map_or(1000, |(w, _)| w);
423+
let max_width = terminal_size().map_or(1000, |(w, _)| w);
423424
for row in grid.iter_mut() {
424425
if row.len() > max_width {
425426
let diff = row.len() - max_width;
@@ -542,11 +543,7 @@ fn fmt_array<T: GridFmt + ArrayValue>(
542543
let row_shape = &shape[1..];
543544
let cell_size = data.len() / cell_count;
544545
let row_height: usize = row_shape.iter().rev().skip(1).product();
545-
let max_height = if term_size::dimensions().is_some() {
546-
100
547-
} else {
548-
300
549-
};
546+
let max_height = if terminal_size().is_some() { 100 } else { 300 };
550547
for (i, cell) in data.chunks(cell_size).enumerate() {
551548
if i > 0 && rank > 2 {
552549
for _ in 0..rank - 2 {

src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ fn clear_watching() {
730730
fn clear_watching_with(s: &str, end: &str) {
731731
print!(
732732
"\r{}{}",
733-
s.repeat(term_size::dimensions().map_or(10, |(w, _)| w)),
733+
s.repeat(terminal_size::terminal_size().map_or(10, |(w, _)| w.0 as usize)),
734734
end,
735735
);
736736
}

src/sys.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2481,3 +2481,7 @@ pub fn now() -> f64 {
24812481
}
24822482
}
24832483
}
2484+
2485+
pub(crate) fn terminal_size() -> Option<(usize, usize)> {
2486+
terminal_size::terminal_size().map(|(w, h)| (w.0 as usize, h.0 as usize))
2487+
}

src/sys_native.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::{
1515
time::Duration,
1616
};
1717

18-
use crate::{GitTarget, Handle, SysBackend};
18+
use crate::{terminal_size, GitTarget, Handle, SysBackend};
1919
use dashmap::DashMap;
2020
use once_cell::sync::Lazy;
2121

@@ -369,7 +369,7 @@ impl SysBackend for NativeSys {
369369
NATIVE_SYS.colored_errors.insert(message, colored);
370370
}
371371
fn term_size(&self) -> Result<(usize, usize), String> {
372-
let (w, h) = term_size::dimensions().ok_or("Failed to get terminal size")?;
372+
let (w, h) = terminal_size().ok_or("Failed to get terminal size")?;
373373
Ok((w, h.saturating_sub(1)))
374374
}
375375
fn exit(&self, code: i32) -> Result<(), String> {
@@ -563,8 +563,8 @@ impl SysBackend for NativeSys {
563563
}
564564
#[cfg(all(feature = "terminal_image", feature = "image"))]
565565
fn show_image(&self, image: image::DynamicImage) -> Result<(), String> {
566-
let (width, height) = if let Some((w, h)) = term_size::dimensions() {
567-
let (tw, th) = (w as u32, h.saturating_sub(1) as u32);
566+
let (width, height) = if let Some((w, h)) = terminal_size::terminal_size() {
567+
let (tw, th) = (w.0 as u32, h.0.saturating_sub(1) as u32);
568568
let (iw, ih) = (image.width(), image.height() / 2);
569569
let scaled_to_height = (iw * th / ih.max(1), th);
570570
let scaled_to_width = (tw, ih * tw / iw.max(1));

0 commit comments

Comments
 (0)