In C++ the following code when run in the console will print the text in colour:
cout << "\e[32;40mGreenForegroundAndBlackBackgroundText" << endl;
In D I get an error:
string s = "\e[32;40mGreenForegroundAndBlackBackgroundText"; // undefined escape sequence \e
Is there any way to get this working in D?
Go to Format > Font > Font. + D to open the Font dialog box. Select the arrow next to Font color, and then choose a color.
Make separate elements Another way is creating a text with separate elements by using the HTML <span> tag, which is an empty container. This means that you create a multicolor text by putting each letter in a separate element to define a different color for each letter of your text.
#ff0000 is the color code for red.
Color fonts, also referred to as “multicolor fonts” or “chromatic fonts,” are a relatively new font technology that allows font designers to use multiple colors within each glyph of the font.
The C++ constant string escape \e
for the escape character is a non-standard GCC extension of C for character escapes (also adopted by Clang, probably).
You just need to put the octal encoding of it perhaps as \033
or \x1b
Be careful however that \e[32;40m
is not standard C or C++, it is the ANSI terminal escape sequence related to tty-s.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With