mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-14 11:18:51 +08:00
Initial commit
This commit is contained in:
@@ -4,9 +4,7 @@ if(DEFINED PROJECT_NAME)
|
||||
set(INDICATORS_SUBPROJECT ON)
|
||||
endif()
|
||||
|
||||
project(indicators VERSION 1.8.0 LANGUAGES CXX
|
||||
HOMEPAGE_URL "https://github.com/p-ranav/indicators"
|
||||
DESCRIPTION "Activity Indicators for Modern C++")
|
||||
project(indicators VERSION 1.8.0 LANGUAGES CXX)
|
||||
|
||||
if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
|
||||
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
void *>::type = nullptr>
|
||||
explicit BlockProgressBar(Args &&... args)
|
||||
: settings_(details::get<details::ProgressBarOption::foreground_color>(
|
||||
option::ForegroundColor{Color::white}, std::forward<Args>(args)...),
|
||||
option::ForegroundColor{Color::unspecified}, std::forward<Args>(args)...),
|
||||
details::get<details::ProgressBarOption::bar_width>(option::BarWidth{100},
|
||||
std::forward<Args>(args)...),
|
||||
details::get<details::ProgressBarOption::start>(option::Start{"["},
|
||||
@@ -188,7 +188,7 @@ private:
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(now - start_time_point_);
|
||||
|
||||
std::cout << termcolor::bold;
|
||||
if (get_value<details::ProgressBarOption::foreground_color>() != Color::unspecified)
|
||||
details::set_stream_color(std::cout, get_value<details::ProgressBarOption::foreground_color>());
|
||||
std::cout << get_value<details::ProgressBarOption::prefix_text>();
|
||||
std::cout << get_value<details::ProgressBarOption::start>();
|
||||
|
||||
@@ -28,5 +28,5 @@ SOFTWARE.
|
||||
#include <indicators/termcolor.hpp>
|
||||
|
||||
namespace indicators {
|
||||
enum class Color { grey, red, green, yellow, blue, magenta, cyan, white };
|
||||
enum class Color { grey, red, green, yellow, blue, magenta, cyan, white, unspecified };
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
details::get<details::ProgressBarOption::saved_start_time>(
|
||||
option::SavedStartTime{false}, std::forward<Args>(args)...),
|
||||
details::get<details::ProgressBarOption::foreground_color>(
|
||||
option::ForegroundColor{Color::white}, std::forward<Args>(args)...)) {}
|
||||
option::ForegroundColor{Color::unspecified}, std::forward<Args>(args)...)) {}
|
||||
|
||||
template <typename T, details::ProgressBarOption id>
|
||||
void set_option(details::Setting<T, id> &&setting) {
|
||||
@@ -201,7 +201,7 @@ private:
|
||||
if (!get_value<details::ProgressBarOption::completed>())
|
||||
elapsed_ = std::chrono::duration_cast<std::chrono::nanoseconds>(now - start_time_point_);
|
||||
|
||||
std::cout << termcolor::bold;
|
||||
if (get_value<details::ProgressBarOption::foreground_color>() != Color::unspecified)
|
||||
details::set_stream_color(std::cout, get_value<details::ProgressBarOption::foreground_color>());
|
||||
|
||||
for (auto &style : get_value<details::ProgressBarOption::font_styles>())
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
void *>::type = nullptr>
|
||||
explicit ProgressSpinner(Args &&... args)
|
||||
: settings_(details::get<details::ProgressBarOption::foreground_color>(
|
||||
option::ForegroundColor{Color::white}, std::forward<Args>(args)...),
|
||||
option::ForegroundColor{Color::unspecified}, std::forward<Args>(args)...),
|
||||
details::get<details::ProgressBarOption::prefix_text>(
|
||||
option::PrefixText{}, std::forward<Args>(args)...),
|
||||
details::get<details::ProgressBarOption::postfix_text>(
|
||||
@@ -182,7 +182,7 @@ private:
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(now - start_time_point_);
|
||||
|
||||
std::cout << termcolor::bold;
|
||||
if (get_value<details::ProgressBarOption::foreground_color>() != Color::unspecified)
|
||||
details::set_stream_color(std::cout, get_value<details::ProgressBarOption::foreground_color>());
|
||||
std::cout << get_value<details::ProgressBarOption::prefix_text>();
|
||||
if (get_value<details::ProgressBarOption::spinner_show>())
|
||||
|
||||
@@ -12,6 +12,7 @@ int main() {
|
||||
indicators::option::End{" ]"},
|
||||
indicators::option::PostfixText{"Getting started"},
|
||||
indicators::option::ForegroundColor{indicators::Color::green},
|
||||
indicators::option::FontStyles{std::vector<indicators::FontStyle>{indicators::FontStyle::bold}}
|
||||
};
|
||||
|
||||
// Update bar state
|
||||
|
||||
Reference in New Issue
Block a user