Feature Request: Context Menu for Tabs #2686

Closed
opened 2026-01-30 23:02:13 +00:00 by claunia · 24 comments
Owner

Originally created by @mdtauk on GitHub (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

Originally created by @mdtauk on GitHub (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 * [x] #5524 ("Close all tabs to the right") would be a good addition. * [ ] "Reload tab" would be a good addition, which would require #3726 * [x] The tab color picker is already in there, #3789 * [x] Renaming was added in #5775 * [ ] "Find" isn't a bad idea #5633 * [x] Split new panes? Another good idea #5025 * [x] Duplicate tab? Why not #9373 * [x] #13580
Author
Owner

@DHowett-MSFT commented on GitHub (Jul 10, 2019):

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

@DHowett-MSFT commented on GitHub (Jul 10, 2019): We almost certainly want to do this. @carlos-zamora indicated an interest in this in April :smile:
Author
Owner

@mdtauk commented on GitHub (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.

@mdtauk commented on GitHub (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.
Author
Owner

@devonzara commented on GitHub (Jul 30, 2019):

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.

@devonzara commented on GitHub (Jul 30, 2019): 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.
Author
Owner

@scrthq commented on GitHub (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.

@scrthq commented on GitHub (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.
Author
Owner

@SirHenryIII commented on GitHub (Aug 7, 2019):

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.

@SirHenryIII commented on GitHub (Aug 7, 2019): 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.
Author
Owner

@altered-dev commented on GitHub (Oct 2, 2019):

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".

@altered-dev commented on GitHub (Oct 2, 2019): 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".
Author
Owner

@zadjii-msft commented on GitHub (Dec 6, 2019):

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

@zadjii-msft commented on GitHub (Dec 6, 2019): Another request from #1000: Actions for "**Split Vertical [|]**" and "**Split Horizontal [-]**", then with sub-menus for which profile to split with.
Author
Owner

@tmknight commented on GitHub (Jan 17, 2020):

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)

@tmknight commented on GitHub (Jan 17, 2020): 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_)
Author
Owner

@zadjii-msft commented on GitHub (Jan 17, 2020):

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.

@zadjii-msft commented on GitHub (Jan 17, 2020): 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.
Author
Owner

@tmknight commented on GitHub (Jan 17, 2020):

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?

@tmknight commented on GitHub (Jan 17, 2020): 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?
Author
Owner

@zadjii-msft commented on GitHub (Jan 17, 2020):

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

  • #2994 allow to pick the color of the tabs
  • "Split Vertical [|]" and "Split Horizontal [-]", then with sub-menus for which profile to split with.
  • reload the tab
  • rename the tab

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.

@zadjii-msft commented on GitHub (Jan 17, 2020): I'm pretty sure it's relevant to a "context menu for tabs", since it literally adds a context menu to tabs: > ![image](https://user-images.githubusercontent.com/3358056/67625749-5a6af600-f842-11e9-9467-b0c334ea1b14.gif) 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 * #2994 allow to pick the color of the tabs * "Split Vertical [|]" and "Split Horizontal [-]", then with sub-menus for which profile to split with. * reload the tab * rename the tab 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.
Author
Owner

@altered-dev commented on GitHub (Jan 17, 2020):

Also a feature for tabs to inherit the background color?

@altered-dev commented on GitHub (Jan 17, 2020): Also a feature for tabs to inherit the background color?
Author
Owner

@zadjii-msft commented on GitHub (Jan 17, 2020):

Also a feature for tabs to inherit the background color?

See now that's something that's off-topic. That's a request that fits better over in #3327

@zadjii-msft commented on GitHub (Jan 17, 2020): > > > Also a feature for tabs to inherit the background color? See now that's something that's _off-topic_. That's a request that fits better over in #3327
Author
Owner

@tmknight commented on GitHub (Jan 17, 2020):

I propose this be closed and all work and comments captured in #3789. Too confusing to know which to watch and comment.

@tmknight commented on GitHub (Jan 17, 2020): I propose this be closed and all work and comments captured in #3789. Too confusing to know which to watch and comment.
Author
Owner

@zadjii-msft commented on GitHub (Jan 17, 2020):

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.

@zadjii-msft commented on GitHub (Jan 17, 2020): 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.
Author
Owner

@ffes commented on GitHub (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.

@ffes commented on GitHub (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.
Author
Owner

@zadjii-msft commented on GitHub (May 19, 2020):

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)
@zadjii-msft commented on GitHub (May 19, 2020): 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)
Author
Owner

@RahulRavishankar commented on GitHub (Jul 31, 2020):

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?

@RahulRavishankar commented on GitHub (Jul 31, 2020): 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?
Author
Owner

@zadjii-msft commented on GitHub (Jul 31, 2020):

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?

@zadjii-msft commented on GitHub (Jul 31, 2020): Go right ahead! Right now the context menu is being constructed in [Tab::_CreateContextMenu](https://github.com/microsoft/terminal/blob/master/src/cascadia/TerminalApp/Tab.cpp#L495). 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?
Author
Owner

@RahulRavishankar commented on GitHub (Jul 31, 2020):

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?

@RahulRavishankar commented on GitHub (Jul 31, 2020): 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?
Author
Owner

@zadjii-msft commented on GitHub (Aug 4, 2020):

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 commented on GitHub (Aug 4, 2020): 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...
Author
Owner

@zadjii-msft commented on GitHub (Aug 4, 2020):

@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!

@zadjii-msft commented on GitHub (Aug 4, 2020): @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!
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Sep 24, 2020):

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.

@KalleOlaviNiemitalo commented on GitHub (Sep 24, 2020): 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.
Author
Owner

@zadjii-msft commented on GitHub (Dec 9, 2021):

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!

@zadjii-msft commented on GitHub (Dec 9, 2021): 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!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#2686