Skip to content

Commit cd25b44

Browse files
committed
PRE-MERGE #18928 Add support for tmux control mode (#3656)
2 parents deec76f + 190008e commit cd25b44

28 files changed

+1964
-6
lines changed

src/cascadia/TerminalApp/Pane.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,10 +1292,10 @@ void Pane::UpdateSettings(const CascadiaSettings& settings)
12921292
// - splitType: How the pane should be attached
12931293
// Return Value:
12941294
// - the new reference to the child created from the current pane.
1295-
std::shared_ptr<Pane> Pane::AttachPane(std::shared_ptr<Pane> pane, SplitDirection splitType)
1295+
std::shared_ptr<Pane> Pane::AttachPane(std::shared_ptr<Pane> pane, SplitDirection splitType, const float splitSize)
12961296
{
12971297
// Splice the new pane into the tree
1298-
const auto [first, _] = _Split(splitType, .5, pane);
1298+
const auto [first, _] = _Split(splitType, splitSize, pane);
12991299

13001300
// If the new pane has a child that was the focus, re-focus it
13011301
// to steal focus from the currently focused pane.

src/cascadia/TerminalApp/Pane.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ class Pane : public std::enable_shared_from_this<Pane>
131131
void Close();
132132

133133
std::shared_ptr<Pane> AttachPane(std::shared_ptr<Pane> pane,
134-
winrt::Microsoft::Terminal::Settings::Model::SplitDirection splitType);
134+
winrt::Microsoft::Terminal::Settings::Model::SplitDirection splitType,
135+
const float splitSize = .5);
135136
std::shared_ptr<Pane> DetachPane(std::shared_ptr<Pane> pane);
136137

137138
int GetLeafPaneCount() const noexcept;

src/cascadia/TerminalApp/TabRowControl.xaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,38 @@
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>
135167
</Grid>
136168
</mux:TabView.TabStripFooter>
137169

src/cascadia/TerminalApp/TerminalAppLib.vcxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@
177177
<ClInclude Include="SettingsPaneContent.h">
178178
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
179179
</ClInclude>
180+
<ClInclude Include="TmuxControl.h">
181+
<DependentUpon>TerminalPage.idl</DependentUpon>
182+
</ClInclude>
180183
<ClInclude Include="Toast.h" />
181184
<ClInclude Include="TerminalSettingsCache.h">
182185
<DependentUpon>TerminalSettingsCache.idl</DependentUpon>
@@ -300,6 +303,9 @@
300303
<ClCompile Include="SettingsPaneContent.cpp">
301304
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
302305
</ClCompile>
306+
<ClCompile Include="TmuxControl.cpp">
307+
<DependentUpon>TerminalPage.xaml</DependentUpon>
308+
</ClCompile>
303309
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
304310
<ClCompile Include="Toast.cpp" />
305311
<ClCompile Include="TerminalSettingsCache.cpp">

src/cascadia/TerminalApp/TerminalPage.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "ScratchpadContent.h"
1919
#include "SnippetsPaneContent.h"
2020
#include "MarkdownPaneContent.h"
21+
#include "TmuxControl.h"
2122
#include "TabRowControl.h"
2223
#include "Remoting.h"
2324

@@ -104,6 +105,8 @@ namespace winrt::TerminalApp::implementation
104105
}
105106
}
106107
_hostingHwnd = hwnd;
108+
109+
_tmuxControl = std::make_unique<TmuxControl>(*this);
107110
return S_OK;
108111
}
109112

@@ -3354,6 +3357,9 @@ namespace winrt::TerminalApp::implementation
33543357
resultPane->ClearActive();
33553358
original->SetActive();
33563359
}
3360+
control.SetTmuxControlHandlerProducer([this, control](auto print) {
3361+
return _tmuxControl->TmuxControlHandlerProducer(control, print);
3362+
});
33573363

33583364
return resultPane;
33593365
}

src/cascadia/TerminalApp/TerminalPage.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "RenameWindowRequestedArgs.g.h"
1111
#include "RequestMoveContentArgs.g.h"
1212
#include "LaunchPositionRequest.g.h"
13+
#include "TmuxControl.h"
1314
#include "Toast.h"
1415

1516
#include "WindowsPackageManagerFactory.h"
@@ -245,6 +246,7 @@ namespace winrt::TerminalApp::implementation
245246
std::vector<std::vector<Microsoft::Terminal::Settings::Model::ActionAndArgs>> _previouslyClosedPanesAndTabs{};
246247

247248
uint32_t _systemRowsToScroll{ DefaultRowsToScroll };
249+
std::unique_ptr<TmuxControl> _tmuxControl{ nullptr };
248250

249251
// use a weak reference to prevent circular dependency with AppLogic
250252
winrt::weak_ref<winrt::TerminalApp::IDialogPresenter> _dialogPresenter;
@@ -565,6 +567,7 @@ namespace winrt::TerminalApp::implementation
565567

566568
friend class TerminalAppLocalTests::TabTests;
567569
friend class TerminalAppLocalTests::SettingsTests;
570+
friend class TmuxControl;
568571
};
569572
}
570573

0 commit comments

Comments
 (0)