From 9f5b4ca5f47c6c6747e60d6f4c0acb153be4ab17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Mah=C3=A9?= Date: Wed, 18 Sep 2024 16:03:58 +0200 Subject: [PATCH] `print_auto_scroll`: resize status when longer than console width --- uuu/uuu.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/uuu/uuu.cpp b/uuu/uuu.cpp index 4fe254bd..bd633e28 100644 --- a/uuu/uuu.cpp +++ b/uuu/uuu.cpp @@ -326,6 +326,7 @@ string build_process_bar(size_t width, size_t pos, size_t total) void print_auto_scroll(string str, size_t len, size_t start) { g_max_process_width = max(str.size(), g_max_process_width); + g_max_process_width = min(g_max_process_width, len); if (str.size() <= len) { str.resize(g_max_process_width, ' '); @@ -338,6 +339,13 @@ void print_auto_scroll(string str, size_t len, size_t start) else start = 0; + if (str.size() >= len){ + str.resize(len - 1); + str[str.size() - 1] = '.'; + str[str.size() - 2] = '.'; + str[str.size() - 3] = '.'; + } + string s = str.substr(start, len); s.resize(len, ' '); cout << s; @@ -594,6 +602,11 @@ void print_oneline(string str) if (w <= 3) return; + if (g_max_process_width == 0){ + g_max_process_width = str.size(); + g_max_process_width = min(g_max_process_width, w); + } + if (str.size() >= w) { str.resize(w - 1); @@ -657,7 +670,7 @@ int progress(uuu_notify nt, void *p) else { string_ex str; - str.format("\rSuccess %d Failure %d ", g_overall_okay, g_overall_failure); + str.format("\rSuccess %d Failure %d ", g_overall_okay, g_overall_failure); if (g_map_path_nt.empty()) str += "Wait for Known USB Device Appear...";