Skip to content

Commit 4817698

Browse files
committed
Add support for tmux control mode (#3656)
Address comments round 1 1 typo fix 2 add the feature for tmux control 3 add the configuration for tmux control 4 change to use present menu/ui/action for tmux control 5 disable draging the tmux control tab 6 close backend panes/windows if close panes/tabs locally 7 fix the bug that cannot input after split the pane
1 parent 190008e commit 4817698

25 files changed

+407
-148
lines changed

src/cascadia/TerminalApp/AppActionHandlers.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,15 @@ namespace winrt::TerminalApp::implementation
273273
}
274274
else if (const auto& realArgs = args.ActionArgs().try_as<SplitPaneArgs>())
275275
{
276+
if constexpr (Feature_TmuxControl::IsEnabled())
277+
{
278+
//Tmux control takes over
279+
if (_tmuxControl && _tmuxControl->ActiveTabIsTmuxControl())
280+
{
281+
return _tmuxControl->SplitActivePane(realArgs.SplitDirection());
282+
}
283+
}
284+
276285
if (_shouldBailForInvalidProfileIndex(_settings, realArgs.ContentArgs()))
277286
{
278287
args.Handled(false);

src/cascadia/TerminalApp/Resources/en-US/Resources.resw

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,4 +986,7 @@
986986
<data name="InvalidRegex" xml:space="preserve">
987987
<value>An invalid regular expression was found.</value>
988988
</data>
989-
</root>
989+
<data name="NewTmuxControlTab.Text" xml:space="preserve">
990+
<value>Tmux Control Tab</value>
991+
</data>
992+
</root>

src/cascadia/TerminalApp/TabRowControl.xaml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -132,38 +132,6 @@
132132
</ResourceDictionary>
133133
</mux:SplitButton.Resources>
134134
</mux:SplitButton>
135-
<mux:SplitButton x:Name="NewTmuxTabButton"
136-
x:Uid="NewTmuxTabSplitButton"
137-
Height="24"
138-
Margin="0,4"
139-
Padding="0"
140-
HorizontalAlignment="Left"
141-
VerticalAlignment="Stretch"
142-
AllowDrop="False"
143-
AutomationProperties.AccessibilityView="Control"
144-
BorderThickness="0"
145-
Content="&#xE710;"
146-
FontFamily="{ThemeResource SymbolThemeFontFamily}"
147-
FontSize="12"
148-
Visibility="Collapsed">
149-
<mux:SplitButton.Flyout>
150-
<MenuFlyout x:Name="SplitMenu" Placement="BottomEdgeAlignedLeft">
151-
<MenuFlyoutItem Text="Horizontal Split">
152-
<MenuFlyoutItem.Icon>
153-
<FontIcon Glyph="&#xE784;">
154-
</FontIcon>
155-
</MenuFlyoutItem.Icon>
156-
</MenuFlyoutItem>
157-
<MenuFlyoutItem Text="Vertical Split">
158-
<MenuFlyoutItem.Icon>
159-
<FontIcon Glyph="&#xE76F;">
160-
</FontIcon>
161-
</MenuFlyoutItem.Icon>
162-
</MenuFlyoutItem>
163-
</MenuFlyout>
164-
</mux:SplitButton.Flyout>
165-
166-
</mux:SplitButton>
167135
</Grid>
168136
</mux:TabView.TabStripFooter>
169137

src/cascadia/TerminalApp/TerminalPage.cpp

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ namespace winrt::TerminalApp::implementation
106106
}
107107
_hostingHwnd = hwnd;
108108

109-
_tmuxControl = std::make_unique<TmuxControl>(*this);
109+
if constexpr (Feature_TmuxControl::IsEnabled())
110+
{
111+
_tmuxControl = std::make_unique<TmuxControl>(*this);
112+
}
110113
return S_OK;
111114
}
112115

