mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-12 17:58:55 +08:00
Added countdown progress bar sample
This commit is contained in:
BIN
img/progress_bar_countdown.gif
Normal file
BIN
img/progress_bar_countdown.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 502 KiB |
@@ -14,6 +14,9 @@ target_link_libraries(progress_bar_set_progress PRIVATE indicators::indicators)
|
||||
add_executable(progress_bar_tick progress_bar_tick.cpp)
|
||||
target_link_libraries(progress_bar_tick PRIVATE indicators::indicators)
|
||||
|
||||
add_executable(progress_bar_countdown progress_bar_countdown.cpp)
|
||||
target_link_libraries(progress_bar_countdown PRIVATE indicators::indicators)
|
||||
|
||||
add_executable(progress_bar_sstream progress_bar_sstream.cpp)
|
||||
target_link_libraries(progress_bar_sstream PRIVATE indicators::indicators)
|
||||
|
||||
|
||||
35
samples/progress_bar_countdown.cpp
Normal file
35
samples/progress_bar_countdown.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <chrono>
|
||||
#include <indicators/progress_bar.hpp>
|
||||
#include <thread>
|
||||
using namespace indicators;
|
||||
|
||||
int main() {
|
||||
|
||||
std::cout << "\n\n";
|
||||
|
||||
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;
|
||||
|
||||
std::cout << "\n\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user