tmp
This commit is contained in:
parent
3ca661f9e6
commit
5528c948e1
@ -63,10 +63,11 @@ void gctl::progress_bar::set_frequency_update(unsigned long frequency_update_)
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::progress_bar::set_style(const char* unit_bar_, const char* unit_space_)
|
||||
void gctl::progress_bar::set_style(const char* unit_bar_, const char* unit_space_, bar_color_e c)
|
||||
{
|
||||
unit_bar = unit_bar_;
|
||||
unit_space = unit_space_;
|
||||
color = c;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -130,9 +131,15 @@ void gctl::progress_bar::progressed(unsigned long idx_)
|
||||
// display progress bar
|
||||
*out << " " << description << " |";
|
||||
|
||||
for(int bar_length=0;bar_length<=bar_size-1;++bar_length){
|
||||
if(bar_length*percent_per_unit_bar<progress_percent){
|
||||
*out << unit_bar;
|
||||
for(int bar_length=0;bar_length<=bar_size-1;++bar_length)
|
||||
{
|
||||
if(bar_length*percent_per_unit_bar<progress_percent)
|
||||
{
|
||||
if (color == Green) *out << GCTL_BOLDGREEN << unit_bar << GCTL_RESET;
|
||||
else if (color == Red) *out << GCTL_BOLDRED << unit_bar << GCTL_RESET;
|
||||
else if (color == Blue) *out << GCTL_BOLDBLUE << unit_bar << GCTL_RESET;
|
||||
else if (color == Yellow) *out << GCTL_BOLDYELLOW << unit_bar << GCTL_RESET;
|
||||
else *out << GCTL_BOLD << unit_bar << GCTL_RESET;
|
||||
}
|
||||
else{
|
||||
*out << unit_space;
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#include "../core/exceptions.h"
|
||||
#include "stream_t.h"
|
||||
|
||||
//进度条宏定义
|
||||
#define TOTAL_PERCENTAGE 100.0 ///< 设置总的百分比为100%。
|
||||
@ -48,6 +48,14 @@
|
||||
|
||||
namespace gctl
|
||||
{
|
||||
enum bar_color_e
|
||||
{
|
||||
Green,
|
||||
Red,
|
||||
Blue,
|
||||
Yellow,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 终端显示进度条的类。
|
||||
* @warning 这个类是一个在终端显示进度的通用类型。
|
||||
@ -84,8 +92,9 @@ namespace gctl
|
||||
*
|
||||
* @param[in] unit_bar_ 字符串,已达到进度的符号。
|
||||
* @param[in] unit_space_ 字符串,未达到进度的符号。
|
||||
* @param[in] c 进度条颜色(可选项为 Green Red Yellow Blue)
|
||||
*/
|
||||
void set_style(const char* unit_bar_, const char* unit_space_);
|
||||
void set_style(const char* unit_bar_, const char* unit_space_, bar_color_e c = Green);
|
||||
/**
|
||||
* @brief 更新当前已达到的进度值。
|
||||
*
|
||||
@ -100,6 +109,7 @@ namespace gctl
|
||||
void progressed_simple(unsigned long idx_);
|
||||
|
||||
protected:
|
||||
bar_color_e color;
|
||||
unsigned long n;
|
||||
unsigned int desc_width;
|
||||
unsigned long frequency_update;
|
||||
@ -113,6 +123,6 @@ namespace gctl
|
||||
int get_console_width();
|
||||
int get_bar_length();
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _GCTL_PROGRESS_BAR_H
|
@ -51,6 +51,7 @@
|
||||
#define GCTL_MOVERIGHT(os, x) do {os << "\033[" << x << "C";} while (0); ///< 终端光标右移x列
|
||||
#define GCTL_MOVELEFT(os, x) do {os << "\033[" << x << "D";} while (0); ///< 终端光标左移x列
|
||||
#define GCTL_MOVETO(os, r, c) do {os << "\033[" << c << ";" << r << "H";} while (0); ///< 终端光标移动至r行c列位置
|
||||
|
||||
namespace gctl
|
||||
{
|
||||
template <typename ObjValType>
|
||||
|
Loading…
Reference in New Issue
Block a user