From 9d99f9e6a706ea802f0b8b638d4ffaa81c69ccab Mon Sep 17 00:00:00 2001 From: DastInDark <2350416+hitenkoku@users.noreply.github.com> Date: Sun, 4 Jun 2023 13:47:48 +0900 Subject: [PATCH] UI(changed detection rule name omit char number by terminal_size #1071): --- src/afterfact.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/afterfact.rs b/src/afterfact.rs index 7c86c0ecf..987ac0653 100644 --- a/src/afterfact.rs +++ b/src/afterfact.rs @@ -27,7 +27,7 @@ use yaml_rust::YamlLoader; use comfy_table::*; use hashbrown::{HashMap, HashSet}; use num_format::{Locale, ToFormattedString}; -use std::cmp::min; +use std::cmp::{self, min}; use std::error::Error; use std::io::{self, BufWriter, Write}; @@ -737,6 +737,7 @@ fn emit_csv( &level_abbr, &mut html_output_stock, stored_static, + cmp::min((terminal_width / 2) - 10, 50), ); println!(); if html_output_flag { @@ -1079,6 +1080,7 @@ fn _print_detection_summary_tables( level_abbr: &Nested>, html_output_stock: &mut Nested, stored_static: &StoredStatic, + limit_num: usize, ) { let buf_wtr = BufferWriter::stdout(ColorChoice::Always); let mut wtr = buf_wtr.buffer(); @@ -1132,8 +1134,8 @@ fn _print_detection_summary_tables( 5 }; for x in sorted_detections.iter().take(take_cnt) { - let output_title = if x.0 .0.len() > 47 { - format!("{}...", &x.0 .0[..47]) + let output_title = if x.0 .0.len() > limit_num - 3 { + format!("{}...", &x.0 .0[..(limit_num - 3)]) } else { x.0 .0.to_string() };