Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ namespace winrt::TerminalApp::implementation

const auto& terminalTab{ _senderOrFocusedTab(sender) };

if constexpr (Feature_TmuxControl::IsEnabled())
{
//Tmux control takes over
if (_tmuxControl && _tmuxControl->TabIsTmuxControl(terminalTab))
{
return _tmuxControl->SplitPane(terminalTab, realArgs.SplitDirection());
}
}

_SplitPane(terminalTab,
realArgs.SplitDirection(),
// This is safe, we're already filtering so the value is (0, 1)
Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1304,10 +1304,10 @@ void Pane::UpdateSettings(const CascadiaSettings& settings)
// - splitType: How the pane should be attached
// Return Value:
// - the new reference to the child created from the current pane.
std::shared_ptr<Pane> Pane::AttachPane(std::shared_ptr<Pane> pane, SplitDirection splitType)
std::shared_ptr<Pane> Pane::AttachPane(std::shared_ptr<Pane> pane, SplitDirection splitType, const float splitSize)
{
// Splice the new pane into the tree
const auto [first, _] = _Split(splitType, .5, pane);
const auto [first, _] = _Split(splitType, splitSize, pane);

// If the new pane has a child that was the focus, re-focus it
// to steal focus from the currently focused pane.
Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalApp/Pane.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ class Pane : public std::enable_shared_from_this<Pane>
void Close();

std::shared_ptr<Pane> AttachPane(std::shared_ptr<Pane> pane,
winrt::Microsoft::Terminal::Settings::Model::SplitDirection splitType);
winrt::Microsoft::Terminal::Settings::Model::SplitDirection splitType,
const float splitSize = .5);
std::shared_ptr<Pane> DetachPane(std::shared_ptr<Pane> pane);

int GetLeafPaneCount() const noexcept;
Expand Down
5 changes: 4 additions & 1 deletion src/cascadia/TerminalApp/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -986,4 +986,7 @@
<data name="InvalidRegex" xml:space="preserve">
<value>An invalid regular expression was found.</value>
</data>
</root>
<data name="NewTmuxControlTab.Text" xml:space="preserve">
<value>Tmux Control Tab</value>
</data>
</root>
6 changes: 6 additions & 0 deletions src/cascadia/TerminalApp/TerminalAppLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@
<ClInclude Include="SettingsPaneContent.h">
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
</ClInclude>
<ClInclude Include="TmuxControl.h">
<DependentUpon>TerminalPage.idl</DependentUpon>
</ClInclude>
<ClInclude Include="Toast.h" />
<ClInclude Include="TerminalSettingsCache.h">
<DependentUpon>TerminalSettingsCache.idl</DependentUpon>
Expand Down Expand Up @@ -302,6 +305,9 @@
<ClCompile Include="SettingsPaneContent.cpp">
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
</ClCompile>
<ClCompile Include="TmuxControl.cpp">
<DependentUpon>TerminalPage.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
<ClCompile Include="Toast.cpp" />
<ClCompile Include="TerminalSettingsCache.cpp">
Expand Down
53 changes: 52 additions & 1 deletion src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "ScratchpadContent.h"
#include "SnippetsPaneContent.h"
#include "MarkdownPaneContent.h"
#include "TmuxControl.h"
#include "TabRowControl.h"
#include "Remoting.h"

Expand Down Expand Up @@ -104,6 +105,11 @@ namespace winrt::TerminalApp::implementation
}
}
_hostingHwnd = hwnd;

if constexpr (Feature_TmuxControl::IsEnabled())
{
_tmuxControl = std::make_unique<TmuxControl>(*this);
}
return S_OK;
}

Expand Down Expand Up @@ -238,6 +244,15 @@ namespace winrt::TerminalApp::implementation
_newTabButton.Click([weakThis{ get_weak() }](auto&&, auto&&) {
if (auto page{ weakThis.get() })
{
if constexpr (Feature_TmuxControl::IsEnabled())
{
//Tmux control takes over
if (page->_tmuxControl && page->_tmuxControl->TabIsTmuxControl(page->_GetFocusedTabImpl()))
{
return;
}
}

page->_OpenNewTerminalViaDropdown(NewTerminalArgs());
}
});
Expand Down Expand Up @@ -1203,6 +1218,15 @@ namespace winrt::TerminalApp::implementation
}
if (altPressed && !debugTap)
{
// tmux control panes don't share tab with other panes
if constexpr (Feature_TmuxControl::IsEnabled())
{
if (_tmuxControl && _tmuxControl->TabIsTmuxControl(_GetFocusedTabImpl()))
{
return;
}
}

this->_SplitPane(_GetFocusedTabImpl(),
SplitDirection::Automatic,
0.5f,
Expand Down Expand Up @@ -2241,6 +2265,15 @@ namespace winrt::TerminalApp::implementation
return false;
}

if constexpr (Feature_TmuxControl::IsEnabled())
{
//Tmux control tab doesn't support to drag
if (_tmuxControl && _tmuxControl->TabIsTmuxControl(tab))
{
return false;
}
}

// If there was a windowId in the action, try to move it to the
// specified window instead of moving it in our tab row.
const auto windowId{ args.Window() };
Expand Down Expand Up @@ -3188,7 +3221,7 @@ namespace winrt::TerminalApp::implementation
const auto tabViewItem = eventArgs.Tab();
if (auto tab{ _GetTabByTabViewItem(tabViewItem) })
{
_HandleCloseTabRequested(tab);
tab.try_as<TabBase>()->CloseRequested.raise(nullptr, nullptr);
}
}

Expand Down Expand Up @@ -3355,6 +3388,16 @@ namespace winrt::TerminalApp::implementation
original->SetActive();
}

if constexpr (Feature_TmuxControl::IsEnabled())
{
if (profile.AllowTmuxControl() && _tmuxControl)
{
control.SetTmuxControlHandlerProducer([this, control](auto print) {
return _tmuxControl->TmuxControlHandlerProducer(control, print);
});
}
}

return resultPane;
}

Expand Down Expand Up @@ -5242,6 +5285,14 @@ namespace winrt::TerminalApp::implementation
tabImpl.copy_from(winrt::get_self<TabBase>(tabBase));
if (tabImpl)
{
if constexpr (Feature_TmuxControl::IsEnabled())
{
//Tmux control tab doesn't support to drag
if (_tmuxControl && _tmuxControl->TabIsTmuxControl(tabImpl.try_as<TerminalTab>()))
{
return;
}
}
// First: stash the tab we started dragging.
// We're going to be asked for this.
_stashed.draggedTab = tabImpl;
Expand Down
3 changes: 3 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "RenameWindowRequestedArgs.g.h"
#include "RequestMoveContentArgs.g.h"
#include "LaunchPositionRequest.g.h"
#include "TmuxControl.h"
#include "Toast.h"

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

uint32_t _systemRowsToScroll{ DefaultRowsToScroll };
std::unique_ptr<TmuxControl> _tmuxControl{ nullptr };

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

friend class TerminalAppLocalTests::TabTests;
friend class TerminalAppLocalTests::SettingsTests;
friend class TmuxControl;
};
}

Expand Down
Loading