mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-16 04:18:51 +08:00
Updated README
This commit is contained in:
39
README.md
39
README.md
@@ -216,8 +216,45 @@ All progress bars and spinners in `indicators` support showing time elapsed and
|
||||
|
||||
Below is an example for configuring this meter:
|
||||
|
||||
```cpp
|
||||
<p align="center">
|
||||
<img src="img/time_meter.gif"/>
|
||||
</p>
|
||||
|
||||
```cpp
|
||||
#include <chrono>
|
||||
#include <indicators/progress_bar.hpp>
|
||||
#include <thread>
|
||||
|
||||
int main() {
|
||||
indicators::ProgressBar bar;
|
||||
|
||||
// Configure the bar
|
||||
bar.set_bar_width(50);
|
||||
bar.start_bar_with(" [");
|
||||
bar.fill_bar_progress_with("█");
|
||||
bar.lead_bar_progress_with("█");
|
||||
bar.fill_bar_remainder_with("-");
|
||||
bar.end_bar_with("]");
|
||||
bar.set_prefix_text("Training Gaze Network 👀");
|
||||
bar.set_foreground_color(indicators::Color::YELLOW);
|
||||
|
||||
// Show time elapsed and remaining
|
||||
bar.show_elapsed_time();
|
||||
bar.show_remaining_time();
|
||||
|
||||
// Update bar state
|
||||
while (true) {
|
||||
bar.tick();
|
||||
if (bar.is_completed())
|
||||
break;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
}
|
||||
|
||||
// Show cursor
|
||||
std::cout << "\e[?25h";
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
# Block Progress Bar
|
||||
|
||||
BIN
img/time_meter.gif
Normal file
BIN
img/time_meter.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
@@ -13,3 +13,6 @@ target_link_libraries(progress_bar_tick PRIVATE indica::indica)
|
||||
|
||||
add_executable(progress_spinner progress_spinner.cpp)
|
||||
target_link_libraries(progress_spinner PRIVATE indica::indica)
|
||||
|
||||
add_executable(time_meter time_meter.cpp)
|
||||
target_link_libraries(time_meter PRIVATE indica::indica)
|
||||
|
||||
34
samples/time_meter.cpp
Normal file
34
samples/time_meter.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <chrono>
|
||||
#include <indicators/progress_bar.hpp>
|
||||
#include <thread>
|
||||
|
||||
int main() {
|
||||
indicators::ProgressBar bar;
|
||||
|
||||
// Configure the bar
|
||||
bar.set_bar_width(50);
|
||||
bar.start_bar_with(" [");
|
||||
bar.fill_bar_progress_with("█");
|
||||
bar.lead_bar_progress_with("█");
|
||||
bar.fill_bar_remainder_with("-");
|
||||
bar.end_bar_with("]");
|
||||
bar.set_prefix_text("Training Gaze Network 👀");
|
||||
bar.set_foreground_color(indicators::Color::YELLOW);
|
||||
|
||||
// Show time elapsed and remaining
|
||||
bar.show_elapsed_time();
|
||||
bar.show_remaining_time();
|
||||
|
||||
// Update bar state
|
||||
while (true) {
|
||||
bar.tick();
|
||||
if (bar.is_completed())
|
||||
break;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
}
|
||||
|
||||
// Show cursor
|
||||
std::cout << "\e[?25h";
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user