From 5fc00d5bb3261f059b041832a3cb6e0e37ee17b3 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 14 May 2020 16:22:38 -0500 Subject: [PATCH] I think this is the rest of the cleanup needed for PR --- src/cascadia/TerminalCore/TerminalDispatch.cpp | 7 ++++--- src/renderer/vt/VtSequences.cpp | 5 ++++- src/renderer/vt/state.cpp | 5 ++++- src/terminal/adapter/InteractDispatch.cpp | 9 +++++---- src/terminal/parser/InputStateMachineEngine.cpp | 11 ++++++++++- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/cascadia/TerminalCore/TerminalDispatch.cpp b/src/cascadia/TerminalCore/TerminalDispatch.cpp index def069cbd2e..d58cf99869f 100644 --- a/src/cascadia/TerminalCore/TerminalDispatch.cpp +++ b/src/cascadia/TerminalCore/TerminalDispatch.cpp @@ -246,10 +246,11 @@ bool TerminalDispatch::SetCursorKeysMode(const bool applicationMode) noexcept return true; } -// Method Description -// - TODO +// Method Description: +// - win32-input-mode: Enable sending full input records encoded as a string of +// characters to the client application. // Arguments: -// - applicationMode - set to true to enable Application Mode Input, false for Numeric Mode Input. +// - win32InputMode - set to true to enable win32-input-mode, false to disable. // Return Value: // - True if handled successfully. False otherwise. bool TerminalDispatch::EnableWin32InputMode(const bool win32Mode) noexcept diff --git a/src/renderer/vt/VtSequences.cpp b/src/renderer/vt/VtSequences.cpp index c94f4842b47..06568831551 100644 --- a/src/renderer/vt/VtSequences.cpp +++ b/src/renderer/vt/VtSequences.cpp @@ -438,7 +438,10 @@ using namespace Microsoft::Console::Render; } // Method Description: -// - TODO +// - Send a sequence to the connected terminal to request win32-input-mode from +// them. This will enable the connected terminal to send us full INPUT_RECORDs +// as input. If the terminal doesn't understand this sequence, it'll just +// ignore it. // Arguments: // - // Return Value: diff --git a/src/renderer/vt/state.cpp b/src/renderer/vt/state.cpp index 7fa21c56a8a..c03b6574634 100644 --- a/src/renderer/vt/state.cpp +++ b/src/renderer/vt/state.cpp @@ -511,7 +511,10 @@ void VtEngine::SetResizeQuirk(const bool resizeQuirk) } // Method Description: -// - TODO +// - Send a sequence to the connected terminal to request win32-input-mode from +// them. This will enable the connected terminal to send us full INPUT_RECORDs +// as input. If the terminal doesn't understand this sequence, it'll just +// ignore it. // Arguments: // - // Return Value: diff --git a/src/terminal/adapter/InteractDispatch.cpp b/src/terminal/adapter/InteractDispatch.cpp index ffc17da0e14..51f176164c9 100644 --- a/src/terminal/adapter/InteractDispatch.cpp +++ b/src/terminal/adapter/InteractDispatch.cpp @@ -37,11 +37,12 @@ bool InteractDispatch::WriteInput(std::deque>& inpu } // Method Description: -// - Writes a Ctrl-C event to the host. The host will then decide what to do -// with it, including potentially sending an interrupt to a client -// application. +// - Writes a key event to the host in a fashion that will enable the host to +// process special keys such as Ctrl-C or Ctrl+Break. The host will then +// decide what to do with it, including potentially sending an interrupt to a +// client application. // Arguments: -// TODO +// - event: The key to send to the host. // Return Value: // True if handled successfully. False otherwise. bool InteractDispatch::WriteCtrlKey(const KeyEvent& event) diff --git a/src/terminal/parser/InputStateMachineEngine.cpp b/src/terminal/parser/InputStateMachineEngine.cpp index 02eddf0b64d..12dbb9d1b36 100644 --- a/src/terminal/parser/InputStateMachineEngine.cpp +++ b/src/terminal/parser/InputStateMachineEngine.cpp @@ -350,7 +350,16 @@ bool InputStateMachineEngine::ActionCsiDispatch(const wchar_t wch, const std::basic_string_view parameters) { const auto actionCode = static_cast(wch); - if (_pDispatch->IsVtInputEnabled() && _pfnFlushToInputQueue && actionCode != CsiActionCodes::Win32KeyboardInput) + + // GH#4999 - If the client was in VT input mode, but we received a + // win32-input-mode sequence, then _don't_ passthrough the sequence to the + // client. It's impossibly unlikely that the client actually wanted + // win32-input-mode, and if they did, then we'll just translate the + // INPUT_RECORD back to the same sequence we say here later on, when the + // client reads it. + if (_pDispatch->IsVtInputEnabled() && + _pfnFlushToInputQueue && + actionCode != CsiActionCodes::Win32KeyboardInput) { return _pfnFlushToInputQueue(); }