Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 1 | // 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 Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 30 | clr::reset::operator const char*() { return "\e[0m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 31 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 32 | clr::grey::operator const char*() { return "\e[1;30m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 33 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 34 | clr::red::operator const char*() { return "\e[31m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 35 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 36 | clr::green::operator const char*() { return "\e[32m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 37 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 38 | clr::yellow::operator const char*() { return "\e[33m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 39 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 40 | clr::blue::operator const char*() { return "\e[34m"; } |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 41 | #elif defined(SPIRV_WINDOWS) |
| 42 | #include <Windows.h> |
| 43 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 44 | clr::reset::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 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 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 54 | clr::grey::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 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 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 64 | clr::red::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 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 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 74 | clr::green::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 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 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 84 | clr::yellow::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 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 | |
Lei Zhang | 1a0334e | 2015-11-02 09:41:20 -0500 | [diff] [blame] | 94 | clr::blue::operator const char*() { |
Kenneth Benzie (Benie) | 83e5a29 | 2015-05-22 18:26:19 +0100 | [diff] [blame] | 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 |