Skip to content

Commit

Permalink
Add support for a "Move Tab to New Window" tab context menu item (#15376
Browse files Browse the repository at this point in the history
)

## Summary of the Pull Request
Add the "Move Tab to New Window" item to the context menu of the tabs 

## References and Relevant Issues
#15127

## Detailed Description of the Pull Request / Additional comments
Add the "Move Tab to New Window" item to the context menu of the tabs. 

![Detailed_description_of_commit_PR1](https://github.com/microsoft/terminal/assets/15957528/915ac07b-1fdd-456b-b180-2645dbc29e48)

## Validation Steps Performed
Checked Code Style
https://github.com/microsoft/terminal/blob/main/doc/STYLE.md

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

---------

Co-authored-by: Mike Griese <migrie@microsoft.com>
  • Loading branch information
Jaswir and zadjii-msft authored May 25, 2023
1 parent 7650ecf commit f5a703c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/cascadia/TerminalApp/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -827,4 +827,10 @@
<value>Reset tab color</value>
<comment>Text used to identify the reset button</comment>
</data>
<data name="MoveTabToNewWindowText" xml:space="preserve">
<value>Move Tab to New Window</value>
</data>
<data name="MoveTabToNewWindowToolTip" xml:space="preserve">
<value>Moves tab to a new window </value>
</data>
</root>
12 changes: 12 additions & 0 deletions src/cascadia/TerminalApp/TabManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ namespace winrt::TerminalApp::implementation
}
});

newTabImpl->MoveTabToNewWindowRequested([weakTab, weakThis{ get_weak() }]() {
auto page{ weakThis.get() };
auto tab{ weakTab.get() };

if (page && tab)
{
MoveTabArgs args{ hstring{ L"new" }, MoveTabDirection::Forward };
page->_SetFocusedTab(*tab);
page->_MoveTab(args);
}
});

newTabImpl->ExportTabRequested([weakTab, weakThis{ get_weak() }]() {
auto page{ weakThis.get() };
auto tab{ weakTab.get() };
Expand Down
24 changes: 23 additions & 1 deletion src/cascadia/TerminalApp/TerminalTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,28 @@ namespace winrt::TerminalApp::implementation
Automation::AutomationProperties::SetHelpText(splitTabMenuItem, splitTabToolTip);
}

Controls::MenuFlyoutItem moveTabToNewWindowMenuItem;
{
// "Move Tab to New Window Tab"
Controls::FontIcon moveTabToNewWindowTabSymbol;
moveTabToNewWindowTabSymbol.FontFamily(Media::FontFamily{ L"Segoe Fluent Icons, Segoe MDL2 Assets" });
moveTabToNewWindowTabSymbol.Glyph(L"\xE8A7");

moveTabToNewWindowMenuItem.Click([weakThis](auto&&, auto&&) {
if (auto tab{ weakThis.get() })
{
tab->_MoveTabToNewWindowRequestedHandlers();
}
});
moveTabToNewWindowMenuItem.Text(RS_(L"MoveTabToNewWindowText"));
moveTabToNewWindowMenuItem.Icon(moveTabToNewWindowTabSymbol);

const auto moveTabToNewWindowToolTip = RS_(L"MoveTabToNewWindowToolTip");

WUX::Controls::ToolTipService::SetToolTip(moveTabToNewWindowMenuItem, box_value(moveTabToNewWindowToolTip));
Automation::AutomationProperties::SetHelpText(moveTabToNewWindowMenuItem, moveTabToNewWindowToolTip);
}

Controls::MenuFlyoutItem closePaneMenuItem = _closePaneMenuItem;
{
// "Close Pane"
Expand Down Expand Up @@ -1404,7 +1426,7 @@ namespace winrt::TerminalApp::implementation
contextMenuFlyout.Items().Append(renameTabMenuItem);
contextMenuFlyout.Items().Append(duplicateTabMenuItem);
contextMenuFlyout.Items().Append(splitTabMenuItem);

contextMenuFlyout.Items().Append(moveTabToNewWindowMenuItem);
contextMenuFlyout.Items().Append(exportTabMenuItem);
contextMenuFlyout.Items().Append(findMenuItem);
contextMenuFlyout.Items().Append(menuSeparator);
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TerminalTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace winrt::TerminalApp::implementation
WINRT_CALLBACK(TabRaiseVisualBell, winrt::delegate<>);
WINRT_CALLBACK(DuplicateRequested, winrt::delegate<>);
WINRT_CALLBACK(SplitTabRequested, winrt::delegate<>);
WINRT_CALLBACK(MoveTabToNewWindowRequested, winrt::delegate<>);
WINRT_CALLBACK(FindRequested, winrt::delegate<>);
WINRT_CALLBACK(ExportTabRequested, winrt::delegate<>);
WINRT_CALLBACK(ColorPickerRequested, winrt::delegate<>);
Expand Down

0 comments on commit f5a703c

Please sign in to comment.