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 support for a "Move Tab to New Window" tab context menu item #15376

Merged
merged 7 commits into from
May 25, 2023
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