refact: Inline ProgressBar::draw(state, newOutput), inline local output

This commit is contained in:
Robert Hensing 2024-09-08 01:21:40 +02:00
parent 047d9643b5
commit e10ea78f93

View file

@ -379,20 +379,6 @@ public:
}
std::chrono::milliseconds draw(State & state)
{
std::optional<std::string> newOutput;
auto nextWakeup = draw(state, newOutput);
if (newOutput)
redraw(*newOutput);
return nextWakeup;
}
/**
* @param output[out] `nullopt` if nothing is to be drawn. Otherwise, a
* string of ANSI terminal output that can be used to
* render the progress bar.
*/
std::chrono::milliseconds draw(State & state, std::optional<std::string> & output)
{
auto nextWakeup = std::chrono::milliseconds::max();
@ -445,7 +431,7 @@ public:
auto width = getWindowSize().second;
if (width <= 0) width = std::numeric_limits<decltype(width)>::max();
output = "\r" + filterANSIEscapes(line, false, width) + ANSI_NORMAL + "\e[K";
redraw("\r" + filterANSIEscapes(line, false, width) + ANSI_NORMAL + "\e[K");
return nextWakeup;
}