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
3 changes: 2 additions & 1 deletion .github/actions/spelling/excludes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ Resources/(?!en)
^NOTICE.md
^oss/.*?/
^samples/PixelShaders/Screenshots/
^src/cascadia/TerminalSettingsEditor/SegoeFluentIconList.h$
^src/cascadia/TerminalApp/TmuxControl\.cpp$
^src/cascadia/TerminalSettingsEditor/SegoeFluentIconList\.h$
^src/interactivity/onecore/BgfxEngine\.
^src/renderer/atlas/
^src/renderer/wddmcon/WddmConRenderer\.
Expand Down
9 changes: 9 additions & 0 deletions src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,15 @@ namespace winrt::TerminalApp::implementation

const auto& activeTab{ _senderOrFocusedTab(sender) };

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

_SplitPane(activeTab,
realArgs.SplitDirection(),
// This is safe, we're already filtering so the value is (0, 1)
Expand Down
8 changes: 4 additions & 4 deletions src/cascadia/TerminalApp/DebugTapConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,25 @@ namespace winrt::Microsoft::TerminalApp::implementation
return ConnectionState::Failed;
}

void DebugTapConnection::_OutputHandler(const std::wstring_view str)
void DebugTapConnection::_OutputHandler(const winrt::array_view<const char16_t> str)
{
auto output = til::visualize_control_codes(str);
auto output = til::visualize_control_codes(winrt_array_to_wstring_view(str));
// To make the output easier to read, we introduce a line break whenever
// an LF control is encountered. But at this point, the LF would have
// been converted to U+240A (␊), so that's what we need to search for.
for (size_t lfPos = 0; (lfPos = output.find(L'\u240A', lfPos)) != std::wstring::npos;)
{
output.insert(++lfPos, L"\r\n");
}
TerminalOutput.raise(output);
TerminalOutput.raise(winrt_wstring_to_array_view(output));
}

// Called by the DebugInputTapConnection to print user input
void DebugTapConnection::_PrintInput(const std::wstring_view str)
{
auto clean{ til::visualize_control_codes(str) };
auto formatted{ wil::str_printf<std::wstring>(L"\x1b[91m%ls\x1b[m", clean.data()) };
TerminalOutput.raise(formatted);
TerminalOutput.raise(winrt_wstring_to_array_view(formatted));
}

// Wire us up so that we can forward input through
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/DebugTapConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace winrt::Microsoft::TerminalApp::implementation

private:
void _PrintInput(const std::wstring_view data);
void _OutputHandler(const std::wstring_view str);
void _OutputHandler(const winrt::array_view<const char16_t> str);

winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection::TerminalOutput_revoker _outputRevoker;
winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection::StateChanged_revoker _stateChangedRevoker;
Expand Down
7 changes: 3 additions & 4 deletions src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,10 +1306,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 Expand Up @@ -2298,8 +2298,7 @@ std::pair<std::shared_ptr<Pane>, std::shared_ptr<Pane>> Pane::_Split(SplitDirect
_firstChild->Closed(_firstClosedToken);
_secondChild->Closed(_secondClosedToken);
// If we are not a leaf we should create a new pane that contains our children
auto first = std::make_shared<Pane>(_firstChild, _secondChild, _splitState, _desiredSplitPosition);
_firstChild = first;
_firstChild = std::make_shared<Pane>(_firstChild, _secondChild, _splitState, _desiredSplitPosition);
}
else
{
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
8 changes: 7 additions & 1 deletion src/cascadia/TerminalApp/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -982,4 +982,10 @@
<data name="InvalidRegex" xml:space="preserve">
<value>An invalid regular expression was found.</value>
</data>
</root>
<data name="TmuxControlInfo" xml:space="preserve">
<value>Running in tmux control mode; Press 'q' to detach:</value>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to {Lock...} the word tmux in some of these. We also historically made the q an insert from another resource (so that in German for example the Azure Connection can say "Enter Ja/nein [J/n]"

</data>
<data name="NewTmuxControlTab.Text" xml:space="preserve">
<value>Tmux Control Tab</value>
</data>
</root>
7 changes: 7 additions & 0 deletions src/cascadia/TerminalApp/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,13 @@ namespace winrt::TerminalApp::implementation
return res;
}

void Tab::Close()
{
ASSERT_UI_THREAD();

Closed.raise(nullptr, nullptr);
}

// Method Description:
// - Prepares this tab for being removed from the UI hierarchy by shutting down all active connections.
void Tab::Shutdown()
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/Tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ namespace winrt::TerminalApp::implementation
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings);
void UpdateTitle();

void Close();
void Shutdown();
void ClosePane();

Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/Tab.idl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace TerminalApp
UInt32 TabViewNumTabs;

void Focus(Windows.UI.Xaml.FocusState focusState);
void Close();
void Shutdown();

void SetDispatch(ShortcutActionDispatch dispatch);
Expand Down
8 changes: 3 additions & 5 deletions src/cascadia/TerminalApp/TabManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,11 @@ namespace winrt::TerminalApp::implementation
auto actions = t->BuildStartupActions(BuildStartupKind::None);
_AddPreviouslyClosedPaneOrTab(std::move(actions));

_RemoveTab(tab);
tab.Close();
}

// Method Description:
// - Removes the tab (both TerminalControl and XAML)
// Arguments:
// - tab: the tab to remove
// Removes the tab (both TerminalControl and XAML).
// NOTE: Don't call this directly, but rather `tab.Close()`.
void TerminalPage::_RemoveTab(const winrt::TerminalApp::Tab& tab)
{
uint32_t tabIndex{};
Expand Down
6 changes: 6 additions & 0 deletions src/cascadia/TerminalApp/TerminalAppLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,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" />
<ClInclude Include="SuggestionsControl.h">
Expand Down Expand Up @@ -285,6 +288,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
19 changes: 10 additions & 9 deletions src/cascadia/TerminalApp/TerminalAppLib.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<ItemGroup>
<Natvis Include="$(SolutionDir)tools\ConsoleTypes.natvis" />
<Natvis Include="$(MSBuildThisFileDirectory)..\..\natvis\wil.natvis" />
<Natvis Include="$(MSBuildThisFileDirectory)..\..\natvis\wil.natstepfilter" />
</ItemGroup>
<ItemGroup>
<PRIResource Include="Resources\en-US\Resources.resw" />
Expand Down Expand Up @@ -33,8 +34,7 @@
</ClCompile>
<ClCompile Include="Toast.cpp" />
<ClCompile Include="LanguageProfileNotifier.cpp" />
<ClCompile Include="Monarch.cpp" />
<ClCompile Include="Peasant.cpp" />
<ClCompile Include="TerminalSettingsCache.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
Expand All @@ -60,14 +60,13 @@
<ClInclude Include="fzf/fzf.h">
<Filter>fzf</Filter>
</ClInclude>
<ClInclude Include="fzf/LICENSE">
<Filter>fzf</Filter>
</ClInclude>
<ClInclude Include="Toast.h" />
<ClInclude Include="LanguageProfileNotifier.h" />
<ClInclude Include="WindowsPackageManagerFactory.h" />
<ClInclude Include="Monarch.h" />
<ClInclude Include="Peasant.h" />
<ClInclude Include="TerminalSettingsCache.h" />
<ClInclude Include="TmuxControl.h">
<Filter>controls</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Midl Include="AppLogic.idl">
Expand All @@ -90,7 +89,8 @@
<Midl Include="TerminalWindow.idl" />
<Midl Include="TaskbarState.idl" />
<Midl Include="IPaneContent.idl" />
<Midl Include="Monarch.idl" />
<Midl Include="Remoting.idl" />
<Midl Include="HighlightedTextControl.idl" />
</ItemGroup>
<ItemGroup>
<Page Include="MinMaxCloseControl.xaml">
Expand Down Expand Up @@ -123,6 +123,7 @@
<Page Include="AboutDialog.xaml" />
<Page Include="SuggestionsControl.xaml" />
<Page Include="SnippetsPaneContent.xaml" />
<Page Include="MarkdownPaneContent.xaml" />
</ItemGroup>
<ItemGroup>
<Filter Include="app">
Expand Down Expand Up @@ -155,4 +156,4 @@
<Filter>app</Filter>
</ApplicationDefinition>
</ItemGroup>
</Project>
</Project>
82 changes: 75 additions & 7 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
#include "pch.h"
#include "TerminalPage.h"

#include <TerminalCore/ControlKeyStates.hpp>
#include <TerminalThemeHelpers.h>
#include <til/hash.h>
#include <Utils.h>
#include <TerminalCore/ControlKeyStates.hpp>

#include "../../types/inc/ColorFix.hpp"
#include "../../types/inc/utils.hpp"
#include "../TerminalSettingsAppAdapterLib/TerminalSettings.h"
#include "App.h"
#include "DebugTapConnection.h"
#include "MarkdownPaneContent.h"
Expand All @@ -18,9 +22,7 @@
#include "SnippetsPaneContent.h"
#include "TabRowControl.h"
#include "TerminalSettingsCache.h"
#include "../../types/inc/ColorFix.hpp"
#include "../../types/inc/utils.hpp"
#include "../TerminalSettingsAppAdapterLib/TerminalSettings.h"
#include "TmuxControl.h"

#include "LaunchPositionRequest.g.cpp"
#include "RenameWindowRequestedArgs.g.cpp"
Expand Down Expand Up @@ -404,6 +406,15 @@ namespace winrt::TerminalApp::implementation
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));

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 @@ -1429,6 +1440,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 @@ -2525,6 +2545,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 @@ -3581,6 +3610,26 @@ namespace winrt::TerminalApp::implementation
original->SetActive();
}

