2020-04-26 18:28:46 +02:00
|
|
|
#include <indicators/cursor_control.hpp>
|
2019-12-16 10:19:47 -06:00
|
|
|
#include <indicators/progress_spinner.hpp>
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
|
|
|
|
|
// Hide cursor
|
2020-04-26 18:28:46 +02:00
|
|
|
indicators::show_console_cursor(false);
|
2019-12-16 10:19:47 -06:00
|
|
|
|
2020-02-04 23:29:14 +01:00
|
|
|
indicators::ProgressSpinner spinner{
|
2020-02-13 14:21:01 +05:30
|
|
|
indicators::option::PostfixText{"Checking credentials"},
|
|
|
|
|
indicators::option::ForegroundColor{indicators::Color::yellow},
|
|
|
|
|
indicators::option::SpinnerStates{
|
|
|
|
|
std::vector<std::string>{"⠈", "⠐", "⠠", "⢀", "⡀", "⠄", "⠂", "⠁"}},
|
2020-04-06 11:25:54 -07:00
|
|
|
indicators::option::FontStyles{
|
2020-05-24 22:56:57 -05:00
|
|
|
std::vector<indicators::FontStyle>{indicators::FontStyle::bold}}};
|
2019-12-17 09:31:43 -06:00
|
|
|
|
2019-12-16 10:19:47 -06:00
|
|
|
// Update spinner state
|
|
|
|
|
auto job = [&spinner]() {
|
|
|
|
|
while (true) {
|
|
|
|
|
if (spinner.is_completed()) {
|
2020-02-11 17:29:41 +05:30
|
|
|
spinner.set_option(indicators::option::ForegroundColor{indicators::Color::green});
|
2020-02-04 23:29:14 +01:00
|
|
|
spinner.set_option(indicators::option::PrefixText{"✔"});
|
2020-02-11 08:57:38 +01:00
|
|
|
spinner.set_option(indicators::option::ShowSpinner{false});
|
2020-02-04 23:29:14 +01:00
|
|
|
spinner.set_option(indicators::option::ShowPercentage{false});
|
|
|
|
|
spinner.set_option(indicators::option::PostfixText{"Authenticated!"});
|
2019-12-16 10:19:47 -06:00
|
|
|
spinner.mark_as_completed();
|
|
|
|
|
break;
|
|
|
|
|
} else
|
|
|
|
|
spinner.tick();
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(40));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
std::thread thread(job);
|
|
|
|
|
thread.join();
|
|
|
|
|
|
|
|
|
|
// Show cursor
|
2020-04-26 18:28:46 +02:00
|
|
|
indicators::show_console_cursor(true);
|
2019-12-16 10:19:47 -06:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|