mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-16 04:18:51 +08:00
Closes #22
This commit is contained in:
37
samples/progress_bar_sstream.cpp
Normal file
37
samples/progress_bar_sstream.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <chrono>
|
||||
#include <indicators/progress_bar.hpp>
|
||||
#include <thread>
|
||||
#include <sstream>
|
||||
|
||||
int main() {
|
||||
using namespace indicators;
|
||||
|
||||
std::stringstream os;
|
||||
|
||||
ProgressBar bar{
|
||||
option::BarWidth{50},
|
||||
option::Start{"["},
|
||||
option::Fill{"="},
|
||||
option::Lead{">"},
|
||||
option::Remainder{" "},
|
||||
option::End{"]"},
|
||||
option::PostfixText{"Getting started"},
|
||||
option::ForegroundColor{indicators::Color::green},
|
||||
option::FontStyles{
|
||||
std::vector<indicators::FontStyle>{indicators::FontStyle::bold}},
|
||||
option::Stream{os}
|
||||
};
|
||||
|
||||
// Update bar state
|
||||
while (true) {
|
||||
bar.tick();
|
||||
if (bar.is_completed())
|
||||
break;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
|
||||
std::cout << "Stream contents:\n";
|
||||
std::cout << os.str() << "\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user