mirror of https://github.com/aria2/aria2
commit
16f458c9a4
|
@ -90,28 +90,31 @@ WinConsoleFile::WinConsoleFile(DWORD stdHandle)
|
||||||
bg_(0)
|
bg_(0)
|
||||||
{
|
{
|
||||||
if (supportsColor()) {
|
if (supportsColor()) {
|
||||||
|
int color;
|
||||||
CONSOLE_SCREEN_BUFFER_INFO info;
|
CONSOLE_SCREEN_BUFFER_INFO info;
|
||||||
GetConsoleScreenBufferInfo(handle(), &info);
|
GetConsoleScreenBufferInfo(handle(), &info);
|
||||||
bold_ = info.wAttributes & FOREGROUND_INTENSITY;
|
bold_ = info.wAttributes & FOREGROUND_INTENSITY;
|
||||||
underline_ = info.wAttributes & BACKGROUND_INTENSITY;
|
underline_ = info.wAttributes & BACKGROUND_INTENSITY;
|
||||||
int fgcolor = info.wAttributes &
|
color = info.wAttributes &
|
||||||
(FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
|
(FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
|
||||||
for (int fg = 0; fg < kForegroundSize; fg++) {
|
for (int fg = 0; fg < kForegroundSize; fg++) {
|
||||||
if (kForeground[fg] == fgcolor) {
|
if (kForeground[fg] == color) {
|
||||||
fg_ = fg;
|
fg_ = fg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int bgcolor = info.wAttributes &
|
color = info.wAttributes &
|
||||||
(BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED);
|
(BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED);
|
||||||
for (int bg = 0; bg < kBackgroundSize; bg++) {
|
for (int bg = 0; bg < kBackgroundSize; bg++) {
|
||||||
if (kBackground[bg] == bgcolor) {
|
if (kBackground[bg] == color) {
|
||||||
bg_ = bg;
|
bg_ = bg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defbold_ = bold_;
|
||||||
|
defunderline_ = underline_;
|
||||||
deffg_ = fg_;
|
deffg_ = fg_;
|
||||||
defbg_ = bg_;
|
defbg_ = bg_;
|
||||||
}
|
}
|
||||||
|
@ -216,9 +219,11 @@ size_t WinConsoleFile::writeColorful(const std::wstring& str)
|
||||||
}
|
}
|
||||||
for (const int a : args) {
|
for (const int a : args) {
|
||||||
if (a == 0) {
|
if (a == 0) {
|
||||||
|
bold_ = defbold_;
|
||||||
|
underline_ = defunderline_;
|
||||||
|
reverse_ = false;
|
||||||
fg_ = deffg_;
|
fg_ = deffg_;
|
||||||
bg_ = defbg_;
|
bg_ = defbg_;
|
||||||
bold_ = underline_ = reverse_ = false;
|
|
||||||
}
|
}
|
||||||
else if (30 <= a && a <= 37) {
|
else if (30 <= a && a <= 37) {
|
||||||
fg_ = a - 30;
|
fg_ = a - 30;
|
||||||
|
|
|
@ -55,8 +55,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DWORD stdHandle_;
|
DWORD stdHandle_;
|
||||||
bool bold_;
|
bool bold_, defbold_;
|
||||||
bool underline_;
|
bool underline_, defunderline_;
|
||||||
bool reverse_;
|
bool reverse_;
|
||||||
WORD fg_, deffg_;
|
WORD fg_, deffg_;
|
||||||
WORD bg_, defbg_;
|
WORD bg_, defbg_;
|
||||||
|
|
Loading…
Reference in New Issue