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