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

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

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

State: closed
Merged: Yes


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).

**Original Pull Request:** https://github.com/microsoft/terminal/pull/11384 **State:** closed **Merged:** Yes --- 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).
claunia added the pull-request label 2026-01-31 09:29:11 +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#28540