[PR #4789] [MERGED] Add support for VT52 emulation #25944

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4789
Author: @j4james
Created: 3/3/2020
Status: Merged
Merged: 6/1/2020
Merged by: @undefined

Base: masterHead: feature-vt52-support


📝 Commits (9)

  • 3ea6be9 Update the state machine to support VT52 escape sequences.
  • 0137763 Add support for the DECANM escape sequence to switch between ANSI and VT52 emulation modes.
  • 18f4350 Hook up VT52 escape sequences to existing methods in the dispatcher.
  • 0b03df0 Add support for the VT52 terminal identifaction sequence.
  • 662a6b1 Add partial support for VT52 key mappings.
  • 45f1fe9 Add state machine and adapter tests to confirm that the mode changing escape sequences are dispatched correctly.
  • 05862a9 Add state machine tests to confirm that the VT52 escape sequences are dispatched correctly when ANSI mode is reset.
  • ad2483e Extend the VT command fuzzer to generate VT52 sequences and mode changes.
  • 5602e86 Reset the designated character sets whenever the DECANM mode is toggled.

📊 Changes

21 files changed (+592 additions, -21 deletions)

View changed files

📝 src/host/outputStream.cpp (+17 -0)
📝 src/host/outputStream.hpp (+1 -0)
📝 src/terminal/adapter/DispatchTypes.hpp (+1 -0)
📝 src/terminal/adapter/ITermDispatch.hpp (+2 -0)
📝 src/terminal/adapter/adaptDispatch.cpp (+30 -0)
📝 src/terminal/adapter/adaptDispatch.hpp (+2 -0)
📝 src/terminal/adapter/conGetSet.hpp (+1 -0)
📝 src/terminal/adapter/termDispatch.hpp (+2 -0)
📝 src/terminal/adapter/ut_adapter/adapterTest.cpp (+34 -0)
📝 src/terminal/input/terminalInput.cpp (+60 -8)
📝 src/terminal/input/terminalInput.hpp (+2 -0)
📝 src/terminal/parser/IStateMachineEngine.hpp (+3 -0)
📝 src/terminal/parser/InputStateMachineEngine.cpp (+18 -0)
📝 src/terminal/parser/InputStateMachineEngine.hpp (+4 -0)
📝 src/terminal/parser/OutputStateMachineEngine.cpp (+83 -0)
📝 src/terminal/parser/OutputStateMachineEngine.hpp (+23 -0)
📝 src/terminal/parser/ft_fuzzer/VTCommandFuzzer.cpp (+30 -1)
📝 src/terminal/parser/stateMachine.cpp (+127 -11)
📝 src/terminal/parser/stateMachine.hpp (+9 -1)
📝 src/terminal/parser/ut_parser/OutputEngineTest.cpp (+139 -0)

...and 1 more files

📄 Description

Summary of the Pull Request

This PR adds support for the core VT52 commands, and implements the DECANM private mode sequence, which switches the terminal between ANSI mode and VT52-compatible mode.

References

PR #2017 defined the initial specification for VT52 support.
PR #4044 removed the original VT52 cursor ops that conflicted with VT100 sequences.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Most of the work involves updates to the parsing state machine, which behaves differently in VT52 mode. CSI, OSC, and SS3 sequences are not applicable, and there is one special-case escape sequence (Direct Cursor Address), which requires an additional state to handle parameters that come after the final character.

Once the parsing is handled though, it's mostly just a matter of dispatching the commands to existing methods in the ITermDispatch interface. Only one new method was required in the interface to handle the Identify command.

The only real new functionality is in the TerminalInput class, which needs to generate different escape sequences for certain keys in VT52 mode. This does not yet support all of the VT52 key sequences, because the VT100 support is itself not yet complete. But the basics are in place, and I think the rest is best left for a follow-up issue, and potentially a refactor of the TerminalInput class.

I should point out that the original spec called for a new Graphic Mode character set, but I've since discovered that the VT terminals that emulate VT52 just use the existing VT100 Special Graphics set, so that is really what we should be doing too. We can always consider adding the VT52 graphic set as a option later, if there is demand for strict VT52 compatibility.

Validation Steps Performed

I've added state machine and adapter tests to confirm that the DECANM mode changing sequences are correctly dispatched and forwarded to the ConGetSet handler. I've also added state machine tests that confirm the VT52 escape sequences are dispatched correctly when the ANSI mode is reset.

For fuzzing support, I've extended the VT command fuzzer to generate the different kinds of VT52 sequences, as well as mode change sequences to switch between the ANSI and VT52 modes.

In terms of manual testing, I've confirmed that the Test of VT52 mode in Vttest now works as expected.


🔄 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/4789 **Author:** [@j4james](https://github.com/j4james) **Created:** 3/3/2020 **Status:** ✅ Merged **Merged:** 6/1/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `feature-vt52-support` --- ### 📝 Commits (9) - [`3ea6be9`](https://github.com/microsoft/terminal/commit/3ea6be9a36ba28f8e70f75d7b7340771cde593e4) Update the state machine to support VT52 escape sequences. - [`0137763`](https://github.com/microsoft/terminal/commit/013776335f29857404f9b8cfb00ec4c702a284a6) Add support for the DECANM escape sequence to switch between ANSI and VT52 emulation modes. - [`18f4350`](https://github.com/microsoft/terminal/commit/18f43504fcd01e055b460d19c6fdea7a0fdfcfca) Hook up VT52 escape sequences to existing methods in the dispatcher. - [`0b03df0`](https://github.com/microsoft/terminal/commit/0b03df02e2271055c43174b21f7cb39abe2653cc) Add support for the VT52 terminal identifaction sequence. - [`662a6b1`](https://github.com/microsoft/terminal/commit/662a6b13c0685e76dd72ec02e3ae484a04549fdf) Add partial support for VT52 key mappings. - [`45f1fe9`](https://github.com/microsoft/terminal/commit/45f1fe935314aeba50f2f44647c06816a64d2610) Add state machine and adapter tests to confirm that the mode changing escape sequences are dispatched correctly. - [`05862a9`](https://github.com/microsoft/terminal/commit/05862a9fa4b76968fbde7bde25563144005c07f8) Add state machine tests to confirm that the VT52 escape sequences are dispatched correctly when ANSI mode is reset. - [`ad2483e`](https://github.com/microsoft/terminal/commit/ad2483e70ac7e2d30a653c38bfb0ab5330f1fea0) Extend the VT command fuzzer to generate VT52 sequences and mode changes. - [`5602e86`](https://github.com/microsoft/terminal/commit/5602e86317239916e9c5c9481e1c8c49571785cc) Reset the designated character sets whenever the DECANM mode is toggled. ### 📊 Changes **21 files changed** (+592 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `src/host/outputStream.cpp` (+17 -0) 📝 `src/host/outputStream.hpp` (+1 -0) 📝 `src/terminal/adapter/DispatchTypes.hpp` (+1 -0) 📝 `src/terminal/adapter/ITermDispatch.hpp` (+2 -0) 📝 `src/terminal/adapter/adaptDispatch.cpp` (+30 -0) 📝 `src/terminal/adapter/adaptDispatch.hpp` (+2 -0) 📝 `src/terminal/adapter/conGetSet.hpp` (+1 -0) 📝 `src/terminal/adapter/termDispatch.hpp` (+2 -0) 📝 `src/terminal/adapter/ut_adapter/adapterTest.cpp` (+34 -0) 📝 `src/terminal/input/terminalInput.cpp` (+60 -8) 📝 `src/terminal/input/terminalInput.hpp` (+2 -0) 📝 `src/terminal/parser/IStateMachineEngine.hpp` (+3 -0) 📝 `src/terminal/parser/InputStateMachineEngine.cpp` (+18 -0) 📝 `src/terminal/parser/InputStateMachineEngine.hpp` (+4 -0) 📝 `src/terminal/parser/OutputStateMachineEngine.cpp` (+83 -0) 📝 `src/terminal/parser/OutputStateMachineEngine.hpp` (+23 -0) 📝 `src/terminal/parser/ft_fuzzer/VTCommandFuzzer.cpp` (+30 -1) 📝 `src/terminal/parser/stateMachine.cpp` (+127 -11) 📝 `src/terminal/parser/stateMachine.hpp` (+9 -1) 📝 `src/terminal/parser/ut_parser/OutputEngineTest.cpp` (+139 -0) _...and 1 more files_ </details> ### 📄 Description ## Summary of the Pull Request This PR adds support for the core VT52 commands, and implements the `DECANM` private mode sequence, which switches the terminal between ANSI mode and VT52-compatible mode. ## References PR #2017 defined the initial specification for VT52 support. PR #4044 removed the original VT52 cursor ops that conflicted with VT100 sequences. ## PR Checklist * [x] Closes #976 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] 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: #2017 ## Detailed Description of the Pull Request / Additional comments Most of the work involves updates to the parsing state machine, which behaves differently in VT52 mode. `CSI`, `OSC`, and `SS3` sequences are not applicable, and there is one special-case escape sequence (_Direct Cursor Address_), which requires an additional state to handle parameters that come _after_ the final character. Once the parsing is handled though, it's mostly just a matter of dispatching the commands to existing methods in the `ITermDispatch` interface. Only one new method was required in the interface to handle the _Identify_ command. The only real new functionality is in the `TerminalInput` class, which needs to generate different escape sequences for certain keys in VT52 mode. This does not yet support _all_ of the VT52 key sequences, because the VT100 support is itself not yet complete. But the basics are in place, and I think the rest is best left for a follow-up issue, and potentially a refactor of the `TerminalInput` class. I should point out that the original spec called for a new _Graphic Mode_ character set, but I've since discovered that the VT terminals that _emulate_ VT52 just use the existing VT100 _Special Graphics_ set, so that is really what we should be doing too. We can always consider adding the VT52 graphic set as a option later, if there is demand for strict VT52 compatibility. ## Validation Steps Performed I've added state machine and adapter tests to confirm that the `DECANM` mode changing sequences are correctly dispatched and forwarded to the `ConGetSet` handler. I've also added state machine tests that confirm the VT52 escape sequences are dispatched correctly when the ANSI mode is reset. For fuzzing support, I've extended the VT command fuzzer to generate the different kinds of VT52 sequences, as well as mode change sequences to switch between the ANSI and VT52 modes. In terms of manual testing, I've confirmed that the _Test of VT52 mode_ in Vttest now works as expected. --- <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:12:50 +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#25944