summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkwkam <kwkam@users.noreply.github.com>2016-02-13 16:01:41 +0800
committerkwkam <kwkam@users.noreply.github.com>2016-02-13 16:01:41 +0800
commit1c573c970831c368942d9173eb27d944aa3faaf8 (patch)
tree8fea13e67411a61d9298ce8ec3600d5c4fa575b1
parent25ae17b4905ed8e9f58f38a53197bb0c4b93405c (diff)
src/WinConsoleFile.cc: fix colour
Try to make it less confusing
-rw-r--r--src/WinConsoleFile.cc37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/WinConsoleFile.cc b/src/WinConsoleFile.cc
index 9300b105..327eca6a 100644
--- a/src/WinConsoleFile.cc
+++ b/src/WinConsoleFile.cc
@@ -86,34 +86,33 @@ WinConsoleFile::WinConsoleFile(DWORD stdHandle)
bold_(false),
underline_(false),
reverse_(false),
- deffg_(FOREGROUND_WHITE),
- defbg_(BACKGROUND_BLACK)
+ fg_(7),
+ bg_(0)
{
if (supportsColor()) {
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(handle(), &info);
- deffg_ = info.wAttributes &
- (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
- defbg_ = info.wAttributes &
- (BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED);
bold_ = info.wAttributes & FOREGROUND_INTENSITY;
underline_ = info.wAttributes & BACKGROUND_INTENSITY;
- }
-
- for (int i = 0; i < kForegroundSize; i++) {
- if (deffg_ == kForeground[i]) {
- deffg_ = i;
- break;
+ int fgcolor = info.wAttributes &
+ (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
+ for (int fg = 0; fg < kForegroundSize; fg++) {
+ if (kForeground[fg] == fgcolor) {
+ fg_ = fg;
+ break;
+ }
}
- }
- for (int i = 0; i < kBackgroundSize; i++) {
- if (defbg_ == kBackground[i]) {
- defbg_ = i;
- break;
+ int bgcolor = info.wAttributes &
+ (BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED);
+ for (int bg = 0; bg < kBackgroundSize; bg++) {
+ if (kBackground[bg] == bgcolor) {
+ bg_ = bg;
+ break;
+ }
}
}
- fg_ = deffg_;
- bg_ = defbg_;
+ deffg_ = fg_;
+ defbg_ = bg_;
}
bool WinConsoleFile::supportsColor()