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:
parent
96681695c9
commit
a79337c3ee
|
@ -307,17 +307,20 @@ int printStats(bool mining)
|
||||||
// Draw 50-character progress bar, which will fit into a 79-character line.
|
// Draw 50-character progress bar, which will fit into a 79-character line.
|
||||||
int blockChars = downloadPercent / 2;
|
int blockChars = downloadPercent / 2;
|
||||||
int headerChars = (nHeaders * 50) / netheight;
|
int headerChars = (nHeaders * 50) / netheight;
|
||||||
std::cout << " | [";
|
// Start with background colour reversed for "full" bar.
|
||||||
|
std::cout << " | [[7m";
|
||||||
for (auto i : boost::irange(0, 50)) {
|
for (auto i : boost::irange(0, 50)) {
|
||||||
if (i < blockChars) {
|
if (i == headerChars) {
|
||||||
std::cout << "█";
|
// Switch to normal background colour for "empty" bar.
|
||||||
} else if (i < headerChars) {
|
std::cout << "[0m";
|
||||||
std::cout << "▄";
|
} else if (i == blockChars) {
|
||||||
} else {
|
// Switch to distinct colour for "headers" bar.
|
||||||
|
std::cout << "[0;43m";
|
||||||
|
}
|
||||||
std::cout << " ";
|
std::cout << " ";
|
||||||
}
|
}
|
||||||
}
|
// Ensure that colour is reset after the progress bar is printed.
|
||||||
std::cout << "]" << std::endl;
|
std::cout << "[0m]" << std::endl;
|
||||||
lines++;
|
lines++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue