terminal/src/cascadia/TerminalApp
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
..
dll Add a keybinding option to Terminal to open the Settings UI (#8048) 2020-12-11 13:47:10 -08:00
Resources/en-US Add support for running a commandline in another WT window (#8898) 2021-02-10 11:28:09 +00:00
ActionPaletteItem.cpp Teach CommandPalette model to natively support tabs and command lines (#8420) 2020-12-10 00:36:28 +00:00
ActionPaletteItem.h Teach CommandPalette model to natively support tabs and command lines (#8420) 2020-12-10 00:36:28 +00:00
ActionPaletteItem.idl Teach CommandPalette model to natively support tabs and command lines (#8420) 2020-12-10 00:36:28 +00:00
App.base.h Apply a GDI region to the top level Island window to allow dragging with a single Island (#929) 2019-06-25 13:06:11 -07:00
App.cpp Make Terminal look great in High Contrast (#6833) 2020-07-08 12:08:08 -07:00
App.h Break everything out of App except Xaml platform init (#3465) 2019-11-07 13:10:58 -08:00
App.idl Fix intellisense errors by moving TerminalApp projects around (#6897) 2020-08-20 22:44:37 +00:00
App.xaml Replace the HRGN-based titlebar cutout with an overlay window (#5485) 2020-04-24 15:22:40 -07:00
AppActionHandlers.cpp Separate runtime TerminalSettings from profile-TerminalSettings (#8602) 2021-02-08 22:01:40 +00:00
AppCommandlineArgs.cpp Add support for running a commandline in another WT window (#8898) 2021-02-10 11:28:09 +00:00
AppCommandlineArgs.h Add support for running a commandline in another WT window (#8898) 2021-02-10 11:28:09 +00:00
AppKeyBindings.cpp Introduce TerminalSettingsModel project (#7667) 2020-10-06 09:56:59 -07:00
AppKeyBindings.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
AppKeyBindings.idl Introduce TerminalSettingsModel project (#7667) 2020-10-06 09:56:59 -07:00
AppLogic.cpp Add support for running a commandline in another WT window (#8898) 2021-02-10 11:28:09 +00:00
AppLogic.h Add support for running a commandline in another WT window (#8898) 2021-02-10 11:28:09 +00:00
AppLogic.idl Add support for running a commandline in another WT window (#8898) 2021-02-10 11:28:09 +00:00
ColorHelper.cpp Fix a few minor typos from #3789 (#5740) 2020-05-04 16:47:29 -05:00
ColorHelper.h Add support for setting a tab's color at runtime w/ context menu (#3789) 2020-05-04 20:57:12 +00:00
ColorPickupFlyout.cpp Add support for setting a tab's color at runtime w/ context menu (#3789) 2020-05-04 20:57:12 +00:00
ColorPickupFlyout.h Add support for setting a tab's color at runtime w/ context menu (#3789) 2020-05-04 20:57:12 +00:00
ColorPickupFlyout.idl Add support for setting a tab's color at runtime w/ context menu (#3789) 2020-05-04 20:57:12 +00:00
ColorPickupFlyout.xaml Show color slider in Tab color picker (#7963) 2020-10-23 20:18:06 +00:00
Commandline.cpp Add support for commandline args to wt.exe (#4023) 2020-01-27 15:34:12 +00:00
Commandline.h Add support for commandline args to wt.exe (#4023) 2020-01-27 15:34:12 +00:00
CommandLinePaletteItem.cpp Teach CommandPalette model to natively support tabs and command lines (#8420) 2020-12-10 00:36:28 +00:00
CommandLinePaletteItem.h Teach CommandPalette model to natively support tabs and command lines (#8420) 2020-12-10 00:36:28 +00:00
CommandLinePaletteItem.idl Teach CommandPalette model to natively support tabs and command lines (#8420) 2020-12-10 00:36:28 +00:00
CommandPalette.cpp Introduce zoom, bell and progress indicators to ATS (#9041) 2021-02-08 17:37:58 +00:00
CommandPalette.h Move Tab Switcher mode handling into CommandPalette (#8656) 2021-01-19 22:18:10 +00:00
CommandPalette.idl Move Tab Switcher mode handling into CommandPalette (#8656) 2021-01-19 22:18:10 +00:00
CommandPalette.xaml Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
DebugTapConnection.cpp Introduce TerminalSettingsModel project (#7667) 2020-10-06 09:56:59 -07:00
DebugTapConnection.h Add explicit identifier to some constructors (#5652) 2020-04-29 16:50:47 -07:00
EmptyStringVisibilityConverter.cpp Add some polish to nested commands in the command palette (#7299) 2020-08-18 19:32:17 +00:00
EmptyStringVisibilityConverter.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
EmptyStringVisibilityConverter.idl Add some polish to nested commands in the command palette (#7299) 2020-08-18 19:32:17 +00:00
FilteredCommand.cpp Teach CommandPalette model to natively support tabs and command lines (#8420) 2020-12-10 00:36:28 +00:00
FilteredCommand.h Teach CommandPalette model to natively support tabs and command lines (#8420) 2020-12-10 00:36:28 +00:00
FilteredCommand.idl Teach CommandPalette model to natively support tabs and command lines (#8420) 2020-12-10 00:36:28 +00:00
HasNestedCommandsVisibilityConverter.cpp Teach CommandPalette model to natively support tabs and command lines (#8420) 2020-12-10 00:36:28 +00:00
HasNestedCommandsVisibilityConverter.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
HasNestedCommandsVisibilityConverter.idl Add some polish to nested commands in the command palette (#7299) 2020-08-18 19:32:17 +00:00
HighlightedText.cpp Bold matching text in the command palette (#7977) 2020-11-05 17:37:45 -08:00
HighlightedText.h Bold matching text in the command palette (#7977) 2020-11-05 17:37:45 -08:00
HighlightedText.idl Bold matching text in the command palette (#7977) 2020-11-05 17:37:45 -08:00
HighlightedTextControl.cpp Bold matching text in the command palette (#7977) 2020-11-05 17:37:45 -08:00
HighlightedTextControl.h Bold matching text in the command palette (#7977) 2020-11-05 17:37:45 -08:00
HighlightedTextControl.idl Bold matching text in the command palette (#7977) 2020-11-05 17:37:45 -08:00
HighlightedTextControl.xaml Bold matching text in the command palette (#7977) 2020-11-05 17:37:45 -08:00
IDirectKeyListener.idl Pass the scancode in our tunneled DirectKey event (#7298) 2020-08-14 23:44:39 +00:00
init.cpp Hook up the WIL fallback error tracer in Terminal (#7864) 2020-10-09 22:20:12 +00:00
Jumplist.cpp Store and expose hidden profiles (#8070) 2020-10-28 16:22:26 +00:00
Jumplist.h Move jumplist creation to background thread (#7978) 2020-10-22 17:17:26 -07:00
MinMaxCloseControl.cpp Get rid of the padding above the tab row when maximized (#5881) 2020-05-21 22:26:37 +00:00
MinMaxCloseControl.h Propagate window style changes to the titlebar and minmax (#3025) 2019-10-02 10:27:07 -07:00
MinMaxCloseControl.idl Fix intellisense errors by moving TerminalApp projects around (#6897) 2020-08-20 22:44:37 +00:00
MinMaxCloseControl.xaml Fix color animation bug of title bar buttons (#8649) 2021-01-07 21:12:29 +00:00
packages.config Update Win32 Toolkit (6.1.2) and VCRT Forwarders (1.0.4) (#8501) 2020-12-10 01:30:00 +00:00
PaletteItem.cpp Teach CommandPalette model to natively support tabs and command lines (#8420) 2020-12-10 00:36:28 +00:00
PaletteItem.h Teach CommandPalette model to natively support tabs and command lines (#8420) 2020-12-10 00:36:28 +00:00
PaletteItem.idl Teach CommandPalette model to natively support tabs and command lines (#8420) 2020-12-10 00:36:28 +00:00
PaletteItemTemplateSelector.cpp Introduce zoom, bell and progress indicators to ATS (#9041) 2021-02-08 17:37:58 +00:00
PaletteItemTemplateSelector.h Introduce zoom, bell and progress indicators to ATS (#9041) 2021-02-08 17:37:58 +00:00
PaletteItemTemplateSelector.idl Introduce zoom, bell and progress indicators to ATS (#9041) 2021-02-08 17:37:58 +00:00
Pane.cpp Separate runtime TerminalSettings from profile-TerminalSettings (#8602) 2021-02-08 22:01:40 +00:00
Pane.h Introduce read-only panes (#8867) 2021-02-08 18:03:55 +00:00
Pane.LayoutSizeNode.cpp Snap to character grid when resizing window (#3181) 2020-01-08 13:19:23 -08:00
pch.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
pch.h Add a keybinding option to Terminal to open the Settings UI (#8048) 2020-12-11 13:47:10 -08:00
SettingsTab.cpp Add a keybinding option to Terminal to open the Settings UI (#8048) 2020-12-11 13:47:10 -08:00
SettingsTab.h Add a keybinding option to Terminal to open the Settings UI (#8048) 2020-12-11 13:47:10 -08:00
SettingsTab.idl Add a keybinding option to Terminal to open the Settings UI (#8048) 2020-12-11 13:47:10 -08:00
ShortcutActionDispatch.cpp Introduce read-only panes (#8867) 2021-02-08 18:03:55 +00:00
ShortcutActionDispatch.h Introduce read-only panes (#8867) 2021-02-08 18:03:55 +00:00
ShortcutActionDispatch.idl Introduce read-only panes (#8867) 2021-02-08 18:03:55 +00:00
TabBase.cpp Teach tab tool tip to show profile name (#8883) 2021-01-25 22:50:21 +00:00
TabBase.h Introduce read-only panes (#8867) 2021-02-08 18:03:55 +00:00
TabBase.idl Introduce read-only panes (#8867) 2021-02-08 18:03:55 +00:00
TabHeaderControl.cpp Prevent context menu of tab renamer text box from canceling edit (#8979) 2021-02-01 16:37:15 +00:00
TabHeaderControl.h Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TabHeaderControl.idl Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TabHeaderControl.xaml Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TabPaletteItem.cpp Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TabPaletteItem.h Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TabPaletteItem.idl Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TabRowControl.cpp Upgrade to Microsoft.UI.Xaml 2.2 (#3027) 2019-10-14 22:41:43 -07:00
TabRowControl.h Upgrade to Microsoft.UI.Xaml 2.2 (#3027) 2019-10-14 22:41:43 -07:00
TabRowControl.idl Upgrade to Microsoft.UI.Xaml 2.2 (#3027) 2019-10-14 22:41:43 -07:00
TabRowControl.xaml Inform user that holding alt opens a new pane (#7866) 2020-10-12 17:14:02 -07:00
TerminalAppLib.vcxproj Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TerminalAppLib.vcxproj.filters Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TerminalPage.cpp Add support for running a commandline in another WT window (#8898) 2021-02-10 11:28:09 +00:00
TerminalPage.h Add support for running a commandline in another WT window (#8898) 2021-02-10 11:28:09 +00:00
TerminalPage.idl Implement ConEmu's OSC 9;4 to set the taskbar progress indicator (#8055) 2020-11-18 14:24:11 -08:00
TerminalPage.xaml Introduce read-only panes (#8867) 2021-02-08 18:03:55 +00:00
TerminalSettings.cpp Add support for "focus follows mouse" mode (#8965) 2021-02-09 22:18:20 +00:00
TerminalSettings.h Add support for "focus follows mouse" mode (#8965) 2021-02-09 22:18:20 +00:00
TerminalSettings.idl Move ICore/ControlSettings to TerminalControl project (#7167) 2020-08-07 14:46:52 +00:00
TerminalTab.cpp Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TerminalTab.h Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TerminalTab.idl Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TerminalTabStatus.cpp Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TerminalTabStatus.h Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TerminalTabStatus.idl Fix ATS tab status indicators (#9076) 2021-02-10 11:27:29 +00:00
TitlebarControl.cpp Add support for setting a tab's color at runtime w/ context menu (#3789) 2020-05-04 20:57:12 +00:00
TitlebarControl.h Add support for setting a tab's color at runtime w/ context menu (#3789) 2020-05-04 20:57:12 +00:00
TitlebarControl.idl Upgrade to Microsoft.UI.Xaml 2.2 (#3027) 2019-10-14 22:41:43 -07:00
TitlebarControl.xaml Upgrade to Microsoft.UI.Xaml 2.2 (#3027) 2019-10-14 22:41:43 -07:00