| 1 | #cxx . . $ `<file>/io/ansiescapecodes.h`/ifndef IOUTILITIES_ANSIESCAPECODES |
| 2 | #define IOUTILITIES_ANSIESCAPECODEScxx . . $ `io/ansiescapecodes.h:2:9`! |
| 3 | |
| 4 | #include "../global.h"cxx . . $ `<file>/global.h`/ |
| 5 | #include "../misc/traits.h"cxx . . $ `<file>/misc/traits.h`/ |
| 6 | |
| 7 | #include <ostream> |
| 8 | #include <string_view> |
| 9 | #include <tuple> |
| 10 | |
| 11 | namespace CppUtilitiescxx . . $ CppUtilities/ { |
| 12 | namespace EscapeCodescxx . . $ CppUtilities/EscapeCodes/ { |
| 13 | |
| 14 | extern CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! bool enabledcxx . . $ CppUtilities/EscapeCodes/enabled.; |
| 15 | |
| 16 | enum class Colorcxx . . $ CppUtilities/EscapeCodes/Color# : char { Blackcxx . . $ CppUtilities/EscapeCodes/Color#Black. = '0', Redcxx . . $ CppUtilities/EscapeCodes/Color#Red., Greencxx . . $ CppUtilities/EscapeCodes/Color#Green., Yellowcxx . . $ CppUtilities/EscapeCodes/Color#Yellow., Bluecxx . . $ CppUtilities/EscapeCodes/Color#Blue., Purplecxx . . $ CppUtilities/EscapeCodes/Color#Purple., Cyancxx . . $ CppUtilities/EscapeCodes/Color#Cyan., Whitecxx . . $ CppUtilities/EscapeCodes/Color#White. }; |
| 17 | |
| 18 | enum class ColorContextcxx . . $ CppUtilities/EscapeCodes/ColorContext# : char { Foregroundcxx . . $ CppUtilities/EscapeCodes/ColorContext#Foreground. = '3', Backgroundcxx . . $ CppUtilities/EscapeCodes/ColorContext#Background. = '4' }; |
| 19 | |
| 20 | enum class TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute# : char { |
| 21 | Resetcxx . . $ CppUtilities/EscapeCodes/TextAttribute#Reset. = '0', |
| 22 | Boldcxx . . $ CppUtilities/EscapeCodes/TextAttribute#Bold. = '1', |
| 23 | Dimcxx . . $ CppUtilities/EscapeCodes/TextAttribute#Dim. = '2', |
| 24 | Italiccxx . . $ CppUtilities/EscapeCodes/TextAttribute#Italic. = '3', |
| 25 | Underscorecxx . . $ CppUtilities/EscapeCodes/TextAttribute#Underscore. = '4', |
| 26 | Blinkcxx . . $ CppUtilities/EscapeCodes/TextAttribute#Blink. = '5', |
| 27 | ReverseVideocxx . . $ CppUtilities/EscapeCodes/TextAttribute#ReverseVideo. = '7', |
| 28 | Concealedcxx . . $ CppUtilities/EscapeCodes/TextAttribute#Concealed. = '8', |
| 29 | Strikethroughcxx . . $ CppUtilities/EscapeCodes/TextAttribute#Strikethrough. = '9', |
| 30 | }; |
| 31 | |
| 32 | enum class Directioncxx . . $ CppUtilities/EscapeCodes/Direction# : char { Upcxx . . $ CppUtilities/EscapeCodes/Direction#Up. = 'A', Downcxx . . $ CppUtilities/EscapeCodes/Direction#Down. = 'B', Forwardcxx . . $ CppUtilities/EscapeCodes/Direction#Forward. = 'C', Backwardcxx . . $ CppUtilities/EscapeCodes/Direction#Backward. = 'D' }; |
| 33 | |
| 34 | inline void setStylecxx . . $ CppUtilities/EscapeCodes/setStyle(347736b94b25c94c).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &stream, TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute# displayAttribute = TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute#::Resetcxx . . $ CppUtilities/EscapeCodes/TextAttribute#Reset.) |
| 35 | { |
| 36 | if (enabledcxx . . $ CppUtilities/EscapeCodes/enabled.) { |
| 37 | stream <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). '\033' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). '[' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). static_cast<char>(displayAttribute) <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). 'm'; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | inline void setStylecxx . . $ CppUtilities/EscapeCodes/setStyle(83f7e8a01fa70fbc).( |
| 42 | stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &stream, Colorcxx . . $ CppUtilities/EscapeCodes/Color# color, ColorContextcxx . . $ CppUtilities/EscapeCodes/ColorContext# context = ColorContextcxx . . $ CppUtilities/EscapeCodes/ColorContext#::Foregroundcxx . . $ CppUtilities/EscapeCodes/ColorContext#Foreground., TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute# displayAttribute = TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute#::Resetcxx . . $ CppUtilities/EscapeCodes/TextAttribute#Reset.) |
| 43 | { |
| 44 | if (enabledcxx . . $ CppUtilities/EscapeCodes/enabled.) { |
| 45 | stream <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). '\033' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). '[' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). static_cast<char>(displayAttribute) <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). ';' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). static_cast<char>(context) <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). static_cast<char>(color) <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). 'm'; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | inline void setStylecxx . . $ CppUtilities/EscapeCodes/setStyle(830efe49533e8b1a).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &stream, Colorcxx . . $ CppUtilities/EscapeCodes/Color# foregroundColor, Colorcxx . . $ CppUtilities/EscapeCodes/Color# backgroundColor, TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute# displayAttribute = TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute#::Resetcxx . . $ CppUtilities/EscapeCodes/TextAttribute#Reset.) |
| 50 | { |
| 51 | if (enabledcxx . . $ CppUtilities/EscapeCodes/enabled.) { |
| 52 | stream <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). '\033' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). '[' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). static_cast<char>(displayAttribute) <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). ';' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). static_cast<char>(ColorContextcxx . . $ CppUtilities/EscapeCodes/ColorContext#::Foregroundcxx . . $ CppUtilities/EscapeCodes/ColorContext#Foreground.) |
| 53 | <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). static_cast<char>(foregroundColor) <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). ';' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). static_cast<char>(ColorContextcxx . . $ CppUtilities/EscapeCodes/ColorContext#::Backgroundcxx . . $ CppUtilities/EscapeCodes/ColorContext#Background.) <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). static_cast<char>(backgroundColor) |
| 54 | <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). 'm'; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | inline void resetStylecxx . . $ CppUtilities/EscapeCodes/resetStyle(f7f45734e6842120).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &stream) |
| 59 | { |
| 60 | if (enabledcxx . . $ CppUtilities/EscapeCodes/enabled.) { |
| 61 | stream <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). '\033' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). '[' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). static_cast<char>(TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute#::Resetcxx . . $ CppUtilities/EscapeCodes/TextAttribute#Reset.) <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). 'm'; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | inline void setCursorcxx . . $ CppUtilities/EscapeCodes/setCursor(6f72aa93eefd9a6).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &stream, unsigned int row = 0, unsigned int col = 0) |
| 66 | { |
| 67 | if (enabledcxx . . $ CppUtilities/EscapeCodes/enabled.) { |
| 68 | stream <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). '\033' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). '[' <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). row <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). ';' <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). col <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). 'H'; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | inline void moveCursorcxx . . $ CppUtilities/EscapeCodes/moveCursor(50dbb652d23c2859).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &stream, unsigned int cells, Directioncxx . . $ CppUtilities/EscapeCodes/Direction# direction) |
| 73 | { |
| 74 | if (enabledcxx . . $ CppUtilities/EscapeCodes/enabled.) { |
| 75 | stream <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). '\033' <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). '[' <<cxx . . $ std/basic_ostream#`operator<<`(b4c055c363850233). cells <<cxx . . $ std/`operator<<`(dd93bb5737bfac24). static_cast<char>(direction); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | inline void saveCursorcxx . . $ CppUtilities/EscapeCodes/saveCursor(f7f45734e6842120).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &stream) |
| 80 | { |
| 81 | if (enabledcxx . . $ CppUtilities/EscapeCodes/enabled.) { |
| 82 | stream <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\033[s"; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | inline void restoreCursorcxx . . $ CppUtilities/EscapeCodes/restoreCursor(f7f45734e6842120).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &stream) |
| 87 | { |
| 88 | if (enabledcxx . . $ CppUtilities/EscapeCodes/enabled.) { |
| 89 | stream <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\033[u"; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | inline void eraseDisplaycxx . . $ CppUtilities/EscapeCodes/eraseDisplay(f7f45734e6842120).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &stream) |
| 94 | { |
| 95 | if (enabledcxx . . $ CppUtilities/EscapeCodes/enabled.) { |
| 96 | stream <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\033[2J"; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | inline void eraseLinecxx . . $ CppUtilities/EscapeCodes/eraseLine(f7f45734e6842120).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &stream) |
| 101 | { |
| 102 | if (enabledcxx . . $ CppUtilities/EscapeCodes/enabled.) { |
| 103 | stream <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\33[2K"; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | inline stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ CppUtilities/EscapeCodes/`operator<<`(b2508d54d7d81196).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &stream, TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute# displayAttribute) |
| 108 | { |
| 109 | setStylecxx . . $ CppUtilities/EscapeCodes/setStyle(347736b94b25c94c).(stream, displayAttribute); |
| 110 | return stream; |
| 111 | } |
| 112 | |
| 113 | constexpr auto colorcxx . . $ CppUtilities/EscapeCodes/color(107d0fac6bd95ee3).(Colorcxx . . $ CppUtilities/EscapeCodes/Color# foreground, Colorcxx . . $ CppUtilities/EscapeCodes/Color# background, TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute# displayAttribute = TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute#::Resetcxx . . $ CppUtilities/EscapeCodes/TextAttribute#Reset.) |
| 114 | { |
| 115 | return stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(foreground, background, displayAttribute); |
| 116 | } |
| 117 | |
| 118 | constexpr auto colorcxx . . $ CppUtilities/EscapeCodes/color(47671eb772bab27c).(Colorcxx . . $ CppUtilities/EscapeCodes/Color# foreground, ColorContextcxx . . $ CppUtilities/EscapeCodes/ColorContext# context, TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute# displayAttribute = TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute#::Resetcxx . . $ CppUtilities/EscapeCodes/TextAttribute#Reset.) |
| 119 | { |
| 120 | return stdcxx . . $ std/::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(foreground, context, displayAttribute); |
| 121 | } |
| 122 | |
| 123 | template <typename TupleType, |
| 124 | Traitscxx . . $ CppUtilities/Traits/::EnableIfAnycxx . . $ CppUtilities/Traits/EnableIfAny#<stdcxx . . $ std/::is_same<TupleType, stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Colorcxx . . $ CppUtilities/EscapeCodes/Color#, Colorcxx . . $ CppUtilities/EscapeCodes/Color#, TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute#>>, |
| 125 | stdcxx . . $ std/::is_same<TupleType, stdcxx . . $ std/::tuplecxx . . $ std/tuple#<Colorcxx . . $ CppUtilities/EscapeCodes/Color#, ColorContextcxx . . $ CppUtilities/EscapeCodes/ColorContext#, TextAttributecxx . . $ CppUtilities/EscapeCodes/TextAttribute#>>> * = nullptr> |
| 126 | inline stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ CppUtilities/EscapeCodes/`operator<<`(28886beb5deab7db).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &stream, TupleType displayAttribute) |
| 127 | { |
| 128 | setStylecxx . . $ CppUtilities/EscapeCodes/setStyle(830efe49533e8b1a).(stream, stdcxx . . $ std/::getcxx . . $ std/get(607352554f49d4b5).<0>(displayAttribute), stdcxx . . $ std/::getcxx . . $ std/get(b5bb845d0107ee72).<1>(displayAttribute), stdcxx . . $ std/::getcxx . . $ std/get(58f9000eff7414f2).<2>(displayAttribute)); |
| 129 | return stream; |
| 130 | } |
| 131 | |
| 132 | /*! |
| 133 | * \brief The Phrases enum contains standard phrases which can be printed to any std::ostream and obtained as strings |
| 134 | * via EscapeCodes::phraseString() and EscapeCodes::formattedPhraseString(). |
| 135 | * |
| 136 | * Example: `std::cerr << Phrases::Error << "Something bad happened." << Phrases::End` |
| 137 | */ |
| 138 | enum class Phrasescxx . . $ CppUtilities/EscapeCodes/Phrases# { |
| 139 | Errorcxx . . $ CppUtilities/EscapeCodes/Phrases#Error., /**< bold, red "Error: " */ |
| 140 | Warningcxx . . $ CppUtilities/EscapeCodes/Phrases#Warning., /**< bold, yellow "Warning: " */ |
| 141 | Endcxx . . $ CppUtilities/EscapeCodes/Phrases#End., /**< resets the style */ |
| 142 | PlainMessagecxx . . $ CppUtilities/EscapeCodes/Phrases#PlainMessage., /**< bold, 4 spaces " " */ |
| 143 | SuccessMessagecxx . . $ CppUtilities/EscapeCodes/Phrases#SuccessMessage., /**< bold, green "==> " */ |
| 144 | SubMessagecxx . . $ CppUtilities/EscapeCodes/Phrases#SubMessage., /**< bold, green " -> " */ |
| 145 | ErrorMessagecxx . . $ CppUtilities/EscapeCodes/Phrases#ErrorMessage., /**< bold, red "==> ERROR: " */ |
| 146 | WarningMessagecxx . . $ CppUtilities/EscapeCodes/Phrases#WarningMessage., /**< bold, yellow "==> WARNING: " */ |
| 147 | EndFlushcxx . . $ CppUtilities/EscapeCodes/Phrases#EndFlush., /**< resets the style and flushes the stream */ |
| 148 | Infocxx . . $ CppUtilities/EscapeCodes/Phrases#Info., /**< bold, blue "Info: " */ |
| 149 | Overridecxx . . $ CppUtilities/EscapeCodes/Phrases#Override., /**< erases the current line */ |
| 150 | SubErrorcxx . . $ CppUtilities/EscapeCodes/Phrases#SubError., /**< bold, red " -> ERROR: " */ |
| 151 | SubWarningcxx . . $ CppUtilities/EscapeCodes/Phrases#SubWarning., /**< bold, yellow " -> WARNING: " */ |
| 152 | InfoMessagecxx . . $ CppUtilities/EscapeCodes/Phrases#InfoMessage., /**< bold, white "==> " */ |
| 153 | }; |
| 154 | CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &operatorcxx . . $ CppUtilities/EscapeCodes/`operator<<`(75f7075e21abbe9a).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &stream, Phrasescxx . . $ CppUtilities/EscapeCodes/Phrases# phrase); |
| 155 | CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! stdcxx . . $ std/::string_viewcxx . . $ std/string_view# phraseStringcxx . . $ CppUtilities/EscapeCodes/phraseString(13a0428c31f1f364).(Phrasescxx . . $ CppUtilities/EscapeCodes/Phrases# phrase); |
| 156 | CPP_UTILITIES_EXPORTcxx . . $ `global.h:11:9`! stdcxx . . $ std/::string_viewcxx . . $ std/string_view# formattedPhraseStringcxx . . $ CppUtilities/EscapeCodes/formattedPhraseString(13a0428c31f1f364).(Phrasescxx . . $ CppUtilities/EscapeCodes/Phrases# phrase); |
| 157 | |
| 158 | } // namespace EscapeCodes |
| 159 | } // namespace CppUtilities |
| 160 | |
| 161 | #endif // IOUTILITIES_ANSIESCAPECODES |