[PR #14444] Add support for the DECRQM escape sequence #30102

Open
opened 2026-01-31 09:38:39 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/14444

State: closed
Merged: Yes


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.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/14444 **State:** closed **Merged:** Yes --- 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.
claunia added the pull-request label 2026-01-31 09:38:39 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30102