blob: 6ee3b01d4a30beadd761d58425258542d458cf22 [file] [log] [blame]
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01001// Copyright (c) 2015 The Khronos Group Inc.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a
4// copy of this software and/or associated documentation files (the
5// "Materials"), to deal in the Materials without restriction, including
6// without limitation the rights to use, copy, modify, merge, publish,
7// distribute, sublicense, and/or sell copies of the Materials, and to
8// permit persons to whom the Materials are furnished to do so, subject to
9// the following conditions:
10//
11// The above copyright notice and this permission notice shall be included
12// in all copies or substantial portions of the Materials.
13//
14// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
15// KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
16// SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
17// https://www.khronos.org/registry/
18//
19// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
26
27#include "print.h"
28
29#if defined(SPIRV_LINUX) || defined(SPIRV_MAC)
30clr::reset::operator const char *() { return "\e[0m"; }
31
32clr::grey::operator const char *() { return "\e[1;30m"; }
33
34clr::red::operator const char *() { return "\e[31m"; }
35
36clr::green::operator const char *() { return "\e[32m"; }
37
38clr::yellow::operator const char *() { return "\e[33m"; }
39
40clr::blue::operator const char *() { return "\e[34m"; }
41#elif defined(SPIRV_WINDOWS)
42#include <Windows.h>
43
44clr::reset::operator const char *() {
45 const DWORD color = 0Xf;
46 HANDLE hConsole;
47 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
48 SetConsoleTextAttribute(hConsole, color);
49 hConsole = GetStdHandle(STD_ERROR_HANDLE);
50 SetConsoleTextAttribute(hConsole, color);
51 return "";
52}
53
54clr::grey::operator const char *() {
55 const DWORD color = 0x8;
56 HANDLE hConsole;
57 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
58 SetConsoleTextAttribute(hConsole, color);
59 hConsole = GetStdHandle(STD_ERROR_HANDLE);
60 SetConsoleTextAttribute(hConsole, color);
61 return "";
62}
63
64clr::red::operator const char *() {
65 const DWORD color = 0x4;
66 HANDLE hConsole;
67 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
68 SetConsoleTextAttribute(hConsole, color);
69 hConsole = GetStdHandle(STD_ERROR_HANDLE);
70 SetConsoleTextAttribute(hConsole, color);
71 return "";
72}
73
74clr::green::operator const char *() {
75 const DWORD color = 0x2;
76 HANDLE hConsole;
77 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
78 SetConsoleTextAttribute(hConsole, color);
79 hConsole = GetStdHandle(STD_ERROR_HANDLE);
80 SetConsoleTextAttribute(hConsole, color);
81 return "";
82}
83
84clr::yellow::operator const char *() {
85 const DWORD color = 0x6;
86 HANDLE hConsole;
87 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
88 SetConsoleTextAttribute(hConsole, color);
89 hConsole = GetStdHandle(STD_ERROR_HANDLE);
90 SetConsoleTextAttribute(hConsole, color);
91 return "";
92}
93
94clr::blue::operator const char *() {
95 const DWORD color = 0x1;
96 HANDLE hConsole;
97 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
98 SetConsoleTextAttribute(hConsole, color);
99 hConsole = GetStdHandle(STD_ERROR_HANDLE);
100 SetConsoleTextAttribute(hConsole, color);
101 return "";
102}
103#endif