Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new panes with specifc profiles and other settings overrides #3825

Merged
33 commits merged into from
Dec 9, 2019

Conversation

zadjii-msft
Copy link
Member

Summary of the Pull Request

This enables the user to set a number of extra settings in the NewTab and SplitPane ShortcutActions, that enable customizing how a new terminal is created at runtime. The following four properties were added:

  • profile
  • commandline
  • tabTitle
  • startingDirectory

profile can be used with either a GUID or the name of a profile, and the action will launch that profile instead of the default.

commandline, tabTitle, and startingDirectory can all be used to override the profile's values of those settings. This will be more useful for #607.

With this PR, you can make bindings like the following:

{ "keys": ["ctrl+a"], "command": { "action": "splitPane", "split": "vertical" } },
{ "keys": ["ctrl+b"], "command": { "action": "splitPane", "split": "vertical", "profile": "{6239a42c-1111-49a3-80bd-e8fdd045185c}" } },
{ "keys": ["ctrl+c"], "command": { "action": "splitPane", "split": "vertical", "profile": "profile1" } },
{ "keys": ["ctrl+d"], "command": { "action": "splitPane", "split": "vertical", "profile": "profile2" } },
{ "keys": ["ctrl+e"], "command": { "action": "splitPane", "split": "horizontal", "commandline": "foo.exe" } },
{ "keys": ["ctrl+f"], "command": { "action": "splitPane", "split": "horizontal", "profile": "profile1", "commandline": "foo.exe" } },
{ "keys": ["ctrl+g"], "command": { "action": "newTab" } },
{ "keys": ["ctrl+h"], "command": { "action": "newTab", "startingDirectory": "c:\\foo" } },
{ "keys": ["ctrl+i"], "command": { "action": "newTab", "profile": "profile2", "startingDirectory": "c:\\foo" } },
{ "keys": ["ctrl+j"], "command": { "action": "newTab", "tabTitle": "bar" } },
{ "keys": ["ctrl+k"], "command": { "action": "newTab", "profile": "profile2", "tabTitle": "bar" } },
{ "keys": ["ctrl+l"], "command": { "action": "newTab", "profile": "profile1", "tabTitle": "bar", "startingDirectory": "c:\\foo", "commandline":"foo.exe" } }

References

This is a lot of work that was largely started in pursuit of #607. We want people to be able to override these properties straight from the commandline. While they may not make as much sense as keybindings like this, they'll make more sense as commandline arguments.

PR Checklist

Validation Steps Performed

There are tests 🎉

Manually added some bindings, they opened the correct profiles in panes/tabs

…ane-action

# Conflicts:
#	src/cascadia/TerminalApp/AppKeyBindings.cpp
#	src/cascadia/TerminalApp/AppKeyBindings.h
#	src/cascadia/TerminalApp/AppKeyBindings.idl
#	src/cascadia/TerminalApp/TerminalPage.cpp
…rminal-args

# Conflicts:
#	src/cascadia/TerminalApp/ActionArgs.idl
  Move all the profile determination stuff into CascadiaSettings. Now it's in
  charge of building the right TerminalSettings based on the index and
  NewTerminalArgs passed to it.

  Then, also hook that up to SplitPane.

  This weirdly makes a new tab _and_ a new pane, which is wrong. Dunno why yet.
  Ill debug mondeay
…rminal-args

# Conflicts:
#	doc/cascadia/profiles.schema.json
#	src/cascadia/TerminalApp/ActionArgs.h
#	src/cascadia/TerminalApp/ActionArgs.idl
#	src/cascadia/TerminalApp/AppActionHandlers.cpp
#	src/cascadia/TerminalApp/TerminalPage.cpp
#	src/cascadia/TerminalApp/TerminalPage.h
…erminal-args

# Conflicts:
#	src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp
#	src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp
#	src/cascadia/LocalTests_TerminalApp/TabTests.cpp
#	src/cascadia/LocalTests_TerminalApp/TerminalApp.LocalTests.AppxManifest.prototype.xml
…rminal-args

# Conflicts:
#	src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp
@zadjii-msft zadjii-msft added Area-Settings Issues related to settings and customizability, for console or terminal Product-Terminal The new Windows Terminal. labels Dec 3, 2019
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Dec 5, 2019
@carlos-zamora
Copy link
Member

