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

Feature Request: Context Menu for Tabs #1912

Closed
6 of 8 tasks
mdtauk opened this issue Jul 10, 2019 · 24 comments
Closed
6 of 8 tasks

Feature Request: Context Menu for Tabs #1912

mdtauk opened this issue Jul 10, 2019 · 24 comments
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. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.

Comments

@mdtauk
Copy link

mdtauk commented Jul 10, 2019

Context Menu for Tabs

Useful for now, whilst the Tab Bar is in an incomplete state, but will also be useful in a finished version. Each Tab should have a Context Menu with a Close command, as well as eventually, options for renaming the Profile/Tab Title, and changing the TabWidth behaviour.

For now, the Tab Title Text can be so long, you need to scroll with the mouse wheel to get to the close button on some tabs, so having a right click option would help for now.

team notes

@mdtauk mdtauk added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Jul 10, 2019
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jul 10, 2019
@DHowett-MSFT DHowett-MSFT added this to the Terminal Backlog milestone Jul 10, 2019
@DHowett-MSFT
Copy link
Contributor

We almost certainly want to do this. @carlos-zamora indicated an interest in this in April 😄

@DHowett-MSFT DHowett-MSFT added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. labels Jul 10, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jul 10, 2019
@DHowett-MSFT DHowett-MSFT removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Jul 10, 2019
@mdtauk
Copy link
Author

mdtauk commented Jul 10, 2019

The sooner this can be added, with the single close command - would be appreciated. Once there is a context menu there, new things can be added over time.

@devonzara
Copy link

Just installed Terminal to try it out and this was the very first thing I noticed... along side having to edit a JSON file for the settings.

@scrthq
Copy link

scrthq commented Aug 3, 2019

Another nice-to-have item for a tab's context menu would be to restart/reload the tab. This is one feature I use heavily in ConEmu currently. Being able to bind that to a keyboard shortcut would also be fantastic.

@SirHenryIII
Copy link

Rename via double-click/key-binding would also be very nice. The new tabTitle option is already useful but sometimes it could be helpful to quickly rename a tab.

@altered-dev
Copy link

Also it may be useful for executing custom commands for profiles.
For example, there could be a setting for this, and in the context menu is an item executing "sudo apt update".

@zadjii-msft
Copy link
Member

Another request from #1000: Actions for "Split Vertical [|]" and "Split Horizontal [-]", then with sub-menus for which profile to split with.

@tmknight
Copy link

This thread seems to be getting muddled with ancillary requests not specific to the title. Please stay on target with the original request. Make separate requests as relevant.

That that end, is there any movement on this request (Feature Request: Context Menu for Tabs)

@zadjii-msft
Copy link
Member

When there's progress, we'll make sure to post in here 😉. #3789 will add a context menu that we can use, then it's just on us to add more features to that flyout.

@tmknight
Copy link

That's not the correct place for this request. That's specific to colors, not #1912, which is content menu. Should #1912 be closed a new request opened since this one has become inundated with ancillary requests and little on the topic itself?

@zadjii-msft
Copy link
Member

I'm pretty sure it's relevant to a "context menu for tabs", since it literally adds a context menu to tabs:

image

We're not planning on having a specific other PR for just adding a context menu to the tabs while this PR (#3789) is active.

Typically, we like to use "feature" issues to track larger buckets of work that might span multiple PRs, and "task" issues to track work that could be done as an individual PR. So in this case, this "feature" encapsulates all the context menu entries, while

Are all reasonable sub-tasks that should be incorporated into a complete design. Obviously, this is all fairly open to change as we work on it, but those are rough estimates of how we track issues on our repo.

@altered-dev

This comment has been minimized.

@zadjii-msft

This comment has been minimized.

@tmknight

This comment has been minimized.

@zadjii-msft
Copy link
Member

Thanks for the suggestion! I think there's a lot of good suggestions in this thread, and I'd rather not muddle #3789 with ancillary requests. That PR is a good atomic PR that adds exactly one feature, and adding more requests to it would further delay a PR that's already overdue.

