terminal/src
Mike Griese 6a4c737686
Add support for arbitrary args in keybindings (#3391)
## Summary of the Pull Request

Enables the user to provide arbitrary argument values to shortcut actions through a new `args` member of keybindings. For some keybindings, like `NewTabWithProfile<N>`, we previously needed 9 different `ShortcutAction`s, one for each value of `Index`. If a user wanted to have a `NewTabWithProfile11` keybinding, that was simply impossible. Now that the args are in their own separate json object, each binding can accept any number of arbitrary argument values.

So instead of:
```json
        { "command": "newTab", "keys": ["ctrl+shift+t"] },
        { "command": "newTabProfile0", "keys": ["ctrl+shift+1"] },
        { "command": "newTabProfile1", "keys": ["ctrl+shift+2"] },
        { "command": "newTabProfile2", "keys": ["ctrl+shift+3"] },
        { "command": "newTabProfile3", "keys": ["ctrl+shift+4"] },
```

We can now use:

```json
        { "command": "newTab", "keys": ["ctrl+shift+t"] },
        { "command": { "action": "newTab", "index": 0 }, "keys": ["ctrl+shift+1"] },
        { "command": { "action": "newTab", "index": 1 }, "keys": ["ctrl+shift+2"] },
        { "command": { "action": "newTab", "index": 2 }, "keys": ["ctrl+shift+3"] },
```

Initially, this does seem more verbose. However, for cases where there are multiple args, or there's a large range of values for the args, this will quickly become a more powerful system of expressing keybindings.

The "legacy" keybindings are _left in_ in this PR. They have helper methods to generate appropriate `IActionArgs` values. Prior to releasing 1.0, I think we should remove them, if only to remove some code bloat.

## References

See [the spec](https://github.com/microsoft/terminal/blob/master/doc/specs/%231142%20-%20Keybinding%20Arguments.md) for more details.

This is part two of the implementation, part one was #2446

## PR Checklist
* [x] Closes #1142
* [x] I work here
* [x] Tests added/passed
* [x] Schema updated

## Validation Steps Performed

* Ran Tests
* Removed the legacy keybindings from the `defaults.json`, everything still works
* Tried leaving the legacy keybingings in my `profiles.json`, everything still works.

-------------------------------------------------
* this is a start, but there's a weird linker bug if I take the SetKeybinding(ShortcutAction, KeyChord) implementation out, which I don't totally understand

* a good old-fashioned clean will fix that right up

* all these things work

* hey this actually _functionally_ works

* Mostly cleanup and completion of implementation

* Hey I bet we could just make NewTab the handler for NewTabWithProfile

* Start writing tests for Keybinding args

* Add tests

* Revert a bad sln change, and clean out dead code

* Change to include "command" as a single object

  This is a change to make @dhowett-msft happy. Changes the args to be a part
  of the "command" object, as opposed to an object on their own.

  EX:

  ```jsonc

    // Old style
    { "command": "switchToTab0", "keys": ["ctrl+1"] },
    { "command": { "action": "switchToTab", "index": 0 }, "keys": ["ctrl+alt+1"] },

    // new style
    { "command": "switchToTab0", "keys": ["ctrl+1"] },
    { "command": "switchToTab", "args": { "index": 0 } "keys": ["ctrl+alt+1"] },

  ```

* schemas are hard yo

* Fix the build?

* wonder why my -Wall settings are different than CI...

* this makes me hate things

* Comments from PR

  * Add a `Direction::None`
  * LOAD BEARING
  * add some GH ids to TODOs

* add a comment

* PR nits from carlos
2019-11-14 16:23:40 -06:00
..
buffer Copy RTF data to the clipboard (#3535) 2019-11-13 14:13:22 -06:00
cascadia Add support for arbitrary args in keybindings (#3391) 2019-11-14 16:23:40 -06:00
host Move project to app CRTs in preparation to run Universal (#3474) 2019-11-08 14:09:39 -08:00
inc Revert locking changes (#3488) 2019-11-08 13:44:52 -08:00
interactivity Revert locking changes (#3488) 2019-11-08 13:44:52 -08:00
internal Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
propsheet Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
propslib Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
renderer Add Selection Background Color as a setting to Profiles and Col… (#3471) 2019-11-13 12:17:39 -06:00
server Revert locking changes (#3488) 2019-11-08 13:44:52 -08:00
terminal Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
testlist inbox: Merge accumulated build fixes from RS_ONECORE_DEP_ACIOSS (#1002) 2019-05-24 12:28:30 -07:00
tools Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
tsf Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
types Replace ConhostConnection with ConptyConnection (#3461) 2019-11-06 15:09:01 -08:00
winconpty Make ConPTY build as both LIB and DLL. (#3565) 2019-11-14 11:22:00 -08:00
common.build.post.props Move project to app CRTs in preparation to run Universal (#3474) 2019-11-08 14:09:39 -08:00
common.build.pre.props Replace ConhostConnection with ConptyConnection (#3461) 2019-11-06 15:09:01 -08:00
common.build.tests.props Refactor TerminalApp and Add Tests for Xaml Content (#1164) 2019-07-15 14:27:56 -05:00
ConsolePerf.regions.xml Tab to spaces (#578) 2019-05-13 18:06:36 -07:00
ConsolePerf.wprp Tab to spaces (#578) 2019-05-13 18:06:36 -07:00
cppwinrt.build.post.props Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
cppwinrt.build.pre.props Move project to app CRTs in preparation to run Universal (#3474) 2019-11-08 14:09:39 -08:00
dirs Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
project.inc Sync with latest inbox changes 2019-10-17 15:11:07 -07:00
project.unittest.inc inbox: merge refactoring payload from FI 2019-06-11 17:01:26 -07:00
StaticAnalysis.ruleset Combined changes to make the build work again (see inside) (#2945) 2019-09-30 10:39:55 -07: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