1 /*! 2 * \file include/TFEL/Utilities/TerminalColors.hxx 3 * \brief This file implements the TerminalColors class. 4 * \author Thomas Helfer 5 * \date 26 Jul 2006 6 * \copyright Copyright (C) 2006-2018 CEA/DEN, EDF R&D. All rights 7 * reserved. 8 * This project is publicly released under either the GNU GPL Licence 9 * or the CECILL-A licence. A copy of thoses licences are delivered 10 * with the sources of TFEL. CEA or EDF may also distribute this 11 * project under specific licensing conditions. 12 */ 13 14 #ifndef LIB_TFEL_TERMINAL_COLORS_HXX 15 #define LIB_TFEL_TERMINAL_COLORS_HXX 16 17 #include"TFEL/Config/TFELConfig.hxx" 18 19 namespace tfel{ 20 21 namespace utilities{ 22 23 /*! 24 * \class TerminalColors 25 * \brief This class contains char sequence corresponding to colors. 26 * This enables to write ouput messages in color in the terminal. 27 * \author Thomas Helfer 28 * \date 26 Jul 2006 29 */ 30 struct TFELUTILITIES_VISIBILITY_EXPORT TerminalColors 31 { 32 /*! 33 * \brief char sequence correponding to black. 34 * \code 35 * cout.write(TerminalColors::Black,sizeof(TerminalColors::Black)); 36 * \endcode 37 */ 38 #if !( defined _WIN32 || defined _WIN64 ||defined __CYGWIN__) 39 static constexpr char Black[5] = {033, '[', '3', '0', 'm'}; 40 #else 41 static const char Black[5]; 42 #endif 43 /*! 44 * \brief char sequence correponding to red. 45 * \code 46 * cout.write(TerminalColors::Red,sizeof(TerminalColors::Red)); 47 * \endcode 48 */ 49 #if !( defined _WIN32 || defined _WIN64 ||defined __CYGWIN__) 50 static constexpr char Red[5] = {033, '[', '3', '1', 'm'}; 51 #else 52 static const char Red[5]; 53 #endif 54 /*! 55 * \brief char sequence correponding to green. 56 * \code 57 * cout.write(TerminalColors::Green,sizeof(TerminalColors::Greeb)); 58 * \endcode 59 */ 60 #if !( defined _WIN32 || defined _WIN64 ||defined __CYGWIN__) 61 static constexpr char Green[5] = {033, '[', '3', '2', 'm'}; 62 #else 63 static const char Green[5]; 64 #endif 65 /*! 66 * \brief char sequence correponding to yellow. 67 * \code 68 * cout.write(TerminalColors::Yellow,sizeof(TerminalColors::Yellow)); 69 * \endcode 70 */ 71 #if !( defined _WIN32 || defined _WIN64 ||defined __CYGWIN__) 72 static constexpr char Yellow[5] = {033, '[', '3', '3', 'm'}; 73 #else 74 static const char Yellow[5]; 75 #endif 76 /*! 77 * \brief char sequence correponding to blue. 78 * \code 79 * cout.write(TerminalColors::Blue,sizeof(TerminalColors::Blue)); 80 * \endcode 81 */ 82 #if !( defined _WIN32 || defined _WIN64 ||defined __CYGWIN__) 83 static constexpr char Blue[5] = {033, '[', '3', '4', 'm'}; 84 #else 85 static const char Blue[5]; 86 #endif 87 /*! 88 * \brief char sequence correponding to purple. 89 * \code 90 * cout.write(TerminalColors::Purple,sizeof(TerminalColors::Purple)); 91 * \endcode 92 */ 93 #if !( defined _WIN32 || defined _WIN64 ||defined __CYGWIN__) 94 static constexpr char Purple[5] = {033, '[', '3', '5', 'm'}; 95 #else 96 static const char Purple[5]; 97 #endif 98 /*! 99 * \brief char sequence correponding to light blue. 100 * \code 101 * cout.write(TerminalColors::LightBlue,sizeof(TerminalColors::LightBlue)); 102 * \endcode 103 */ 104 #if !( defined _WIN32 || defined _WIN64 ||defined __CYGWIN__) 105 static constexpr char LightBlue[5] = {033, '[', '3', '6', 'm'}; 106 #else 107 static const char LightBlue[5]; 108 #endif 109 /*! 110 * \brief char sequence correponding to white. 111 * \code 112 * cout.write(TerminalColors::White,sizeof(TerminalColors::White)); 113 * \endcode 114 */ 115 #if !( defined _WIN32 || defined _WIN64 ||defined __CYGWIN__) 116 static constexpr char White[5] = {033, '[', '3', '7', 'm'}; 117 #else 118 static const char White[5]; 119 #endif 120 /*! 121 * \brief char sequence correponding to the reset command. 122 * This causes the terminal to go back to its initial state. 123 * \code 124 * cout.write(TerminalColors::Reset,sizeof(TerminalColors::Reset)); 125 * \endcode 126 */ 127 #if !( defined _WIN32 || defined _WIN64 ||defined __CYGWIN__) 128 static constexpr char Reset[4] = {033, '[', 'm', 017}; 129 #else 130 static const char Reset[4]; 131 #endif 132 }; 133 134 } // end of namespace utilities 135 136 } // end of namespace tfel 137 138 #endif /* LIB_TFEL_TERMINAL_COLORS_HXX */ 139 140