if constexpr (Feature_TmuxControl::IsEnabled())
{
if (!_tmuxControl)
{
_tmuxControl = std::make_shared<TmuxControl>(*this);
}

control.EnterTmuxControl([tmuxControl = _tmuxControl.get()](auto&& sender, auto&& args) {
if (auto control = sender.try_as<TermControl>())
{
if (tmuxControl->AcquireSingleUseLock(std::move(control)))
{
args.InputCallback([tmuxControl](auto&& str) {
tmuxControl->FeedInput(winrt_array_to_wstring_view(str));
});
}
}
});
}

return resultPane;
}

Expand Down Expand Up @@ -5000,9 +5049,10 @@ namespace winrt::TerminalApp::implementation
void TerminalPage::_adjustProcessPriority() const
{
// Windowing is single-threaded, so this will not cause a race condition.
static bool supported{ true };
static uint64_t s_lastUpdateHash{ 0 };
static bool s_supported{ true };

if (!supported || !_hostingHwnd.has_value())
if (!s_supported || !_hostingHwnd.has_value())
{
return;
}
Expand Down Expand Up @@ -5066,11 +5116,20 @@ namespace winrt::TerminalApp::implementation
}

const auto count{ gsl::narrow_cast<DWORD>(it - processes.begin()) };
const auto hash = til::hash((void*)processes.data(), count * sizeof(HANDLE));

if (hash == s_lastUpdateHash)
{
return;
}

s_lastUpdateHash = hash;
const auto hr = TerminalTrySetWindowAssociatedProcesses(_hostingHwnd.value(), count, count ? processes.data() : nullptr);

if (S_FALSE == hr)
{
// Don't bother trying again or logging. The wrapper tells us it's unsupported.
supported = false;
s_supported = false;
return;
}

Expand Down Expand Up @@ -5468,6 +5527,15 @@ namespace winrt::TerminalApp::implementation
tabImpl.copy_from(winrt::get_self<Tab>(tabBase));
if (tabImpl)
{
if constexpr (Feature_TmuxControl::IsEnabled())
{
//Tmux control tab doesn't support to drag
if (_tmuxControl && _tmuxControl->TabIsTmuxControl(tabImpl))
{
return;
}
}

// First: stash the tab we started dragging.
// We're going to be asked for this.
_stashed.draggedTab = tabImpl;
Expand Down
Loading