blob: 455f2db303812a3e9a8ae98326155a4cd5776018 [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)
Lei Zhang1a0334e2015-11-02 09:41:20 -050030clr::reset::operator const char*() { return "\e[0m"; }
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010031
Lei Zhang1a0334e2015-11-02 09:41:20 -050032clr::grey::operator const char*() { return "\e[1;30m"; }
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010033
Lei Zhang1a0334e2015-11-02 09:41:20 -050034clr::red::operator const char*() { return "\e[31m"; }
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010035
Lei Zhang1a0334e2015-11-02 09:41:20 -050036clr::green::operator const char*() { return "\e[32m"; }
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010037
Lei Zhang1a0334e2015-11-02 09:41:20 -050038clr::yellow::operator const char*() { return "\e[33m"; }
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010039
Lei Zhang1a0334e2015-11-02 09:41:20 -050040clr::blue::operator const char*() { return "\e[34m"; }
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010041#elif defined(SPIRV_WINDOWS)
42#include <Windows.h>
43
Lei Zhang1a0334e2015-11-02 09:41:20 -050044clr::reset::operator const char*() {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010045 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
Lei Zhang1a0334e2015-11-02 09:41:20 -050054clr::grey::operator const char*() {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010055 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
Lei Zhang1a0334e2015-11-02 09:41:20 -050064clr::red::operator const char*() {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010065 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
Lei Zhang1a0334e2015-11-02 09:41:20 -050074clr::green::operator const char*() {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010075 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
Lei Zhang1a0334e2015-11-02 09:41:20 -050084clr::yellow::operator const char*() {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010085 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
Lei Zhang1a0334e2015-11-02 09:41:20 -050094clr::blue::operator const char*() {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010095 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