Once that PR is merged, we'll use this thread as the master thread for all the follow-up tasks to add to the context menu.

@ffes
Copy link

ffes commented May 18, 2020

The context menu should also have a Duplicate tab option. The command and default shortcut key Ctrl+Shift+D are already there, so once there is a context menu it should be easy to add.

@zadjii-msft
Copy link
Member

So the only reason I'm reluctant to just slam that feature in now is the following question: what happens when the tab has multiple panes in it?

The "duplicateTab" keybinding currently only duplicates the active pane into a new tab. It was also authored before panes were really a thing. So maybe we'll need to do two things here:

  1. duplicateTab should get an new param "duplicatePanes" which is false by default. When true, duplicateTab will dupe the pane structure too.
  2. We'll add 2 actions to the menu here. Naming isn't my strong suit, but I'd imaging something like "Duplicate Tab" and "Duplicate Tab and Panes" (and maybe the panes option is only visible when there is >1 pane)

@RahulRavishankar
Copy link

Can I take up this issue?
I tried to navigate through the codebase to find the relevant files but I couldn't.
I'm a beginner. I'm willing to contribute. Can someone guide me through this?

@zadjii-msft
Copy link
Member

Go right ahead!

Right now the context menu is being constructed in Tab::_CreateContextMenu.

Honestly, the hardest part might just be wiring up the Tab to the ShortcutActionDispatch, which is the object that can be used for executing actions (like those that are bindable to keys). The CommandPalette does something similar to what I think you'd need to do.

Then it's just a matter of creating an ActionAndArgs corresponding to the action you'd like to perform, and passing it to the ShortcutActionDispatch. If there's not a ShortcutAction that corresponds to the action that you want to add to the context menu, then we'd have to add support for that too, but usually that's not too hard.

Which action(s) were you thinking of adding to the context menu?

@RahulRavishankar
Copy link

I was thinking of adding "Close all tabs to the right" to the context menu.

I went through the file mentioned by you and I have a fair idea to solve this issue. Under CreateContextMenu() in Tab I can create a new MenuItem, implement a Click() and then append it to the context menu, ShortcutActionDispatch - contains all the actions that can be executed(in my case, I need CloseTab action and it already exists). In my case, I need a list of all the tabs that have been created so that I can iterate through it and then close all the tabs to right. Is this the right approach? How do I list all the tabs?

@zadjii-msft
Copy link
Member

Yea, that's a little bit of the challenge with that action. Right now, I think the closeTab action doesn't actually accept any arguments, so it always just closes the active tab. I like half drafted a design for a closeTabs action that would accept parameters in #5888:

In both of those cases, it might be important to somehow refer to the
context of the current tab or control in the json. Think for example about
"Close tab" or "Close other tabs" - currently, those work by knowing which
tab the "action" is specified for, not by actually using a closeTab action.
In the future, they might need to be implemented as something like

  • Close Tab: { "action": "closeTab", "index": "${selectedTab.index}" }
  • Close Other Tabs: { "action": "closeTabs", "otherThan": "${selectedTab.index}" }
  • Close Tabs to the Right: { "action": "closeTabs", "after": "${selectedTab.index}" }

Unfortunately, that doesn't really help you right now. I might need to roll that action (or a variation) together before this is actually possible...

@zadjii-msft
Copy link
Member

@RahulRavishankar I threw together a PR for the actions that you'll probably need over in #7176. You'd still need some way for a Tab to figure out what index it is, but that shouldn't be that hard. Hope that helps!

ghost pushed a commit that referenced this issue Aug 6, 2020
## Summary of the Pull Request

Adds support for two actions, `closeOtherTabs` and `closeTabsAfter`. Both these actions accept an `index` parameter.

* `closeOtherTabs`: Close tabs other than `index`
* `closeTabsAfter`: Close tabs after `index` (This is also "Close tabs to the right")

## References
* This PR is being made to unblock @RahulRavishankar in #1912
## PR Checklist
* [x] I work here
* [ ] Tests added/passed
* [x] Requires documentation to be updated
* [ ] We should file an issue for "add an `index` param to `closeTab`" to add similar support to the close tab action
* [ ] We should file an issue for "make the `index` param to `closeOtherTabs`, `closeTabsAfter` optional" to make them both work on the _active_ tab when there's no `index` provided

