Skip to content

Commit

Permalink
print_auto_scroll: resize status when longer than console width
Browse files Browse the repository at this point in the history
  • Loading branch information
thmahe committed Sep 18, 2024
1 parent a446338 commit 9f5b4ca
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion uuu/uuu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, ' ');
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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...";
Expand Down

0 comments on commit 9f5b4ca

Please sign in to comment.