mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-16 04:18:51 +08:00
Updated test example
This commit is contained in:
26
test/bar.cpp
26
test/bar.cpp
@@ -1,4 +1,5 @@
|
||||
#include <progress/bar.hpp>
|
||||
#include <vector>
|
||||
|
||||
int main() {
|
||||
|
||||
@@ -11,7 +12,7 @@ int main() {
|
||||
bar.lead_progress_with("■");
|
||||
bar.fill_remainder_with("-");
|
||||
bar.end_with(" ]");
|
||||
bar.color(ProgressBar::Color::GREEN);
|
||||
bar.color(ProgressBar::Color::YELLOW);
|
||||
|
||||
// As configured, the bar will look like this:
|
||||
//
|
||||
@@ -19,12 +20,29 @@ int main() {
|
||||
//
|
||||
//
|
||||
|
||||
auto job = [&bar]() {
|
||||
std::atomic<size_t> index{0};
|
||||
std::vector<std::string> status_text =
|
||||
{
|
||||
"Rocket.exe is not responding",
|
||||
"Finding a replacement engineer",
|
||||
"Buying more snacks",
|
||||
"Assimilating the modding community",
|
||||
"Crossing fingers",
|
||||
"Porting KSP to a Nokia 3310"
|
||||
"Flexing struts",
|
||||
"Releasing space whales",
|
||||
"Watching paint dry"
|
||||
};
|
||||
|
||||
auto job = [&bar, &index, &status_text]() {
|
||||
while (true) {
|
||||
if (bar.completed())
|
||||
if (bar.completed()) {
|
||||
break;
|
||||
}
|
||||
bar.append_text(status_text[index % status_text.size()]);
|
||||
bar.tick();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
index += 1;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user