[PR #4289] [MERGED] Remove unneeded VT-specific control character handling #25705

Closed
opened 2026-01-31 09:11:15 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4289
Author: @j4james
Created: 1/18/2020
Status: Merged
Merged: 1/29/2020
Merged by: @undefined

Base: masterHead: cleanup-vt-control-chars


📝 Commits (8)

  • 8f9f3a9 Don't treat a TAB differently in VT mode in the WriteCharsLegacy function.
  • 77eb3ba Remove WC_NONDESTRUCTIVE_TAB flag, since that functionality is no longer required.
  • abf3ba8 Don't treat BS differently in VT mode in the WriteCharsLegacy function.
  • 36c41f0 Simplify the delayed EOL implementation, removing special case handling of VT control characters.
  • 94f4db3 Remove control chars from Terminal::_WriteBuffer that are now handled in the dispatcher.
  • 550a685 Make the InVTMode method private, since it's only used internally by the SCREEN_INFORMATION class now.
  • 7f0bcad Move the Terminal::_WriteBuffer cursor movement into a separate method so that functionality can be reused.
  • da0924b Create a new TerminalApi method to implement linefeeds, so LF handling can be removed from the _WriteBuffer method.

📊 Changes

10 files changed (+145 additions, -208 deletions)

View changed files

📝 src/cascadia/TerminalCore/ITerminalApi.hpp (+1 -0)
📝 src/cascadia/TerminalCore/Terminal.cpp (+62 -82)
📝 src/cascadia/TerminalCore/Terminal.hpp (+3 -0)
📝 src/cascadia/TerminalCore/TerminalApi.cpp (+21 -0)
📝 src/cascadia/TerminalCore/TerminalDispatch.cpp (+2 -5)
📝 src/host/_stream.cpp (+41 -105)
📝 src/host/cmdline.h (+1 -1)
📝 src/host/outputStream.cpp (+1 -1)
📝 src/host/screenInfo.cpp (+12 -12)
📝 src/host/screenInfo.hpp (+1 -2)

📄 Description

Summary of the Pull Request

This PR removes all of the VT-specific functionality from the WriteCharsLegacy function that dealt with control characters, since those controls are now handled in the state machine when in VT mode. It also removes most of the control character handling from the Terminal::_WriteBuffer method for the same reason.

References

This is a followup to PR #4171

PR Checklist

Detailed Description of the Pull Request / Additional comments

There are four changes to the WriteCharsLegacy implementation:

  1. The TAB character had special case handling in VT mode which is now no longer required. This fixes a bug in the Python REPL editor (when run from a cmd shell in Windows Terminal), which would prevent you tabbing past the end of the line. It also fixes #3971.

  2. Following on from point 1, the WC_NONDESTRUCTIVE_TAB flag could also now be removed. It only ever applied in VT mode, in which case the TAB character isn't handled in WriteCharsLegacy, so there isn't a need for a non-destructive version.

  3. There used to be special case handling for a BS character at the beginning of the line when in VT mode, and that is also no longer required. This fixes an edge-case bug which would prevent a glyph being output for code point 8 when ENABLE_PROCESSED_OUTPUT was disabled.

  4. There was quite a lot of special case handling for control characters in the "end-of-line wrap" implementation, which is no longer required. This fixes a bug which would prevent "low ASCII" characters from wrapping when output at the end of a line.

Then in the Terminal::_WriteBuffer implementation, I've simply removed all control character handling, except for LF. The Terminal is always in VT mode, so the control characters are always handled by the state machine. The exception for the LF character is simply because it doesn't have a proper implementation yet, so it still passes the character through to _WriteBuffer. That will get cleaned up eventually, but I thought that could wait for a later PR.

Finally, with the removal of the VT mode handling in WriteCharsLegacy, there was no longer a need for the SCREEN_INFORMATION::InVTMode method to be publicly accessible. That has now been made private.

Validation Steps Performed

I've only tested manually, making sure the conhost and Windows Terminal still basically work, and confirming that the above-mentioned bugs are fixed by these changes.


🔄 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/4289 **Author:** [@j4james](https://github.com/j4james) **Created:** 1/18/2020 **Status:** ✅ Merged **Merged:** 1/29/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `cleanup-vt-control-chars` --- ### 📝 Commits (8) - [`8f9f3a9`](https://github.com/microsoft/terminal/commit/8f9f3a9e7cb3416fc4e2109c6bc81af56c7cde59) Don't treat a TAB differently in VT mode in the WriteCharsLegacy function. - [`77eb3ba`](https://github.com/microsoft/terminal/commit/77eb3ba03787172cea4101110f9984caa54eb91b) Remove WC_NONDESTRUCTIVE_TAB flag, since that functionality is no longer required. - [`abf3ba8`](https://github.com/microsoft/terminal/commit/abf3ba8207a9205d2e6387a87a841da9f7068f54) Don't treat BS differently in VT mode in the WriteCharsLegacy function. - [`36c41f0`](https://github.com/microsoft/terminal/commit/36c41f06a42dbcf190b2078bcb68d9850741952c) Simplify the delayed EOL implementation, removing special case handling of VT control characters. - [`94f4db3`](https://github.com/microsoft/terminal/commit/94f4db32cdbc41fc9f3234f5c35554f230aab7fc) Remove control chars from Terminal::_WriteBuffer that are now handled in the dispatcher. - [`550a685`](https://github.com/microsoft/terminal/commit/550a68587984448210c60bf6298cadb9f0afd94a) Make the InVTMode method private, since it's only used internally by the SCREEN_INFORMATION class now. - [`7f0bcad`](https://github.com/microsoft/terminal/commit/7f0bcad72bba5e131ba94aab84efdc6a911247e5) Move the Terminal::_WriteBuffer cursor movement into a separate method so that functionality can be reused. - [`da0924b`](https://github.com/microsoft/terminal/commit/da0924b43df07f2d5831f38090f83949575659fb) Create a new TerminalApi method to implement linefeeds, so LF handling can be removed from the _WriteBuffer method. ### 📊 Changes **10 files changed** (+145 additions, -208 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalCore/ITerminalApi.hpp` (+1 -0) 📝 `src/cascadia/TerminalCore/Terminal.cpp` (+62 -82) 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+3 -0) 📝 `src/cascadia/TerminalCore/TerminalApi.cpp` (+21 -0) 📝 `src/cascadia/TerminalCore/TerminalDispatch.cpp` (+2 -5) 📝 `src/host/_stream.cpp` (+41 -105) 📝 `src/host/cmdline.h` (+1 -1) 📝 `src/host/outputStream.cpp` (+1 -1) 📝 `src/host/screenInfo.cpp` (+12 -12) 📝 `src/host/screenInfo.hpp` (+1 -2) </details> ### 📄 Description ## Summary of the Pull Request This PR removes all of the VT-specific functionality from the `WriteCharsLegacy` function that dealt with control characters, since those controls are now handled in the state machine when in VT mode. It also removes most of the control character handling from the `Terminal::_WriteBuffer` method for the same reason. ## References This is a followup to PR #4171 ## PR Checklist * [x] Closes #3971 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Requires documentation to be updated * [x] 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: https://github.com/microsoft/terminal/issues/780#issuecomment-570287435 ## Detailed Description of the Pull Request / Additional comments There are four changes to the `WriteCharsLegacy` implementation: 1. The `TAB` character had special case handling in VT mode which is now no longer required. This fixes a bug in the Python REPL editor (when run from a cmd shell in Windows Terminal), which would prevent you tabbing past the end of the line. It also fixes #3971. 2. Following on from point 1, the `WC_NONDESTRUCTIVE_TAB` flag could also now be removed. It only ever applied in VT mode, in which case the `TAB` character isn't handled in `WriteCharsLegacy`, so there isn't a need for a non-destructive version. 3. There used to be special case handling for a `BS` character at the beginning of the line when in VT mode, and that is also no longer required. This fixes an edge-case bug which would prevent a glyph being output for code point 8 when `ENABLE_PROCESSED_OUTPUT` was disabled. 4. There was quite a lot of special case handling for control characters in the "end-of-line wrap" implementation, which is no longer required. This fixes a bug which would prevent "low ASCII" characters from wrapping when output at the end of a line. Then in the `Terminal::_WriteBuffer` implementation, I've simply removed all control character handling, except for `LF`. The Terminal is always in VT mode, so the control characters are always handled by the state machine. The exception for the `LF` character is simply because it doesn't have a proper implementation yet, so it still passes the character through to `_WriteBuffer`. That will get cleaned up eventually, but I thought that could wait for a later PR. Finally, with the removal of the VT mode handling in `WriteCharsLegacy`, there was no longer a need for the `SCREEN_INFORMATION::InVTMode` method to be publicly accessible. That has now been made private. ## Validation Steps Performed I've only tested manually, making sure the conhost and Windows Terminal still basically work, and confirming that the above-mentioned bugs are fixed by these changes. --- <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:11:15 +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#25705