Can we also have support for profileIndex? That way we can include something like the following in defaults.json

{ "keys": ["ctrl+alt+1"], "command": { "action": "splitPane", "split": "vertical", "profileIndex": 0 } },
{ "keys": ["ctrl+alt+2"], "command": { "action": "splitPane", "split": "vertical", "profileIndex": 1 } },
{ "keys": ["ctrl+alt+3"], "command": { "action": "splitPane", "split": "vertical", "profileIndex": 2 } },

{ "keys": ["ctrl+alt+shift+1"], "command": { "action": "splitPane", "split": "horizontal", "profileIndex": 0 } },
{ "keys": ["ctrl+alt+shift+2"], "command": { "action": "splitPane", "split": "horizontal", "profileIndex": 1 } },
{ "keys": ["ctrl+alt+shift+3"], "command": { "action": "splitPane", "split": "horizontal", "profileIndex": 2 } },

Or should this be a separate issue?

@zadjii-msft
Copy link
Member Author

zadjii-msft commented Dec 6, 2019

@carlos-zamora I actually secretly snuck that in with the refactor to have ProfileIndex be part of NewTerminalArgs. index should just work for splitPane now too :)

src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
Comment on lines 286 to 293
auto actionAndArgs = winrt::make_self<winrt::TerminalApp::implementation::ActionAndArgs>();
actionAndArgs->Action(ShortcutAction::NewTab);
auto newTabArgs = winrt::make_self<winrt::TerminalApp::implementation::NewTabArgs>();
newTabArgs->ProfileIndex(profileIndex);
auto newTerminalArgs = winrt::make_self<winrt::TerminalApp::implementation::NewTerminalArgs>();
newTerminalArgs->ProfileIndex(profileIndex);
newTabArgs->TerminalArgs(*newTerminalArgs);
actionAndArgs->Args(*newTabArgs);
profileKeyChord = keyBindings.GetKeyBindingForActionWithArgs(*actionAndArgs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super expensive, we'll want to maybe not have it be so expensive later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(One can file a task for this)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought make_self was the non-expensive version that just makes a com_ptr for the class, but didn't do the binary boundary hopping

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no no it is, but it's still a heap alloc of like four objects for what amounts to a hash table lookup 😄

…rminal-args

# Conflicts:
#	src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp
@zadjii-msft zadjii-msft added the AutoMerge Marked for automatic merge by the bot when requirements are met label Dec 9, 2019
@ghost
Copy link

ghost commented Dec 9, 2019

Hello @zadjii-msft!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit dd1c7b3 into master Dec 9, 2019
@ghost ghost deleted the dev/migrie/f/new-terminal-args branch December 9, 2019 13:02
ghost pushed a commit that referenced this pull request Dec 11, 2019
## Summary of the Pull Request

I accidentally did the wrong check here to see if the value exists. For an `IReference`, you need to do `variable != nullptr`. I did `variable.Value()`. 

## References
Introduced in #3825

## PR Checklist
* [x] Closes #3897
* [x] I work here
* [ ] Tests added/passed - wow this was a lot harder than I expected
* [n/a] Requires documentation to be updated

## Detailed Description of the Pull Request / Additional comments

This includes a maybe unrelated fix to make `TerminalPage`'s `ShortcutActionDispatch` a `com_ptr`. While I was messing with the tests for this, I caught that we're not supposed to direct allocate winrt types like that. Ofc, the `TerminalAppLib` project doesn't catch this.

## Validation Steps Performed
Ran the terminal manually, instead of just running the tests
ghost pushed a commit that referenced this pull request Dec 11, 2019
## Summary of the Pull Request

On this month's episode of "Mike accidentally breaks this": 
  Mike forgets that `==` is defined on a pair of winrt objects as "do these point to the _SAME_ object", not "do they have the same values". 

This just slipped right through code review.

## References

Broken in #3825

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

## Detailed Description of the Pull Request / Additional comments

## Validation Steps Performed

Manually checked that these are still there
@ghost
Copy link

ghost commented Jan 14, 2020

🎉Windows Terminal Preview v0.8.10091.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost ghost mentioned this pull request Jan 14, 2020
4 tasks
Copy link

@runerei runerei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal AutoMerge Marked for automatic merge by the bot when requirements are met Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open panes with a specific profile
5 participants