-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Did you know about X Macros? Now you do!
**Summary of the Pull Request** This PR adds an X Macro for defining our ShortcutActions. This means that you can add the action in one place, and have the macro synthesize all sorts of boilerplate for you! From the `AllShortcutActions.h` file: > 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 marcro > 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. **PR Checklist** * [x] Scratches an itch * [x] I work here * [x] Tests passed * [n/a] Requires documentation to be updated **Detailed Description of the Pull Request / Additional comments** Originally I had this blocked as a follow up to #9662. However, I've grown tired after a month of merging main into this branch, and I'm just shipping it separately. It will inevitably conflict with anyone who has actions in flight currently. **Validation Steps Performed** The code still builds exactly as before!
- Loading branch information
1 parent
5ab78fc
commit d972c6a
Showing
7 changed files
with
98 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// 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 marcro | ||
// 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) \ | ||
ON_ALL_ACTIONS(IdentifyWindows) |
Oops, something went wrong.
d972c6a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misspellings found, please review:
To accept these changes, run the following commands from this repository on this branch
✏️ Contributor please read this
By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
perl
command excluding the outer'
marks and dropping any'"
/"'
quotation mark pairs into a file and then runperl file.pl
from the root of the repository to run the code. Alternatively, you can manually insert the items...If the listed items are:
.github/actions/spelling/dictionary/names.txt
..github/actions/spelling/dictionary/
..github/actions/spelling/expect/
..github/actions/spelling/patterns/
.See the
README.md
in each directory for more information.🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉
🗜️ If you see a bunch of garbage and it relates to a binary-ish string, please add a file path to the
.github/actions/spelling/excludes.txt
file instead of just accepting the garbage.File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^
refers to the file's path from the root of the repository, so^README\.md$
would exclude README.md (on whichever branch you're using).