mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-16 04:18:51 +08:00
Update README.md
This commit is contained in:
43
README.md
43
README.md
@@ -36,6 +36,7 @@
|
||||
* [Multi Progress](#multiprogress)
|
||||
* [Dynamic Progress](#dynamicprogress)
|
||||
* [Progress Spinner](#progress-spinner)
|
||||
* [Decremental Progress](#decremental-progress)
|
||||
* [Working with Iterables](#working-with-iterables)
|
||||
* [Unicode Support](#unicode-support)
|
||||
* [Building Samples](#building-samples)
|
||||
@@ -626,6 +627,48 @@ int main() {
|
||||
}
|
||||
```
|
||||
|
||||
## Decremental Progress
|
||||
|
||||
`indicators` allows you to easily control the progress direction, i.e., incremental or decremental progress by using `option::ProgressType`. To program a countdown progress bar, use `option::ProgressType::decremental`
|
||||
|
||||
<p align="center">
|
||||
<img src="img/progress_bar_countdown.gif"/>
|
||||
</p>
|
||||
|
||||
```cpp
|
||||
#include <chrono>
|
||||
#include <indicators/progress_bar.hpp>
|
||||
#include <thread>
|
||||
using namespace indicators;
|
||||
|
||||
int main() {
|
||||
|
||||
ProgressBar bar{option::BarWidth{50},
|
||||
option::ProgressType{ProgressType::decremental},
|
||||
option::Start{"["},
|
||||
option::Fill{"■"},
|
||||
option::Lead{"■"},
|
||||
option::Remainder{"-"},
|
||||
option::End{"]"},
|
||||
option::PostfixText{"Reverting System Restore"},
|
||||
option::ForegroundColor{Color::yellow},
|
||||
option::FontStyles{std::vector<FontStyle>{FontStyle::bold}}};
|
||||
|
||||
// Update bar state
|
||||
while (true) {
|
||||
bar.tick();
|
||||
if (bar.is_completed())
|
||||
break;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
|
||||
std::cout << termcolor::bold << termcolor::white
|
||||
<< "Task Failed Successfully\n" << termcolor::reset;
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## Working with Iterables
|
||||
|
||||
If you'd like to use progress bars to indicate progress while iterating over iterables, e.g., a list of numbers, this
|
||||
|
||||
Reference in New Issue
Block a user