-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Fix Ctrl+Alt not being treated as a substitute for AltGr anymore #5552
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -498,16 +498,16 @@ bool TerminalInput::HandleKey(const IInputEvent* const pInEvent) | |
if (ch == UNICODE_NULL) | ||
{ | ||
// For Alt+Ctrl+Key messages GetCharData() returns 0. | ||
// The values of the ASCII characters and virtual key codes | ||
// of <Space>, A-Z (as used below) are numerically identical. | ||
// -> Get the char from the virtual key. | ||
ch = LOWORD(MapVirtualKeyW(keyEvent.GetVirtualKeyCode(), MAPVK_VK_TO_CHAR)); | ||
ch = keyEvent.GetVirtualKeyCode(); | ||
} | ||
if (ch == UNICODE_SPACE) | ||
{ | ||
// Ctrl+@ and Ctrl+Space are supposed to send null bytes. | ||
// -> Change Ctrl+Space to Ctrl+@ for compatibility reasons. | ||
ch = 0x40; | ||
} | ||
if (ch >= 0x40 && ch < 0x7F) | ||
// Alt+Ctrl acts as a substitute for AltGr on Windows. | ||
// For instance using a German keyboard both AltGr+< and Alt+Ctrl+< produce a | (pipe) character. | ||
// The below condition primitively ensures that we allow all common Alt+Ctrl combinations | ||
// while preserving most of the functionality of Alt+Ctrl as a substitute for AltGr. | ||
if (ch == UNICODE_SPACE || (ch > 0x40 && ch <= 0x5A)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see: this change is safe because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DHowett-MSFT Did you ever see this article? https://garbagecollected.org/2017/01/31/four-column-ascii/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually used to have a giant version of this table printed in my office, which has been immensely helpful |
||
{ | ||
// Pressing the control key causes all bits but the 5 least | ||
// significant ones to be zeroed out (when using ASCII). | ||
|
@@ -530,7 +530,7 @@ bool TerminalInput::HandleKey(const IInputEvent* const pInEvent) | |
|
||
// This section is similar to the Alt modifier section above, | ||
// but handles cases without Ctrl modifiers. | ||
if (keyEvent.IsAltPressed() && keyEvent.GetCharData() != 0) | ||
if (keyEvent.IsAltPressed() && !keyEvent.IsCtrlPressed() && keyEvent.GetCharData() != 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've had to add these two additional checks, because (This wasn't an issue in the past when |
||
{ | ||
_SendEscapedInputSequence(keyEvent.GetCharData()); | ||
return true; | ||
|
@@ -544,7 +544,7 @@ bool TerminalInput::HandleKey(const IInputEvent* const pInEvent) | |
// -> Send a "null input sequence" in that case. | ||
// We don't need to handle other kinds of Ctrl combinations, | ||
// as we rely on the caller to pretranslate those to characters for us. | ||
if (keyEvent.IsCtrlPressed()) | ||
if (!keyEvent.IsAltPressed() && keyEvent.IsCtrlPressed()) | ||
{ | ||
const auto ch = keyEvent.GetCharData(); | ||
const auto vkey = keyEvent.GetVirtualKeyCode(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've taken the liberty to remove this call to
MapVirtualKeyW
.As far as I now understood virtual key codes in Windows, the numeric values of the vkeys for Space and A-Z are identical with their respective ASCII value. As such a call to
MapVirtualKeyW
is IMO unnecessary.Am I seing this correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you are correct.