Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for win32-input-mode to conhost, ConPTY, Terminal #6309

Merged
46 commits merged into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
e96fc60
Begin drafting spec for win32-input-mode
zadjii-msft May 7, 2020
a2b28cf
stashing this for now
zadjii-msft May 8, 2020
1a6ebbe
Merge remote-tracking branch 'origin/master' into dev/migrie/s/4999-w…
zadjii-msft May 12, 2020
c570496
change it to a CSI because I like that better
zadjii-msft May 12, 2020
92e3aa9
Add a note about num lock
zadjii-msft May 12, 2020
981b4c4
Finish for review
zadjii-msft May 13, 2020
eddcbe4
Add support to conhost for the proposed win32-input-mode
zadjii-msft May 13, 2020
583a3d2
Add suport to conpty to parse these sequences into KeyEvents
zadjii-msft May 13, 2020
2699f89
Make conpty request win32-input-mode on startup
zadjii-msft May 13, 2020
46a270d
change terminator to '_', fix typos
zadjii-msft May 14, 2020
1c5e126
more typos
zadjii-msft May 14, 2020
943e714
change terminator to '_' to match spec changes
zadjii-msft May 14, 2020
6b2d952
Add support to the Windows Terminal for win32-input-mode
zadjii-msft May 14, 2020
03bf19f
infinite happiness as all the broken scenarios work again
zadjii-msft May 14, 2020
fe44dd5
Tons of doc comments
zadjii-msft May 14, 2020
5fc00d5
I think this is the rest of the cleanup needed for PR
zadjii-msft May 14, 2020
63255d5
Merge branch 'dev/migrie/s/4999-win32-input-mode' into dev/migrie/f/4…
zadjii-msft May 14, 2020
1dac38e
Some last cleanup from reviewing the PR diff
zadjii-msft May 14, 2020
61e7b2a
Merge remote-tracking branch 'origin/master' into dev/migrie/s/4999-w…
zadjii-msft May 20, 2020
4828220
A typo, and elaborate a tiny bit more on sending more input record types
zadjii-msft May 20, 2020
97292e4
This is actually quite a bit more notes about other INPUT_RECORD types
zadjii-msft May 20, 2020
5322f32
Change the request OSC to a private mode, 9001
zadjii-msft May 20, 2020
8eab51f
Merge remote-tracking branch 'origin/master' into dev/migrie/s/4999-w…
zadjii-msft May 22, 2020
ae4ef46
Re-order the params based on a discussion with @j4james
zadjii-msft May 22, 2020
d32a2b6
Merge remote-tracking branch 'origin/master' into dev/migrie/s/4999-w…
zadjii-msft Jun 1, 2020
89d2b35
good bot
zadjii-msft Jun 1, 2020
0889223
Some clarifications for @miniksa
zadjii-msft Jun 1, 2020
2844b32
Merge branch 'dev/migrie/s/4999-win32-input-mode' into dev/migrie/f/4…
zadjii-msft Jun 2, 2020
e711e11
Merge remote-tracking branch 'origin/master' into dev/migrie/f/4999-w…
zadjii-msft Jun 2, 2020
f39807d
Update implementation to match spec
zadjii-msft Jun 2, 2020
2881b51
good bot
zadjii-msft Jun 2, 2020
7373049
Remove unused WindowsOSCFunctions enum
zadjii-msft Jun 2, 2020
fd38a5f
Merge remote-tracking branch 'origin/master' into dev/migrie/f/4999-w…
zadjii-msft Jun 4, 2020
20ec191
Merge remote-tracking branch 'origin/master' into dev/migrie/f/4999-w…
zadjii-msft Jun 5, 2020
08df78e
most of the PR nits
zadjii-msft Jun 5, 2020
ac282b0
Add tests for `_GenerateWin32Key`
zadjii-msft Jun 5, 2020
d4a13f5
fix the build (I hope)
zadjii-msft Jun 8, 2020
f7b50ff
fix the build (pt 2)
zadjii-msft Jun 8, 2020
7b491c1
Merge remote-tracking branch 'origin/master' into dev/migrie/f/4999-w…
zadjii-msft Jun 8, 2020
430d0e9
This fixes the test and the SA build (part 3)
zadjii-msft Jun 8, 2020
ac516c6
Add a flag to let conpty consumers opt-in to this behavior
zadjii-msft Jun 8, 2020
1a938d7
Add `experimental.input.forceVT` as a ripchord
zadjii-msft Jun 8, 2020
a2cbfcd
lets get the build to pass
zadjii-msft Jun 8, 2020
6b2d0a8
default to repeatcount = 1
zadjii-msft Jun 8, 2020
be96c40
There's a second copy of this comment somewhere
zadjii-msft Jun 8, 2020
6661620
fix the test mock
DHowett Jun 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cascadia/PublicTerminalCore/HwndTerminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,11 +557,11 @@ catch (...)
return false;
}

void HwndTerminal::_SendKeyEvent(WORD vkey, WORD scanCode) noexcept
void HwndTerminal::_SendKeyEvent(WORD vkey, WORD scanCode, bool keyDown) noexcept
try
{
const auto flags = getControlKeyState();
_terminal->SendKeyEvent(vkey, scanCode, flags);
_terminal->SendKeyEvent(vkey, scanCode, flags, keyDown);
}
CATCH_LOG();

Expand Down Expand Up @@ -590,10 +590,10 @@ try
}
CATCH_LOG();

void _stdcall TerminalSendKeyEvent(void* terminal, WORD vkey, WORD scanCode)
void _stdcall TerminalSendKeyEvent(void* terminal, WORD vkey, WORD scanCode, bool keyDown)
{
const auto publicTerminal = static_cast<HwndTerminal*>(terminal);
publicTerminal->_SendKeyEvent(vkey, scanCode);
publicTerminal->_SendKeyEvent(vkey, scanCode, keyDown);
}

void _stdcall TerminalSendCharEvent(void* terminal, wchar_t ch, WORD scanCode)
Expand Down
6 changes: 3 additions & 3 deletions src/cascadia/PublicTerminalCore/HwndTerminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ __declspec(dllexport) bool _stdcall TerminalIsSelectionActive(void* terminal);
__declspec(dllexport) void _stdcall DestroyTerminal(void* terminal);
__declspec(dllexport) void _stdcall TerminalSetTheme(void* terminal, TerminalTheme theme, LPCWSTR fontFamily, short fontSize, int newDpi);
__declspec(dllexport) void _stdcall TerminalRegisterWriteCallback(void* terminal, const void __stdcall callback(wchar_t*));
__declspec(dllexport) void _stdcall TerminalSendKeyEvent(void* terminal, WORD vkey, WORD scanCode);
__declspec(dllexport) void _stdcall TerminalSendKeyEvent(void* terminal, WORD vkey, WORD scanCode, bool keyDown);
__declspec(dllexport) void _stdcall TerminalSendCharEvent(void* terminal, wchar_t ch, WORD scanCode);
__declspec(dllexport) void _stdcall TerminalBlinkCursor(void* terminal);
__declspec(dllexport) void _stdcall TerminalSetCursorVisible(void* terminal, const bool visible);
Expand Down Expand Up @@ -92,7 +92,7 @@ struct HwndTerminal : ::Microsoft::Console::Types::IControlAccessibilityInfo
friend void _stdcall TerminalClearSelection(void* terminal);
friend const wchar_t* _stdcall TerminalGetSelection(void* terminal);
friend bool _stdcall TerminalIsSelectionActive(void* terminal);
friend void _stdcall TerminalSendKeyEvent(void* terminal, WORD vkey, WORD scanCode);
friend void _stdcall TerminalSendKeyEvent(void* terminal, WORD vkey, WORD scanCode, bool keyDown);
friend void _stdcall TerminalSendCharEvent(void* terminal, wchar_t ch, WORD scanCode);
friend void _stdcall TerminalSetTheme(void* terminal, TerminalTheme theme, LPCWSTR fontFamily, short fontSize, int newDpi);
friend void _stdcall TerminalBlinkCursor(void* terminal);
Expand All @@ -115,7 +115,7 @@ struct HwndTerminal : ::Microsoft::Console::Types::IControlAccessibilityInfo
bool _CanSendVTMouseInput() const noexcept;
bool _SendMouseEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) noexcept;

