-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
WT should set COLORTERM #11057
Comments
Discussed this with Dustin last week - I think we're both cool with this now. I think we were both more reluctant to do it in the past because it's just not a great solution, but it works for most people. So we may as well, same with |
@DHowett, @mislav for truecolor-detection support, is this really the right detection then? There's mention of many different From a quick search for |
Woah, I've never seen that particular sequence ( You might be able to get away with just adding a |
https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences exists and notcurses is using it for the new experimental support of Windows. Notcurses in facts manipulates the terminfo entry to grab what it needs for the various terminals. There's no denying that terminfo isn't the greatest solution but no consensus appears to have been reached for implementing a standardized query method for terminals to use so any terminal that does have a query detection feature implements it in different ways, which does in the end rely on terminfo at some point. (This all being said, WT is certainly able to create it's own query method that reflects that doc, but since there are other terminals on Windows to account for, the env vars would still be needed for them) |
With that in mind, it really seems like there's no good solution since the CLI supports pre-Windows 10 as do many apps out there. So would just trying to emit an RGB VT sequence be best? If a terminal doesn't support it, it should just ignore the sequence and emit text with the default background and foreground colors, right? So there's really no point in trying to detect if truecolor is supported? /cc @mislav |
It should but doesn't always. Terminal.app does not support RGB colors and yet outputs strange formatting when you try to use RGB sequences. As long as the default terminal emulator on one of major operating systems can't get this right, authors of CLI apps such as myself will rather want to operate on detection rather than blind faith. Plus, we might want to output 256-color to clients that do not support truecolor, rather than outputting truecolor and have it be rendered with default foreground+background.
I don't know! That's the best (read: easiest, most straightforward) that I saw various CLI tools come up with. |
Totally makes sense and I agree. It's just strange that, at least when it comes to colors/VT support, writing console apps seems to be harder/more involved than writing windowed apps. 🙄 Still, the crux of this bug: if |
I'm sure I have mentioned this before somewhere, but I'm convinced that just supporting I actually have a partial That said, I am also in favor of a |
I felt like this for a while, but then I realized that we're fighting a losing battle against people who are looking for |
If you'd set |
This PR adds support for the `DECRQSS` (Request Selection or Setting) escape sequence, which is a standard VT query for reporting the state of various control functions. This initial implementation only supports queries for the `DECSTBM` margins, and the `SGR` graphic rendition attributes. This can be useful for certain forms of capability detection (#1040). As one example in particular, it can serve as an alternative to the `COLORTERM` environment variable for detecting truecolor support (#11057). Of the settings that can be queried by `DECRQSS`, the only other one that we could be supporting at the moment is `DECSCUSR` (Cursor Style). However, that would require passing the query through to the conpty client, which is a lot more complicated, so I thought it best to leave for a future PR. For now this gets the basic framework in place, so we are at least responding to queries, and even just supporting the `SGR` attributes query is useful in itself. Validation ---------- I've added a unit test verifying the reports for the `DECSTBM` and `SGR` settings with a range of different parameters. I've also tested the `DECSTBM` and `SGR` reports manually in _Vttest_, under menu 11.2.5.3.6 (Status-String Reports).
Side note for those who are following this ticket: https://github.com//termstandard/colors is the best documentation out there for what supports COLORTERM. Windows Terminal is already on this list, even though it isn't emitting the variable yet. |
oh-my-zsh changed their update script to use truecolor if supported. I had replaced the omz ASCII art and color definitions, so having to merge this linked commit made me realize $TERM is xterm-256color and $COLORTERM is undefined in Windows Terminal. Until this issue changes (subscribe for issue updates) the update script will detect full color and choose the right palette after adding The new oh-my-zsh commit uses the XVilke gist that @heaths linked—although not the query method—so any other script using the variable check from this gist should also get support after defining COLORTERM. I imagine one could simply add this in .bashrc as well (or whichever dotfile is shell-relevant). |
Just FYI, that |
ok after looking |
|
No I seen lots of Linux terminals that return xterm-256 from that variable. If it’s unset that means it’s an older terminal then you should also look for $TERM but $TERM a lot of times gets set to an older color value such as xterm not 256 and xterm-256 even if it supports true color that value will remain non true color regardless.
Example easily produced. `gnome-terminal` latest linux mint distro. print `$TERM` and `$COLORTERM` it will give you xterm-256color or was it xterm-256, fallowed by truecolor
|
Software out there that implements truecolor either check if |
Is there a way to make Windows Terminal set |
@eggbean you can check for |
@heaths Thanks. |
Nah tested on 40 Linux terminals colorterm not being set doesn't mean it's going to be true color
|
Unfortunately
Why not? I have no idea and don't wish to spend time finding out. Please please please just implement TERM_PROGRAM and other user agent strings. Yes, feature detection, I know. It's a lovely idea but it will never be enough by itself. In our case we're trying to detect WT specifically because there are bugs in the old legacy terminal, maybe in old versions of Windows I don't know, for example setting the console to UTF-8 will change the font in every single legacy console window. That annoys people who for whatever reason prefer to use that vs the new WT (they exist, I've worked with them) and so we just say oh whatever, if you use old stuff you get old stuff. That's why we want to detect WT, it's more like a negative detection and thus feature detection won't ever work because old conhost will gamely advertise that it has these features and then do the wrong thing. Yep, it does create other problems. Non-WT terminals that use the same codepaths, for example. Fine, a problem for another day. They can advertise themselves as "Windows Terminal/5 (compatible; FooTerm)" and that's OK. |
@mikehearn what you're seeing there is #13006 and is a Hard problem - in that scenario, |
Huh, OK, that's an interesting problem indeed. I guess ANSI escapes to do feature detection and/or getting a user-agent equivalent would be the only way forward there. |
Much of this issue has talked about corner cases where setting Is it really worth not setting the variables as describe above in spite of all the programs that would work just fine? Feature detection based on ANSI sequences is burdensome for every program to implement when a couple of env vars are much easier to check and correct in the vast majority of cases. And feature detection via ANSI escape sequences don't give you the full picture anyway. Just because it reports truecolor doesn't mean it supports hyperlinks. And it's been discussed how different terminals respond to |
What is the actual status of this ticket? I see earlier in the ticket that there was some resistence to using $COLORTERM, but then broadly there seems to be support, even from maintainers, throughout the rest of the ticket. The ticket is tagged with "Help Wanted". Is this ticket really waiting for someone to come along and add a single environment variable in a PR? |
Description of the new feature/enhancement
Related to #1040, WT should set the
COLORTERM
environment variable to "truecolor" since WT does support truecolor. I can understand how changingTERM
to "xterm-truecolor" (from "xterm-256color") could be a breaking change, but that's whatCOLORTERM
is for.Some tools like with cli/cli#4079 use this to determine if 24-bit colors should be emitted. Easy enough for users to define - either as Windows environment variables or update their shell profile e.g., .bashrc, but users who don't know what won't enjoy a wash of color by default like with
gh issue list
starting with v2.0.0.Proposed technical implementation details (optional)
WT should ideally define the environment variable
COLORTERM=truecolor
within its own process environment block by default./cc @mislav
The text was updated successfully, but these errors were encountered: