terminal/src/host
Mike Griese 6268a4779c
Implement and action for manually clearing the Terminal (and conpty) buffer (#10906)
## Summary of the Pull Request

![clear-buffer-000](https://user-images.githubusercontent.com/18356694/127570078-90c6089e-0430-4dfc-bcd4-a0cde20c9167.gif)

This adds a new action, `clearBuffer`. It accepts 3 values for the `clear` type:
* `"clear": "screen"`: Clear the terminal viewport content. Leaves the scrollback untouched. Moves the cursor row to the top of the viewport (unmodified).
* `"clear": "scrollback"`: Clear the scrollback. Leaves the viewport untouched.
* `"clear": "all"`: (**default**) Clear the scrollback and the visible viewport. Moves the cursor row to the top of the viewport (unmodified).

"Clear Buffer" has also been added to `defaults.json`.

## References
* From microsoft/vscode#75141 originally

## PR Checklist
* [x] Closes #1193
* [x] Closes #1882
* [x] I work here
* [x] Tests added/passed
* [ ] Requires documentation to be updated

## Detailed Description of the Pull Request / Additional comments

This is a bit tricky, because we need to plumb it all the way through conpty to clear the buffer. If we don't, then conpty will immediately just redraw the screen. So this sends a signal to the attached conpty, and then waits for conpty to draw the updated, cleared, screen back to us.

## Validation Steps Performed
* works for each of the three clear types as expected
* tests pass.
* works even with `ping -t 8.8.8.8` as you'd hope.
2021-09-02 14:59:42 +00:00
..
exe Persist inbox conhost; delegate control activities to it via a pipe (#10415) 2021-06-16 19:23:37 +00:00
ft_fuzzer Add a Fuzzing configuration and a version of conhost that can be fuzzed (#9604) 2021-03-29 14:23:30 +00:00
ft_host Merged PR 6140256: Migrate OSS up to 94d39b758 2021-06-09 23:03:04 +00:00
ft_integrity Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
ft_uia Enable /Zc:preprocessor (#10593) 2021-07-13 23:00:11 +00:00
lib Implement Default Terminal (#7489) 2021-03-26 17:09:49 -05:00
proxy Persist inbox conhost; delegate control activities to it via a pipe (#10415) 2021-06-16 19:23:37 +00:00
ut_host Remove std::deque from Renderer (#10923) 2021-08-24 15:27:59 +00:00
ut_lib Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
_output.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
_output.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
_stream.cpp Improve WriteCharsLegacy performance by increasing local buffer size (#10921) 2021-08-12 17:54:59 +00:00
_stream.h WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
alias.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
alias.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiRoutines.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
cmdline.cpp WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
cmdline.h WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
CommandListPopup.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
CommandListPopup.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CommandNumberPopup.cpp WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
CommandNumberPopup.hpp Add explicit identifier to some constructors (#5652) 2020-04-29 16:50:47 -07:00
conapi.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
conareainfo.cpp Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
conareainfo.h Improve the legacy color conversions (#6358) 2020-06-08 19:05:06 +00:00
conattrs.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
conddkrefs.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
conhost.rcv Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
conhostv2_traceviewpp.tvpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
conimeinfo.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
conimeinfo.h Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
conserv.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ConsoleArguments.cpp Fix startup race of resizing ConPTY (#10449) 2021-06-22 19:23:16 +00:00
ConsoleArguments.hpp Fix startup race of resizing ConPTY (#10449) 2021-06-22 19:23:16 +00:00
consoleInformation.cpp Vectorize TextColor::GetColor (#10779) 2021-08-02 19:02:59 +00:00
conv.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
convarea.cpp Make sure we don't hide the cursor until the IME starts (#7673) 2020-09-18 19:25:39 +00:00
conwinuserrefs.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CopyFromCharPopup.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CopyFromCharPopup.hpp Add explicit identifier to some constructors (#5652) 2020-04-29 16:50:47 -07:00
CopyToCharPopup.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CopyToCharPopup.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CursorBlinker.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
CursorBlinker.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
dbcs.cpp Replace gsl::at with a new til::at(span) for pre-checked bounds (#6925) 2020-07-15 10:29:36 -07:00
dbcs.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
directio.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
directio.h Switch all DSR responses to appending instead of prepending (#7583) 2020-09-09 23:55:22 +00:00
dirs Merged PR 5677497: [Git2Git] Merged PR 5655213: Allow conhost to handoff to registered default app handler 2021-02-11 21:07:50 +00:00
getset.cpp Implement and action for manually clearing the Terminal (and conpty) buffer (#10906) 2021-09-02 14:59:42 +00:00
getset.h Implement and action for manually clearing the Terminal (and conpty) buffer (#10906) 2021-09-02 14:59:42 +00:00
globals.cpp Implement a pair of shims for cls, Clear-Host in conpty mode (#5627) 2020-04-30 21:53:31 +00:00
globals.h Persist inbox conhost; delegate control activities to it via a pipe (#10415) 2021-06-16 19:23:37 +00:00
handle.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
handle.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
history.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
history.h Replace macros with constexpr part 2 (#3416) 2019-11-04 07:37:47 -06:00
host-common.vcxitems Implement Default Terminal (#7489) 2021-03-26 17:09:49 -05:00
IIoProvider.hpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
init.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
init.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
input.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
input.h Replace macros with constexpr part 2 (#3416) 2019-11-04 07:37:47 -06:00
inputBuffer.cpp [Conpty] Pass through request for mouse mode to the Terminal (#9970) 2021-05-07 02:46:11 +00:00
inputBuffer.hpp [Conpty] Pass through request for mouse mode to the Terminal (#9970) 2021-05-07 02:46:11 +00:00
inputKeyInfo.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
inputReadHandleData.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
inputReadHandleData.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
misc.cpp #10497: Do not force the font on output codepage change (#10591) 2021-07-08 21:10:35 +00:00
misc.h WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
ntprivapi.cpp Change NULL to nullptr since they are pointers (#4960) 2020-03-20 20:35:12 +00:00
ntprivapi.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
output.cpp Add support for double-width/double-height lines in conhost (#8664) 2021-02-18 05:44:50 +00:00
output.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
outputStream.cpp Implement and action for manually clearing the Terminal (and conpty) buffer (#10906) 2021-09-02 14:59:42 +00:00
outputStream.hpp Implement and action for manually clearing the Terminal (and conpty) buffer (#10906) 2021-09-02 14:59:42 +00:00
popup.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
popup.h Improve the legacy color conversions (#6358) 2020-06-08 19:05:06 +00:00
precomp.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
precomp.h Reduce Transient Allocations during Bulk Text Output (#8617) 2021-01-05 18:06:06 +00:00
PtySignalInputThread.cpp Implement and action for manually clearing the Terminal (and conpty) buffer (#10906) 2021-09-02 14:59:42 +00:00
PtySignalInputThread.hpp Implement and action for manually clearing the Terminal (and conpty) buffer (#10906) 2021-09-02 14:59:42 +00:00
readData.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
readData.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataCooked.cpp Merged PR 6142815: OS build fixes on top of 94d39b758 2021-06-10 15:52:14 +00:00
readDataCooked.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataDirect.cpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataDirect.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataRaw.cpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataRaw.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
registry.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
registry.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
renderData.cpp Eliminate more transient allocations: Titles and invalid rectangles and bitmap runs and utf8 conversions (#8621) 2021-02-16 20:52:33 +00:00
renderData.hpp Expose Text Attributes to UI Automation (#10336) 2021-07-09 23:21:35 +00:00
renderFontDefaults.cpp Allow FontInfo{,Base,Desired} to store a font name > 32 wch (#3107) 2019-10-14 21:23:45 -07:00
renderFontDefaults.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
res.rc Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
resource.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
runft.bat Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
runtests.bat Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
runut.bat Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
ScreenBufferRenderTarget.cpp Fix TerminalControl crash on exit (#10031) 2021-05-04 21:17:37 +00:00
ScreenBufferRenderTarget.hpp Fix TerminalControl crash on exit (#10031) 2021-05-04 21:17:37 +00:00
screenInfo.cpp Implement and action for manually clearing the Terminal (and conpty) buffer (#10906) 2021-09-02 14:59:42 +00:00
screenInfo.hpp Implement and action for manually clearing the Terminal (and conpty) buffer (#10906) 2021-09-02 14:59:42 +00:00
scrolling.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
scrolling.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
selection.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
selection.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
selectionInput.cpp Fix color selection operations in conhost (#8577) 2020-12-14 19:45:49 +00:00
selectionState.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
server.h Eliminate more transient allocations: Titles and invalid rectangles and bitmap runs and utf8 conversions (#8621) 2021-02-16 20:52:33 +00:00
settings.cpp Vectorize TextColor::GetColor (#10779) 2021-08-02 19:02:59 +00:00
settings.hpp Vectorize TextColor::GetColor (#10779) 2021-08-02 19:02:59 +00:00
sources.inc Merged PR 6176782: [Git2Git] Get rid of dead build macros/#defines FE_IME, W32_SB, etc. 2021-06-21 10:50:52 -07:00
sources.test.inc Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
srvinit.cpp Pass inbound handoff message via heap so it cannot race out of scope by the time it reaches the ConsoleIoThread (#10751) 2021-07-22 12:51:30 +00:00
srvinit.h Persist inbox conhost; delegate control activities to it via a pipe (#10415) 2021-06-16 19:23:37 +00:00
stream.cpp Fix building with v143 toolchain (#10727) 2021-07-20 19:00:49 +02:00
stream.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
telemetry.cpp Vectorize TextColor::GetColor (#10779) 2021-08-02 19:02:59 +00:00
telemetry.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
tracing.cpp Reflect recent OS build changes, incl. a version of GH-10166 2021-06-09 22:57:38 +00:00
tracing.hpp Reflect recent OS build changes, incl. a version of GH-10166 2021-06-09 22:57:38 +00:00
utf8ToWideCharParser.cpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
utf8ToWideCharParser.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
utils.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
utils.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
VtInputThread.cpp Add names to threads to make debugging a slight bit easier (#9801) 2021-04-14 10:56:52 +00:00
VtInputThread.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
VtIo.cpp [Conpty] Pass through request for mouse mode to the Terminal (#9970) 2021-05-07 02:46:11 +00:00
VtIo.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
writeData.cpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
writeData.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00