## Validation Steps Performed
* _Verified that_ closing all tabs when I have the `index`'th tab selected _works as expected_
* _Verified that_ closing all tabs when I have a tab other than the `index`'th tab selected _works as expected_
* _Verified that_ closing tabs to the right when I have the `index`'th tab selected _works as expected_
* _Verified that_ closing tabs to the right when I have a tab other than the `index`'th tab selected _works as expected_
    - This one has one caveat: for whatever reason, if you run this action when the tab that's currently focused is _before_ the `index` param, then the tabs will expand to fill the entire width of the tab row, until you mouse over them. Probably has something to do with tabs not resizing down until there's a mouse exit event.
zadjii-msft added a commit that referenced this issue Aug 12, 2020
## Summary of the Pull Request

⚠️ This spec has been moved from #6902. That version was branched off the new tab menu customization, and had a terribly convoluted git history. After discussion with the team, we've decided that it's best that this spec is merged atomically _first_, and used as the basis for #5888, as opposed to the other way around.

> This document is intended to serve as an addition to the [Command Palette Spec],
> as well as the [New Tab Menu Customization Spec].
> 
> As we come to rely more on actions being a mechanism by which the user defines
> "do something in the Terminal", we'll want to make it even easier for users to
> re-use the actions that they've already defined, as to reduce duplicated json as
> much as possible. This spec proposes a mechanism by which actions could be
> uniquely identifiable, so that the user could refer to bindings in other
> contexts without needing to replicate an entire json blob.
> 

## PR Checklist
* [x] Specs: #6899
* [x] References: #1571, #1912, #3337, #5025, #5524, #5633
* [x] I work here

## Detailed Description of the Pull Request / Additional comments
_\*<sup>\*</sup><sub>\*</sub> read the spec  <sub>\*</sub><sup>\*</sup>\*_



[Command Palette Spec]: https://github.com/microsoft/terminal/blob/master/doc/specs/%232046%20-%20Command%20Palette.md
[New Tab Menu Customization Spec]: https://github.com/microsoft/terminal/blob/master/doc/specs/%231571%20-%20New%20Tab%20Menu%20Customization.md
@KalleOlaviNiemitalo
Copy link

Can those menu items be grayed out if there are no tabs that would be closed by them? I suppose that can be done as a separate feature that applies to the command palette as well.

zadjii-msft pushed a commit that referenced this issue Oct 15, 2020
<!-- 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 a "Close..." option to the tab context menu, with nested entries to close tabs to the right and close other tabs (actions already available)
![immagine](https://user-images.githubusercontent.com/1140981/94178005-c7e03600-fe9a-11ea-9f87-c6f4895d4cf3.png)

<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> 
## References
#1912 

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [x] Closes #5524
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] 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.
* [ ] 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
First contribution 🙂
Tried to follow some suggestions from #1912 (comment)

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
@zadjii-msft zadjii-msft added 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. labels Mar 4, 2021
ghost pushed a commit that referenced this issue Aug 5, 2021
<!-- 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
Adds the Split Tab option to the tab context menu.
Clicking this option will `auto` split the active pane of the tab into a duplicate pane.
Clicking on an unfocused tab and splitting it will bring that tab into focus and split its active pane.

We could make this a flyout from the context menu to let people choose horizontal/vertical split in the future if it's requested.

I'm also wondering if this should be called Split Pane instead of Split Tab?

<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> 
## References
#1912

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [x] Closes #5025
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] 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.
* [ ] 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

https://user-images.githubusercontent.com/48369326/127691919-aae4683a-212a-4525-a0eb-a61c877461ed.mp4

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
@zadjii-msft
Copy link
Member

You know, the fundamental work for this has been done (and shipped for quite some time). I don't really think we need to keep this open to track the various individual items of the menu any longer. Thanks all!

@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Dec 9, 2021
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. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests