Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Changing the color palette on the fly

May
12,846
164
My CONHOST.EXE is nothing special ... just up-to-date.

Code:
TCC 28.00.12 x64
Microsoft Windows 10 Pro for Workstations
10.0.19043.1165 (2009, 21H1)

There's an escape sequence that will change a color palette entry on the fly, and update the console. The syntax is

Code:
ESC]4;i;rgb:r/g/bESC

where i is the color index and r,g, and b are hex (0-FF) values for the new color.

Before:

1630634426086.png


After:

1630634652495.png
 
I mentioned in the support forum that I didn't have the sequence terminator right (no fault of mine). It worked as it was but caused problems. The sequence should have a \ at the end, like this.

Code:
ESC]4;i;rgb:r/g/bESC\

You can also use

Code:
ESC]4;i;rgb:r/g/b%@char[0x9C]

If anyone's interested, the sequence terminator is called "ST" (for "string terminator"). ESC\ is the 7-bit version of ST and %@char[0x9C] is the 8-bit version. I guess these things go back to a time when some systems/terminals couldn't deal with 8-bit characters.
 
Back
Top