diff --git a/Cargo.lock b/Cargo.lock index 5f817c4..7fc3726 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -249,7 +249,7 @@ dependencies = [ "serde_qs", "serde_repr", "serde_with", - "term_size", + "terminal_size", "tokio", "unicode-width", "words-count", @@ -1255,16 +1255,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "term_size" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "terminal_size" version = "0.2.6" diff --git a/Cargo.toml b/Cargo.toml index ade1e10..edffc32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,6 @@ futures = "0.3.28" clap = { version = "4.4.3", features = ["derive", "wrap_help"] } colored = "2.0.4" -term_size = "0.3.2" +terminal_size = "0.2.6" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/display/colorful.rs b/src/display/colorful.rs index f76b87b..7247764 100644 --- a/src/display/colorful.rs +++ b/src/display/colorful.rs @@ -15,6 +15,7 @@ use colored::Colorize; use std::fmt::Display; use std::ops::Not; use std::path::PathBuf; +use terminal_size::terminal_size; use unicode_width::UnicodeWidthStr; pub fn login(cfg_path: &Result) { @@ -90,7 +91,7 @@ pub fn list_ing( println!(" {} {}", "#".dimmed(), ing.id.to_string().dimmed()); let content = if align { let user_name_width = ing.user_name.width_cjk(); - let (term_width, _) = term_size::dimensions().expect("Can not get terminal size"); + let term_width = terminal_size().expect("Can not get terminal size").0 .0 as usize; let left_width = term_width.saturating_sub(user_name_width + 3); fmt_content(&ing.content) .width_split(left_width) diff --git a/src/display/normal.rs b/src/display/normal.rs index 99bdc32..debe727 100644 --- a/src/display/normal.rs +++ b/src/display/normal.rs @@ -15,6 +15,7 @@ use colored::Colorize; use std::fmt::Display; use std::ops::Not; use std::path::PathBuf; +use terminal_size::terminal_size; use unicode_width::UnicodeWidthStr; pub fn login(cfg_path: &Result) { @@ -90,7 +91,7 @@ pub fn list_ing( println!(" # {}", ing.id); let content = if align { let user_name_width = ing.user_name.width_cjk(); - let (term_width, _) = term_size::dimensions().expect("Can not get terminal size"); + let term_width = terminal_size().expect("Can not get terminal size").0 .0 as usize; let left_width = term_width.saturating_sub(user_name_width + 3); fmt_content(&ing.content) .width_split(left_width) diff --git a/src/infra/str.rs b/src/infra/str.rs index 9390e8a..ccc6b13 100644 --- a/src/infra/str.rs +++ b/src/infra/str.rs @@ -63,6 +63,7 @@ fn test_width_split_head() { #[test] fn test_width_split() { + use crate::infra::option::IntoOption; let text = "测试test⭐测试test⭐"; assert_eq!(text.width_split(0), None); assert_eq!(text.width_split(1), None);