mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-14 03:08:52 +08:00
Add a MaxProgress option (default: 100).
The MaxProgress option allows you to set the maximum number of ticks that are within a progress bar. Each call to tick() increments the tick count. The progress bar percentage is the number of ticks divided by the MaxProgress option. The default MaxProgress is 100, so each tick would be 1%. If MaxProgress is set to 500, for example, then each tick would be 0.2%.
This commit is contained in:
30
samples/max_progress.cpp
Normal file
30
samples/max_progress.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <chrono>
|
||||
#include <indicators/block_progress_bar.hpp>
|
||||
#include <indicators/cursor_control.hpp>
|
||||
#include <thread>
|
||||
|
||||
int main() {
|
||||
|
||||
// Hide cursor
|
||||
indicators::show_console_cursor(false);
|
||||
|
||||
indicators::BlockProgressBar bar{
|
||||
indicators::option::BarWidth{80},
|
||||
indicators::option::FontStyles{
|
||||
std::vector<indicators::FontStyle>{indicators::FontStyle::bold}},
|
||||
indicators::option::MaxProgress{400}
|
||||
};
|
||||
|
||||
// Update bar state
|
||||
while (true) {
|
||||
bar.tick();
|
||||
if (bar.is_completed())
|
||||
break;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
}
|
||||
|
||||
// Show cursor
|
||||
indicators::show_console_cursor(true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user