[PR #13227] [MERGED] Restore the DECCTR color table report over conpty #29429

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/13227
Author: @j4james
Created: 6/4/2022
Status: Merged
Merged: 6/10/2022
Merged by: @undefined

Base: mainHead: enhance-passthrough-decctr


📝 Commits (4)

  • 085f642 Provide a way to forward DCS sequences over conpty.
  • 47bc327 Flush passthrough data at the end of each output segment.
  • b248ec9 Avoid caching string sequence data in the state machine.
  • 1450ae2 Add a conpty test to verify DECCTR is now passed through.

📊 Changes

5 files changed (+117 additions, -2 deletions)

View changed files

📝 src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp (+38 -0)
📝 src/terminal/adapter/adaptDispatch.cpp (+51 -0)
📝 src/terminal/adapter/adaptDispatch.hpp (+2 -0)
📝 src/terminal/parser/stateMachine.cpp (+24 -2)
📝 src/terminal/parser/stateMachine.hpp (+2 -0)

📄 Description

Summary of the Pull Request

Up to now we haven't supported passing DCS sequences over conpty, so
any DCS operations would just be ignored in Windows Terminal. This PR
introduces a mechanism whereby we can selectively pass through
operations that could reasonably be handled by the connected terminal
without interfering with the regular conpty renderer. For now this is
just used to support restoring the DECCTR color table report.

References

Support for DECCTR was originally added to conhost in PR #13139.

PR Checklist

  • Closes Prompt, history (#13223)
  • CLA signed.
  • Tests added/passed
  • Documentation updated.
  • Schema updated.
  • I've discussed this with core contributors already. If not
    checked, I'm ready to accept this work might be rejected in favor of a
    different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

The way this works is we have a helper method in AdaptDispatch that
DCS operations can use to create a passthrough StringHandler for the
incoming data instead of their usual handler. To make this passthrough
process more efficient, the handler buffers the data before forwarding
it to conpty.

However, it's important that we aren't holding back data if output is
paused before the string terminator, so we need to flush the buffer
whenever we reach the end of the current write operation. This is
achieved by querying a new method in the StateMachine that lets us
know if we're currently dealing with the last character.

Another issue that came up was with the way the StateMachine caches
sequences that it might later need to forward to conpty. In the case of
string sequences like DCS, we don't want the actual string data cached
here, because that will just waste memory, and can also result in the
data being mistakenly output. So I've now disabled that caching when
we're in any of the string processing states.

Validation Steps Performed

I've manually confirmed that the DECCTR sequence can now update the
color table in Windows Terminal. I've also added a new unit test in
ConptyRoundtripTests to verify the sequence is being passed through
successfully.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/13227 **Author:** [@j4james](https://github.com/j4james) **Created:** 6/4/2022 **Status:** ✅ Merged **Merged:** 6/10/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `enhance-passthrough-decctr` --- ### 📝 Commits (4) - [`085f642`](https://github.com/microsoft/terminal/commit/085f642395997d222a8d6e763d4e679877474c7f) Provide a way to forward DCS sequences over conpty. - [`47bc327`](https://github.com/microsoft/terminal/commit/47bc3277a892cdb8e90f4b06842e9cd4dd2af328) Flush passthrough data at the end of each output segment. - [`b248ec9`](https://github.com/microsoft/terminal/commit/b248ec97d441b9a995fe18299e6fac43ba95adab) Avoid caching string sequence data in the state machine. - [`1450ae2`](https://github.com/microsoft/terminal/commit/1450ae2f7d550cc1d5d72141e96d8bf8f34ea992) Add a conpty test to verify DECCTR is now passed through. ### 📊 Changes **5 files changed** (+117 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp` (+38 -0) 📝 `src/terminal/adapter/adaptDispatch.cpp` (+51 -0) 📝 `src/terminal/adapter/adaptDispatch.hpp` (+2 -0) 📝 `src/terminal/parser/stateMachine.cpp` (+24 -2) 📝 `src/terminal/parser/stateMachine.hpp` (+2 -0) </details> ### 📄 Description ## Summary of the Pull Request Up to now we haven't supported passing `DCS` sequences over conpty, so any `DCS` operations would just be ignored in Windows Terminal. This PR introduces a mechanism whereby we can selectively pass through operations that could reasonably be handled by the connected terminal without interfering with the regular conpty renderer. For now this is just used to support restoring the `DECCTR` color table report. ## References Support for `DECCTR` was originally added to conhost in PR #13139. ## PR Checklist * [x] Closes #13223 * [x] CLA signed. * [x] Tests added/passed * [ ] Documentation updated. * [ ] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx ## Detailed Description of the Pull Request / Additional comments The way this works is we have a helper method in `AdaptDispatch` that `DCS` operations can use to create a passthrough `StringHandler` for the incoming data instead of their usual handler. To make this passthrough process more efficient, the handler buffers the data before forwarding it to conpty. However, it's important that we aren't holding back data if output is paused before the string terminator, so we need to flush the buffer whenever we reach the end of the current write operation. This is achieved by querying a new method in the `StateMachine` that lets us know if we're currently dealing with the last character. Another issue that came up was with the way the `StateMachine` caches sequences that it might later need to forward to conpty. In the case of string sequences like `DCS`, we don't want the actual string data cached here, because that will just waste memory, and can also result in the data being mistakenly output. So I've now disabled that caching when we're in any of the string processing states. ## Validation Steps Performed I've manually confirmed that the `DECCTR` sequence can now update the color table in Windows Terminal. I've also added a new unit test in `ConptyRoundtripTests` to verify the sequence is being passed through successfully. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:34:52 +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#29429