mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
Fix progress bar
This commit is contained in:
parent
1d5e99362f
commit
829bd066c4
@ -244,9 +244,14 @@ void ProgressIndication::writeProgress()
|
||||
double bar_width = UnicodeBar::getWidth(current_count, 0, max_count, width_of_progress_bar);
|
||||
std::string bar = UnicodeBar::render(bar_width);
|
||||
|
||||
/// Whitespaces after the progress bar.
|
||||
std::string whitespaces;
|
||||
if (width_of_progress_bar > static_cast<int64_t>(bar.size() / UNICODE_BAR_CHAR_SIZE))
|
||||
whitespaces.assign(width_of_progress_bar - bar.size() - profiling_msg.size() / UNICODE_BAR_CHAR_SIZE, ' ');
|
||||
|
||||
if (profiling_msg.empty())
|
||||
{
|
||||
message << "\033[0;32m" << bar << "\033[0m";
|
||||
message << "\033[0;32m" << bar << "\033[0m" << whitespaces;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -257,23 +262,15 @@ void ProgressIndication::writeProgress()
|
||||
/// Render profiling_msg at left on top of the progress bar.
|
||||
|
||||
message << "\033[30;42m" << profiling_msg << "\033[0m"
|
||||
<< "\033[0;32m" << bar.substr(profiling_msg.size()) << "\033[0m";
|
||||
|
||||
/// Whitespaces after the progress bar.
|
||||
if (width_of_progress_bar > static_cast<int64_t>(bar.size() / UNICODE_BAR_CHAR_SIZE))
|
||||
message << std::string(width_of_progress_bar - bar.size() / UNICODE_BAR_CHAR_SIZE, ' ');
|
||||
<< "\033[0;32m" << bar.substr(profiling_msg.size()) << "\033[0m"
|
||||
<< whitespaces;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Render profiling_msg at right after the progress bar.
|
||||
|
||||
message << "\033[0;32m" << bar << "\033[0m";
|
||||
|
||||
/// Whitespaces after the progress bar.
|
||||
if (width_of_progress_bar > static_cast<int64_t>(profiling_msg.size()) + static_cast<int64_t>(bar.size() / UNICODE_BAR_CHAR_SIZE))
|
||||
message << std::string(width_of_progress_bar - profiling_msg.size() - bar.size() / UNICODE_BAR_CHAR_SIZE, ' ');
|
||||
|
||||
message << "\033[2m" << profiling_msg << "\033[0m";
|
||||
message << "\033[0;32m" << bar << "\033[0m"
|
||||
<< whitespaces << "\033[2m" << profiling_msg << "\033[0m";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user