-
That works in a console. Below I'm changing color 0, which is the background color. Before: After: Should it work in WindowsTerminal? It doesn't. |
Beta Was this translation helpful? Give feedback.
Replies: 39 comments 18 replies
-
You are redefining color 0, which is one of the colors in the 16-color palette (usually assigned to black.) The vintage console only supports having indexed colors for the foreground or the background. All other terminals, WT included, support 18 paletted colors: the 16 from ANSI/VT, plus a foreground and background which are independent. You'll want to use OSC 11 (if I remember properly) to set the background, not OSC 4 to overwrite black. |
Beta Was this translation helpful? Give feedback.
-
My only reference is https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences which doesn't mention OSC 11. Is there a better reference, one that describes OSC 11 in detail? |
Beta Was this translation helpful? Give feedback.
-
Hmmm! If I have the terminators right [0x7 (BEL) or 0x9C (ST?)], I find that OSC]10;16;... changes the color of the background OSC]10;17;... changes the color of the foreground Are they the last two colors in the 18-color palette you spoke of? And OSC]11;x;... changes the color of the cursor (the x doesn't seem to matter) I wish I knew how it's supposed to work. |
Beta Was this translation helpful? Give feedback.
-
While the sequences from my previous post work as stated, I guess I didn't try hard enough. These also work and are as I have found documeted. ESC]10;rgb:r/g/bST ... foreground color |
Beta Was this translation helpful? Give feedback.
-
So! The documentation for these is right under the "Operating System Commands" section in the inimitable xterm control sequences guide. We have a backlog item booked to update our docs with all our supported sequences and the versions they came out in. Your finding is pretty interesting! This set of OSC can be "chained" -- if you start with
The 10 indicates that we wanted to start with the foreground. You could do the same thing with three sequences, |
Beta Was this translation helpful? Give feedback.
-
(We do not support all the resources specified in |
Beta Was this translation helpful? Give feedback.
-
And finally, last note before I give you space to reply (!) (:smile:) The venerated Console also supports this "separate" palette, though it does make some applications act strange. It's in the "Terminal" tab in the old settings sheet, marked down as "experimental" terminal settings, with a link to a fairly wordy blog post explaining them: |
Beta Was this translation helpful? Give feedback.
-
Thanks for all the info, especially about "chaining" the sequences. I have never played with that tab in the settings. Do "separate foreground" and "separate background" act as two "extra" colors (perhaps in the 18-color palette you mentioned earlier)? |
Beta Was this translation helpful? Give feedback.
-
Yep, they are exactly that! They are accessible in VT using SGR |
Beta Was this translation helpful? Give feedback.
-
Are they what ESC[0m gives? |
Beta Was this translation helpful? Give feedback.
-
Indeed they are. For console, they replace the old "default" colors in any place except the API (which doesn't report with a data type large enough to express more colors :() |
Beta Was this translation helpful? Give feedback.
-
Aha! That's nice. So I can have "default" colors that are not a combination of two colors from the console's 16-color palette. |
Beta Was this translation helpful? Give feedback.
-
In a console, I can set "DefaultForefround" and "DefaultBackground" in the Properties dialog. Can I set them on the fly with a control sequence? I tried SGR 39 and SGR 49 (with 2;r;g;b, as in 38/48); that didn't work. [If that question is answered above, I couldn't find it.] |
Beta Was this translation helpful? Give feedback.
-
I'm sorry what did you try? You don't need to use the
|
Beta Was this translation helpful? Give feedback.
-
I'm sorry. I misinterpreted the purpose of SGR 39/49. What I really want to do is SET (on the fly) the console's default foreground/background and/or WT's defaultForeground/defaultBackground. Can either or both of those be done? It's part of a (mostly academic) project to let the user issue a command to change the console's (or WT's) color scheme. Some of the schemes don't work correctly if those fore/back colors are not set. And (off-topic) ... Are the Creators Update console colors still the default in Windows 10? If so, maybe a "Creators Update" scheme in WT would be appropriate. I added such a scheme myself, works fine. I'll post it if it will be of any value. |
Beta Was this translation helpful? Give feedback.
-
Ah, I think I figured it out. If you installed in 2019, you've got Campbell. For sure. What we're seeing here, though, is two translation issues! First: the color ordering for console colors, as well as legacy VGA attributes (on which console colors are based) swaps red and blue (and derivatives like teal and cyan).
Translation error two is that the registry values are stored in In this example, I have lined up red and blue.
|
Beta Was this translation helpful? Give feedback.
-
Thanks! I know all about the red/blue swap and just plain failed to see that that's what was happening ... and that I didn't take that into consideration in making my C array initializer ... or, more likely, that I swapped them twice. Doh! I'm sorry I wasted so much of your time on this. |
Beta Was this translation helpful? Give feedback.
-
You've probably guessed by now, but I love answering questions like this 🙂 |
Beta Was this translation helpful? Give feedback.
-
And thanks again to @zadjii-msft. My color scheme sampler is working well both in a console and in WT. |
Beta Was this translation helpful? Give feedback.
-
I discovered by accident that you can chain the OSC4 specs (16-color palette) without specifying palette indices (if the starting index is meant to be 0, I suppose). For example, And when I was specifying indices, a bug in my code (failure to divide by 3) produced sequences like this
It worked anyway! When chaining OSC4 sequences, are specified indices after the first simply ignored ... and if none are specified, is the first assumed to be 0? It seems that way. |
Beta Was this translation helpful? Give feedback.
-
Where can I find the code for the handling of OSC4? I'm terrible at finding my way around the code. I saw that several issues became "conversations". Can conversations be seen (en masse) ... searched? |
Beta Was this translation helpful? Give feedback.
-
I see! They're "discussions", not "conversations". Thanks. |
Beta Was this translation helpful? Give feedback.
-
I'm having a hard time seeing palette color 0 in the current preview version. Below are the release version (left) and the preview version (right). Both are using the Campbell theme and have executed the same command. The one on the right also shows the utility I use to see screen coordinates and color at the mouse pointer. The command should produce palette color 0 (CSI 30 m). It does that in the release version (0C/0C/0C, equal to the background color). In the preview version, it produces color 4E/4E/4E. In fact, with the preview version it produces 4E/4E/4E with ANY theme. This has nothing to do with my programming. Is this an issue ... known ... or just something experimental and beyond my grasp? |
Beta Was this translation helpful? Give feedback.
-
Where is that setting? |
Beta Was this translation helpful? Give feedback.
-
Yup! That was it. |
Beta Was this translation helpful? Give feedback.
-
That's like "one size fits all". 4E/4E/4E works for all themes. 😁 |
Beta Was this translation helpful? Give feedback.
-
It's 4E/4E/4E with all the built-in themes. |
Beta Was this translation helpful? Give feedback.
-
I know it's 1.5 yrs later, but is there a way to query the current RGB values of any of the 16 colors? |
Beta Was this translation helpful? Give feedback.
-
Hi, @ClaireCJS! 😁 |
Beta Was this translation helpful? Give feedback.
So! The documentation for these is right under the "Operating System Commands" section in the inimitable xterm control sequences guide. We have a backlog item booked to update our docs with all our supported sequences and the versions they came out in.
Your finding is pretty interesting! This set of OSC can be "chained" -- if you start with
10
, and specify multiple colors (For your sequence,E]10;16;XYZ
,16
here was interpreted as the first color, andXYZ
the second!), you will set resources 10, 11, 12, ...The 10 indicates that we wanted to start with the foreground.
You could do the same thing …