7b7dea009c
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).
31 lines
793 B
C++
31 lines
793 B
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#include "precomp.h"
|
|
#include <windows.h>
|
|
#include "terminalInput.hpp"
|
|
|
|
using namespace Microsoft::Console::VirtualTerminal;
|
|
|
|
// Routine Description:
|
|
// - Notify the MouseInput handler that the screen buffer has been swapped to the alternate buffer
|
|
// Parameters:
|
|
// <none>
|
|
// Return value:
|
|
// <none>
|
|
void TerminalInput::UseAlternateScreenBuffer() noexcept
|
|
{
|
|
_mouseInputState.inAlternateBuffer = true;
|
|
}
|
|
|
|
// Routine Description:
|
|
// - Notify the MouseInput handler that the screen buffer has been swapped to the alternate buffer
|
|
// Parameters:
|
|
// <none>
|
|
// Return value:
|
|
// <none>
|
|
void TerminalInput::UseMainScreenBuffer() noexcept
|
|
{
|
|
_mouseInputState.inAlternateBuffer = false;
|
|
}
|