void _SendKeyEvent(WORD vkey, WORD scanCode) noexcept;
void _SendKeyEvent(WORD vkey, WORD scanCode, bool keyDown) noexcept;
void _SendCharEvent(wchar_t ch, WORD scanCode) noexcept;

// Inherited via IControlAccessibilityInfo
Expand Down
59 changes: 42 additions & 17 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
if (!handled)
{
// _TrySendKeyEvent pretends it didn't handle F7 for some unknown reason.
(void)_TrySendKeyEvent(VK_F7, 0, modifiers);
(void)_TrySendKeyEvent(VK_F7, 0, modifiers, true);
zadjii-msft marked this conversation as resolved.
Show resolved Hide resolved
handled = true;
}

Expand All @@ -714,6 +714,17 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation

void TermControl::_KeyDownHandler(winrt::Windows::Foundation::IInspectable const& /*sender*/,
Input::KeyRoutedEventArgs const& e)
{
_KeyHandler(e, true);
}

void TermControl::_KeyUpHandler(winrt::Windows::Foundation::IInspectable const& /*sender*/,
Input::KeyRoutedEventArgs const& e)
{
_KeyHandler(e, false);
}

void TermControl::_KeyHandler(Input::KeyRoutedEventArgs const& e, const bool keyDown)
{
// If the current focused element is a child element of searchbox,
// we do not send this event up to terminal
Expand All @@ -722,14 +733,15 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
return;
}

// mark event as handled and do nothing if...
// - closing
// - key modifier is pressed
// NOTE: for key combos like CTRL + C, two events are fired (one for CTRL, one for 'C'). We care about the 'C' event and then check for key modifiers below.
// Mark the event as handled and do nothing if we're closing, or the key
// was the Windows key.
//
// NOTE: for key combos like CTRL + C, two events are fired (one for
// CTRL, one for 'C'). Since it's possible the terminal is in
// win32-input-mode, then we'll send all these keystrokes to the
// terminal - it's smart enough to ignore the keys it doesn't care
// about.
if (_closing ||
e.OriginalKey() == VirtualKey::Control ||
e.OriginalKey() == VirtualKey::Shift ||
e.OriginalKey() == VirtualKey::Menu ||
e.OriginalKey() == VirtualKey::LeftWindows ||
e.OriginalKey() == VirtualKey::RightWindows)

Expand All @@ -743,19 +755,28 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
const auto scanCode = gsl::narrow_cast<WORD>(e.KeyStatus().ScanCode);
bool handled = false;

// Alt-Numpad# input will send us a character once the user releases Alt, so we should be ignoring the individual keydowns.
// The character will be sent through the TSFInputControl.
// See GH#1401 for more details
if (modifiers.IsAltPressed() && (e.OriginalKey() >= VirtualKey::NumberPad0 && e.OriginalKey() <= VirtualKey::NumberPad9))
// Alt-Numpad# input will send us a character once the user releases
// Alt, so we should be ignoring the individual keydowns. The character
// will be sent through the TSFInputControl. See GH#1401 for more
// details
if (modifiers.IsAltPressed() &&
(e.OriginalKey() >= VirtualKey::NumberPad0 && e.OriginalKey() <= VirtualKey::NumberPad9))

{
e.Handled(true);
return;
}

