Updated demo code

This commit is contained in:
Pranav Srinivas KumaR
2019-12-04 20:17:56 -06:00
parent 6bf1ce76ea
commit 5f9dc6e042

View File

@@ -6,6 +6,7 @@ int main() {
// Hide cursor // Hide cursor
std::cout << "\e[?25l"; std::cout << "\e[?25l";
{ {
// //
// PROGRESS BAR 1 // PROGRESS BAR 1
@@ -44,67 +45,73 @@ int main() {
thread.join(); thread.join();
} }
{
// //
// PROGRESS BAR 3 // PROGRESS BAR 2
// //
indica::ProgressBar p3; indica::ProgressBar p;
p3.set_bar_width(40); p.set_bar_width(40);
p3.set_prefix_text("Reading package list... "); p.set_prefix_text("Reading package list... ");
p3.start_bar_with(""); p.start_bar_with("");
p3.fill_bar_progress_with(""); p.fill_bar_progress_with("");
p3.lead_bar_progress_with(""); p.lead_bar_progress_with("");
p3.fill_bar_remainder_with(""); p.fill_bar_remainder_with("");
p3.end_bar_with(""); p.end_bar_with("");
p3.set_foreground_color(indica::Color::WHITE); p.set_foreground_color(indica::Color::WHITE);
p3.hide_percentage(); p.hide_percentage();
auto job3 = [&p3]() { auto job = [&p]() {
while (true) { while (true) {
p3.set_prefix_text("Reading package list... " + p.set_prefix_text("Reading package list... " +
std::to_string(p3.current()) + "% "); std::to_string(p.current()) + "% ");
if (p3.current() + 2 >= 100) if (p.current() + 2 >= 100)
p3.set_prefix_text("Reading package list... Done"); p.set_prefix_text("Reading package list... Done");
p3.tick(); p.tick();
if (p3.is_completed()) { if (p.is_completed()) {
break; break;
} }
std::this_thread::sleep_for(std::chrono::milliseconds(25)); std::this_thread::sleep_for(std::chrono::milliseconds(25));
} }
}; };
std::thread thread3(job3); std::thread thread(job);
thread3.join(); thread.join();
}
{
// //
// PROGRESS BAR 2 // PROGRESS BAR 3
// //
indica::ProgressBar p2; indica::ProgressBar p;
p2.set_bar_width(50); p.set_bar_width(50);
p2.start_bar_with("["); p.start_bar_with("[");
p2.fill_bar_progress_with("="); p.fill_bar_progress_with("=");
p2.lead_bar_progress_with(">"); p.lead_bar_progress_with(">");
p2.fill_bar_remainder_with(" "); p.fill_bar_remainder_with(" ");
p2.end_bar_with("]"); p.end_bar_with("]");
p2.set_postfix_text("Getting started"); p.set_postfix_text("Getting started");
p2.set_foreground_color(indica::Color::GREEN); p.set_foreground_color(indica::Color::GREEN);
auto job2 = [&p2]() { auto job = [&p]() {
while (true) { while (true) {
auto ticks = p2.current(); auto ticks = p.current();
if (ticks > 20 && ticks < 50) if (ticks > 20 && ticks < 50)
p2.set_postfix_text("Delaying the inevitable"); p.set_postfix_text("Delaying the inevitable");
else if (ticks > 50 && ticks < 80) else if (ticks > 50 && ticks < 80)
p2.set_postfix_text("Crying quietly"); p.set_postfix_text("Crying quietly");
else if (ticks > 80 && ticks < 98) else if (ticks > 80 && ticks < 98)
p2.set_postfix_text("Almost there"); p.set_postfix_text("Almost there");
else if (ticks >= 98) else if (ticks >= 98)
p2.set_postfix_text("Done"); p.set_postfix_text("Done");
p2.tick(); p.tick();
if (p2.is_completed()) if (p.is_completed())
break; break;
std::this_thread::sleep_for(std::chrono::milliseconds(30)); std::this_thread::sleep_for(std::chrono::milliseconds(30));
} }
}; };
std::thread thread2(job2); std::thread thread(job);
thread2.join(); thread.join();
}
{
// //
// PROGRESS BAR 4 // PROGRESS BAR 4
// //
@@ -180,7 +187,12 @@ int main() {
thread.join(); thread.join();
} }
}
{ {
//
// PROGRESS BAR 5
//
indica::ProgressSpinner p; indica::ProgressSpinner p;
p.set_prefix_text(""); p.set_prefix_text("");
p.set_postfix_text("Checking credentials"); p.set_postfix_text("Checking credentials");
@@ -207,6 +219,9 @@ int main() {
std::cout << " Compiling mission\n"; std::cout << " Compiling mission\n";
{ {
//
// PROGRESS BAR 6
//
indica::ProgressSpinner p; indica::ProgressSpinner p;
p.set_prefix_text(" - "); p.set_prefix_text(" - ");
p.set_postfix_text("Searching for the Moon"); p.set_postfix_text("Searching for the Moon");