Reputation: 31
My buffer:
CHAR_INFO *ciScreenBuffer = new CHAR_INFO[bufferWidth * bufferHeight];
How can i use ANSI codes like this to colorize my output char ?
"\x1b[38;2;R;G;Bm""
P.S i use that
WriteConsoleOutputA(hConsoleOutput, ciScreenBuffer, { (SHORT)bufferWidth, (SHORT)bufferHeight }, { 0, 0 }, &writeRegion);
Upvotes: 1
Views: 511
Reputation: 32732
WriteConsoleOutput
does not use nor parse ANSI sequences. You provide the color information as part of the CHAR_INFO
data you pass in.
To add color to your output, update the color member of the ciScreenBuffer
array when you add the characters you want to display. For example, based on an example in one of your comments,
ciScreenBuffer[50].Attributes = FOREGROUND_BLUE;
Upvotes: 1