[PR #10638] [MERGED] Preliminary work to add Swap Panes functionality (GH Issues 1000, 4922) #28147

Open
opened 2026-01-31 09:26:38 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/10638
Author: @Rosefield
Created: 7/12/2021
Status: Merged
Merged: 7/22/2021
Merged by: @undefined

Base: mainHead: feature/GH1000-4922-swap-panes


📝 Commits (10+)

  • d364cfd Preliminary work to add Swap Panes functionality (GH Issues 1000, 4922)
  • dc81ee0 Add an actual visual-adjacency testing implementation
  • 0fda879 Run code formatting tool
  • fbc4d4e Code review: dont try to set default keybindings for the new actions
  • 5123c2d Dont overwrite borders after we swap panes, actually assign the row/column locations to the correct elements.
  • 69bb7b4 Attempt to add tests for basic move pane functionality
  • 49e888e Run code formatter again
  • 983c58a Fix method comment, make a method const that can be
  • 4397d16 Code review: less confusing naming, attempt at a more consistent test
  • 53382d0 Even more aggressively sleep between each action

📊 Changes

20 files changed (+1037 additions, -2 deletions)

View changed files

📝 doc/cascadia/profiles.schema.json (+19 -0)
📝 src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp (+119 -0)
📝 src/cascadia/LocalTests_TerminalApp/TabTests.cpp (+208 -0)
📝 src/cascadia/TerminalApp/AppActionHandlers.cpp (+18 -0)
📝 src/cascadia/TerminalApp/AppCommandlineArgs.cpp (+52 -0)
📝 src/cascadia/TerminalApp/AppCommandlineArgs.h (+4 -0)
📝 src/cascadia/TerminalApp/Pane.cpp (+406 -0)
📝 src/cascadia/TerminalApp/Pane.h (+35 -0)
📝 src/cascadia/TerminalApp/Resources/en-US/Resources.resw (+10 -0)
📝 src/cascadia/TerminalApp/TerminalPage.cpp (+16 -0)
📝 src/cascadia/TerminalApp/TerminalPage.h (+1 -0)
📝 src/cascadia/TerminalApp/TerminalTab.cpp (+33 -0)
📝 src/cascadia/TerminalApp/TerminalTab.h (+1 -0)
📝 src/cascadia/TerminalSettingsModel/ActionAndArgs.cpp (+2 -0)
📝 src/cascadia/TerminalSettingsModel/ActionArgs.cpp (+27 -0)
📝 src/cascadia/TerminalSettingsModel/ActionArgs.h (+61 -0)
📝 src/cascadia/TerminalSettingsModel/ActionArgs.idl (+6 -0)
📝 src/cascadia/TerminalSettingsModel/AllShortcutActions.h (+2 -0)
📝 src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw (+11 -1)
📝 src/cascadia/TerminalSettingsModel/defaults.json (+6 -1)

📄 Description

Summary of the Pull Request

Add functionality to swap a pane with an adjacent (Up/Down/Left/Right) neighbor.

References

This work potentially touches on: #1000 #2398 and #4922

PR Checklist

  • Closes a component of #1000 (partially, comment), #4922 (partially, SwapPanes function is added but not hooked up, no detach functionality)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Documentation updated. If checked, please file a pull request on our docs repo and link it here: #xxx
  • 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

Detailed Description of the Pull Request / Additional comments

Its been a while since I've written C++ code, and it is my first time working on a Windows application. I hope that I have not made too many mistakes.

Work currently done:

  • Add boilerplate/infrastructure for argument parsing, hotkeys, event handling
  • Adds the MovePane function that finds the focused pane, and then tries to find
    a pane that is visually adjacent to according to direction.
  • First pass at the SwapPanes function that swaps the tree location of two panes
  • First working version of helpers _FindFocusAndNeighbor and _FindNeighborFromFocus
    that search the tree for the currently focused pane, and then climbs back up the tree
    to try to find a sibling pane that is adjacent to it.
  • An `_IsAdjacent' function that tests whether two panes, given their relative offsets, are adjacent to each other according to the direction.

Next steps:

  • Once working these functions (_FindFocusAndNeighbor, etc) could be utilized to also solve #2398 by updating the NavigateFocus function.
  • Do we want default hotkeys for the new actions?

Validation Steps Performed

At this point, compilation and manual testing of functionality (with hotkeys) by creating panes, adding distinguishers to each pane, and then swapping them around to confirm they went to the right location.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/10638 **Author:** [@Rosefield](https://github.com/Rosefield) **Created:** 7/12/2021 **Status:** ✅ Merged **Merged:** 7/22/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `feature/GH1000-4922-swap-panes` --- ### 📝 Commits (10+) - [`d364cfd`](https://github.com/microsoft/terminal/commit/d364cfdfdf5c3d5b75beb14516b71cdb1771fb22) Preliminary work to add Swap Panes functionality (GH Issues 1000, 4922) - [`dc81ee0`](https://github.com/microsoft/terminal/commit/dc81ee049f33bdbc467d0517de60a351fe2e76f1) Add an actual visual-adjacency testing implementation - [`0fda879`](https://github.com/microsoft/terminal/commit/0fda87976456db27e285d10b29c062f92a6296ee) Run code formatting tool - [`fbc4d4e`](https://github.com/microsoft/terminal/commit/fbc4d4eae49eaef09fb094099dd97c166cc46027) Code review: dont try to set default keybindings for the new actions - [`5123c2d`](https://github.com/microsoft/terminal/commit/5123c2d8fde5be11cfa7c8703b3db9abef68bd1c) Dont overwrite borders after we swap panes, actually assign the row/column locations to the correct elements. - [`69bb7b4`](https://github.com/microsoft/terminal/commit/69bb7b4ea8eee8e6309389337a8cd0c9e2e727e2) Attempt to add tests for basic move pane functionality - [`49e888e`](https://github.com/microsoft/terminal/commit/49e888ee0c1f1f041ef2d89d3a1f8cabbc24d73c) Run code formatter again - [`983c58a`](https://github.com/microsoft/terminal/commit/983c58a64dd87ed835f28fda8fe66fe275836c59) Fix method comment, make a method const that can be - [`4397d16`](https://github.com/microsoft/terminal/commit/4397d16f20266a292a9bf5b1520202fa57eee951) Code review: less confusing naming, attempt at a more consistent test - [`53382d0`](https://github.com/microsoft/terminal/commit/53382d0c9cd97e4bc35032d4d543e2ac250c25eb) Even more aggressively sleep between each action ### 📊 Changes **20 files changed** (+1037 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `doc/cascadia/profiles.schema.json` (+19 -0) 📝 `src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp` (+119 -0) 📝 `src/cascadia/LocalTests_TerminalApp/TabTests.cpp` (+208 -0) 📝 `src/cascadia/TerminalApp/AppActionHandlers.cpp` (+18 -0) 📝 `src/cascadia/TerminalApp/AppCommandlineArgs.cpp` (+52 -0) 📝 `src/cascadia/TerminalApp/AppCommandlineArgs.h` (+4 -0) 📝 `src/cascadia/TerminalApp/Pane.cpp` (+406 -0) 📝 `src/cascadia/TerminalApp/Pane.h` (+35 -0) 📝 `src/cascadia/TerminalApp/Resources/en-US/Resources.resw` (+10 -0) 📝 `src/cascadia/TerminalApp/TerminalPage.cpp` (+16 -0) 📝 `src/cascadia/TerminalApp/TerminalPage.h` (+1 -0) 📝 `src/cascadia/TerminalApp/TerminalTab.cpp` (+33 -0) 📝 `src/cascadia/TerminalApp/TerminalTab.h` (+1 -0) 📝 `src/cascadia/TerminalSettingsModel/ActionAndArgs.cpp` (+2 -0) 📝 `src/cascadia/TerminalSettingsModel/ActionArgs.cpp` (+27 -0) 📝 `src/cascadia/TerminalSettingsModel/ActionArgs.h` (+61 -0) 📝 `src/cascadia/TerminalSettingsModel/ActionArgs.idl` (+6 -0) 📝 `src/cascadia/TerminalSettingsModel/AllShortcutActions.h` (+2 -0) 📝 `src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw` (+11 -1) 📝 `src/cascadia/TerminalSettingsModel/defaults.json` (+6 -1) </details> ### 📄 Description <!-- 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 swap a pane with an adjacent (Up/Down/Left/Right) neighbor. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References This work potentially touches on: #1000 #2398 and #4922 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes a component of #1000 (partially, comment), #4922 (partially, `SwapPanes` function is added but not hooked up, no detach functionality) * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed * [ ] 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 Its been a while since I've written C++ code, and it is my first time working on a Windows application. I hope that I have not made too many mistakes. Work currently done: - Add boilerplate/infrastructure for argument parsing, hotkeys, event handling - Adds the `MovePane` function that finds the focused pane, and then tries to find a pane that is visually adjacent to according to direction. - First pass at the `SwapPanes` function that swaps the tree location of two panes - First working version of helpers `_FindFocusAndNeighbor` and `_FindNeighborFromFocus` that search the tree for the currently focused pane, and then climbs back up the tree to try to find a sibling pane that is adjacent to it. - An `_IsAdjacent' function that tests whether two panes, given their relative offsets, are adjacent to each other according to the direction. Next steps: - Once working these functions (`_FindFocusAndNeighbor`, etc) could be utilized to also solve #2398 by updating the `NavigateFocus` function. - Do we want default hotkeys for the new actions? <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed At this point, compilation and manual testing of functionality (with hotkeys) by creating panes, adding distinguishers to each pane, and then swapping them around to confirm they went to the right location. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:26:38 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28147