Initial commit

This commit is contained in:
Pranav Srinivas Kumar
2020-04-06 11:10:41 -07:00
parent 07b9eede8a
commit 833e1cd6db
7 changed files with 13 additions and 14 deletions

View File

@@ -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")

View File

@@ -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,8 +188,8 @@ 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;
details::set_stream_color(std::cout, get_value<details::ProgressBarOption::foreground_color>());
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>();

View File

@@ -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 };
}

View File

@@ -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,8 +201,8 @@ private:
if (!get_value<details::ProgressBarOption::completed>())
elapsed_ = std::chrono::duration_cast<std::chrono::nanoseconds>(now - start_time_point_);
std::cout << termcolor::bold;
details::set_stream_color(std::cout, get_value<details::ProgressBarOption::foreground_color>());
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>())
details::set_font_style(std::cout, style);

View File

@@ -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,8 +182,8 @@ 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;
details::set_stream_color(std::cout, get_value<details::ProgressBarOption::foreground_color>());
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>())
std::cout << get_value<details::ProgressBarOption::spinner_states>()

View File

@@ -205,4 +205,4 @@ using HideBarWhenComplete =
using FontStyles =
details::Setting<std::vector<FontStyle>, details::ProgressBarOption::font_styles>;
} // namespace option
} // namespace indicators
} // namespace indicators

View File

@@ -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