terminal/src
Mike Griese 03ebe514e9
Add support for running a commandline in another WT window (#8898)
## Summary of the Pull Request

**If you're reading this PR and haven't signed off on #8135, go there first.**

![window-management-000](https://user-images.githubusercontent.com/18356694/103932910-25199380-50e8-11eb-97e3-594a31da62d2.gif)

This provides the basic parts of the implementation of #4472. Namely:
* We add support for the `--window,-w <window-id>` argument to `wt.exe`, to allow a commandline to be given to another window.
    * If `window-id` is `0`, run the given commands in _the current window_.
    * If `window-id` is a negative number, run the commands in a _new_ Terminal window.
    * If `window-id` is the ID of an existing window, then run the commandline in that window.
    * If `window-id` is _not_ the ID of an existing window, create a new window. That window will be assigned the ID provided in the commandline. The provided subcommands will be run in that new window.
    * If `window-id` is omitted, then create a new window.


## References
* Spec: #8135
* Megathread: #5000
* Project: projects/5

## PR Checklist
* [x] Closes #4472
* [x] I work here
* [x] Tests added/passed
* [ ] Requires documentation to be updated - **sure does**

## Detailed Description of the Pull Request / Additional comments

Note that `wt -w 1 -d c:\foo cmd.exe` does work, by causing window 1 to change 

There are limitations, and there are plenty of things to work on in the future:
* [ ] We don't support names for windows yet
* [ ] We don't support window glomming by default, or a setting to configure what happens when `-w` is omitted. I thought it best to lay the groundwork first, then come back to that.
* [ ] `-w 0` currently just uses the "last activated" window, not "the current". There's more follow-up work to try and smartly find the actual window we're being called from.
* [ ] Basically anything else that's listed in projects/5.

I'm cutting this PR where it currently is, because this is already a huge PR. I believe the remaining tasks will all be easier to land, once this is in. 

## Validation Steps Performed

I've been creating windows, and closing them, and running cmdlines for a while now. I'm gonna keep doing that while the PR is open, till no bugs remain.

# TODOs
* [x] There are a bunch of `GetID`, `GetPID` calls that aren't try/caught 😬 
  -  [x] `Monarch.cpp`
  -  [x] `Peasant.cpp`
  -  [x] `WindowManager.cpp`
  -  [x] `AppHost.cpp`
* [x] If the monarch gets hung, then _you can't launch any Terminals_ 😨 We should handle this gracefully.
  - Proposed idea: give the Monarch some time to respond to a proposal for a commandline. If there's no response in that timeframe, this window is now a _hermit_, outside of society entirely. It can't be elected Monarch. It can't receive command lines. It has no ID.  
  	- Could we gracefully recover from such a state? maybe, probably not though.
    -  Same deal if a peasant hangs, it could end up hanging the monarch, right? Like if you do `wt -w 2`, and `2` is hung, then does the monarch get hung waiting on the hung peasant?
  - After talking with @miniksa, **we're gonna punt this from the initial implementation**. If people legit hit this in the wild, we'll fix it then.
2021-02-10 11:28:09 +00:00
..
buffer ROW: clean up in preparation to hide CharRow & AttrRow (#8446) 2021-01-20 21:16:56 +00:00
cascadia Add support for running a commandline in another WT window (#8898) 2021-02-10 11:28:09 +00:00
dep Move all wildcards into targets or expand them (#6406) 2020-06-08 14:01:47 -07:00
host ROW: clean up in preparation to hide CharRow & AttrRow (#8446) 2021-01-20 21:16:56 +00:00
inc ROW: clean up in preparation to hide CharRow & AttrRow (#8446) 2021-01-20 21:16:56 +00:00
interactivity ci: update to Spell check to 0.0.17a (#9014) 2021-02-03 11:17:38 -08:00
internal Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
propsheet Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
propslib Greatly reduce allocations in the conhost/OpenConsole startup path (#8489) 2020-12-16 10:40:30 -08:00
renderer Fix shader time input (#8994) 2021-02-02 17:12:04 +00:00
server Reduce Transient Allocations during Bulk Text Output (#8617) 2021-01-05 18:06:06 +00:00
terminal Fixed #5205: Ctrl+Alt+2 doesn't send ^[^@ (#5272) 2021-02-08 15:33:38 +00:00
testlist inbox: Merge accumulated build fixes from RS_ONECORE_DEP_ACIOSS (#1002) 2019-05-24 12:28:30 -07:00
til Give til::bitmap custom allocator support and add til::pmr::bitmap (#8787) 2021-01-19 18:24:39 +00:00
tools Add a Monarch/Peasant sample app (#8171) 2021-01-19 21:55:30 +00:00
tsf Fix Korean IME to display a character being composed in conhost (#8632) 2021-01-04 21:05:24 +00:00
types Separate runtime TerminalSettings from profile-TerminalSettings (#8602) 2021-02-08 22:01:40 +00:00
winconpty winconpty: close the pty host handle after terminating it (#8707) 2021-01-08 10:18:27 +00:00
common.build.post.props Move CI and audit build to the WinDev scale set pool (#8080) 2020-10-28 20:49:13 +00:00
common.build.pre.props Greatly reduce allocations in the conhost/OpenConsole startup path (#8489) 2020-12-16 10:40:30 -08:00
common.build.tests.props Update TAEF to 10.57.200731005-develop (#7164) 2020-08-03 20:47:02 +00:00
ConsolePerf.regions.xml Tab to spaces (#578) 2019-05-13 18:06:36 -07:00
ConsolePerf.wprp Fix the WPR profile (#4007) 2019-12-17 17:14:15 -08:00
cppwinrt.build.post.props Remove all our path antics; force native projects to bin/, obj/ (#8062) 2020-10-27 15:00:41 -07:00
cppwinrt.build.pre.props Fix the WINRT_NO_MAKE_DETECTION build break (#8067) 2020-10-27 17:56:09 -07:00
dirs build: move oss required to build conhost out of dep/ (#5451) 2020-04-21 14:43:09 -07:00
project.inc Merged PR 5425054: [Git2Git] conhost: explicitly set /utf-8 on the compiler commandline 2020-11-19 23:25:34 +00:00
project.unittest.inc Merged PR 4915530: Reflect OS Build fixes on top of 58f5d7c7 2020-07-13 23:00:53 +00:00
StaticAnalysis.ruleset Fix SA for Visual Studio 16.8 (#8551) 2020-12-11 05:04:30 +00:00
unit.tests.x64.runsettings Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
unit.tests.x86.runsettings Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
wap-common.build.post.props Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
wap-common.build.pre.props Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00