@@ -241,6 +244,15 @@ namespace winrt::TerminalApp::implementation
241244
_newTabButton.Click([weakThis{ get_weak() }](auto&&, auto&&) {
242245
if (auto page{ weakThis.get() })
243246
{
247+
if constexpr (Feature_TmuxControl::IsEnabled())
248+
{
249+
//Tmux control takes over
250+
if (page->_tmuxControl && page->_tmuxControl->ActiveTabIsTmuxControl())
251+
{
252+
return;
253+
}
254+
}
255+
244256
page->_OpenNewTerminalViaDropdown(NewTerminalArgs());
245257
}
246258
});
@@ -1206,6 +1218,15 @@ namespace winrt::TerminalApp::implementation
12061218
}
12071219
if (altPressed && !debugTap)
12081220
{
1221+
// tmux control panes don't share tab with other panes
1222+
if constexpr (Feature_TmuxControl::IsEnabled())
1223+
{
1224+
if (_tmuxControl && _tmuxControl->ActiveTabIsTmuxControl())
1225+
{
1226+
return;
1227+
}
1228+
}
1229+
12091230
this->_SplitPane(_GetFocusedTabImpl(),
12101231
SplitDirection::Automatic,
12111232
0.5f,
@@ -2244,6 +2265,15 @@ namespace winrt::TerminalApp::implementation
22442265
return false;
22452266
}
22462267

2268+
if constexpr (Feature_TmuxControl::IsEnabled())
2269+
{
2270+
//Tmux control tab doesn't support to drag
2271+
if (_tmuxControl && _tmuxControl->ActiveTabIsTmuxControl())
2272+
{
2273+
return false;
2274+
}
2275+
}
2276+
22472277
// If there was a windowId in the action, try to move it to the
22482278
// specified window instead of moving it in our tab row.
22492279
const auto windowId{ args.Window() };
@@ -2306,7 +2336,7 @@ namespace winrt::TerminalApp::implementation
23062336
// for it. The Title change will be propagated upwards through the tab's
23072337
// PropertyChanged event handler.
23082338
void TerminalPage::_activePaneChanged(winrt::TerminalApp::TerminalTab sender,
2309-
Windows::Foundation::IInspectable args)
2339+
Windows::Foundation::IInspectable /*args*/)
23102340
{
23112341
if (const auto tab{ _GetTerminalTabImpl(sender) })
23122342
{
@@ -3191,7 +3221,7 @@ namespace winrt::TerminalApp::implementation
31913221
const auto tabViewItem = eventArgs.Tab();
31923222
if (auto tab{ _GetTabByTabViewItem(tabViewItem) })
31933223
{
3194-
_HandleCloseTabRequested(tab);
3224+
tab.try_as<TabBase>()->CloseRequested.raise(nullptr, nullptr);
31953225
}
31963226
}
31973227

@@ -3357,9 +3387,16 @@ namespace winrt::TerminalApp::implementation
33573387
resultPane->ClearActive();
33583388
original->SetActive();
33593389
}
3360-
control.SetTmuxControlHandlerProducer([this, control](auto print) {
3361-
return _tmuxControl->TmuxControlHandlerProducer(control, print);
3362-
});
3390+
3391+
if constexpr (Feature_TmuxControl::IsEnabled())
3392+
{
3393+
if (profile.AllowTmuxControl() && _tmuxControl)
3394+
{
3395+
control.SetTmuxControlHandlerProducer([this, control](auto print) {
3396+
return _tmuxControl->TmuxControlHandlerProducer(control, print);
3397+
});
3398+
}
3399+
}
33633400

33643401
return resultPane;
33653402
}
@@ -5241,6 +5278,14 @@ namespace winrt::TerminalApp::implementation
52415278
void TerminalPage::_onTabDragStarting(const winrt::Microsoft::UI::Xaml::Controls::TabView&,
52425279
const winrt::Microsoft::UI::Xaml::Controls::TabViewTabDragStartingEventArgs& e)
52435280
{
5281+
if constexpr (Feature_TmuxControl::IsEnabled())
5282+
{
5283+
//Tmux control tab doesn't support to drag
5284+
if (_tmuxControl && _tmuxControl->ActiveTabIsTmuxControl())
5285+
{
5286+
return;
5287+
}
5288+
}
52445289
// Get the tab impl from this event.
52455290
const auto eventTab = e.Tab();
52465291
const auto tabBase = _GetTabByTabViewItem(eventTab);
@@ -5388,8 +5433,8 @@ namespace winrt::TerminalApp::implementation
53885433
_sendDraggedTabToWindow(winrt::to_hstring(args.TargetWindow()), args.TabIndex(), std::nullopt);
53895434
}
53905435

5391-
void TerminalPage::_onTabDroppedOutside(winrt::IInspectable sender,
5392-
winrt::MUX::Controls::TabViewTabDroppedOutsideEventArgs e)
5436+
void TerminalPage::_onTabDroppedOutside(winrt::IInspectable /*sender*/,
5437+
winrt::MUX::Controls::TabViewTabDroppedOutsideEventArgs /*e*/)
53935438
{
53945439
// Get the current pointer point from the CoreWindow
53955440
const auto& pointerPoint{ CoreWindow::GetForCurrentThread().PointerPosition() };

0 commit comments

Comments
 (0)