-
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
Feature Request: Clients of terminal need a way to inquire about the capabilities of the terminal #1040
Comments
As of #897, you can look for |
@DHowett-MSFT why not use TERM_PROGRAM also, like vs code, hyper and fluentterminal already do? Not too late to change :) |
Agreed. We can't keep creating new environment variables every single time a new terminal program comes out. Linux already uses $env:TERM and if we have to check several per platform it's just terrible from a UX standpoint. Why reinvent the wheel yet again? |
An application-specific variable like TERM_PROGRAM is slightly better, but is really just a lazy version of TERM, which is what all of these terminals should be setting. Eventually, we're going to get a |
Hold up, I think there's been a misunderstanding here. I'm sorry about that. We should definitely support
The idea there is that if WT eventually supports reloading and showing a session's history, that resumed state will use the same session GUID so the shell can do additional things like restoring the working directory or anything else it might have saved off. |
This is why I threw it out as an example and didn't close the feature request. I'll seek to communicate things that are rattling around in my head a bit better going forward. |
It would be nice if conhost would define new |
@DHowett-MSFT Maybe both? |
Fix potential loss of data warning, size_t to int.
Sorry, I wasn't clear. The Window in my gif is conhost, not the Terminal. There's no |
Is a perfect solution necessary? It's clear from the thread that there's not really an established pattern, but Running some EXE as suggested above or relying on Windows- or Windows Terminal-specific solutions don't make scripts portable, or at least make them harder to write (would always need a precondition of Seems the sooner a solution is added that is close to what most other terminals do, the less workarounds get invented that might be even worse. |
@heaths If you're just trying to detect true color support, you should be able to use the standard method documented here: https://gist.github.com/XVilka/8346728#querying-the-terminal I believe that should be supported in Windows Terminal from version 1.12. |
My original reason for jumping onto this thread was to find an easy way a script or program can query. Even the suggested gist - which I had found previously - doesn't always work. Even if you replace echo -e '\e[48;2;1;2;3m\eP$qm\e\\'
^[P1$r0;48;2;1;2;3m^[\ The gist shows "r;48" instead of what Windows Terminal reports back, "r0;48". So depending on what people are checking for when reading back, it seems to vary from terminal to terminal. Whether you use This makes it more difficult to write portable shell scripts as well, where an env var is pretty straight forward to use. |
When a console is allocated on the client side, the internal function For handoff, the delegated console (openconsole) would need to obtain the session environment variables from the delegated terminal when it calls |
I actually really like this. We've been thinking about what it would mean to extend the Console API surface, too, with both inbox consumers (conclnt) and out-of-box ones. The Windows release cycle gives us a bit of trouble, but since DefTerm is locked behind Windows updates as well ... it isn't as much of a problem. Interesting. |
@heaths wrote:
The leading The response for When the query I wrote Test-RgbMode for example, but I don't have a wide test base to verify it works. |
Thanks for the explaining the 0 there. In hindsight I probably should've realized that (I tend to reset colors to be sure myself), but wasn't entirely sure what the printed sequence was representing. But looking at your gist shows the complexity that any script would have to do in Windows Terminal as opposed to most other terminals with a combination of Even the detection mechanism you demo above has variants for terminals like using |
@heaths Note that there are three different truecolor formats, and terminals don't necessarily support all of them. If
No - that's indicating that WT doesn't support the colon format, which is exactly the point. A That said, if you're happy with the all the limitations of environment variables, that's fine. I just want to make sure you are actually aware of those limitations. |
I appreciate the limitations, yes. Not only have I been following this thread, but working with @DHowett offline with some GitHub CLI (and related modules) issues, along with a couple GitHub developers. The main reason I brought up my concern/question above was questioning whether or not the limitations of env vars like Scenarios where env vars are probably good enough would be colors, I would think. Let's say that you only set IMO, I just don't see a great reason to avoid using common |
Not for people actually making terminal programs that won't always be run in windows... not to mention there are different terminals for windows itself. WT_* may indicate that it's "Windows Terminal" that said it's a horrible experience when trying to support different terminals, or possibly even trying to create something that can detect features. It's very similar to at least being able to get the application name ( Specific, similar example.... Internet Explorer 5.0.0 had a very specific bug in which it implemented a new interface for managing the options in a In this case, the terminal is effectively a browser for a command line application, including the shell environment. Some features that concern me that would be nice to be able to determine in a consistent way....
Doing so in the most consistent way, termcap library support for WT, etc. But short of having at LEAST the TERM_PROGRAM, it's not at all consistent with other terminals. For that matter, maybe a settings option for adding/setting/overriding custom environment variables, so the user can CHOOSE to add appropriate options for their environment (wsl, ssh, etc). |
You should be able to determine this with a
This could probably be detected by ouputting a UTF-8 character and then measuring the consumed space with a
You can determine Sixel image support from the
Not possible yet, but I'm hoping to persuade other terminals to use
Not sure what you mean.
If you mean you want to determine the size of the screen, and whether you can resize the window, a |
The issue I was trying to raise in the last couple comments above, though, is why writing to a TTY and checking the results would be the most accurate way to determine capabilities, are you expecting that every program and, more important, every shell script (especially those that want to remain simple but maybe write out some colors) have to write to the TTY, read back, then clear the line just to emit some colored output? The environment variables like |
@heaths I'm not expecting anyone to do anything. I'm just saying there are queries you can use if you need an accurate way to determine those features. If asynchronous queries are not appropriate for your application, or you don't particularly care whether your feature detection is accurate or not, then you can of course use any other method you prefer. As I said before, if you're happy with the limitations of environment variable, that's fine - whatever works best for you. |
This PR adds support for the `DECRQM` (Request Mode) escape sequence, which allows applications to query the state of the various modes supported by the terminal. It also adds support for the `DECNKM` mode, which aliases the existing `DECKPAM` and `DECKPNM` operations, so they can be queried with `DECRQM` too. This is one solution for #10153 (saving and restoring the state of bracketed paste mode), and should also help with #1040 (providing a way for clients to determine the capabilities of the terminal). Prior to adding `DECRQM`, I also did some refactoring of the mode handling to get rid of the mode setting methods in the `ITermDispatch` interface that had no need to be there. Most of them were essentially a single line of code that could easily be executed directly from the `_ModeParamsHelper` handler anyway. As part of this refactoring I combined all the internal `AdaptDispatch` modes into an `enumset` to allow for easier management, and made sure all modes were correctly reset in the `HardReset` method (prior to this, there were a number of modes that we weren't restoring when we should have been). And note that there are some differences in behavior between conhost and Windows Terminal. In conhost, `DECRQM` will report bracketed paste mode as unsupported, and in Terminal, both `DECCOLM` and `AllowDECCOLM` are reported as unsupported. And `DECCOLM` is now explicitly ignored in conpty mode, to avoid the conpty client and conhost getting out of sync. ## Validation Steps Performed I've manually confirmed that all the supported modes are reported in the `DECRQM` tests in Vttest, and I have my own test scripts which I've used to confirm that `RIS` is now resetting the modes correctly. I've also added a unit test in `AdapterTest` that iterates through the modes, checking the responses from `DECRQM` for both the set and reset states. I should also mention that I had to do some refactoring of the existing tests to compensate for methods that were removed from `ITermDispatch`, particularly in `OutputEngineTest`. In many cases, though, these tests weren't doing much more than testing the test framework.
Hi all, maintainer of https://gitub.com/gui-cs/Terminal.Gui here. We would really like a way to ask terminals (not just Windows Term) if a specific unicode glyph is supported at runtime. The idea being, we have to choose a least-common-denominator glyph for things like the one used for checkboxes. In this example, we choose the square root symbol as it empirically works on every terminal we've tried, with every font we've tried, where other "check mark" symbols do not. What we'd like to do is emit a DECRQM asking, "Can you render this pretty glyph"? If the answer is no, we'll fall back to our default. If the answer is yes, we'll use the prettier glyph. We could also do this via querying an environment var or something, but it seems to me the most cross-platform way to do this is to extend DECRQM to support such a query? I know it is possible to ask (at least on Windows) if a particular font supports a particular glyph. I found this Issue in my searching for existing solutions to this and it seems like a good place to start. Let me know if you have suggestions on how to proceed further. My dream (big dreamer here) is other terminals will also implement such a thing in a standard way... |
@tig If I remember correctly, there was a some discussion a while back about coming up with a terminal standard for querying Unicode glyph support. I may be misremembering the details, and I haven't been able to track down the thread where it was discussed, but I think it would probably have covered your use case if it were ever implemented. That said, this isn't something that Windows Terminal could easily implement, even if such a standard did exist, because these query sequences are handled in conhost, which doesn't know anything about the fonts that the actual conpty client is using. So this might be one of those things that would only work with a pass-through mode (#1173). In short, it's possible this might be feasible one day, but unlikely in the near future. |
It's clear that setting I guess we can have a terminfo for WT, for all kinds of *NIX applications. We can always be This is supposed to done by terminals and not ConHost or ConPTY. For any terminal out there, if they want to support all capabilities of ConHost then they should need to announce it. ConHost won't do it for them. Applications should just behave the way they do right now when terminfo is not found or they don't recognise the terminal. Remaining problems:
|
This is in accordance to [this comment](microsoft/terminal#1040 (comment)). As discussed further in the issue, in an ideal world, we wouldn't check "user agents" of terminals one-by-one, but instead would do proper feature probing like described [here](https://github.com/termstandard/colors). But anyway: This is a good first step to enhance Windows support. Co-authored-by: Ankit <oss@ankit.pl>
Summary of the new feature/enhancement
Maybe this is as simple as an environment variable like VSCode uses for its terminal e.g.
TERM_PROGRAM=WindowsTerminal
/TERM_PROGRAM_VERSION=0.0.1.0
.Proposed technical implementation details (optional)
Start by creating the environment variables above so those of us using PowerShell can adapt our user experience (via PowerShell profiles) to Windows Terminal.
The text was updated successfully, but these errors were encountered: