Updated demo code

This commit is contained in:
Pranav Srinivas KumaR
2019-12-04 19:54:13 -06:00
parent 418057ac68
commit ff28c7fb02

View File

@@ -2,64 +2,25 @@
#include <indica/progress_spinner.hpp>
#include <vector>
/*
[
"|/-\\",
"⠂-–—–-",
"◐◓◑◒",
"◴◷◶◵",
"◰◳◲◱",
"▖▘▝▗",
"■□▪▫",
"▌▀▐▄",
"▉▊▋▌▍▎▏▎▍▌▋▊▉",
"▁▃▄▅▆▇█▇▆▅▄▃",
"←↖↑↗→↘↓↙",
"┤┘┴└├┌┬┐",
"◢◣◤◥",
".oO°Oo.",
".oO@*",
["🌍", "🌎", "🌏"],
"◡◡ ⊙⊙ ◠◠",
"☱☲☴",
"⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏",
"⠋⠙⠚⠞⠖⠦⠴⠲⠳⠓",
"⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆",
"⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋",
"⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁",
"⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈",
"⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈",
"⢄⢂⢁⡁⡈⡐⡠",
"⢹⢺⢼⣸⣇⡧⡗⡏",
"⣾⣽⣻⢿⡿⣟⣯⣷",
"⠁⠂⠄⡀⢀⠠⠐⠈",
["🌑", "🌒", "🌓", "🌔", "🌕", "🌝", "🌖", "🌗", "🌘", "🌚"],
["🕛", "🕐", "🕑", "🕒", "🕓", "🕔", "🕕", "🕖", "🕗", "🕘", "🕙", "🕚"]
]
*/
int main() {
// Hide cursor
std::cout << "\e[?25l";
std::cout << "\n\n";
{}
{
//
// PROGRESS BAR 1
//
indica::ProgressBar p1;
p1.set_bar_width(50);
p1.start_bar_with(" [");
p1.fill_bar_progress_with("");
p1.lead_bar_progress_with("");
p1.fill_bar_remainder_with(" ");
p1.end_bar_with(" ]");
p1.set_foreground_color(indica::Color::YELLOW);
indica::ProgressBar p;
p.set_bar_width(50);
p.start_bar_with("[");
p.fill_bar_progress_with("");
p.lead_bar_progress_with("");
p.fill_bar_remainder_with(" ");
p.end_bar_with(" ]");
p.set_foreground_color(indica::Color::YELLOW);
std::atomic<size_t> index1{0};
std::vector<std::string> status_text1 = {"Rocket.exe is not responding",
std::atomic<size_t> index{0};
std::vector<std::string> status_text = {"Rocket.exe is not responding",
"Buying more snacks",
"Finding a replacement engineer",
"Assimilating the modding community",
@@ -69,18 +30,19 @@ int main() {
"Releasing space whales",
"Watching paint dry"};
auto job1 = [&p1, &index1, &status_text1]() {
auto job = [&p, &index, &status_text]() {
while (true) {
if (p1.is_completed())
if (p.is_completed())
break;
p1.set_postfix_text(status_text1[index1 % status_text1.size()]);
p1.set_progress(index1 * 10);
index1 += 1;
p.set_postfix_text(status_text[index % status_text.size()]);
p.set_progress(index * 10);
index += 1;
std::this_thread::sleep_for(std::chrono::milliseconds(600));
}
};
std::thread thread1(job1);
thread1.join();
std::thread thread(job);
thread.join();
}
//
// PROGRESS BAR 3
@@ -332,11 +294,8 @@ int main() {
thread.join();
}
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
// Show cursor
std::cout << "\e[?25h";
std::cout << "\n\n";
return 0;
}