Skip to content

Commit eefdfd8

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 a4f443a commit eefdfd8

24 files changed

+437
-156
lines changed

src/cascadia/TerminalApp/AppActionHandlers.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,15 @@ namespace winrt::TerminalApp::implementation
283283

284284
const auto& terminalTab{ _senderOrFocusedTab(sender) };
285285

286+
if constexpr (Feature_TmuxControl::IsEnabled())
287+
{
288+
//Tmux control takes over
289+
if (_tmuxControl && _tmuxControl->TabIsTmuxControl(terminalTab))
290+
{
291+
return _tmuxControl->SplitPane(terminalTab, realArgs.SplitDirection());
292+
}
293+
}
294+
286295
_SplitPane(terminalTab,
287296
realArgs.SplitDirection(),
288297
// This is safe, we're already filtering so the value is (0, 1)

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: 50 additions & 5 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->TabIsTmuxControl(page->_GetFocusedTabImpl()))
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->TabIsTmuxControl(_GetFocusedTabImpl()))
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->TabIsTmuxControl(tab))
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() };
@@ -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
}
@@ -5248,6 +5285,14 @@ namespace winrt::TerminalApp::implementation
52485285
tabImpl.copy_from(winrt::get_self<TabBase>(tabBase));
52495286
if (tabImpl)
52505287
{
5288+
if constexpr (Feature_TmuxControl::IsEnabled())
5289+
{
5290+
//Tmux control tab doesn't support to drag
5291+
if (_tmuxControl && _tmuxControl->TabIsTmuxControl(tabImpl.try_as<TerminalTab>()))
5292+
{
5293+
return;
5294+
}
5295+
}
52515296
// First: stash the tab we started dragging.
52525297
// We're going to be asked for this.
52535298
_stashed.draggedTab = tabImpl;

0 commit comments

Comments
 (0)