terminal/src/server
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
..
lib Implement a pair of shims for cls, Clear-Host in conpty mode (#5627) 2020-04-30 21:53:31 +00:00
ApiDispatchers.cpp Implement a pair of shims for cls, Clear-Host in conpty mode (#5627) 2020-04-30 21:53:31 +00:00
ApiDispatchers.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
ApiDispatchersInternal.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiMessage.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiMessage.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiMessageState.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiMessageState.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiSorter.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiSorter.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ConsoleShimPolicy.cpp Implement a pair of shims for cls, Clear-Host in conpty mode (#5627) 2020-04-30 21:53:31 +00:00
ConsoleShimPolicy.h Implement a pair of shims for cls, Clear-Host in conpty mode (#5627) 2020-04-30 21:53:31 +00:00
DeviceComm.cpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
DeviceComm.h Revert locking changes (#3488) 2019-11-08 13:44:52 -08:00
DeviceHandle.cpp Apply audit mode to TerminalConnection/Core/Settings and WinCon… (#4016) 2020-01-03 10:44:27 -08:00
DeviceHandle.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
dirs Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
Entrypoints.cpp Change NULL to nullptr since they are pointers (#4960) 2020-03-20 20:35:12 +00:00
Entrypoints.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
IApiRoutines.h Implement a pair of shims for cls, Clear-Host in conpty mode (#5627) 2020-04-30 21:53:31 +00:00
IoDispatchers.cpp ci: run spell check in CI, fix remaining issues (#4799) 2020-03-25 11:02:53 -07:00
IoDispatchers.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
IoSorter.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
IoSorter.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
IoThread.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
IWaitRoutine.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ObjectHandle.cpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
ObjectHandle.h Prevent cleanup of object given to handle that failed access check (#3414) 2019-11-05 14:22:55 -08:00
ObjectHeader.cpp Prevent cleanup of object given to handle that failed access check (#3414) 2019-11-05 14:22:55 -08:00
ObjectHeader.h Prevent cleanup of object given to handle that failed access check (#3414) 2019-11-05 14:22:55 -08:00
precomp.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
precomp.h Introduce chromium safe math (#4144) 2020-01-16 18:51:06 +00:00
ProcessHandle.cpp Implement a pair of shims for cls, Clear-Host in conpty mode (#5627) 2020-04-30 21:53:31 +00:00
ProcessHandle.h Implement a pair of shims for cls, Clear-Host in conpty mode (#5627) 2020-04-30 21:53:31 +00:00
ProcessList.cpp ci: run spell check in CI, fix remaining issues (#4799) 2020-03-25 11:02:53 -07:00
ProcessList.h Revert locking changes (#3488) 2019-11-08 13:44:52 -08:00
ProcessPolicy.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
ProcessPolicy.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
sources.inc Implement a pair of shims for cls, Clear-Host in conpty mode (#5627) 2020-04-30 21:53:31 +00:00
WaitBlock.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
WaitBlock.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
WaitQueue.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
WaitQueue.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
WaitTerminationReason.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
winbasep.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
WinNTControl.cpp Apply audit mode to TerminalConnection/Core/Settings and WinCon… (#4016) 2020-01-03 10:44:27 -08:00
WinNTControl.h Apply audit mode to TerminalConnection/Core/Settings and WinCon… (#4016) 2020-01-03 10:44:27 -08:00