-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document the Win32 API for using 24-bit colors in the new console host #1118
Comments
@bitcrazed left a blogpost on the console team blog promising documentation. |
We're not planning on expanding the Win32 API surface for this feature. Every function we add to the Console API just creates another point of incompatibility with linux terminal applications. If you want to use the new color support in your application, you'll have to use VT sequences. Support can be enabled with The sequences to emit actual colors are as follows Pm = 3 8 ; 2 ; Pr; Pg; Pb -> Set foreground color to the closest match in xterm's palette for the given RGB Pr/Pg/Pb. (from http://invisible-island.net/xterm/ctlseqs/ctlseqs.html) We're not going to be adding any API for reading the colors back out with 24-bit color, and as far as I know there are no VT sequences for reading the buffer or it's attributes. |
Ha, that's really really cool. I just opened powershell for work, and it's doing dynamic text coloring? Was that added in this build? It looks like FiSH almost (at least when I typed in exit?) |
@zadjii-msft Was looking over that documentation. I tried the naïve thing and tried entering those escapes inside of a console window with bash.exe running (since it has VT processing enabled), and as I am sure you know, I learned that lots of those escapes don't work like that, sitting down typing them directly in like that (I'm sure it's the same if you just sit down and do it in xterm). Is there like an escape sequence "sandbox" (or a setting or program in WSL or something) that you can sit down in front of and just type escape sequences to see what they do? |
Try something like the following in bash (I might be misunderstanding the question):
|
@therealkenc I was sitting there pressing the escape key then some keys following it. I was able to insert an uparrow with But when I tried typing in the escape sequence to say, underline text, Also, when I tried the manual cursor move escapes (the first ones in the docs), it didn't do much ( |
@fpqc that's the PSReadline module |
@jcotton42 I guess it comes stock now? That's cool! |
@fpqc Okay, so this isn't the prettiest code in the world, but it should provide a base for what you're looking for. Just stick this in any old python file and run it. Type in whatever characters you want for your CSI sequence and hit enter. import sys
def csi(seq):
sys.stdout.write('\x1b[{}'.format(seq))
def main(argv):
while(True):
user_input = str(raw_input('Enter sequence to emit'))
csi(user_input)
if __name__ == '__main__':
main(sys.argv) So, for example, if you want to test the sequence It's not great, but it is a playground. Also good to know is that cmd.exe has support for VT sequences enabled by default, so you can test some of the effects right from the prompt, using Ctrl-[ to input the escape character. |
@zadjii-msft Cool! By the way, I was messing around trying to get some of the powerline-patched fonts working in conhost, and they actually do work fine, but the trick is that you have to use the .ttf versions (many of which you have to manually re-patch yourself. Is there any reason Conhost won't use .otf? I thought MS and Adobe developed OTF as a replacement for .ttf, but for some reason conhost can't use them. Don't know if it would be difficult to implement, but something worth taking a quick glance at! Anyway, nice work! |
Closing as by-design. |
so which sequence determines color mode for the "new conhost"? OSC 10/11 is empty in the older, means 4 bits (okay) |
So we can use this function either.
The text was updated successfully, but these errors were encountered: