<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Add functionality to move a pane to another tab. If the tab index is greater than the number of current tabs a new tab will be created with the pane as its root. Similarly, if the last pane on a tab is moved to another tab, the original tab will be closed. This is largely complete, but I know that I'm messing around with things that I am unfamiliar with, and would like to avoid footguns where possible. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References #4587 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #7075 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [x] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [x] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments Things done: - Moving a pane to a new tab appears to work. Moving a pane to an existing tab mostly works. Moving a pane back to its original tab appears to work. - Set up {Attach,Detach}Pane methods to add or remove a pane from a pane. Detach is slightly different than Close in that we want to persist the tree structure and terminal controls. - Add `Detached` event on a pane that can be subscribed to to remove other event handlers if desired. - Added simple WalkTree abstraction for one-off recursion use cases that calls a provided function on each pane in order (and optionally terminates early). - Fixed an in-prod bug with closing panes. Specifically, if you have a tree (1; 2 3) and close the 1 pane, then 3 will lose its borders because of these lines clearing the border on both children https://github.com/microsoft/terminal/blob/main/src/cascadia/TerminalApp/Pane.cpp#L1197-L1201 . To do: - Right now I have `TerminalTab` as a friend class of `Pane` so I can access some extra properties in my `WalkTree` callbacks, but there is probably a better choice for the abstraction boundary. Next Steps: - In a future PR Drag & Drop handlers could be added that utilize the Attach/Detach infrastructure to provide a better UI. - Similarly once this is working, it should be possible to convert an entire tab into a pane on an existing tab (Tab::DetachRoot on original tab followed by Tab::AttachPane on the target tab). - Its been 10 years, I just really want to use concepts already. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed Manual testing by creating pane(s), and moving them between tabs and creating new tabs and destroying tabs by moving the last remaining pane.
113 lines
5 KiB
C
113 lines
5 KiB
C
// 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(ToggleSplitOrientation) \
|
|
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(MovePane) \
|
|
ON_ALL_ACTIONS(SwapPane) \
|
|
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) \
|
|
ON_ALL_ACTIONS(RenameWindow) \
|
|
ON_ALL_ACTIONS(OpenWindowRenamer) \
|
|
ON_ALL_ACTIONS(GlobalSummon) \
|
|
ON_ALL_ACTIONS(QuakeMode) \
|
|
ON_ALL_ACTIONS(FocusPane)
|
|
|
|
#define ALL_SHORTCUT_ACTIONS_WITH_ARGS \
|
|
ON_ALL_ACTIONS_WITH_ARGS(AdjustFontSize) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(CloseOtherTabs) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(CloseTabsAfter) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(CloseTab) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(CopyText) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(ExecuteCommandline) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(FindMatch) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(GlobalSummon) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(MoveFocus) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(MovePane) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(SwapPane) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(MoveTab) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(NewTab) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(NewWindow) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(NextTab) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(OpenSettings) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(PrevTab) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(RenameTab) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(RenameWindow) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(ResizePane) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(ScrollDown) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(ScrollUp) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(SendInput) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(SetColorScheme) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(SetTabColor) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(SplitPane) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(SwitchToTab) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(ToggleCommandPalette) \
|
|
ON_ALL_ACTIONS_WITH_ARGS(FocusPane)
|