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