metrics: Switch to ANSI colour codes for progress bar

We already assume that ANSI colour codes work for the metrics art,
whereas the block characters have inconsistent support in fonts.
This commit is contained in:
Jack Grigg 2020-06-02 14:20:55 +12:00
parent 96681695c9
commit a79337c3ee
1 changed files with 11 additions and 8 deletions

View File

@ -307,17 +307,20 @@ int printStats(bool mining)
// Draw 50-character progress bar, which will fit into a 79-character line.
int blockChars = downloadPercent / 2;
int headerChars = (nHeaders * 50) / netheight;
std::cout << " | [";
// Start with background colour reversed for "full" bar.
std::cout << " | [";
for (auto i : boost::irange(0, 50)) {
if (i < blockChars) {
std::cout << "";
} else if (i < headerChars) {
std::cout << "";
} else {
std::cout << " ";
if (i == headerChars) {
// Switch to normal background colour for "empty" bar.
std::cout << "";
} else if (i == blockChars) {
// Switch to distinct colour for "headers" bar.
std::cout << "";
}
std::cout << " ";
}
std::cout << "]" << std::endl;
// Ensure that colour is reset after the progress bar is printed.
std::cout << "]" << std::endl;
lines++;
}
} else {