aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/patched/replxx/src/windows.hxx
blob: 243f41cb7e8b6c60fd4f2217abda097db05e0ec1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef REPLXX_WINDOWS_HXX_INCLUDED
#define REPLXX_WINDOWS_HXX_INCLUDED 1

#include <conio.h>
#include <windows.h>
#include <io.h>

namespace replxx {

static const int FOREGROUND_WHITE =
		FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
static const int BACKGROUND_WHITE =
		BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE;
static const int INTENSITY = FOREGROUND_INTENSITY | BACKGROUND_INTENSITY;

class WinAttributes {
 public:
	WinAttributes() {
		CONSOLE_SCREEN_BUFFER_INFO info;
		GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info);
		_defaultAttribute = info.wAttributes & INTENSITY;
		_defaultColor = info.wAttributes & FOREGROUND_WHITE;
		_defaultBackground = info.wAttributes & BACKGROUND_WHITE;

		_consoleAttribute = _defaultAttribute;
		_consoleColor = _defaultColor | _defaultBackground;
	}

 public:
	int _defaultAttribute;
	int _defaultColor;
	int _defaultBackground;

	int _consoleAttribute;
	int _consoleColor;
};

int win_write( HANDLE, bool, char const*, int );

extern WinAttributes WIN_ATTR;

}

#endif