mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-13 18:48:53 +08:00
Update README.md
This commit is contained in:
50
README.md
50
README.md
@@ -27,24 +27,6 @@ To introduce a progress bar in your application, include `indicators/progress_ba
|
|||||||
```cpp
|
```cpp
|
||||||
#include <indicators/progress_bar.hpp>
|
#include <indicators/progress_bar.hpp>
|
||||||
|
|
||||||
int main() {
|
|
||||||
indicators::ProgressBar bar;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Here's the general structure of a progress bar:
|
|
||||||
|
|
||||||
```
|
|
||||||
<prefix_text> <bar_start> <fill> <lead> <remaining> <bar_end> <progress_percentage>? <postfix_text>
|
|
||||||
^^^^^^^^^^^^^^^^^^ Bar Width ^^^^^^^^^^^^^^^^^^ ^^^^^ Show/Hide ^^^^^
|
|
||||||
```
|
|
||||||
|
|
||||||
Each of these elements (and more) can be configured using the ProgressBar API. Here's an example configuration:
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
#include <indicators/progress_bar.hpp>
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
indicators::ProgressBar bar;
|
indicators::ProgressBar bar;
|
||||||
|
|
||||||
@@ -64,7 +46,14 @@ int main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Now that the bar is configured, let's update the state of the bar. The amount of progress in ProgressBar is maintained as a float in range `[0, 100]`. When progress reaches 100, the progression is complete.
|
Here's the general structure of a progress bar:
|
||||||
|
|
||||||
|
```
|
||||||
|
<prefix_text> <bar_start> <fill> <lead> <remaining> <bar_end> <progress_percentage>? <postfix_text>
|
||||||
|
^^^^^^^^^^^^^^^^^^ Bar Width ^^^^^^^^^^^^^^^^^^ ^^^^^ Show/Hide ^^^^^
|
||||||
|
```
|
||||||
|
|
||||||
|
The amount of progress in ProgressBar is maintained as a float in range `[0, 100]`. When progress reaches 100, the progression is complete.
|
||||||
|
|
||||||
From application-level code, there are two ways in which you can update this progress:
|
From application-level code, there are two ways in which you can update this progress:
|
||||||
|
|
||||||
@@ -267,23 +256,6 @@ To introduce a progress spinner in your application, include `indicators/progres
|
|||||||
```cpp
|
```cpp
|
||||||
#include <indicators/progress_spinner.hpp>
|
#include <indicators/progress_spinner.hpp>
|
||||||
|
|
||||||
int main() {
|
|
||||||
indicators::ProgressSpinner spinner;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Here's the general structure of a progress spinner:
|
|
||||||
|
|
||||||
```
|
|
||||||
<prefix_text> <spinner> <progress_percentage>? <postfix_text>
|
|
||||||
```
|
|
||||||
|
|
||||||
Each of these elements (and more) can be configured using the ProgressSpinner API. Here's an example configuration:
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
#include <indicators/progress_spinner.hpp>
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
indicators::ProgressSpinner spinner;
|
indicators::ProgressSpinner spinner;
|
||||||
|
|
||||||
@@ -299,6 +271,12 @@ int main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Here's the general structure of a progress spinner:
|
||||||
|
|
||||||
|
```
|
||||||
|
<prefix_text> <spinner> <progress_percentage>? <postfix_text>
|
||||||
|
```
|
||||||
|
|
||||||
ProgressSpinner has a vector of strings: `spinner_states`. At each update, the spinner will pick the next string from this sequence to print to the console. The spinner state can be updated similarly to ProgressBars: Using either `tick()` or `set_progress(value)`.
|
ProgressSpinner has a vector of strings: `spinner_states`. At each update, the spinner will pick the next string from this sequence to print to the console. The spinner state can be updated similarly to ProgressBars: Using either `tick()` or `set_progress(value)`.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user