-
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
Support for XTSAVE and XTRESTORE or DECRQM #10153
Comments
I'd prefer we didn't implement |
So, I'm of two minds on this. It's really useful to generally know the state of the terminal, but it seems like the generally-accepted practice is that an application asserts the states that it needs before it needs them. Shells that support bracketed paste re-emit DECSET 2004 before every prompt, and DECRST before every invocation; applications that want DECCKM likewise turn it on/off when they want it. This "revert to the default state" behavior generally works, apart from when an application is terminated unceremoniously. Is it more worth it to add a back-and-forth exchange (including over links of unknown latency?) between application and terminal emulator, or to simply allow for some minor breakage¹ when an app or shell doesn't behave as it should? ¹ and of course, in the case of OSS projects, request remediation 😄 |
This is really similar to the discussions around |
Yes, if this is really the state of things then this is of course fine. I understand that adding state management is a big drag. I was hoping that it wouldn't be too hard to at least to provide the I am just dabbling into VT100 and it is a bit confusing to figure out what is implicit and not in the spec or not implemented. I would have thought that querying capabilities, getting state and set/restore would be features implemented in general. |
Yeah, this is one of the reasons I'm opposed to those sequences. They have all the same flaws. Also the
And with a decent level of support for feature detection, we have a better argument for not reporting version information. |
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.
Description of the new feature/enhancement
With the introduction of bracketed paste mode it is now possible to handle pasting when announcing support via DECSET 2004 (see #395), which is great! As a terminal-based user interface application the question now arises how to know which value to restore at the end of the application. This is usually done by using XTSAVE prior to setting bracketed paste mode and then calling XTRESTORE before closing the application or by querying the state of bracketed paste mode via DECRQM (as far as I understand).
Why is this important? Imagine the following:
\x1b[200~
etc when pasting.Please add support for either method, so we can leave bracketed paste mode in the same state as it was before the application was started.
Proposed technical implementation details (optional)
XTSAVE and XTRESTORE need to keep a stack of values for the given CSI and either push the current value on the stack or restore the value from the stack and pop.
The text was updated successfully, but these errors were encountered: