terminal/src/cascadia/Remoting/ProposeCommandlineResult.h
Mike Griese 43c469fc95
Add support for naming windows with the -w parameter (#9300)
This finishes the implementation of `--window` to also accept a string
as the "name" of the window. So you can say 

```sh
wt -w foo new-tab
wt -w foo split-pane
```

and have both those commands execute in the same window, the one named
"foo". This is just slightly more ergonomic than manually using the IDs
of windows. In the future, I'll be working on renaming windows, and
displaying these names. 

> #### `--window,-w <window-id>`
> Run these commands in the given Windows Terminal session. This enables opening
> new tabs, splits, etc. in already running Windows Terminal windows.
> * If `window-id` is `0`, run the given commands in _the current window_.
> * If `window-id` is a negative number, or the reserved name `new`, run the
>   commands in a _new_ Terminal window.
> * If `window-id` is the ID or name of an existing window, then run the
>   commandline in that window.
> * If `window-id` is _not_ the ID or name of an existing window, create a new
>   window. That window will be assigned the ID or name provided in the
>   commandline. The provided subcommands will be run in that new window.
> * If `window-id` is omitted, then obey the value of `windowingBehavior` when
>   determining which window to run the command in.

Before this PR, I think we didn't actually properly support assigning
the id with `wt -w 12345`. If `12345` didn't exist, it would make a new
window, but just assign it the next id, not assign it 12345.

## References
* #4472, #8135
* https://github.com/microsoft/terminal/projects/5

## Validation Steps Performed
Ran tests
Messed with naming windows, working as expected.

Closes https://github.com/microsoft/terminal/projects/5#card-51431478
2021-03-17 19:28:01 +00:00

38 lines
1.2 KiB
C++

/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Class Name:
- ProposeCommandlineResult.h
Abstract:
- This is a helper class for encapsulating the result of a
Monarch::ProposeCommandline call. The monarch will be telling the new process
whether it should create a new window or not. If the value of
ShouldCreateWindow is false, that implies that some other window process was
given the commandline for handling, and the caller should just exit.
- If ShouldCreateWindow is true, the Id property may or may not contain an ID
that the new window should use as it's ID.
--*/
#pragma once
#include "ProposeCommandlineResult.g.h"
#include "../cascadia/inc/cppwinrt_utils.h"
namespace winrt::Microsoft::Terminal::Remoting::implementation
{
struct ProposeCommandlineResult : public ProposeCommandlineResultT<ProposeCommandlineResult>
{
public:
WINRT_PROPERTY(Windows::Foundation::IReference<uint64_t>, Id);
WINRT_PROPERTY(winrt::hstring, WindowName);
WINRT_PROPERTY(bool, ShouldCreateWindow, true);
public:
ProposeCommandlineResult(bool shouldCreateWindow) :
_ShouldCreateWindow{ shouldCreateWindow } {};
};
}