Ausgabefarbtext in CPP
//Read and Execute the code below to learn how to format system text in C++
#include <iostream>
using namespace std;
int main(){
cout<<"Printing most useful text format modes: ";
cout<<"\n1. \x1b[1mBOLD\x1b[0m";
cout<<"\n3. \x1b[3mITALIC\x1b[0m";
cout<<"\n4. \x1b[4mUNDERLINE\x1b[0m";
cout<<"\n5. \x1b[5mBLINKING\x1b[0m";
cout<<"\n7. \x1b[7mHIGHLIGHT\x1b[0m";
cout<<"\n8. \x1b[8mPRINT NOTHING\x1b[0m";
cout<<"\n30. \x1b[30mBLACK\x1b[0m";
cout<<"\n31. \x1b[31mRED\x1b[0m";
cout<<"\n32. \x1b[32mGREEN\x1b[0m";
cout<<"\n33. \x1b[33mPURPLE\x1b[0m";
cout<<"\n34. \x1b[34mYELLOW\x1b[0m";
cout<<"\n35. \x1b[35mPINK\x1b[0m";
cout<<"\n36. \x1b[36mLIGHTBLUE\x1b[0m";
cout<<"\n37. \x1b[37mWHITE\x1b[0m";
cout<<"\n40. \x1b[40m Black Background \x1b[0m";
cout<<"\n41. \x1b[41m Red Background \x1b[0m";
cout<<"\n42. \x1b[42m Green Background \x1b[0m";
cout<<"\n43. \x1b[43m Yellow Background \x1b[0m";
cout<<"\n44. \x1b[44m Blue Background \x1b[0m";
cout<<"\n45. \x1b[45m Pink Background \x1b[0m";
cout<<"\n46. \x1b[46m Light Blue Background \x1b[0m";
cout<<"\n-----------------------------------------------------";
//Creating some string constants - shortcuts - combining text format modes
const string RESET = "\e[0m"; //Format Mode 0
const string BOLD_HIGHLIGHT = "\e[1;7m"; //Format Modes 1 and 7
const string COMPLEX_FORMAT_1 = "\x1b[5;1;3;35;44m"; //Format Modes 5, 1, 2, 35 and 44
const string COMPLEX_FORMAT_2 = "\x1b[4;30;42m"; //Format Modes 4, 30 and 42
const string COMPLEX_FORMAT_3 = "\x1b[5;1m"; //Format Modes 5 and 1
//Examples using shortcuts
cout<<"\n\n\t** Program has been "<<BOLD_HIGHLIGHT<<"Terminated"<<RESET<<" **";
cout<<"\n\n\t"<<COMPLEX_FORMAT_1<<"** Program has been Terminated **"<<RESET;
cout<<"\n\n\t"<<COMPLEX_FORMAT_2<<"** Program has been Terminated"<<COMPLEX_FORMAT_3<<" **"<<RESET;
cout<<endl;
return 0;
}
ALeonidou