mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-14 11:18:51 +08:00
Clang format
This commit is contained in:
@@ -107,7 +107,7 @@ public:
|
|||||||
size_t current() {
|
size_t current() {
|
||||||
std::unique_lock<std::mutex> lock{_mutex};
|
std::unique_lock<std::mutex> lock{_mutex};
|
||||||
return std::min(static_cast<size_t>(_progress), size_t(100));
|
return std::min(static_cast<size_t>(_progress), size_t(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_completed() const { return _completed; }
|
bool is_completed() const { return _completed; }
|
||||||
|
|
||||||
|
|||||||
@@ -36,32 +36,31 @@ namespace indicators {
|
|||||||
|
|
||||||
template <typename Indicator, size_t count> class MultiProgress {
|
template <typename Indicator, size_t count> class MultiProgress {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
template <typename... Indicators,
|
template <typename... Indicators,
|
||||||
typename = typename std::enable_if<(sizeof...(Indicators) == count)>::type
|
typename = typename std::enable_if<(sizeof...(Indicators) == count)>::type>
|
||||||
>
|
explicit MultiProgress(Indicators &... bars) {
|
||||||
explicit MultiProgress(Indicators&... bars) {
|
|
||||||
_bars = {bars...};
|
_bars = {bars...};
|
||||||
for (auto& bar: _bars) {
|
for (auto &bar : _bars) {
|
||||||
bar.get()._multi_progress_mode = true;
|
bar.get()._multi_progress_mode = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t index>
|
template <size_t index>
|
||||||
typename std::enable_if<(index >=0 && index < count), void>::type set_progress(float value) {
|
typename std::enable_if<(index >= 0 && index < count), void>::type set_progress(float value) {
|
||||||
if (!_bars[index].get().is_completed())
|
if (!_bars[index].get().is_completed())
|
||||||
_bars[index].get().set_progress(value);
|
_bars[index].get().set_progress(value);
|
||||||
_print_progress();
|
_print_progress();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t index> typename std::enable_if<(index >=0 && index < count), void>::type tick() {
|
template <size_t index>
|
||||||
|
typename std::enable_if<(index >= 0 && index < count), void>::type tick() {
|
||||||
if (!_bars[index].get().is_completed())
|
if (!_bars[index].get().is_completed())
|
||||||
_bars[index].get().tick();
|
_bars[index].get().tick();
|
||||||
_print_progress();
|
_print_progress();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t index>
|
template <size_t index>
|
||||||
typename std::enable_if<(index >=0 && index < count), bool>::type is_completed() const {
|
typename std::enable_if<(index >= 0 && index < count), bool>::type is_completed() const {
|
||||||
return _bars[index].get().is_completed();
|
return _bars[index].get().is_completed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public:
|
|||||||
size_t current() {
|
size_t current() {
|
||||||
std::unique_lock<std::mutex> lock{_mutex};
|
std::unique_lock<std::mutex> lock{_mutex};
|
||||||
return std::min(static_cast<size_t>(_progress), size_t(100));
|
return std::min(static_cast<size_t>(_progress), size_t(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_completed() const { return _completed; }
|
bool is_completed() const { return _completed; }
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ int main() {
|
|||||||
bar.set_bar_width(50);
|
bar.set_bar_width(50);
|
||||||
bar.start_bar_with("[");
|
bar.start_bar_with("[");
|
||||||
bar.fill_bar_progress_with("■");
|
bar.fill_bar_progress_with("■");
|
||||||
bar.lead_bar_progress_with("■");
|
bar.lead_bar_progress_with("■");
|
||||||
bar.fill_bar_remainder_with("-");
|
bar.fill_bar_remainder_with("-");
|
||||||
bar.end_bar_with(" ]");
|
bar.end_bar_with(" ]");
|
||||||
bar.set_postfix_text("Loading dependency 1/4");
|
bar.set_postfix_text("Loading dependency 1/4");
|
||||||
bar.set_foreground_color(indicators::Color::CYAN);
|
bar.set_foreground_color(indicators::Color::CYAN);
|
||||||
|
|
||||||
// Update bar state
|
// Update bar state
|
||||||
@@ -25,14 +25,14 @@ int main() {
|
|||||||
// do some work
|
// do some work
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(800));
|
std::this_thread::sleep_for(std::chrono::milliseconds(800));
|
||||||
|
|
||||||
bar.set_postfix_text("Loading dependency 2/4");
|
bar.set_postfix_text("Loading dependency 2/4");
|
||||||
|
|
||||||
bar.set_progress(30); // 30% done
|
bar.set_progress(30); // 30% done
|
||||||
|
|
||||||
// do some more work
|
// do some more work
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(700));
|
std::this_thread::sleep_for(std::chrono::milliseconds(700));
|
||||||
|
|
||||||
bar.set_postfix_text("Loading dependency 3/4");
|
bar.set_postfix_text("Loading dependency 3/4");
|
||||||
|
|
||||||
bar.set_progress(65); // 65% done
|
bar.set_progress(65); // 65% done
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ int main() {
|
|||||||
bar.mark_as_completed();
|
bar.mark_as_completed();
|
||||||
|
|
||||||
// Show cursor
|
// Show cursor
|
||||||
std::cout << "\e[?25h";
|
std::cout << "\e[?25h";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user