Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add close pane to the tab context menu (when there are multiple panes) #13580

Closed
Tracked by #1912
vertigo220 opened this issue Jul 23, 2022 · 9 comments · Fixed by #15198
Closed
Tracked by #1912

Add close pane to the tab context menu (when there are multiple panes) #13580

vertigo220 opened this issue Jul 23, 2022 · 9 comments · Fixed by #15198
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal good first issue This is a fix that might be easier for someone to do as a first contribution Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Milestone

Comments

@vertigo220
Copy link

Description of the new feature/enhancement

Once a tab is split, there's no way to return it to normal, meaning either having to continue working in half the space or starting a new tab and losing everything from the current one. It should allow for either closing one half or splitting them into two tabs.

Proposed technical implementation details (optional)

@vertigo220 vertigo220 added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Jul 23, 2022
@ghost ghost added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jul 23, 2022
@zadjii-msft
Copy link
Member

You mean like the closePane action/? Or maybe moving panes to their own tabs? Or heck even zooming a pane, to make it take the full size of the tab again?

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jul 23, 2022
@zadjii-msft zadjii-msft added Issue-Question For questions or discussion Resolution-Answered Related to questions that have been answered and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Jul 23, 2022
@vertigo220
Copy link
Author

I guess all three options would be nice, though I was mainly talking about the first. I didn't realize it was even an option since I didn't think to check the actions, and it's something I feel should be available via a menu and not just a shortcut, both to make it more obvious that it is an option, and to make it easier to do without having to remember the shortcut, especially since it's likely not something most would use very often.

I see three ways of handling this. The cleanest, most space-efficient, and probably most obvious would be to add the actions to the tab's right-click menu, e.g. "Close active pane," "Move active pane to new tab," "Make active pane full-size" (zoom it), and "Close all non-active panes" (though this one could be dangerous and would probably benefit from a confirmation dialog). Then whichever pane is active when right-clicking the tab and selecting one of the options would be the one acted on.

The second possibility would be to add a small title bar to each pane that could be right-clicked, which would bring up a menu with the previous options, minus the word active or replacing it with "other" in the case of closing the other panes, of course.

The third option would be to add a few small buttons at the top-right of each pane, an x to close it, a square to maximize it or double square to restore it, and something like a square with an arrow for separating it out into a new tab.

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jul 24, 2022
@zadjii-msft
Copy link
Member

FWIW, the general pattern the Terminal uses is that all the actions for the Terminal are in the Command Palette. We don't have a whole lot of UI space, so the command palette is a great way for us to have LOTS of actions while also making sure most menus aren't excessively cluttered. That being said

  • Sure, okay, we can use this to track "Add close pane to the tab context menu (when there are multiple panes)"
  • see: Add title to split window #4717
  • This will probably also fit under the same feature set as above

@zadjii-msft zadjii-msft changed the title Unsplit tabs Add close pane to the tab context menu (when there are multiple panes) Jul 29, 2022
@zadjii-msft zadjii-msft added Help Wanted We encourage anyone to jump in on these. Area-User Interface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. Issue-Task It's a feature request, but it doesn't really need a major design. good first issue This is a fix that might be easier for someone to do as a first contribution and removed Issue-Question For questions or discussion Resolution-Answered Related to questions that have been answered Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Attention The core contributors need to come back around and look at this ASAP. labels Jul 29, 2022
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jul 29, 2022
@zadjii-msft zadjii-msft added this to the Backlog milestone Jul 29, 2022
@rismoney
Copy link

how is this on the backlog? How do people even use this half-baked capability?

@zadjii-msft
Copy link
Member

@rismoney Probably because most people just close panes with the keyboard (ctrl+shift+w), or the Command Palette ctrl+shift+p. If you're passionate about the feature, I can try and help provide a roadmap of where the code changes would need to go.

@rismoney
Copy link

keyboard shortcuts ftw!

@Smeyer025
Copy link
Contributor

Smeyer025 commented Mar 20, 2023

@rismoney Probably because most people just close panes with the keyboard (ctrl+shift+w), or the Command Palette ctrl+shift+p. If you're passionate about the feature, I can try and help provide a roadmap of where the code changes would need to go.

@zadjii-msft I don't know if the offer is still on the table (or open to outside help), but I would love to take a crack at this and a roadmap would be extremely helpful!

@zadjii-msft
Copy link
Member

Of course!

Note

Walkthrough

  • I'd start by taking a look at TerminalTab::_CreateContextMenu, in TerminalTab.cpp. That's what we use for building all the other context menu entries for the tabs, so that's a good place to insert a new one.
  • I'd stash the Controls::MenuFlyoutItem that you make for ClosePane into the TerminalTab itself as a member. That way, we can use that member to toggle the visibility when the number of panes in the tab changes.
  • I'd start by setting the item to be Visibility(Collapsed), so that it's not initially visible.
  • TerminalTab::SplitPane is where new splits get added, so that would be a good place to change the Visibility to Visible
  • in TerminalTab::_AttachEventHandlersToPane, we add a pane->Closed callback, which we could use to set the Visibility back to Collapsed if there's only one pane in the tree.

Lemme know if you need any more help!

@joadoumie
Copy link
Contributor

Image

I decided to take a crack at this one and I think I have the functionality working. What should we use for the icon in the context menu?

@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Apr 18, 2023
microsoft-github-policy-service bot pushed a commit that referenced this issue Apr 26, 2023
## Summary of the Pull Request
Adding a 'Close Pane' menu item in the context menu.

## References and Relevant Issues
#13580 

## Detailed Description of the Pull Request / Additional comments
If a user decides to split a tab to create multiple panes through the
context menu, they should be able to then close the pane via the context
menu too. This PR introduces a new context menu item, 'Close Pane', that
only appears when a user has 2 or more panes in a tab. When a user
clicks close pane, the _active_pane will be closed.

## Validation Steps Performed

![close_pane_terminal](https://user-images.githubusercontent.com/98557455/232649000-8b521070-4f1b-4da9-8092-6ff802e91e2c.gif)

As it's my first PR, I still need to understand how to go through the
testing suite.

## PR Checklist
- [x] Closes #13580 
- [ ] 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
- [ ] Schema updated (if necessary)

---------

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal good first issue This is a fix that might be easier for someone to do as a first contribution Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants