not printing activities at all when no progress information is available hides *all* progress information from e.g. flake show. this is not ideal and needs to be fixed, but the fix *still* has problems with flake show: in multiline mode we will overwrite all useful flake show output as soon as the progress bar is redrawn. flake show output is also mangled in any number of other situations (like -v being set), so we should probably be not too worried about it and fix progress reporting properly another day Change-Id: I6d39d670e261bbae00560b6a8e15dec8e16b35c4
This commit is contained in:
parent
24852355d8
commit
e7517419a6
2 changed files with 26 additions and 8 deletions
|
@ -318,6 +318,16 @@ void ProgressBar::update(State & state)
|
|||
updateCV.notify_one();
|
||||
}
|
||||
|
||||
void ProgressBar::eraseProgressDisplay(State & state)
|
||||
{
|
||||
if (printMultiline && (state.lastLines >= 1)) {
|
||||
// FIXME: make sure this works on windows
|
||||
writeToStderr(fmt("\e[G\e[%dF\e[J", state.lastLines));
|
||||
} else {
|
||||
writeToStderr("\r\e[K");
|
||||
}
|
||||
}
|
||||
|
||||
std::chrono::milliseconds ProgressBar::draw(State & state, const std::optional<std::string_view> & s)
|
||||
{
|
||||
auto nextWakeup = A_LONG_TIME;
|
||||
|
@ -331,15 +341,12 @@ std::chrono::milliseconds ProgressBar::draw(State & state, const std::optional<s
|
|||
width = std::numeric_limits<decltype(width)>::max();
|
||||
}
|
||||
|
||||
if (printMultiline && (state.lastLines >= 1)) {
|
||||
// FIXME: make sure this works on windows
|
||||
writeToStderr(fmt("\e[G\e[%dF\e[J", state.lastLines));
|
||||
}
|
||||
eraseProgressDisplay(state);
|
||||
|
||||
state.lastLines = 0;
|
||||
|
||||
if (s != std::nullopt)
|
||||
writeToStderr("\r\e[K" + filterANSIEscapes(s.value(), !isTTY) + ANSI_NORMAL "\n");
|
||||
writeToStderr(filterANSIEscapes(s.value(), !isTTY) + ANSI_NORMAL "\n");
|
||||
|
||||
std::string line;
|
||||
std::string status = getStatus(state);
|
||||
|
@ -401,9 +408,14 @@ std::chrono::milliseconds ProgressBar::draw(State & state, const std::optional<s
|
|||
if (printMultiline && moreActivities)
|
||||
writeToStderr(fmt("And %d more...", moreActivities));
|
||||
|
||||
if (!printMultiline && !line.empty()) {
|
||||
line += " " + activity_line;
|
||||
writeToStderr("\r" + filterANSIEscapes(line, false, width) + ANSI_NORMAL + "\e[K");
|
||||
if (!printMultiline) {
|
||||
if (!line.empty()) {
|
||||
line += " ";
|
||||
}
|
||||
line += activity_line;
|
||||
if (!line.empty()) {
|
||||
writeToStderr(filterANSIEscapes(line, false, width) + ANSI_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
return nextWakeup;
|
||||
|
@ -531,6 +543,9 @@ void ProgressBar::writeToStdout(std::string_view s)
|
|||
{
|
||||
auto state(state_.lock());
|
||||
if (state->paused == 0) {
|
||||
if (isTTY && !printMultiline) {
|
||||
eraseProgressDisplay(*state);
|
||||
}
|
||||
Logger::writeToStdout(s);
|
||||
draw(*state, {});
|
||||
} else {
|
||||
|
|
|
@ -108,6 +108,9 @@ struct ProgressBar : public Logger
|
|||
void setPrintBuildLogs(bool printBuildLogs) override;
|
||||
|
||||
void setPrintMultiline(bool printMultiline) override;
|
||||
|
||||
private:
|
||||
void eraseProgressDisplay(State & state);
|
||||
};
|
||||
|
||||
Logger * makeProgressBar();
|
||||
|
|
Loading…
Reference in a new issue