terminal/src/host/ut_host
Mike Griese 7612044363
Implement a pair of shims for cls, Clear-Host in conpty mode (#5627)
## Summary of the Pull Request

This PR implements a pair of shims for `cmd` and `powershell`, so that their `cls` and `Clear-Host` functions will clear the entire terminal buffer (like they do in conhost), instead of just the viewport. With the conpty viewport and buffer being the same size, there's effectively no way to know if an application is calling these API's in this way with the intention of clearing the buffer or the viewport. We absolutely have to guess. 

Each of these shims checks to see if the way that the API is being called exactly matches the way `cmd` or `powershell` would call these APIs. If it does, we manually write a `^[[3J` to the connected terminal, to get he Terminal to clear it's own scrollback.

~~_⚠️ If another application were trying to clear the **viewport** with an exactly similar API call, this would also cause the terminal scrollback to get cleared ⚠️_~~

* [x] Should these shims be restricted to when the process that's calling them is actually `cmd.exe` or `powershell.exe`? Can I even do this? I think we've done such a good job of isolating the client process information from the rest of the host code that I can't figure out how to do this.
  - YES, this can be done, and I did it.
* [ ] **TODO**: _While I'm here_, should I have `DoSrvPrivateEraseAll` (the implementation for `^[[2J`, in `getset.cpp`) also manually trigger a EraseAll in the terminal in conpty mode?

## PR Checklist
* [x] Closes #3126
* [x] Actually closes #1305 too, which is really the same thing, but probably deserves a callout
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated

## Validation Steps Performed
* ran tests
* checked `cls` in the Terminal
* checked `Clear-Host` in the Terminal
* Checked running `powershell clear-host` from `cmd.exe`
2020-04-30 21:53:31 +00:00
..
AliasTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiRoutinesTests.cpp Remove unwanted DECSTBM clipping (#2764) 2019-09-23 16:16:54 -07:00
AttrRowTests.cpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
CharRowBaseTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ClipboardTests.cpp Abstract GetTextForClipboard() for UIA (#4578) 2020-03-09 08:17:34 -07:00
CodepointWidthDetectorTests.cpp Replace CodepointWidthDetector's runtime table with a static one (#2368) 2019-08-16 10:54:17 -07:00
CommandLineTests.cpp Change NULL to nullptr since they are pointers (#4960) 2020-03-20 20:35:12 +00:00
CommandListPopupTests.cpp Replace casting 0 to a pointer with nullptr (#5062) 2020-03-23 09:38:39 -07:00
CommandNumberPopupTests.cpp Change NULL to nullptr since they are pointers (#4960) 2020-03-20 20:35:12 +00:00
ConptyOutputTests.cpp Implement a pair of shims for cls, Clear-Host in conpty mode (#5627) 2020-04-30 21:53:31 +00:00
ConsoleArgumentsTests.cpp Change NULL to nullptr since they are pointers (#4960) 2020-03-20 20:35:12 +00:00
CopyFromCharPopupTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CopyToCharPopupTests.cpp Replace casting 0 to a pointer with nullptr (#5062) 2020-03-23 09:38:39 -07:00
DbcsTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
DefaultResource.rc Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
HistoryTests.cpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
Host.UnitTests.vcxproj Create tests that roundtrip output through a conpty to a Terminal (#4213) 2020-01-17 16:40:12 +00:00
Host.UnitTests.vcxproj.filters Prevent cleanup of object given to handle that failed access check (#3414) 2019-11-05 14:22:55 -08:00
InitTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
InputBufferTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ObjectTests.cpp Prevent cleanup of object given to handle that failed access check (#3414) 2019-11-05 14:22:55 -08:00
OutputCellIteratorTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07: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 Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
ScreenBufferTests.cpp Update the virtual bottom location if the cursor moves below it (#5317) 2020-04-14 13:20:30 -07:00
SearchTests.cpp Migrate Search module as a shared component for Terminal Search (#3279) 2019-11-14 14:36:41 -08:00
SelectionTests.cpp Move rect expansion to textbuffer; refactor selection code (#4560) 2020-02-27 16:42:26 -08:00
sources Create tests that roundtrip output through a conpty to a Terminal (#4213) 2020-01-17 16:40:12 +00:00
testmd.definition Integrate inbox changes up to 68d3b53286dd 2019-12-02 17:24:26 -08:00
TextBufferIteratorTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
TextBufferTests.cpp Improve wide glyph support in UIA (#4946) 2020-03-23 23:50:17 +00:00
TitleTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07: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 NULL to nullptr since they are pointers (#4960) 2020-03-20 20:35:12 +00:00
ViewportTests.cpp Make the RIS command clear the display and scrollback correctly (#2367) 2019-08-27 18:45:38 -07:00
VtIoTests.cpp Move tests to invoke te.exe directly instead of using VSTest runner (#4490) 2020-02-10 19:14:06 +00:00
VtRendererTests.cpp Move ConPTY to use til::bitmap (#5024) 2020-03-23 15:57:54 +00:00