From b99398fb18b209143554ee936592f129610b90ca Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Thu, 12 Mar 2026 19:58:53 +0800 Subject: Update helpdoc viewer UI and improve text handling - Add title localization for helpdoc viewer - Implement ANSI-aware string truncation for proper display - Improve focus indication with color highlighting - Move display_width utility to shared module - Update welcome and command helpdoc formatting - Bump copyright year to 2026 --- utils/src/display/table.rs | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'utils/src/display/table.rs') diff --git a/utils/src/display/table.rs b/utils/src/display/table.rs index ae745d8..e6f1aca 100644 --- a/utils/src/display/table.rs +++ b/utils/src/display/table.rs @@ -1,3 +1,5 @@ +use crate::display::str_width::display_width; + pub struct Table { items: Vec, line: Vec>, @@ -122,22 +124,3 @@ impl std::fmt::Display for Table { Ok(()) } } - -pub fn display_width(s: &str) -> usize { - // Filter out ANSI escape sequences before calculating width - let filtered_bytes = strip_ansi_escapes::strip(s); - let filtered_str = match std::str::from_utf8(&filtered_bytes) { - Ok(s) => s, - Err(_) => s, // Fallback to original string if UTF-8 conversion fails - }; - - let mut width = 0; - for c in filtered_str.chars() { - if c.is_ascii() { - width += 1; - } else { - width += 2; - } - } - width -} -- cgit