-
Notifications
You must be signed in to change notification settings - Fork 212
Cursor color escape codes #184
Description
I'm interested in finding the escape codes to send to a Console (think: win32 console application) that will change the color of the cursor
Environment:
- Windows 10
- Visual Studio 2019.
- C++
- Win32 Console Application. Plain old console app.
I've read through:
terminal sequences
I've examined other documents such as:
Wikipedia ANSI Codes
I've looked at the Properties panel of the Console App itself and under Terminal >> There's a setting for Cursor Color!
But, what I'm looking for is the exact escape codes to send to the stdout of my Win32 console application.
Eg:
To change the shape of the cursor (Windows environment as listed above):
#define CSI "\x1b["
// ...
// Make block cursor.
printf(CSI "2 q");
Another example of what does work fairly cross-platform:
// Modify the text color... (snagged off Wikipedia)
int stuff(void)
{
int i, j, n;
for (i = 0; i < 11; i++) {
for (j = 0; j < 10; j++) {
n = 10 * i + j;
if (n > 108) break;
printf("\033[%dm %3d\033[m", n, n);
}
printf("\n");
}
return (0);
}
Modifying the text color is fine. I'm actually interested in modifying the cursor color.
To change Cursor color, this works, albeit on Cygwin/Linux:
// codes to set cursor color red.
printf("\e]12;red\a");
But this doesn't work in the Win32 Console Application. I wasn't all that surprised. I just don't know what the right sequence Windows Console (Terminal) expects.
I've searched high and low and cannot find the documentation on what (ESC+ stuff ) to send to the Win32 Console stdout to render a cursor color.
Care to share some guidance on where those codes are to render a specific cursor color?
Thanks.
Edit:
I must have been tired. But, I realized a work-around. I cannot change the color of the cursor, but I can change the color of the text.. Not that exciting, I know.. But.. it means since the default behavior is to invert the color of the text when rendering the cursor, I can (sort of) force the cursor color by choosing a text color (actually background color to think of it) that is the inverted color. Not ideal. Though, but for the purposes I have, it will be a work-around.
Terminal-Cursor-Color hits --more--
Terminal-Cursor-Color hits --more--
Anyway -- if the Doc team for Terminal (Console terminal, aka Win32 Console App, etc.. Properties) ever decide to document the ESC code that I can emit to cause the cursor color rendering, that would be great.
And... it looks like Cursor color has no alpha channel behavior -- Eg., if you get a Cursor color (manually selected), the character underneath is masked. Not a worry. Maybe later, maybe not.