// GH#2235: Terminal::Settings hasn't been modified to differentiate between AltGr and Ctrl+Alt yet.
// GH#2235: Terminal::Settings hasn't been modified to differentiate
// between AltGr and Ctrl+Alt yet.
// -> Don't check for key bindings if this is an AltGr key combination.
if (!modifiers.IsAltGrPressed())
//
// GH#4999: Only process keybindings on the keydown. If we don't check
// this at all, we'll process the keybinding twice. If we only process
// keybindings on the keyUp, then we'll still send the keydown to the
// connected terminal application, and something like ctrl+shift+T will
// emit a ^T to the pipe.
DHowett marked this conversation as resolved.
Show resolved Hide resolved
if (!modifiers.IsAltGrPressed() && keyDown)
{
auto bindings = _settings.KeyBindings();
if (bindings)
Expand All @@ -771,7 +792,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation

if (!handled)
{
handled = _TrySendKeyEvent(vkey, scanCode, modifiers);
handled = _TrySendKeyEvent(vkey, scanCode, modifiers, keyDown);
}

// Manually prevent keyboard navigation with tab. We want to send tab to
Expand All @@ -793,7 +814,11 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// Arguments:
// - vkey: The vkey of the key pressed.
// - states: The Microsoft::Terminal::Core::ControlKeyStates representing the modifier key states.
bool TermControl::_TrySendKeyEvent(const WORD vkey, const WORD scanCode, const ControlKeyStates modifiers)
// - keyDown: If true, the key was pressed, otherwise the key was released.
bool TermControl::_TrySendKeyEvent(const WORD vkey,
const WORD scanCode,
const ControlKeyStates modifiers,
const bool keyDown)
{
// When there is a selection active, escape should clear it and NOT flow through
// to the terminal. With any other keypress, it should clear the selection AND
Expand All @@ -818,7 +843,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// If the terminal translated the key, mark the event as handled.
// This will prevent the system from trying to get the character out
// of it and sending us a CharacterReceived event.
const auto handled = vkey ? _terminal->SendKeyEvent(vkey, scanCode, modifiers) : true;
const auto handled = vkey ? _terminal->SendKeyEvent(vkey, scanCode, modifiers, keyDown) : true;

if (_cursorTimer.has_value())
{
Expand Down
4 changes: 3 additions & 1 deletion src/cascadia/TerminalControl/TermControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
void _SetFontSize(int fontSize);
void _TappedHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs const& e);
void _KeyDownHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e);
void _KeyUpHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e);
void _CharacterHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Input::CharacterReceivedRoutedEventArgs const& e);
void _PointerPressedHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e);
void _PointerMovedHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e);
Expand Down Expand Up @@ -218,8 +219,9 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
void _ScrollbarUpdater(Windows::UI::Xaml::Controls::Primitives::ScrollBar scrollbar, const int viewTop, const int viewHeight, const int bufferSize);
static Windows::UI::Xaml::Thickness _ParseThicknessFromPadding(const hstring padding);

void _KeyHandler(Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e, const bool keyDown);
::Microsoft::Terminal::Core::ControlKeyStates _GetPressedModifierKeys() const;
bool _TrySendKeyEvent(const WORD vkey, const WORD scanCode, ::Microsoft::Terminal::Core::ControlKeyStates modifiers);
bool _TrySendKeyEvent(const WORD vkey, const WORD scanCode, ::Microsoft::Terminal::Core::ControlKeyStates modifiers, const bool keyDown);
bool _TrySendMouseEvent(Windows::UI::Input::PointerPoint const& point);
bool _CanSendVTMouseInput();

Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalControl/TermControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Tapped="_TappedHandler"
PointerWheelChanged="_MouseWheelHandler"
PreviewKeyDown="_KeyDownHandler"
KeyUp="_KeyUpHandler"
CharacterReceived="_CharacterHandler"
GotFocus="_GotFocusHandler"
LostFocus="_LostFocusHandler">
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalCore/ITerminalApi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace Microsoft::Terminal::Core
virtual bool SetDefaultForeground(const DWORD color) noexcept = 0;
virtual bool SetDefaultBackground(const DWORD color) noexcept = 0;

virtual bool EnableWin32InputMode(const bool win32InputMode) noexcept = 0;
virtual bool SetCursorKeysMode(const bool applicationMode) noexcept = 0;
virtual bool SetKeypadMode(const bool applicationMode) noexcept = 0;
virtual bool EnableVT200MouseMode(const bool enabled) noexcept = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalCore/ITerminalInput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft::Terminal::Core
ITerminalInput& operator=(const ITerminalInput&) = default;
ITerminalInput& operator=(ITerminalInput&&) = default;

