diff --git a/Cargo.lock b/Cargo.lock index e766a1f5b..926850baf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -703,7 +703,7 @@ dependencies = [ "parking_lot", "signal-hook", "signal-hook-mio", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -712,7 +712,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] @@ -1592,6 +1592,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + [[package]] name = "kqueue" version = "1.0.8" @@ -1828,7 +1838,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ "cfg-if", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -2759,7 +2769,7 @@ dependencies = [ "unicode-segmentation", "unicode-width", "utf8parse", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -3084,7 +3094,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", - "winapi", + "winapi 0.3.9", ] [[package]] @@ -3208,6 +3218,17 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "term_size" +version = "1.0.0-beta1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8a17d8699e154863becdf18e4fd28bd0be27ca72856f54daf75c00f2566898f" +dependencies = [ + "kernel32-sys", + "libc", + "winapi 0.2.8", +] + [[package]] name = "termcolor" version = "1.3.0" @@ -3573,7 +3594,7 @@ dependencies = [ "serde_json", "serde_tuple", "serde_yaml", - "terminal_size", + "term_size", "thread_local", "tinyvec", "tokio", @@ -3819,6 +3840,12 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + [[package]] name = "winapi" version = "0.3.9" @@ -3829,6 +3856,12 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -3841,7 +3874,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ - "winapi", + "winapi 0.3.9", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ad9cd8be2..05d15e5a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ rayon = "1.8.0" regex = "1.10.2" serde = {version = "1", features = ["derive"]} serde_json = "1" -terminal_size = "0.3.0" +term_size = "1.0.0-beta1" thread_local = "1" tinyvec = {version = "1", features = ["alloc", "serde"]} toml = "0.8.8" diff --git a/src/grid_fmt.rs b/src/grid_fmt.rs index 232c6e0b3..70eb798ea 100644 --- a/src/grid_fmt.rs +++ b/src/grid_fmt.rs @@ -224,7 +224,7 @@ impl GridFmt for Array { } *grid.last_mut().unwrap().last_mut().unwrap() = if boxed { '╜' } else { '╯' }; // Handle really big grid - let max_width = terminal_size::terminal_size().map_or(54, |(w, _)| w.0 as usize); + let max_width = term_size::dimensions().map_or(54, |(w, _)| w); for row in grid.iter_mut() { if row.len() > max_width { let diff = row.len() - max_width; diff --git a/src/main.rs b/src/main.rs index 1517e5f4f..674b9ce9b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -696,7 +696,7 @@ fn clear_watching() { fn clear_watching_with(s: &str, end: &str) { print!( "\r{}{}", - s.repeat(terminal_size::terminal_size().map_or(10, |(w, _)| w.0 as usize)), + s.repeat(term_size::dimensions().map_or(10, |(w, _)| w)), end, ); } diff --git a/src/sys_native.rs b/src/sys_native.rs index 69b98d463..52ca47cc5 100644 --- a/src/sys_native.rs +++ b/src/sys_native.rs @@ -148,9 +148,7 @@ impl SysBackend for NativeSys { NATIVE_SYS.colored_errors.insert(message, colored); } fn term_size(&self) -> Result<(usize, usize), String> { - let (w, h) = terminal_size::terminal_size() - .ok_or("Failed to get terminal size") - .map(|(w, h)| (w.0 as usize, h.0 as usize))?; + let (w, h) = term_size::dimensions().ok_or("Failed to get terminal size")?; Ok((w, h.saturating_sub(1))) } #[cfg(feature = "raw_mode")] @@ -256,8 +254,7 @@ impl SysBackend for NativeSys { } #[cfg(feature = "terminal_image")] fn show_image(&self, image: image::DynamicImage) -> Result<(), String> { - let dim = terminal_size::terminal_size().map(|(w, h)| (w.0 as usize, h.0 as usize)); - let (width, height) = if let Some((w, h)) = dim { + let (width, height) = if let Some((w, h)) = term_size::dimensions() { let (tw, th) = (w as u32, h.saturating_sub(1) as u32); let (iw, ih) = (image.width(), image.height() / 2); let scaled_to_height = (iw * th / ih.max(1), th);