terminal/src/terminal/adapter
James Holderness 7fcff4d33a
Refactor VT control sequence identification (#7304)
This PR changes the way VT control sequences are identified and
dispatched, to be more efficient and easier to extend. Instead of
parsing the intermediate characters into a vector, and then having to
identify a sequence using both that vector and the final char, we now
use just a single `uint64_t` value as the identifier.

The way the identifier is constructed is by taking the private parameter
prefix, each of the intermediate characters, and then the final
character, and shifting them into a 64-bit integer one byte at a time,
in reverse order. For example, the `DECTLTC` control has a private
parameter prefix of `?`, one intermediate of `'`, and a final character
of `s`. The ASCII values of those characters are `0x3F`, `0x27`, and
`0x73` respectively, and reversing them gets you 0x73273F, so that would
then be the identifier for the control.

The reason for storing them in reverse order, is because sometimes we
need to look at the first intermediate to determine the operation, and
treat the rest of the sequence as a kind of sub-identifier (the
character set designation sequences are one example of this). When in
reverse order, this can easily be achieved by masking off the low byte
to get the first intermediate, and then shifting the value right by 8
bits to get a new identifier with the rest of the sequence.

With 64 bits we have enough space for a private prefix, six
intermediates, and the final char, which is way more than we should ever
need (the _DEC STD 070_ specification recommends supporting at least
three intermediates, but in practice we're unlikely to see more than
two).

With this new way of identifying controls, it should now be possible for
every action code to be unique (for the most part). So I've also used
this PR to clean up the action codes a bit, splitting the codes for the
escape sequences from the control sequences, and sorting them into
alphabetical order (which also does a reasonable job of clustering
associated controls).

## Validation Steps Performed

I think the existing unit tests should be good enough to confirm that
all sequences are still being dispatched correctly. However, I've also
manually tested a number of sequences to make sure they were still
working as expected, in particular those that used intermediates, since
they were the most affected by the dispatch code refactoring.

Since these changes also affected the input state machine, I've done
some manual testing of the conpty keyboard handling (both with and
without the new Win32 input mode enabled) to make sure the keyboard VT
sequences were processed correctly. I've also manually tested the
various VT mouse modes in Vttest to confirm that they were still working
correctly too.

Closes #7276
2020-08-18 18:57:52 +00:00
..
lib Improve support for VT character sets (#4496) 2020-06-04 19:40:15 +00:00
ut_adapter Add support for the "doubly underlined" graphic rendition attribute (#7223) 2020-08-10 17:06:16 +00:00
adaptDefaults.hpp Fix the build on VS 2019 Update 5 (#4722) 2020-02-26 00:28:32 +00:00
adaptDispatch.cpp Refactor VT control sequence identification (#7304) 2020-08-18 18:57:52 +00:00
adaptDispatch.hpp Refactor VT control sequence identification (#7304) 2020-08-18 18:57:52 +00:00
adaptDispatchGraphics.cpp Add support for the "doubly underlined" graphic rendition attribute (#7223) 2020-08-10 17:06:16 +00:00
charsets.hpp Improve support for VT character sets (#4496) 2020-06-04 19:40:15 +00:00
conGetSet.hpp Add support for win32-input-mode to conhost, ConPTY, Terminal (#6309) 2020-06-08 22:31:28 +00:00
dirs Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
DispatchCommon.cpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
DispatchCommon.hpp Make the terminal parser/adapter and related classes use modern… (#3956) 2019-12-19 14:12:53 -08:00
DispatchTypes.hpp Refactor VT control sequence identification (#7304) 2020-08-18 18:57:52 +00:00
IInteractDispatch.hpp Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
InteractDispatch.cpp Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
InteractDispatch.hpp Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
ITermDispatch.hpp Refactor VT control sequence identification (#7304) 2020-08-18 18:57:52 +00:00
precomp.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
precomp.h Replace old C headers (xxx.h) with modern ones (cxxx) (#5080) 2020-07-01 11:00:24 -07:00
runtest.bat Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
sources.inc Move MouseInput from TermAdapter to TermInput (#4848) 2020-03-12 22:25:43 +00:00
telemetry.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
telemetry.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
termDispatch.hpp Refactor VT control sequence identification (#7304) 2020-08-18 18:57:52 +00:00
terminalOutput.cpp Refactor VT control sequence identification (#7304) 2020-08-18 18:57:52 +00:00
terminalOutput.hpp Refactor VT control sequence identification (#7304) 2020-08-18 18:57:52 +00:00
tracing.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
tracing.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00