virtual bool SendKeyEvent(const WORD vkey, const WORD scanCode, const ControlKeyStates states) = 0;
virtual bool SendKeyEvent(const WORD vkey, const WORD scanCode, const ControlKeyStates states, const bool keyDown) = 0;
virtual bool SendMouseEvent(const COORD viewportPos, const unsigned int uiButton, const ControlKeyStates states, const short wheelDelta) = 0;
virtual bool SendCharEvent(const wchar_t ch, const WORD scanCode, const ControlKeyStates states) = 0;

Expand Down
19 changes: 15 additions & 4 deletions src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,14 @@ bool Terminal::IsTrackingMouseInput() const noexcept
// - vkey: The vkey of the last pressed key.
// - scanCode: The scan code of the last pressed key.
// - states: The Microsoft::Terminal::Core::ControlKeyStates representing the modifier key states.
// - keyDown: If true, the key was pressed, otherwise the key was released.
// Return Value:
// - true if we translated the key event, and it should not be processed any further.
// - false if we did not translate the key, and it should be processed into a character.
bool Terminal::SendKeyEvent(const WORD vkey, const WORD scanCode, const ControlKeyStates states)
bool Terminal::SendKeyEvent(const WORD vkey,
const WORD scanCode,
const ControlKeyStates states,
const bool keyDown)
{
TrySnapOnInput();
_StoreKeyEvent(vkey, scanCode);
Expand Down Expand Up @@ -452,7 +456,7 @@ bool Terminal::SendKeyEvent(const WORD vkey, const WORD scanCode, const ControlK
return false;
}

KeyEvent keyEv{ true, 0, vkey, scanCode, ch, states.Value() };
KeyEvent keyEv{ keyDown, 1, vkey, scanCode, ch, states.Value() };
return _terminalInput->HandleKey(&keyEv);
}

Expand Down Expand Up @@ -513,8 +517,15 @@ bool Terminal::SendCharEvent(const wchar_t ch, const WORD scanCode, const Contro
vkey = _VirtualKeyFromCharacter(ch);
}

KeyEvent keyEv{ true, 0, vkey, scanCode, ch, states.Value() };
return _terminalInput->HandleKey(&keyEv);
// Unfortunately, the UI doesn't give us both a character down and a
// character up event, only a character received event. So fake sending both
// to the terminal input translator. Unless it's in win32-input-mode, it'll
// ignore the keyup.
KeyEvent keyDown{ true, 1, vkey, scanCode, ch, states.Value() };
KeyEvent keyUp{ false, 1, vkey, scanCode, ch, states.Value() };
const auto handledDown = _terminalInput->HandleKey(&keyDown);
const auto handledUp = _terminalInput->HandleKey(&keyUp);
return handledDown || handledUp;
}

// Method Description:
Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalCore/Terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class Microsoft::Terminal::Core::Terminal final :
bool SetDefaultForeground(const COLORREF color) noexcept override;
bool SetDefaultBackground(const COLORREF color) noexcept override;

bool EnableWin32InputMode(const bool win32InputMode) noexcept override;
bool SetCursorKeysMode(const bool applicationMode) noexcept override;
bool SetKeypadMode(const bool applicationMode) noexcept override;
bool EnableVT200MouseMode(const bool enabled) noexcept override;
Expand All @@ -117,7 +118,7 @@ class Microsoft::Terminal::Core::Terminal final :

#pragma region ITerminalInput
// These methods are defined in Terminal.cpp
bool SendKeyEvent(const WORD vkey, const WORD scanCode, const Microsoft::Terminal::Core::ControlKeyStates states) override;
bool SendKeyEvent(const WORD vkey, const WORD scanCode, const Microsoft::Terminal::Core::ControlKeyStates states, const bool keyDown) override;
bool SendMouseEvent(const COORD viewportPos, const unsigned int uiButton, const ControlKeyStates states, const short wheelDelta) override;
bool SendCharEvent(const wchar_t ch, const WORD scanCode, const ControlKeyStates states) override;

