18 if (m_terminal_width <= 8)
23 m_bar_width = m_terminal_width - 7;
24 if (max_message_size != 0)
26 m_bar_width -= max_message_size + 1;
33 progress = std::clamp(progress, 0.f, 1.f);
34 u32 int_progress = (
u32)(progress * 100.0f);
40 if (m_terminal_width <= 8)
45 u32 pos = (
u32)(m_bar_width * progress);
47 if (pos <= m_printed_progress && m_last_message ==
message)
53 m_printed_progress = pos;
58 bar += std::string(pos,
'=');
60 if (pos < m_bar_width)
64 if (pos + 1 < m_bar_width)
66 bar += std::string(m_bar_width - pos - 1,
' ');
70 if (print_message.size() > m_max_message_size)
72 if (m_max_message_size <= 3)
74 print_message = std::string(m_max_message_size,
'.');
78 print_message = print_message.substr(0, m_max_message_size - 3) +
"...";
82 std::stringstream
str;
83 str <<
"[" << bar <<
"] ";
85 str << std::right << std::setw(3) << int_progress <<
'%';
87 if (!print_message.empty())
89 str <<
" " << print_message;
95 if (
output.size() < (
u32)m_terminal_width)
97 std::cerr << std::string(m_terminal_width -
output.size(),
' ');
100 std::cerr <<
"\r" << std::flush;
105 if (m_terminal_width <= 8)
109 std::cerr << std::string(m_terminal_width,
' ') <<
"\r" << std::flush;
114 m_printed_progress = 0;
115 m_last_message =
"$^äü+";
118 int ProgressPrinter::get_terminal_width()
121 int retval = ioctl(STDERR_FILENO, TIOCGWINSZ, &size);
static std::function< void(int, const std::string &)> s_progress_indicator_function
void print_progress(float progress, const std::string &message="")
ProgressPrinter(u32 max_message_size=0)
message(VERBOSE "Qt5Widgets_LIBRARIES: ${Qt5Widgets_LIBRARIES}") elseif(NOT Qt5Widgets_FOUND) set(Missing_package "TRUE") if(APPLE AND CMAKE_HOST_APPLE) message(STATUS "To install qt5 on MacOS using homebrew run following command
const int dont_believe_in_terminal_width_bigger_than_this_value