aboutsummaryrefslogtreecommitdiff
path: root/src/libmain/progress-bar.cc
diff options
context:
space:
mode:
authorAlois Wohlschlager <alois1@gmx-topmail.de>2024-09-07 10:37:12 +0200
committerAlois Wohlschlager <alois1@gmx-topmail.de>2024-09-07 10:37:12 +0200
commit4715d557ef1c0dd306cde585820a2a00accd51d6 (patch)
tree1e150a1c5f6e7b26a677775eb53ed7ccfd8fc0a9 /src/libmain/progress-bar.cc
parent991d8ce2752d117c2431ddf8df454bda6df16a77 (diff)
libmain/progress-bar: erase all lines of the multi-line format
When the multi-line log format is enabled, the progress bar usually occupies multiple lines on the screen. When stopping the progress bar, only the last line was wiped, leaving all others visible on the screen. Erase all lines belonging to the progress bar to prevent these leftovers. Asking the user for input is theoretically affected by a similar issue, but this is not observed in practice since the only place where the user is asked (whether configuration options coming from flakes should be accepted) does not actually have multiple lines on the progress bar. However, there is no real reason to not fix this either, so let's do it anyway. Change-Id: Iaa5a701874fca32e6f06d85912835d86b8fa7a16
Diffstat (limited to 'src/libmain/progress-bar.cc')
-rw-r--r--src/libmain/progress-bar.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libmain/progress-bar.cc b/src/libmain/progress-bar.cc
index cdb15d8c7..68349ad26 100644
--- a/src/libmain/progress-bar.cc
+++ b/src/libmain/progress-bar.cc
@@ -92,7 +92,7 @@ void ProgressBar::resume()
nextWakeup = draw(*state, {});
state.wait_for(quitCV, std::chrono::milliseconds(50));
}
- writeLogsToStderr("\r\e[K");
+ eraseProgressDisplay(*state);
});
}
@@ -558,7 +558,8 @@ std::optional<char> ProgressBar::ask(std::string_view msg)
{
auto state(state_.lock());
if (state->paused > 0 || !isatty(STDIN_FILENO)) return {};
- std::cerr << fmt("\r\e[K%s ", msg);
+ eraseProgressDisplay(*state);
+ std::cerr << msg;
auto s = trim(readLine(STDIN_FILENO));
if (s.size() != 1) return {};
draw(*state, {});