diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/zen/zen.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/zen/zen.cpp b/src/zen/zen.cpp index 0fcf9d871..b7faddaca 100644 --- a/src/zen/zen.cpp +++ b/src/zen/zen.cpp @@ -32,6 +32,7 @@ #include <zencore/scopeguard.h> #include <zencore/string.h> #include <zencore/trace.h> +#include <zencore/windows.h> #include <zenhttp/httpcommon.h> #include <zenutil/logging.h> #include <zenutil/zenserverprocess.h> @@ -323,7 +324,18 @@ ProgressBar::UpdateState(const State& NewState, bool DoLinebreak) ETA, NewState.Details.empty() ? "" : fmt::format(". {}", NewState.Details)); std::string::size_type EraseLength = m_LastOutputLength > Output.length() ? (m_LastOutputLength - Output.length()) : 0; - printf("%s%s%s", Output.c_str(), std::string(EraseLength, ' ').c_str(), DoLinebreak ? "\n" : ""); + + ExtendableStringBuilder<128> LineToPrint; + LineToPrint << Output << std::string(EraseLength, ' '); + if (DoLinebreak) + LineToPrint << "\n"; + +#if ZEN_PLATFORM_WINDOWS + WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), LineToPrint.c_str(), (DWORD)LineToPrint.Size(), 0, 0); +#else + fwrite(LineToPrint.c_str(), 1, LineToPrint.Size(), stdout); +#endif + m_LastOutputLength = DoLinebreak ? 0 : Output.length(); m_State = NewState; } |