2021-03-31 18:38:25 +02:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
|
|
// Licensed under the MIT license.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// For a clearer explanation of how this file should be used, see:
|
|
|
|
// https://en.wikipedia.org/wiki/X_Macro
|
|
|
|
//
|
|
|
|
// Include this file to be able to quickly define some code in the exact same
|
|
|
|
// way for _every single shortcut action_. To use:
|
|
|
|
//
|
|
|
|
// 1. Include this file
|
|
|
|
// 2. Define the ON_ALL_ACTIONS macro with what you want each action to show up
|
|
|
|
// as. Ex:
|
|
|
|
//
|
|
|
|
// #define ON_ALL_ACTIONS(action) void action##Handler();
|
|
|
|
//
|
|
|
|
// 3. Then, use the ALL_SHORTCUT_ACTIONS macro to get the ON_ALL_ACTIONS macro
|
|
|
|
// repeated once for every ShortcutAction
|
|
|
|
//
|
|
|
|
// This is used in KeyMapping.idl, ShortcutAction.*, TerminalPage.*, etc. to
|
|
|
|
// reduce the number of places where we must copy-paste boiler-plate code for
|
|
|
|
// each action. This is _NOT_ something that should be used when any individual
|
|
|
|
// case should be customized.
|
|
|
|
|
|
|
|
#define ALL_SHORTCUT_ACTIONS \
|
|
|
|
ON_ALL_ACTIONS(CopyText) \
|
|
|
|
ON_ALL_ACTIONS(PasteText) \
|
|
|
|
ON_ALL_ACTIONS(OpenNewTabDropdown) \
|
|
|
|
ON_ALL_ACTIONS(DuplicateTab) \
|
|
|
|
ON_ALL_ACTIONS(NewTab) \
|
|
|
|
ON_ALL_ACTIONS(CloseWindow) \
|
|
|
|
ON_ALL_ACTIONS(CloseTab) \
|
|
|
|
ON_ALL_ACTIONS(ClosePane) \
|
|
|
|
ON_ALL_ACTIONS(NextTab) \
|
|
|
|
ON_ALL_ACTIONS(PrevTab) \
|
|
|
|
ON_ALL_ACTIONS(SendInput) \
|
|
|
|
ON_ALL_ACTIONS(SplitPane) \
|
|
|
|
ON_ALL_ACTIONS(TogglePaneZoom) \
|
|
|
|
ON_ALL_ACTIONS(SwitchToTab) \
|
|
|
|
ON_ALL_ACTIONS(AdjustFontSize) \
|
|
|
|
ON_ALL_ACTIONS(ResetFontSize) \
|
|
|
|
ON_ALL_ACTIONS(ScrollUp) \
|
|
|
|
ON_ALL_ACTIONS(ScrollDown) \
|
|
|
|
ON_ALL_ACTIONS(ScrollUpPage) \
|
|
|
|
ON_ALL_ACTIONS(ScrollDownPage) \
|
|
|
|
ON_ALL_ACTIONS(ScrollToTop) \
|
|
|
|
ON_ALL_ACTIONS(ScrollToBottom) \
|
|
|
|
ON_ALL_ACTIONS(ResizePane) \
|
|
|
|
ON_ALL_ACTIONS(MoveFocus) \
|
|
|
|
ON_ALL_ACTIONS(Find) \
|
|
|
|
ON_ALL_ACTIONS(ToggleShaderEffects) \
|
|
|
|
ON_ALL_ACTIONS(ToggleFocusMode) \
|
|
|
|
ON_ALL_ACTIONS(ToggleFullscreen) \
|
|
|
|
ON_ALL_ACTIONS(ToggleAlwaysOnTop) \
|
|
|
|
ON_ALL_ACTIONS(OpenSettings) \
|
|
|
|
ON_ALL_ACTIONS(SetColorScheme) \
|
|
|
|
ON_ALL_ACTIONS(SetTabColor) \
|
|
|
|
ON_ALL_ACTIONS(OpenTabColorPicker) \
|
|
|
|
ON_ALL_ACTIONS(RenameTab) \
|
|
|
|
ON_ALL_ACTIONS(OpenTabRenamer) \
|
|
|
|
ON_ALL_ACTIONS(ExecuteCommandline) \
|
|
|
|
ON_ALL_ACTIONS(ToggleCommandPalette) \
|
|
|
|
ON_ALL_ACTIONS(CloseOtherTabs) \
|
|
|
|
ON_ALL_ACTIONS(CloseTabsAfter) \
|
|
|
|
ON_ALL_ACTIONS(TabSearch) \
|
|
|
|
ON_ALL_ACTIONS(MoveTab) \
|
|
|
|
ON_ALL_ACTIONS(BreakIntoDebugger) \
|
|
|
|
ON_ALL_ACTIONS(TogglePaneReadOnly) \
|
|
|
|
ON_ALL_ACTIONS(FindMatch) \
|
|
|
|
ON_ALL_ACTIONS(NewWindow) \
|
|
|
|
ON_ALL_ACTIONS(IdentifyWindow) \
|
Add support for renaming windows (#9662)
## Summary of the Pull Request
This PR adds support for renaming windows.
![window-renaming-000](https://user-images.githubusercontent.com/18356694/113034344-9a30be00-9157-11eb-9443-975f3c294f56.gif)
![window-renaming-001](https://user-images.githubusercontent.com/18356694/113034452-b5033280-9157-11eb-9e35-e5ac80fef0bc.gif)
It does so through two new actions:
* `renameWindow` takes a `name` parameter, and attempts to set the window's name
to the provided name. This is useful if you always want to hit <kbd>F3</kbd>
and rename a window to "foo" (READ: probably not that useful)
* `openWindowRenamer` is more interesting: it opens a `TeachingTip` with a
`TextBox`. When the user hits Ok, it'll request a rename for the provided
value. This lets the user pick a new name for the window at runtime.
In both cases, if there's already a window with that name, then the monarch will
reject the rename, and pop a `Toast` in the window informing the user that the
rename failed. Nifty!
## References
* Builds on the toasts from #9523
* #5000 - process model megathread
## PR Checklist
* [x] Closes https://github.com/microsoft/terminal/projects/5#card-50771747
* [x] I work here
* [x] Tests addded (and pass with the help of #9660)
* [ ] Requires documentation to be updated
## Detailed Description of the Pull Request / Additional comments
I'm sending this PR while finishing up the tests. I figured I'll have time to sneak them in before I get the necessary reviews.
> PAIN: We can't immediately focus the textbox in the TeachingTip. It's
> not technically focusable until it is opened. However, it doesn't
> provide an even tto tell us when it is opened. That's tracked in
> microsoft/microsoft-ui-xaml#1607. So for now, the user _needs_ to
> click on the text box manually.
> We're also not using a ContentDialog for this, because in Xaml
> Islands a text box in a ContentDialog won't recieve _any_ keypresses.
> Fun!
## Validation Steps Performed
I've been playing with
```json
{ "keys": "f1", "command": "identifyWindow" },
{ "keys": "f2", "command": "identifyWindows" },
{ "keys": "f3", "command": "openWindowRenamer" },
{ "keys": "f4", "command": { "action": "renameWindow", "name": "foo" } },
{ "keys": "f5", "command": { "action": "renameWindow", "name": "bar" } },
```
and they seem to work as expected
2021-04-02 18:00:04 +02:00
|
|
|
ON_ALL_ACTIONS(IdentifyWindows) \
|
|
|
|
ON_ALL_ACTIONS(RenameWindow) \
|
|
|
|
ON_ALL_ACTIONS(OpenWindowRenamer)
|