1 #include <chrono>
2 #include <indicators/block_progress_bar.hpp>
3 #include <indicators/cursor_control.hpp>
4 #include <thread>
5 
main()6 int main() {
7 
8   // Hide cursor
9   indicators::show_console_cursor(false);
10 
11   // Random list of numbers
12   std::vector<size_t> numbers;
13   for (size_t i = 0; i < 1259438; ++i) {
14     numbers.push_back(i);
15   }
16 
17   using namespace indicators;
18   BlockProgressBar bar{option::BarWidth{80}, option::ForegroundColor{Color::white},
19                        option::FontStyles{std::vector<FontStyle>{FontStyle::bold}},
20                        option::MaxProgress{numbers.size()}};
21 
22   std::cout << "Iterating over a list of numbers (size = " << numbers.size() << ")\n";
23 
24   std::vector<size_t> result;
25   for (size_t i = 0; i < numbers.size(); ++i) {
26 
27     // Perform some computation
28     result.push_back(numbers[i] * numbers[i]);
29 
30     // Show iteration as postfix text
31     bar.set_option(option::PostfixText{std::to_string(i) + "/" + std::to_string(numbers.size())});
32 
33     // update progress bar
34     bar.tick();
35   }
36 
37   bar.mark_as_completed();
38 
39   // Show cursor
40   indicators::show_console_cursor(true);
41 
42   return 0;
43 }
44