[PR #11384] [MERGED] Consolidate the interfaces for setting VT input modes #28535

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/11384
Author: @j4james
Created: 9/30/2021
Status: Merged
Merged: 10/26/2021
Merged by: @undefined

Base: mainHead: consolidate-input-modes


📝 Commits (6)

  • c8e4b4a Merge the TerminalInput keyboard mode methods.
  • 04c753e Merge the ConGetSet keyboard mode methods.
  • 7aea2f6 Merge the mouse encoding with the other input modes.
  • e577683 Merge the mouse tracking with other input modes.
  • a9a9875 Merge alternate scroll with the other input modes.
  • 2e32c87 Simplify ITerminalApi in the same way as ConGetSet.

📊 Changes

17 files changed (+181 additions, -752 deletions)

View changed files

📝 src/cascadia/TerminalCore/ITerminalApi.hpp (+3 -9)
📝 src/cascadia/TerminalCore/Terminal.hpp (+2 -9)
📝 src/cascadia/TerminalCore/TerminalApi.cpp (+4 -50)
📝 src/cascadia/TerminalCore/TerminalDispatch.cpp (+10 -10)
📝 src/host/getset.cpp (+0 -121)
📝 src/host/getset.h (+0 -11)
📝 src/host/outputStream.cpp (+19 -117)
📝 src/host/outputStream.hpp (+1 -9)
📝 src/terminal/adapter/adaptDispatch.cpp (+9 -100)
📝 src/terminal/adapter/adaptDispatch.hpp (+0 -2)
📝 src/terminal/adapter/conGetSet.hpp (+3 -9)
📝 src/terminal/adapter/ut_adapter/MouseInputTest.cpp (+18 -18)
📝 src/terminal/adapter/ut_adapter/adapterTest.cpp (+45 -122)
📝 src/terminal/input/mouseInput.cpp (+24 -29)
📝 src/terminal/input/mouseInputState.cpp (+0 -85)
📝 src/terminal/input/terminalInput.cpp (+21 -14)
📝 src/terminal/input/terminalInput.hpp (+22 -37)

📄 Description

Instead of having a separate method for setting each mouse and keyboard
mode, this PR consolidates them all into a single method which takes a
mode parameter, and stores the modes in a til::enumset rather than
having a separate bool for each mode.

This enables us to get rid of a lot of boilerplate code, and makes the
code easier to extend when we want to introduce additional modes in the
future. It'll also makes it easier to read back the state of the various
modes when implementing the DECRQM query.

Most of the complication is in the TerminalInput class, which had to
be adjusted to work with an enumset in place of all the bool fields.
For the rest, it was largely a matter of replacing calls to all the old
mode setting methods with the new SetInputMode method, and deleting a
bunch of unused code.

One thing worth mentioning is that the AdaptDispatch implementation
used to have a _ShouldPassThroughInputModeChange method that was
called after every mode change. This code has now been moved up into the
SetInputMode implementation in ConhostInternalGetSet so it's just
handled in one place. Keeping this out of the dispatch class will also
be beneficial for sharing the implementation with TerminalDispatch.

Validation

The updated interface necessitated some adjustments to the tests in
AdapterTest and MouseInputTest, but the essential structure of the
tests remains unchanged, and everything still passes.

I've also tested the keyboard and mouse modes in Vttest and confirmed
they still work at least as well as they did before (both conhost and
Windows Terminal), and I tested the alternate scroll mode manually
(conhost only).

Simplifying the ConGetSet and ITerminalApi is also part of the plan
to de-duplicate the AdaptDispatch and TerminalDispatch
implementation (#3849).


🔄 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/11384 **Author:** [@j4james](https://github.com/j4james) **Created:** 9/30/2021 **Status:** ✅ Merged **Merged:** 10/26/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `consolidate-input-modes` --- ### 📝 Commits (6) - [`c8e4b4a`](https://github.com/microsoft/terminal/commit/c8e4b4af47766b14faf5eae5c90831ef0d831d9a) Merge the TerminalInput keyboard mode methods. - [`04c753e`](https://github.com/microsoft/terminal/commit/04c753e499e9667edf2d8a3ccb43366122f2d3e1) Merge the ConGetSet keyboard mode methods. - [`7aea2f6`](https://github.com/microsoft/terminal/commit/7aea2f6e4fb405df5192608da847c618bf87b721) Merge the mouse encoding with the other input modes. - [`e577683`](https://github.com/microsoft/terminal/commit/e577683a21873fb1215035e56daac1dd4fc58442) Merge the mouse tracking with other input modes. - [`a9a9875`](https://github.com/microsoft/terminal/commit/a9a9875004cdc4af54a8bd6f6190a2d90cd4e0eb) Merge alternate scroll with the other input modes. - [`2e32c87`](https://github.com/microsoft/terminal/commit/2e32c87d8763d8039cb292aa00937509b3371127) Simplify ITerminalApi in the same way as ConGetSet. ### 📊 Changes **17 files changed** (+181 additions, -752 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalCore/ITerminalApi.hpp` (+3 -9) 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+2 -9) 📝 `src/cascadia/TerminalCore/TerminalApi.cpp` (+4 -50) 📝 `src/cascadia/TerminalCore/TerminalDispatch.cpp` (+10 -10) 📝 `src/host/getset.cpp` (+0 -121) 📝 `src/host/getset.h` (+0 -11) 📝 `src/host/outputStream.cpp` (+19 -117) 📝 `src/host/outputStream.hpp` (+1 -9) 📝 `src/terminal/adapter/adaptDispatch.cpp` (+9 -100) 📝 `src/terminal/adapter/adaptDispatch.hpp` (+0 -2) 📝 `src/terminal/adapter/conGetSet.hpp` (+3 -9) 📝 `src/terminal/adapter/ut_adapter/MouseInputTest.cpp` (+18 -18) 📝 `src/terminal/adapter/ut_adapter/adapterTest.cpp` (+45 -122) 📝 `src/terminal/input/mouseInput.cpp` (+24 -29) 📝 `src/terminal/input/mouseInputState.cpp` (+0 -85) 📝 `src/terminal/input/terminalInput.cpp` (+21 -14) 📝 `src/terminal/input/terminalInput.hpp` (+22 -37) </details> ### 📄 Description Instead of having a separate method for setting each mouse and keyboard mode, this PR consolidates them all into a single method which takes a mode parameter, and stores the modes in a `til::enumset` rather than having a separate `bool` for each mode. This enables us to get rid of a lot of boilerplate code, and makes the code easier to extend when we want to introduce additional modes in the future. It'll also makes it easier to read back the state of the various modes when implementing the `DECRQM` query. Most of the complication is in the `TerminalInput` class, which had to be adjusted to work with an `enumset` in place of all the `bool` fields. For the rest, it was largely a matter of replacing calls to all the old mode setting methods with the new `SetInputMode` method, and deleting a bunch of unused code. One thing worth mentioning is that the `AdaptDispatch` implementation used to have a `_ShouldPassThroughInputModeChange` method that was called after every mode change. This code has now been moved up into the `SetInputMode` implementation in `ConhostInternalGetSet` so it's just handled in one place. Keeping this out of the dispatch class will also be beneficial for sharing the implementation with `TerminalDispatch`. ## Validation The updated interface necessitated some adjustments to the tests in `AdapterTest` and `MouseInputTest`, but the essential structure of the tests remains unchanged, and everything still passes. I've also tested the keyboard and mouse modes in Vttest and confirmed they still work at least as well as they did before (both conhost and Windows Terminal), and I tested the alternate scroll mode manually (conhost only). Simplifying the `ConGetSet` and `ITerminalApi` is also part of the plan to de-duplicate the `AdaptDispatch` and `TerminalDispatch` implementation (#3849). --- <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:29:10 +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#28535