Expand Down
6 changes: 6 additions & 0 deletions src/cascadia/TerminalCore/TerminalApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,12 @@ try
}
CATCH_LOG_RETURN_FALSE()

bool Terminal::EnableWin32InputMode(const bool win32InputMode) noexcept
{
_terminalInput->ChangeWin32InputMode(win32InputMode);
return true;
}

bool Terminal::SetCursorKeysMode(const bool applicationMode) noexcept
{
_terminalInput->ChangeCursorKeysMode(applicationMode);
Expand Down
16 changes: 16 additions & 0 deletions src/cascadia/TerminalCore/TerminalDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,19 @@ bool TerminalDispatch::SetCursorKeysMode(const bool applicationMode) noexcept
return true;
}

// Method Description:
// - win32-input-mode: Enable sending full input records encoded as a string of
// characters to the client application.
// Arguments:
// - 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
{
_terminalApi.EnableWin32InputMode(win32Mode);
return true;
}

//Routine Description:
// Enable VT200 Mouse Mode - Enables/disables the mouse input handler in default tracking mode.
//Arguments:
Expand Down Expand Up @@ -394,6 +407,9 @@ bool TerminalDispatch::_PrivateModeParamsHelper(const DispatchTypes::PrivateMode
case DispatchTypes::PrivateModeParams::ATT610_StartCursorBlink:
success = EnableCursorBlinking(enable);
break;
case DispatchTypes::PrivateModeParams::W32IM_Win32InputMode:
success = EnableWin32InputMode(enable);
break;
default:
// If no functions to call, overall dispatch was a failure.
success = false;
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalCore/TerminalDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class TerminalDispatch : public Microsoft::Console::VirtualTerminal::TermDispatc
bool CursorPosition(const size_t line,
const size_t column) noexcept override; // CUP

bool EnableWin32InputMode(const bool win32InputMode) noexcept override; // win32-input-mode

bool CursorVisibility(const bool isVisible) noexcept override; // DECTCEM
bool EnableCursorBlinking(const bool enable) noexcept override; // ATT610

Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/UnitTests_TerminalCore/InputTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ namespace TerminalCoreUnitTests
// Make sure we don't handle Alt+Space. The system will use this to
// bring up the system menu for restore, min/maximize, size, move,
// close
VERIFY_IS_FALSE(term.SendKeyEvent(L' ', 0, ControlKeyStates::LeftAltPressed));
VERIFY_IS_FALSE(term.SendKeyEvent(L' ', 0, ControlKeyStates::LeftAltPressed, true));
VERIFY_IS_FALSE(term.SendKeyEvent(L' ', 0, ControlKeyStates::LeftAltPressed, false));
VERIFY_IS_FALSE(term.SendCharEvent(L' ', 0, ControlKeyStates::LeftAltPressed));
}
}
7 changes: 6 additions & 1 deletion src/cascadia/WpfTerminalControl/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public enum WindowMessage : int
/// </summary>
WM_KEYDOWN = 0x0100,

/// <summary>
/// The WM_KEYUP message is posted to the window with the keyboard focus when a nonsystem key is released. A nonsystem key is a key that is pressed when the ALT key is not pressed, or a keyboard key that is pressed when a window has the keyboard focus.
/// </summary>
WM_KEYUP = 0x0101,

/// <summary>
/// The WM_CHAR message is posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function. The WM_CHAR message contains the character code of the key that was pressed.
/// </summary>
Expand Down Expand Up @@ -207,7 +212,7 @@ public enum SetWindowPosFlags : uint
public static extern void DestroyTerminal(IntPtr terminal);

[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern void TerminalSendKeyEvent(IntPtr terminal, ushort vkey, ushort scanCode);
public static extern void TerminalSendKeyEvent(IntPtr terminal, ushort vkey, ushort scanCode, bool keyDown);

[DllImport("PublicTerminalCore.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
public static extern void TerminalSendCharEvent(IntPtr terminal, char ch, ushort scanCode);
Expand Down
Loading