mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 00:48:23 -06:00
wip
This commit is contained in:
parent
1ca0c76bc7
commit
ef23e6676c
@ -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)
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -131,7 +131,8 @@ public:
|
||||
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;
|
||||
|
||||
@ -982,4 +982,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>
|
||||
|
||||
@ -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">
|
||||
@ -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" />
|
||||
|
||||
@ -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" />
|
||||
@ -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" />
|
||||
@ -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">
|
||||
@ -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">
|
||||
@ -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">
|
||||
@ -155,4 +156,4 @@
|
||||
<Filter>app</Filter>
|
||||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@ -10,6 +10,9 @@
|
||||
#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"
|
||||
@ -19,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"
|
||||
@ -261,6 +262,11 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
|
||||
_hostingHwnd = hwnd;
|
||||
|
||||
if constexpr (Feature_TmuxControl::IsEnabled())
|
||||
{
|
||||
_tmuxControl = std::make_unique<TmuxControl>(*this);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -405,6 +411,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());
|
||||
}
|
||||
});
|
||||
@ -1430,6 +1445,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,
|
||||
@ -2526,6 +2550,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() };
|
||||
@ -3412,7 +3445,7 @@ namespace winrt::TerminalApp::implementation
|
||||
const auto tabViewItem = eventArgs.Tab();
|
||||
if (auto tab{ _GetTabByTabViewItem(tabViewItem) })
|
||||
{
|
||||
_HandleCloseTabRequested(tab);
|
||||
winrt::get_self<Tab>(tab)->CloseRequested.raise(nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3582,6 +3615,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;
|
||||
}
|
||||
|
||||
@ -5469,6 +5512,14 @@ 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;
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#include "RenameWindowRequestedArgs.g.h"
|
||||
#include "RequestMoveContentArgs.g.h"
|
||||
#include "LaunchPositionRequest.g.h"
|
||||
#include "TmuxControl.h"
|
||||
#include "Toast.h"
|
||||
|
||||
#include "WindowsPackageManagerFactory.h"
|
||||
@ -256,6 +257,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;
|
||||
@ -580,6 +582,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
friend class TerminalAppLocalTests::TabTests;
|
||||
friend class TerminalAppLocalTests::SettingsTests;
|
||||
friend class TmuxControl;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
1504
src/cascadia/TerminalApp/TmuxControl.cpp
Normal file
1504
src/cascadia/TerminalApp/TmuxControl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
413
src/cascadia/TerminalApp/TmuxControl.h
Normal file
413
src/cascadia/TerminalApp/TmuxControl.h
Normal file
@ -0,0 +1,413 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <regex>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <functional>
|
||||
|
||||
#include "Pane.h"
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
struct TerminalPage;
|
||||
|
||||
class TmuxControl
|
||||
{
|
||||
using StringHandler = std::function<bool(const wchar_t)>;
|
||||
using PrintHandler = std::function<void(const std::wstring_view)>;
|
||||
using StringHandlerProducer = std::function<StringHandler(PrintHandler)>;
|
||||
using SplitDirection = winrt::Microsoft::Terminal::Settings::Model::SplitDirection;
|
||||
|
||||
public:
|
||||
TmuxControl(TerminalPage& page);
|
||||
StringHandler TmuxControlHandlerProducer(const winrt::Microsoft::Terminal::Control::TermControl control, const PrintHandler print);
|
||||
bool TabIsTmuxControl(const winrt::com_ptr<Tab>& tab);
|
||||
void SplitPane(const winrt::com_ptr<Tab>& tab, SplitDirection direction);
|
||||
|
||||
private:
|
||||
static const std::wregex REG_BEGIN;
|
||||
static const std::wregex REG_END;
|
||||
static const std::wregex REG_ERROR;
|
||||
|
||||
static const std::wregex REG_CLIENT_SESSION_CHANGED;
|
||||
static const std::wregex REG_CLIENT_DETACHED;
|
||||
static const std::wregex REG_CONFIG_ERROR;
|
||||
static const std::wregex REG_CONTINUE;
|
||||
static const std::wregex REG_DETACH;
|
||||
static const std::wregex REG_EXIT;
|
||||
static const std::wregex REG_EXTENDED_OUTPUT;
|
||||
static const std::wregex REG_LAYOUT_CHANGED;
|
||||
static const std::wregex REG_MESSAGE;
|
||||
static const std::wregex REG_OUTPUT;
|
||||
static const std::wregex REG_PANE_MODE_CHANGED;
|
||||
static const std::wregex REG_PASTE_BUFFER_CHANGED;
|
||||
static const std::wregex REG_PASTE_BUFFER_DELETED;
|
||||
static const std::wregex REG_PAUSE;
|
||||
static const std::wregex REG_SESSION_CHANGED;
|
||||
static const std::wregex REG_SESSION_RENAMED;
|
||||
static const std::wregex REG_SESSION_WINDOW_CHANGED;
|
||||
static const std::wregex REG_SESSIONS_CHANGED;
|
||||
static const std::wregex REG_SUBSCRIPTION_CHANGED;
|
||||
static const std::wregex REG_UNLINKED_WINDOW_ADD;
|
||||
static const std::wregex REG_UNLINKED_WINDOW_CLOSE;
|
||||
static const std::wregex REG_UNLINKED_WINDOW_RENAMED;
|
||||
static const std::wregex REG_WINDOW_ADD;
|
||||
static const std::wregex REG_WINDOW_CLOSE;
|
||||
static const std::wregex REG_WINDOW_PANE_CHANGED;
|
||||
static const std::wregex REG_WINDOW_RENAMED;
|
||||
|
||||
enum State : int
|
||||
{
|
||||
INIT,
|
||||
ATTACHING,
|
||||
ATTACHED,
|
||||
} _state{ INIT };
|
||||
|
||||
enum CommandState : int
|
||||
{
|
||||
READY,
|
||||
WAITING,
|
||||
} _cmdState{ READY };
|
||||
|
||||
enum EventType : int
|
||||
{
|
||||
BEGIN,
|
||||
END,
|
||||
ERR,
|
||||
|
||||
ATTACH,
|
||||
DETACH,
|
||||
CLIENT_SESSION_CHANGED,
|
||||
CLIENT_DETACHED,
|
||||
CONFIG_ERROR,
|
||||
CONTINUE,
|
||||
EXIT,
|
||||
EXTENDED_OUTPUT,
|
||||
LAYOUT_CHANGED,
|
||||
NOTHING,
|
||||
MESSAGE,
|
||||
OUTPUT,
|
||||
PANE_MODE_CHANGED,
|
||||
PASTE_BUFFER_CHANGED,
|
||||
PASTE_BUFFER_DELETED,
|
||||
PAUSE,
|
||||
RESPONSE,
|
||||
SESSION_CHANGED,
|
||||
SESSION_RENAMED,
|
||||
SESSION_WINDOW_CHANGED,
|
||||
SESSIONS_CHANGED,
|
||||
SUBSCRIPTION_CHANGED,
|
||||
UNLINKED_WINDOW_ADD,
|
||||
UNLINKED_WINDOW_CLOSE,
|
||||
UNLINKED_WINDOW_RENAMED,
|
||||
WINDOW_ADD,
|
||||
WINDOW_CLOSE,
|
||||
WINDOW_PANE_CHANGED,
|
||||
WINDOW_RENAMED,
|
||||
};
|
||||
|
||||
struct Event
|
||||
{
|
||||
EventType type{ NOTHING };
|
||||
int sessionId{ -1 };
|
||||
int windowId{ -1 };
|
||||
int paneId{ -1 };
|
||||
|
||||
std::wstring response;
|
||||
} _event;
|
||||
|
||||
// Command structs
|
||||
struct Command
|
||||
{
|
||||
public:
|
||||
virtual std::wstring GetCommand() = 0;
|
||||
virtual bool ResultHandler(const std::wstring& /*result*/, TmuxControl& /*tmux*/) { return true; };
|
||||
};
|
||||
|
||||
struct AttachDone : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
bool ResultHandler(const std::wstring& result, TmuxControl& tmux) override;
|
||||
};
|
||||
|
||||
struct CapturePane : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
bool ResultHandler(const std::wstring& result, TmuxControl& tmux) override;
|
||||
|
||||
int paneId{ -1 };
|
||||
int cursorX{ 0 };
|
||||
int cursorY{ 0 };
|
||||
int history{ 0 };
|
||||
};
|
||||
|
||||
struct DiscoverPanes : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
bool ResultHandler(const std::wstring& result, TmuxControl& tmux) override;
|
||||
|
||||
int sessionId{ -1 };
|
||||
int windowId{ -1 };
|
||||
bool newWindow{ false };
|
||||
};
|
||||
|
||||
struct DiscoverWindows : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
bool ResultHandler(const std::wstring& result, TmuxControl& tmux) override;
|
||||
|
||||
int sessionId{ -1 };
|
||||
};
|
||||
|
||||
struct KillPane : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int paneId{ -1 };
|
||||
};
|
||||
|
||||
struct KillWindow : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int windowId{ -1 };
|
||||
};
|
||||
|
||||
struct ListPanes : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
bool ResultHandler(const std::wstring& result, TmuxControl& tmux) override;
|
||||
|
||||
int windowId{ -1 };
|
||||
int history{ 2000 };
|
||||
};
|
||||
|
||||
struct ListWindow : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
bool ResultHandler(const std::wstring& result, TmuxControl& tmux) override;
|
||||
|
||||
int windowId{ -1 };
|
||||
int sessionId{ -1 };
|
||||
};
|
||||
|
||||
struct NewWindow : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
};
|
||||
|
||||
struct ResizePane : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int width{ 0 };
|
||||
int height{ 0 };
|
||||
int paneId{ -1 };
|
||||
};
|
||||
|
||||
struct ResizeWindow : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
int width{ 0 };
|
||||
int height{ 0 };
|
||||
int windowId{ -1 };
|
||||
};
|
||||
|
||||
struct SelectWindow : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int windowId{ -1 };
|
||||
};
|
||||
|
||||
struct SelectPane : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int paneId{ -1 };
|
||||
};
|
||||
|
||||
struct SendKey : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int paneId{ -1 };
|
||||
std::wstring keys;
|
||||
wchar_t key{ '\0' };
|
||||
};
|
||||
|
||||
struct SetOption : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
std::wstring option;
|
||||
};
|
||||
|
||||
struct SplitPane : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int paneId{ -1 };
|
||||
SplitDirection direction{ SplitDirection::Left };
|
||||
};
|
||||
|
||||
// Layout structs
|
||||
enum TmuxLayoutType : int
|
||||
{
|
||||
SINGLE_PANE,
|
||||
SPLIT_HORIZONTAL,
|
||||
SPLIT_VERTICAL,
|
||||
};
|
||||
|
||||
struct TmuxPaneLayout
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int left;
|
||||
int top;
|
||||
int id;
|
||||
};
|
||||
|
||||
struct TmuxWindowLayout
|
||||
{
|
||||
TmuxLayoutType type{ SINGLE_PANE };
|
||||
std::vector<TmuxPaneLayout> panes;
|
||||
};
|
||||
|
||||
struct TmuxWindow
|
||||
{
|
||||
int sessionId{ -1 };
|
||||
int windowId{ -1 };
|
||||
int width{ 0 };
|
||||
int height{ 0 };
|
||||
int history{ 2000 };
|
||||
bool active{ false };
|
||||
std::wstring name;
|
||||
std::wstring layoutChecksum;
|
||||
std::vector<TmuxWindowLayout> layout;
|
||||
};
|
||||
|
||||
struct TmuxPane
|
||||
{
|
||||
int sessionId;
|
||||
int windowId;
|
||||
int paneId;
|
||||
int cursorX;
|
||||
int cursorY;
|
||||
bool active;
|
||||
};
|
||||
|
||||
struct AttachedPane
|
||||
{
|
||||
int windowId;
|
||||
int paneId;
|
||||
winrt::Microsoft::Terminal::Control::TermControl control;
|
||||
bool initialized{ false };
|
||||
};
|
||||
|
||||
// Private methods
|
||||
void _AttachSession();
|
||||
void _DetachSession();
|
||||
void _SetupProfile();
|
||||
void _CreateNewTabMenu();
|
||||
|
||||
float _ComputeSplitSize(int newSize, int originSize, SplitDirection direction) const;
|
||||
TerminalApp::Tab _GetTab(int windowId) const;
|
||||
|
||||
void _SendOutput(int paneId, const std::wstring& text);
|
||||
void _Output(int paneId, const std::wstring& result);
|
||||
void _CloseWindow(int windowId);
|
||||
void _RenameWindow(int windowId, const std::wstring& name);
|
||||
void _NewWindowFinalize(int windowId, int paneId, const std::wstring& windowName);
|
||||
void _SplitPaneFinalize(int windowId, int paneId);
|
||||
std::shared_ptr<Pane> _NewPane(int windowId, int paneId);
|
||||
|
||||
bool _SyncPaneState(std::vector<TmuxPane> panes, int history);
|
||||
bool _SyncWindowState(std::vector<TmuxWindow> windows);
|
||||
std::vector<TmuxWindowLayout> _ParseTmuxWindowLayout(std::wstring& layout);
|
||||
|
||||
void _EventHandler(const Event& e);
|
||||
void _Parse(const std::wstring& buffer);
|
||||
bool _Advance(wchar_t ch);
|
||||
|
||||
// Tmux command methods
|
||||
void _AttachDone();
|
||||
void _CapturePane(int paneId, int cursorX, int cursorY, int history);
|
||||
void _DiscoverPanes(int sessionId, int windowId, bool newWindow);
|
||||
void _DiscoverWindows(int sessionId);
|
||||
void _KillPane(int paneId);
|
||||
void _KillWindow(int windowId);
|
||||
void _ListWindow(int sessionId, int windowId);
|
||||
void _ListPanes(int windowId, int history);
|
||||
void _NewWindow();
|
||||
void _OpenNewTerminalViaDropdown();
|
||||
void _ResizePane(int paneId, int width, int height);
|
||||
void _ResizeWindow(int windowId, int width, int height);
|
||||
void _SelectPane(int paneId);
|
||||
void _SelectWindow(int windowId);
|
||||
void _SendKey(int paneId, const std::wstring keys);
|
||||
void _SetOption(const std::wstring& option);
|
||||
void _SplitPane(std::shared_ptr<Pane> pane, SplitDirection direction);
|
||||
|
||||
void _CommandHandler(const std::wstring& result);
|
||||
void _SendCommand(std::unique_ptr<Command> cmd);
|
||||
void _ScheduleCommand();
|
||||
|
||||
// Private variables
|
||||
TerminalPage& _page;
|
||||
winrt::Microsoft::Terminal::Settings::Model::Profile _profile;
|
||||
winrt::Microsoft::Terminal::Control::TermControl _control{ nullptr };
|
||||
TerminalApp::Tab _controlTab{ nullptr };
|
||||
winrt::Windows::System::DispatcherQueue _dispatcherQueue{ nullptr };
|
||||
|
||||
winrt::event_token _detachKeyDownRevoker;
|
||||
winrt::event_token _windowSizeChangedRevoker;
|
||||
winrt::event_token _newTabClickRevoker;
|
||||
|
||||
::winrt::Windows::UI::Xaml::Controls::MenuFlyoutItem _newTabMenu{};
|
||||
|
||||
std::vector<wchar_t> _dcsBuffer;
|
||||
std::deque<std::unique_ptr<TmuxControl::Command>> _cmdQueue;
|
||||
std::unordered_map<int, AttachedPane> _attachedPanes;
|
||||
std::unordered_map<int, TerminalApp::Tab> _attachedWindows;
|
||||
std::unordered_map<int, std::wstring> _outputBacklog;
|
||||
|
||||
int _sessionId{ -1 };
|
||||
|
||||
int _terminalWidth{ 0 };
|
||||
int _terminalHeight{ 0 };
|
||||
|
||||
float _fontWidth{ 0 };
|
||||
float _fontHeight{ 0 };
|
||||
|
||||
::winrt::Windows::UI::Xaml::Thickness _thickness{ 0, 0, 0, 0 };
|
||||
|
||||
std::pair<std::shared_ptr<Pane>, SplitDirection> _splittingPane{ nullptr, SplitDirection::Right };
|
||||
|
||||
int _activePaneId{ -1 };
|
||||
int _activeWindowId{ -1 };
|
||||
|
||||
std::function<void(const std::wstring_view string)> _Print;
|
||||
bool _inUse{ false };
|
||||
std::mutex _inUseMutex;
|
||||
};
|
||||
}
|
||||
@ -33,6 +33,9 @@
|
||||
<ClInclude Include="EchoConnection.h">
|
||||
<DependentUpon>EchoConnection.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TmuxConnection.h">
|
||||
<DependentUpon>TmuxConnection.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CTerminalHandoff.cpp" />
|
||||
@ -52,6 +55,9 @@
|
||||
<ClCompile Include="ConptyConnection.cpp">
|
||||
<DependentUpon>ConptyConnection.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TmuxConnection.cpp">
|
||||
<DependentUpon>TmuxConnection.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -60,6 +66,7 @@
|
||||
<Midl Include="ConptyConnection.idl" />
|
||||
<Midl Include="EchoConnection.idl" />
|
||||
<Midl Include="AzureConnection.idl" />
|
||||
<Midl Include="TmuxConnection.idl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PRIResource Include="Resources\en-US\Resources.resw">
|
||||
@ -99,4 +106,4 @@
|
||||
<Import Project="$(SolutionDir)build\rules\CollectWildcardResources.targets" />
|
||||
<!-- This -must- go after cppwinrt.build.post.props because that includes many VS-provided props including appcontainer.common.props, which stomps on what cppwinrt.targets did. -->
|
||||
<Import Project="$(OpenConsoleDir)src\common.nugetversions.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
<ClCompile Include="AzureConnection.cpp" />
|
||||
<ClCompile Include="init.cpp" />
|
||||
<ClCompile Include="CTerminalHandoff.cpp" />
|
||||
<ClCompile Include="TmuxConnection.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
@ -27,6 +28,7 @@
|
||||
<ClInclude Include="AzureClientID.h" />
|
||||
<ClInclude Include="CTerminalHandoff.h" />
|
||||
<ClInclude Include="BaseTerminalConnection.h" />
|
||||
<ClInclude Include="TmuxConnection.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Midl Include="ITerminalConnection.idl" />
|
||||
@ -34,6 +36,7 @@
|
||||
<Midl Include="AzureConnection.idl" />
|
||||
<Midl Include="ConptyConnection.idl" />
|
||||
<Midl Include="ConnectionInformation.idl" />
|
||||
<Midl Include="TmuxConnection.idl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include="$(SolutionDir)tools\ConsoleTypes.natvis" />
|
||||
@ -42,4 +45,4 @@
|
||||
<ItemGroup>
|
||||
<PRIResource Include="Resources\en-US\Resources.resw" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
36
src/cascadia/TerminalConnection/TmuxConnection.cpp
Normal file
36
src/cascadia/TerminalConnection/TmuxConnection.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include "pch.h"
|
||||
#include "TmuxConnection.h"
|
||||
#include <sstream>
|
||||
|
||||
#include "TmuxConnection.g.cpp"
|
||||
|
||||
namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
{
|
||||
TmuxConnection::TmuxConnection() noexcept = default;
|
||||
|
||||
void TmuxConnection::Start() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
void TmuxConnection::WriteInput(const winrt::array_view<const char16_t> buffer)
|
||||
{
|
||||
const auto data = winrt_array_to_wstring_view(buffer);
|
||||
std::wstringstream prettyPrint;
|
||||
for (const auto& wch : data)
|
||||
{
|
||||
prettyPrint << wch;
|
||||
}
|
||||
TerminalInput.raise(prettyPrint.str());
|
||||
}
|
||||
|
||||
void TmuxConnection::Resize(uint32_t /*rows*/, uint32_t /*columns*/) noexcept
|
||||
{
|
||||
}
|
||||
|
||||
void TmuxConnection::Close() noexcept
|
||||
{
|
||||
}
|
||||
}
|
||||
35
src/cascadia/TerminalConnection/TmuxConnection.h
Normal file
35
src/cascadia/TerminalConnection/TmuxConnection.h
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "TmuxConnection.g.h"
|
||||
|
||||
namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
{
|
||||
struct TmuxConnection : DummyConnectionT<TmuxConnection>
|
||||
{
|
||||
TmuxConnection() noexcept;
|
||||
|
||||
void Start() noexcept;
|
||||
void WriteInput(const winrt::array_view<const char16_t> buffer);
|
||||
void Resize(uint32_t rows, uint32_t columns) noexcept;
|
||||
void Close() noexcept;
|
||||
|
||||
void Initialize(const Windows::Foundation::Collections::ValueSet& /*settings*/) const noexcept {};
|
||||
|
||||
winrt::guid SessionId() const noexcept { return {}; }
|
||||
ConnectionState State() const noexcept { return ConnectionState::Connected; }
|
||||
|
||||
til::event<TerminalOutputHandler> TerminalOutput;
|
||||
til::event<TerminalOutputHandler> TerminalInput;
|
||||
til::typed_event<ITerminalConnection, IInspectable> StateChanged;
|
||||
|
||||
bool _rawMode{ false };
|
||||
};
|
||||
}
|
||||
|
||||
namespace winrt::Microsoft::Terminal::TerminalConnection::factory_implementation
|
||||
{
|
||||
BASIC_FACTORY(TmuxConnection);
|
||||
}
|
||||
14
src/cascadia/TerminalConnection/TmuxConnection.idl
Normal file
14
src/cascadia/TerminalConnection/TmuxConnection.idl
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import "ITerminalConnection.idl";
|
||||
|
||||
namespace Microsoft.Terminal.TerminalConnection
|
||||
{
|
||||
[default_interface]
|
||||
runtimeclass TmuxConnection : ITerminalConnection
|
||||
{
|
||||
TmuxConnection();
|
||||
event TerminalOutputHandler TerminalInput;
|
||||
};
|
||||
}
|
||||
@ -495,6 +495,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
}
|
||||
}
|
||||
|
||||
void ControlCore::SendOutput(const std::wstring_view wstr)
|
||||
{
|
||||
if (wstr.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto lock = _terminal->LockForWriting();
|
||||
_terminal->Write(wstr);
|
||||
}
|
||||
|
||||
bool ControlCore::SendCharEvent(const wchar_t ch,
|
||||
const WORD scanCode,
|
||||
const ::Microsoft::Terminal::Core::ControlKeyStates modifiers)
|
||||
@ -1555,6 +1566,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
return _terminal->GetViewport().Height();
|
||||
}
|
||||
|
||||
// Function Description:
|
||||
// - Gets the width of the terminal in lines of text. This is just the
|
||||
// width of the viewport.
|
||||
// Return Value:
|
||||
// - The width of the terminal in lines of text
|
||||
int ControlCore::ViewWidth() const
|
||||
{
|
||||
const auto lock = _terminal->LockForReading();
|
||||
return _terminal->GetViewport().Width();
|
||||
}
|
||||
// Function Description:
|
||||
// - Gets the height of the terminal in lines of text. This includes the
|
||||
// history AND the viewport.
|
||||
@ -2918,4 +2939,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
{
|
||||
_terminal->PreviewText(input);
|
||||
}
|
||||
|
||||
void ControlCore::SetTmuxControlHandlerProducer(ITermDispatch::StringHandlerProducer producer)
|
||||
{
|
||||
_terminal->SetTmuxControlHandlerProducer(producer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include "../../buffer/out/search.h"
|
||||
#include "../../cascadia/TerminalCore/Terminal.hpp"
|
||||
#include "../../renderer/inc/FontInfoDesired.hpp"
|
||||
#include "../../terminal/adapter/ITermDispatch.hpp"
|
||||
|
||||
namespace Microsoft::Console::Render::Atlas
|
||||
{
|
||||
@ -40,6 +41,8 @@ namespace ControlUnitTests
|
||||
class ControlInteractivityTests;
|
||||
};
|
||||
|
||||
using Microsoft::Console::VirtualTerminal::ITermDispatch;
|
||||
|
||||
#define RUNTIME_SETTING(type, name, setting) \
|
||||
private: \
|
||||
std::optional<type> _runtime##name{ std::nullopt }; \
|
||||
@ -123,6 +126,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
til::color BackgroundColor() const;
|
||||
|
||||
void SendInput(std::wstring_view wstr);
|
||||
void SendOutput(std::wstring_view wstr);
|
||||
void PasteText(const winrt::hstring& hstr);
|
||||
bool CopySelectionToClipboard(bool singleLine, bool withControlSequences, const CopyFormat formats);
|
||||
void SelectAll();
|
||||
@ -172,6 +176,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
int ScrollOffset();
|
||||
int ViewHeight() const;
|
||||
int ViewWidth() const;
|
||||
int BufferHeight() const;
|
||||
|
||||
bool HasSelection() const;
|
||||
@ -264,6 +269,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
bool ShouldShowSelectOutput();
|
||||
|
||||
void PreviewInput(std::wstring_view input);
|
||||
void SetTmuxControlHandlerProducer(ITermDispatch::StringHandlerProducer producer);
|
||||
|
||||
RUNTIME_SETTING(float, Opacity, _settings.Opacity());
|
||||
RUNTIME_SETTING(float, FocusedOpacity, FocusedAppearance().Opacity());
|
||||
@ -461,6 +467,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
friend class ControlUnitTests::ControlInteractivityTests;
|
||||
bool _inUnitTests{ false };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Control::factory_implementation
|
||||
|
||||
@ -67,6 +67,10 @@ namespace Microsoft.Terminal.Control
|
||||
Boolean SearchRegexInvalid;
|
||||
};
|
||||
|
||||
delegate Boolean TmuxDCSHandler(Char ch);
|
||||
delegate void PrintHandler(String str);
|
||||
delegate TmuxDCSHandler TmuxDCSHandlerProducer(PrintHandler print);
|
||||
|
||||
[default_interface] runtimeclass SelectionColor
|
||||
{
|
||||
SelectionColor();
|
||||
@ -127,6 +131,7 @@ namespace Microsoft.Terminal.Control
|
||||
Int16 scanCode,
|
||||
Microsoft.Terminal.Core.ControlKeyStates modifiers);
|
||||
void SendInput(String text);
|
||||
void SendOutput(String text);
|
||||
void PasteText(String text);
|
||||
void SelectAll();
|
||||
void ClearSelection();
|
||||
@ -183,6 +188,7 @@ namespace Microsoft.Terminal.Control
|
||||
Boolean ShouldShowSelectOutput();
|
||||
|
||||
void OpenCWD();
|
||||
void SetTmuxControlHandlerProducer(TmuxDCSHandlerProducer producer);
|
||||
|
||||
void ClearQuickFix();
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ namespace Microsoft.Terminal.Control
|
||||
|
||||
Int32 ScrollOffset { get; };
|
||||
Int32 ViewHeight { get; };
|
||||
Int32 ViewWidth { get; };
|
||||
Int32 BufferHeight { get; };
|
||||
|
||||
Boolean HasSelection { get; };
|
||||
|
||||
@ -903,6 +903,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
RawWriteString(wstr);
|
||||
}
|
||||
void TermControl::SendOutput(const winrt::hstring& wstr)
|
||||
{
|
||||
_core.SendOutput(wstr);
|
||||
}
|
||||
void TermControl::ClearBuffer(Control::ClearBufferType clearType)
|
||||
{
|
||||
_core.ClearBuffer(clearType);
|
||||
@ -1423,6 +1427,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// Likewise, run the event handlers outside of lock (they could
|
||||
// be reentrant)
|
||||
Initialized.raise(*this, nullptr);
|
||||
|
||||
if (_tmuxDCSHandlerProducer)
|
||||
{
|
||||
_core.SetTmuxControlHandlerProducer(_tmuxDCSHandlerProducer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2668,6 +2677,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
return _core.ViewHeight();
|
||||
}
|
||||
|
||||
int TermControl::ViewWidth() const
|
||||
{
|
||||
return _core.ViewWidth();
|
||||
}
|
||||
|
||||
int TermControl::BufferHeight() const
|
||||
{
|
||||
return _core.BufferHeight();
|
||||
@ -2867,7 +2881,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
else
|
||||
{
|
||||
// Do we ever get here (= uninitialized terminal)? If so: How?
|
||||
assert(false);
|
||||
// Yes, we can get here, when do Pane._Split, it need to call _SetupEntranceAnimation^M
|
||||
// which need the control's size, while this size can only be available when the control^M
|
||||
// is initialized.^M
|
||||
return { 10, 10 };
|
||||
}
|
||||
}
|
||||
@ -4080,4 +4096,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
_core.ForceCursorVisible(cursorVisibility == CursorDisplayState::Shown);
|
||||
}
|
||||
}
|
||||
void TermControl::SetTmuxControlHandlerProducer(winrt::Microsoft::Terminal::Control::TmuxDCSHandlerProducer producer)
|
||||
{
|
||||
_tmuxDCSHandlerProducer = producer;
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,6 +97,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
int ScrollOffset() const;
|
||||
int ViewHeight() const;
|
||||
int ViewWidth() const;
|
||||
int BufferHeight() const;
|
||||
|
||||
bool HasSelection() const;
|
||||
@ -119,6 +120,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
void SelectOutput(const bool goUp);
|
||||
|
||||
winrt::hstring CurrentWorkingDirectory() const;
|
||||
void SetTmuxControlHandlerProducer(winrt::Microsoft::Terminal::Control::TmuxDCSHandlerProducer producer);
|
||||
#pragma endregion
|
||||
|
||||
void ScrollViewport(int viewTop);
|
||||
@ -128,6 +130,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
winrt::Windows::Foundation::Size GetFontSize() const;
|
||||
|
||||
void SendInput(const winrt::hstring& input);
|
||||
void SendOutput(const winrt::hstring& input);
|
||||
void ClearBuffer(Control::ClearBufferType clearType);
|
||||
|
||||
void ToggleShaderEffects();
|
||||
@ -254,6 +257,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
Control::IKeyBindings _keyBindings{ nullptr };
|
||||
TsfDataProvider _tsfDataProvider{ this };
|
||||
winrt::com_ptr<SearchBoxControl> _searchBox;
|
||||
winrt::Microsoft::Terminal::Control::TmuxDCSHandlerProducer _tmuxDCSHandlerProducer{ nullptr };
|
||||
|
||||
enum class AltNumpadEncoding
|
||||
{
|
||||
|
||||
@ -127,6 +127,7 @@ namespace Microsoft.Terminal.Control
|
||||
|
||||
void ToggleShaderEffects();
|
||||
void SendInput(String input);
|
||||
void SendOutput(String input);
|
||||
Boolean RawWriteKeyEvent(UInt16 vkey, UInt16 scanCode, Microsoft.Terminal.Core.ControlKeyStates modifiers, Boolean keyDown);
|
||||
Boolean RawWriteChar(Char character, UInt16 scanCode, Microsoft.Terminal.Core.ControlKeyStates modifiers);
|
||||
void RawWriteString(String text);
|
||||
@ -166,5 +167,6 @@ namespace Microsoft.Terminal.Control
|
||||
void ClearQuickFix();
|
||||
|
||||
void Detach();
|
||||
void SetTmuxControlHandlerProducer(TmuxDCSHandlerProducer producer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,6 +253,12 @@ void Terminal::SetOptionalFeatures(winrt::Microsoft::Terminal::Core::ICoreSettin
|
||||
engine.Dispatch().SetOptionalFeatures(features);
|
||||
}
|
||||
|
||||
void Terminal::SetTmuxControlHandlerProducer(ITermDispatch::StringHandlerProducer producer) const noexcept
|
||||
{
|
||||
auto& engine = reinterpret_cast<OutputStateMachineEngine&>(_stateMachine->Engine());
|
||||
engine.Dispatch().SetTmuxControlHandlerProducer(producer);
|
||||
}
|
||||
|
||||
bool Terminal::IsXtermBracketedPasteModeEnabled() const noexcept
|
||||
{
|
||||
return _systemMode.test(Mode::BracketedPaste);
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include "../../types/inc/Viewport.hpp"
|
||||
#include "../../types/inc/GlyphWidth.hpp"
|
||||
#include "../../cascadia/terminalcore/ITerminalInput.hpp"
|
||||
#include "../../terminal/adapter/ITermDispatch.hpp"
|
||||
|
||||
#include <til/generational.h>
|
||||
#include <til/ticket_lock.h>
|
||||
@ -128,6 +129,7 @@ public:
|
||||
std::wstring CurrentCommand() const;
|
||||
|
||||
void SerializeMainBuffer(HANDLE handle) const;
|
||||
void SetTmuxControlHandlerProducer(Microsoft::Console::VirtualTerminal::ITermDispatch::StringHandlerProducer producer) const noexcept;
|
||||
|
||||
#pragma region ITerminalApi
|
||||
// These methods are defined in TerminalApi.cpp
|
||||
|
||||
@ -352,6 +352,7 @@ namespace winrt::Microsoft::Terminal::Settings
|
||||
_AllowVtChecksumReport = profile.AllowVtChecksumReport();
|
||||
_AllowVtClipboardWrite = profile.AllowVtClipboardWrite();
|
||||
_PathTranslationStyle = profile.PathTranslationStyle();
|
||||
_AllowTmuxControl = profile.AllowTmuxControl();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
||||
@ -92,6 +92,7 @@ namespace winrt::Microsoft::Terminal::Settings
|
||||
SIMPLE_OVERRIDABLE_SETTING(bool, Elevate, false);
|
||||
SIMPLE_OVERRIDABLE_SETTING(IEnvironmentVariableMapView, EnvironmentVariables, nullptr);
|
||||
SIMPLE_OVERRIDABLE_SETTING(bool, ReloadEnvironmentVariables, true);
|
||||
SIMPLE_OVERRIDABLE_SETTING(bool, AllowTmuxControl, false);
|
||||
|
||||
public:
|
||||
// TerminalApp overrides these when duplicating a session
|
||||
|
||||
@ -189,6 +189,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
|
||||
_parsedPadding = StringToXamlThickness(_profile.Padding());
|
||||
_defaultAppearanceViewModel.IsDefault(true);
|
||||
|
||||
if constexpr (Feature_TmuxControl::IsEnabled())
|
||||
{
|
||||
TmuxControlEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileViewModel::_UpdateBuiltInIcons()
|
||||
|
||||
@ -171,9 +171,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AnswerbackMessage);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, RainbowSuggestions);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, PathTranslationStyle);
|
||||
OBSERVABLE_PROJECTED_SETTING(_profile, AllowTmuxControl);
|
||||
|
||||
WINRT_PROPERTY(bool, IsBaseLayer, false);
|
||||
WINRT_PROPERTY(bool, FocusDeleteButton, false);
|
||||
WINRT_PROPERTY(bool, TmuxControlEnabled, false);
|
||||
WINRT_PROPERTY(Windows::Foundation::Collections::IVector<Windows::Foundation::IInspectable>, IconTypes);
|
||||
GETSET_BINDABLE_ENUM_SETTING(AntiAliasingMode, Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode);
|
||||
GETSET_BINDABLE_ENUM_SETTING(CloseOnExitMode, Microsoft::Terminal::Settings::Model::CloseOnExitMode, CloseOnExit);
|
||||
|
||||
@ -114,6 +114,7 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||
Boolean UsingBuiltInIcon { get; };
|
||||
Boolean UsingEmojiIcon { get; };
|
||||
Boolean UsingImageIcon { get; };
|
||||
Boolean TmuxControlEnabled;
|
||||
String IconPath;
|
||||
|
||||
EnumEntry CurrentBuiltInIcon;
|
||||
@ -162,5 +163,6 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, RainbowSuggestions);
|
||||
OBSERVABLE_PROJECTED_PROFILE_SETTING(Microsoft.Terminal.Control.PathTranslationStyle, PathTranslationStyle);
|
||||
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AllowVtClipboardWrite);
|
||||
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AllowTmuxControl);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,6 +77,16 @@
|
||||
<TextBox Style="{StaticResource TextBoxSettingStyle}"
|
||||
Text="{x:Bind Profile.AnswerbackMessage, Mode=TwoWay}" />
|
||||
</local:SettingContainer>
|
||||
|
||||
<!-- Allow Tmux Control -->
|
||||
<local:SettingContainer x:Uid="Profile_AllowTmuxControl"
|
||||
ClearSettingValue="{x:Bind Profile.ClearAllowTmuxControl}"
|
||||
HasSettingValue="{x:Bind Profile.HasAllowTmuxControl, Mode=OneWay}"
|
||||
SettingOverrideSource="{x:Bind Profile.AllowTmuxControlOverrideSource, Mode=OneWay}"
|
||||
Visibility="{x:Bind Profile.TmuxControlEnabled}">
|
||||
<ToggleSwitch IsOn="{x:Bind Profile.AllowTmuxControl, Mode=TwoWay}"
|
||||
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
|
||||
</local:SettingContainer>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@ -568,6 +568,10 @@
|
||||
<value>Always on top</value>
|
||||
<comment>Header for a control to toggle if the app will always be presented on top of other windows, or is treated normally (when disabled).</comment>
|
||||
</data>
|
||||
<data name="Profile_AllowTmuxControl.Header" xml:space="preserve">
|
||||
<value>Allow Tmux Control</value>
|
||||
<comment>Header for a control to toggle tmux control.</comment>
|
||||
</data>
|
||||
<data name="Profile_ForceVTInput.Header" xml:space="preserve">
|
||||
<value>Use the legacy input encoding</value>
|
||||
<comment>Header for a control to toggle legacy input encoding for the terminal.</comment>
|
||||
|
||||
@ -106,6 +106,7 @@ Author(s):
|
||||
X(bool, AllowVtChecksumReport, "compatibility.allowDECRQCRA", false) \
|
||||
X(bool, AllowVtClipboardWrite, "compatibility.allowOSC52", true) \
|
||||
X(bool, AllowKeypadMode, "compatibility.allowDECNKM", false) \
|
||||
X(bool, AllowTmuxControl, "AllowTmuxControl", false) \
|
||||
X(Microsoft::Terminal::Control::PathTranslationStyle, PathTranslationStyle, "pathTranslationStyle", Microsoft::Terminal::Control::PathTranslationStyle::None)
|
||||
|
||||
// Intentionally omitted Profile settings:
|
||||
|
||||
@ -91,6 +91,7 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
INHERITABLE_PROFILE_SETTING(Boolean, AllowVtChecksumReport);
|
||||
INHERITABLE_PROFILE_SETTING(Boolean, AllowKeypadMode);
|
||||
INHERITABLE_PROFILE_SETTING(Boolean, AllowVtClipboardWrite);
|
||||
INHERITABLE_PROFILE_SETTING(Boolean, AllowTmuxControl);
|
||||
|
||||
INHERITABLE_PROFILE_SETTING(Microsoft.Terminal.Control.PathTranslationStyle, PathTranslationStyle);
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@
|
||||
|
||||
<!-- For ALL build types-->
|
||||
<PropertyGroup Label="Configuration">
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<name>Feature_EditableUnfocusedAppearance</name>
|
||||
<description>The unfocused appearance section in profiles in the SUI that allows users to create and edit unfocused appearances.</description>
|
||||
<stage>AlwaysEnabled</stage>
|
||||
<alwaysDisabledReleaseTokens/>
|
||||
<alwaysDisabledReleaseTokens />
|
||||
</feature>
|
||||
|
||||
<feature>
|
||||
@ -189,7 +189,7 @@
|
||||
<name>Feature_DebugModeUI</name>
|
||||
<description>Enables UI access to the debug mode setting</description>
|
||||
<stage>AlwaysEnabled</stage>
|
||||
<alwaysDisabledReleaseTokens/>
|
||||
<alwaysDisabledReleaseTokens />
|
||||
</feature>
|
||||
|
||||
<feature>
|
||||
@ -203,4 +203,16 @@
|
||||
</alwaysEnabledBrandingTokens>
|
||||
</feature>
|
||||
|
||||
<feature>
|
||||
<name>Feature_TmuxControl</name>
|
||||
<description>Enables Tmux Control</description>
|
||||
<id>3656</id>
|
||||
<stage>AlwaysDisabled</stage>
|
||||
<alwaysEnabledBrandingTokens>
|
||||
<brandingToken>Dev</brandingToken>
|
||||
<brandingToken>Canary</brandingToken>
|
||||
<brandingToken>Preview</brandingToken>
|
||||
</alwaysEnabledBrandingTokens>
|
||||
</feature>
|
||||
|
||||
</featureStaging>
|
||||
|
||||
@ -24,6 +24,9 @@ class Microsoft::Console::VirtualTerminal::ITermDispatch
|
||||
{
|
||||
public:
|
||||
using StringHandler = std::function<bool(const wchar_t)>;
|
||||
using PrintHandler = std::function<void(const std::wstring_view)>;
|
||||
// Use this get the StringHandler, meanwhile pass the function to give app a function to print message bypass the parser
|
||||
using StringHandlerProducer = std::function<StringHandler(PrintHandler)>;
|
||||
|
||||
enum class OptionalFeature
|
||||
{
|
||||
@ -192,6 +195,9 @@ public:
|
||||
virtual void PlaySounds(const VTParameters parameters) = 0; // DECPS
|
||||
|
||||
virtual void SetOptionalFeatures(const til::enumset<OptionalFeature> features) = 0;
|
||||
|
||||
virtual StringHandler EnterTmuxControl(const VTParameters parameters) = 0; // tmux -CC
|
||||
virtual void SetTmuxControlHandlerProducer(StringHandlerProducer producer) = 0; // tmux -CC
|
||||
};
|
||||
inline Microsoft::Console::VirtualTerminal::ITermDispatch::~ITermDispatch() = default;
|
||||
#pragma warning(pop)
|
||||
|
||||
@ -4760,3 +4760,27 @@ void AdaptDispatch::SetOptionalFeatures(const til::enumset<OptionalFeature> feat
|
||||
{
|
||||
_optionalFeatures = features;
|
||||
}
|
||||
|
||||
ITermDispatch::StringHandler AdaptDispatch::EnterTmuxControl(const VTParameters parameters)
|
||||
{
|
||||
if (parameters.size() != 1 || parameters.at(0).value() != 1000)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (_tmuxControlHandlerProducer)
|
||||
{
|
||||
const auto page = _pages.ActivePage();
|
||||
return _tmuxControlHandlerProducer([this, page](auto s) {
|
||||
PrintString(s);
|
||||
_DoLineFeed(page, true, true);
|
||||
});
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AdaptDispatch::SetTmuxControlHandlerProducer(StringHandlerProducer producer)
|
||||
{
|
||||
_tmuxControlHandlerProducer = producer;
|
||||
}
|
||||
|
||||
@ -190,6 +190,9 @@ namespace Microsoft::Console::VirtualTerminal
|
||||
|
||||
void SetOptionalFeatures(const til::enumset<OptionalFeature> features) noexcept override;
|
||||
|
||||
StringHandler EnterTmuxControl(const VTParameters parameters) override; // tmux -CC
|
||||
void SetTmuxControlHandlerProducer(StringHandlerProducer producer) override; // tmux -CC
|
||||
|
||||
private:
|
||||
enum class Mode
|
||||
{
|
||||
@ -327,6 +330,7 @@ namespace Microsoft::Console::VirtualTerminal
|
||||
til::enumset<Mode> _modes{ Mode::PageCursorCoupling };
|
||||
|
||||
SgrStack _sgrStack;
|
||||
StringHandlerProducer _tmuxControlHandlerProducer{ nullptr };
|
||||
|
||||
void _SetUnderlineStyleHelper(const VTParameter option, TextAttribute& attr) noexcept;
|
||||
size_t _SetRgbColorsHelper(const VTParameters options,
|
||||
|
||||
@ -179,6 +179,9 @@ public:
|
||||
void PlaySounds(const VTParameters /*parameters*/) override{}; // DECPS
|
||||
|
||||
void SetOptionalFeatures(const til::enumset<OptionalFeature> /*features*/) override{};
|
||||
|
||||
StringHandler EnterTmuxControl(const VTParameters /*parameters*/) override { return nullptr; }; // tmux -CC
|
||||
void SetTmuxControlHandlerProducer(StringHandlerProducer /*producer*/) override{}; // tmux -CC
|
||||
};
|
||||
|
||||
#pragma warning(default : 26440) // Restore "can be declared noexcept" warning
|
||||
|
||||
@ -724,6 +724,9 @@ IStateMachineEngine::StringHandler OutputStateMachineEngine::ActionDcsDispatch(c
|
||||
case DcsActionCodes::DECRSPS_RestorePresentationState:
|
||||
handler = _dispatch->RestorePresentationState(parameters.at(0));
|
||||
break;
|
||||
case DcsActionCodes::TMUX_ControlEnter:
|
||||
handler = _dispatch->EnterTmuxControl(parameters);
|
||||
break;
|
||||
default:
|
||||
handler = nullptr;
|
||||
break;
|
||||
|
||||
@ -178,6 +178,7 @@ namespace Microsoft::Console::VirtualTerminal
|
||||
DECRSTS_RestoreTerminalState = VTID("$p"),
|
||||
DECRQSS_RequestSetting = VTID("$q"),
|
||||
DECRSPS_RestorePresentationState = VTID("$t"),
|
||||
TMUX_ControlEnter = VTID("p"),
|
||||
};
|
||||
|
||||
enum Vt52ActionCodes : uint64_t
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user