Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions engine/cli/utils/download_progress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ bool DownloadProgress::Connect(const std::string& host, int port) {

bool DownloadProgress::Handle(const DownloadType& event_type) {
assert(!!ws_);
#if defined(_WIN32)
HANDLE h_out = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD dw_original_out_mode = 0;
if (h_out != INVALID_HANDLE_VALUE) {
GetConsoleMode(h_out, &dw_original_out_mode);

// Enable ANSI escape code processing
DWORD dw_requested_out_mode =
dw_original_out_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
if (!SetConsoleMode(h_out, dw_requested_out_mode)) {
SetConsoleMode(h_out, dw_original_out_mode);
}
}
#endif
std::unordered_map<std::string, uint64_t> totals;
status_ = DownloadStatus::DownloadStarted;
std::unique_ptr<indicators::DynamicProgress<indicators::ProgressBar>> bars;
Expand Down Expand Up @@ -124,6 +138,11 @@ bool DownloadProgress::Handle(const DownloadType& event_type) {
ws_->dispatch(handle_message);
}
indicators::show_console_cursor(true);
#if defined(_WIN32)
if (dw_original_out_mode != 0 && h_out != INVALID_HANDLE_VALUE) {
SetConsoleMode(h_out, dw_original_out_mode);
}
#endif
if (status_ == DownloadStatus::DownloadError)
return false;
return true;
Expand Down
Loading