terminal/src/host/ut_host
Dustin Howett 66b9b9d6f1 Merged PR 5984262: [Git2Git] Merged PR 5982901: Reintroduce GetQuickCharWidth for numpad event synthesis
When we encounter clipboard input that cannot be mapped to a keyboard
key, we try our best to map it to an event. If if is an alphanumeric
character or a wide glyph (per the old width algorithm), we will pass it
through as the UnicodeChar of a key event. If it's *not* wide and *not*
alphanumeric, we will synthesize a set of Alt+NumPad events.

Those events comprise a set containing...

1. Alt Down (modifiers = LAlt, UnicodeChar = 0)
2. Numpad 0 Down/Up (modifiers = LAlt, UnicodeChar = 0)
3. Numpad 1 Down/Up (modifiers = LAlt, UnicodeChar = 0)
4. Numpad 2 Down/Up (modifiers = LAlt, UnicodeChar = 0)
5. Alt Up (modifiers = 0, UnicodeChar = [THE CHARACTER])

Because of event group 5, application developers seem to have taken a
dependency on receiving Alt Up + Character and don't seek to recompose
the original character from its numpad representation.

In pull request GH-8035 (!5394370), we stripped the old width algorithm
out and replaced it with a lookup table (finally!). Unfortunately, that
broke clipboard input for Chinese text as it was no longer considered
"Wide" for the purposes of detecting whether we should use numpad
events.

This commit introduces a version of GetQuickCharWidth that fulfills the
exact contract CharToKeyEvents needs, and doesn't answer for a codepoint
more. We'll use it in Windows to fix MSFT-32901370.

The Terminal analogue of this bug, GH-9052, is fixed by *never emitting
numpad events again.* We think this is okay because it looks like nobody
was ever handling numpad events... and that we were only using them as a
way to communicate within conhost (which we're *also* not using) and any
public exposition of event 5 as a contract was unintended.

VALIDATION
----------
I took this new implementation (with an early return) and the old
implementation and compared whether they would yield a numpad event or a
key event over the entire supported codepoint space [0000..FFFF].

They matched.

Fixes MSFT-32901370
Fixes GH-9052

Retrieved from https://microsoft.visualstudio.com os.2020 OS official/rs_wdx_dxp_windev 224751bbb061f5f59d794c2c9bdac5a9674ebde6
2021-04-27 23:17:53 +00:00
..
AliasTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
ApiRoutinesTests.cpp Eliminate more transient allocations: Titles and invalid rectangles and bitmap runs and utf8 conversions (#8621) 2021-02-16 20:52:33 +00:00
ClipboardTests.cpp Merged PR 5984262: [Git2Git] Merged PR 5982901: Reintroduce GetQuickCharWidth for numpad event synthesis 2021-04-27 23:17:53 +00:00
CodepointWidthDetectorTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
CommandLineTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
CommandListPopupTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
CommandNumberPopupTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
ConptyOutputTests.cpp Improve the propagation of color attributes over ConPTY (#6506) 2020-07-01 11:10:36 -07:00
ConsoleArgumentsTests.cpp Add -ForceNoHandoff for compatibility; stop handoff for double-click launches (#9802) 2021-04-15 16:54:04 +00:00
CopyFromCharPopupTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
CopyToCharPopupTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
DbcsTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
DefaultResource.rc Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
HistoryTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
Host.UnitTests.vcxproj Link to WinMM.Lib for PlaySound with 19041 (#9624) 2021-03-26 11:35:17 -05:00
Host.UnitTests.vcxproj.filters ROW: clean up in preparation to hide CharRow & AttrRow (#8446) 2021-01-20 21:16:56 +00:00
InitTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
InputBufferTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
ObjectTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
OutputCellIteratorTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
PopupTestHelper.hpp Replace macros with constexpr part 2 (#3416) 2019-11-04 07:37:47 -06:00
product.pbxproj Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
ReadWaitTests.cpp Removed using namespace directive from header files (#955) 2019-05-30 11:14:21 -07:00
RendererTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
ScreenBufferTests.cpp Retain horizontal viewport offset when moving to bottom (#8434) 2020-11-30 19:58:03 +00:00
SearchTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
SelectionTests.cpp Add support for double-width/double-height lines in conhost (#8664) 2021-02-18 05:44:50 +00:00
sources ROW: clean up in preparation to hide CharRow & AttrRow (#8446) 2021-01-20 21:16:56 +00:00
testmd.definition Integrate inbox changes up to 68d3b53286dd 2019-12-02 17:24:26 -08:00
TextBufferIteratorTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
TextBufferTests.cpp Add support for double-width/double-height lines in conhost (#8664) 2021-02-18 05:44:50 +00:00
TitleTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
Utf8ToWideCharParserTests.cpp Compensate for non-minimal UTF-8 encodings (#3380) 2019-10-31 10:50:34 -07:00
Utf16ParserTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
UtilsTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
ViewportTests.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
VtIoTests.cpp Eliminate more transient allocations: Titles and invalid rectangles and bitmap runs and utf8 conversions (#8621) 2021-02-16 20:52:33 +00:00
VtRendererTests.cpp Add support for the "doubly underlined" graphic rendition attribute (#7223) 2020-08-10 17:06:16 +00:00