mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 00:48:23 -06:00
wip
This commit is contained in:
parent
a804faedda
commit
d2dc2092a6
@ -262,11 +262,6 @@ namespace winrt::TerminalApp::implementation
|
||||
}
|
||||
|
||||
_hostingHwnd = hwnd;
|
||||
|
||||
if constexpr (Feature_TmuxControl::IsEnabled())
|
||||
{
|
||||
_tmuxControl = std::make_unique<TmuxControl>(*this);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -413,7 +408,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
if constexpr (Feature_TmuxControl::IsEnabled())
|
||||
{
|
||||
//Tmux control takes over
|
||||
// tmux control takes over
|
||||
if (page->_tmuxControl && page->_tmuxControl->TabIsTmuxControl(page->_GetFocusedTabImpl()))
|
||||
{
|
||||
return;
|
||||
@ -3445,7 +3440,7 @@ namespace winrt::TerminalApp::implementation
|
||||
const auto tabViewItem = eventArgs.Tab();
|
||||
if (auto tab{ _GetTabByTabViewItem(tabViewItem) })
|
||||
{
|
||||
winrt::get_self<Tab>(tab)->CloseRequested.raise(nullptr, nullptr);
|
||||
_HandleCloseTabRequested(tab);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3617,12 +3612,19 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
if constexpr (Feature_TmuxControl::IsEnabled())
|
||||
{
|
||||
if (profile.AllowTmuxControl() && _tmuxControl)
|
||||
{
|
||||
control.SetTmuxControlHandlerProducer([this, control](auto print) {
|
||||
return _tmuxControl->TmuxControlHandlerProducer(control, print);
|
||||
});
|
||||
}
|
||||
control.EnterTmuxControl([this](auto&&, auto&& args) {
|
||||
if (!_tmuxControl)
|
||||
{
|
||||
_tmuxControl = std::make_unique<TmuxControl>(*this);
|
||||
}
|
||||
|
||||
if (_tmuxControl->AcquireSingleUseLock())
|
||||
{
|
||||
args.InputCallback([this](auto&& str) {
|
||||
_tmuxControl->FeedInput(winrt_array_to_wstring_view(str));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return resultPane;
|
||||
@ -5520,6 +5522,7 @@ namespace winrt::TerminalApp::implementation
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// First: stash the tab we started dragging.
|
||||
// We're going to be asked for this.
|
||||
_stashed.draggedTab = tabImpl;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -16,32 +16,29 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
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 AcquireSingleUseLock() noexcept;
|
||||
void FeedInput(std::wstring_view str);
|
||||
bool TabIsTmuxControl(const winrt::com_ptr<Tab>& tab);
|
||||
void SplitPane(const winrt::com_ptr<Tab>& tab, SplitDirection direction);
|
||||
void SplitPane(const winrt::com_ptr<Tab>& tab, winrt::Microsoft::Terminal::Settings::Model::SplitDirection direction);
|
||||
|
||||
private:
|
||||
enum class State : int
|
||||
enum class State
|
||||
{
|
||||
INIT,
|
||||
ATTACHING,
|
||||
ATTACHED,
|
||||
};
|
||||
|
||||
enum class CommandState : int
|
||||
enum class CommandState
|
||||
{
|
||||
READY,
|
||||
WAITING,
|
||||
};
|
||||
|
||||
enum class EventType : int
|
||||
enum class EventType
|
||||
{
|
||||
BEGIN,
|
||||
END,
|
||||
@ -64,9 +61,9 @@ namespace winrt::TerminalApp::implementation
|
||||
struct Event
|
||||
{
|
||||
EventType type{ EventType::NOTHING };
|
||||
int sessionId{ -1 };
|
||||
int windowId{ -1 };
|
||||
int paneId{ -1 };
|
||||
int64_t sessionId{ -1 };
|
||||
int64_t windowId{ -1 };
|
||||
int64_t paneId{ -1 };
|
||||
|
||||
std::wstring response;
|
||||
};
|
||||
@ -92,10 +89,10 @@ namespace winrt::TerminalApp::implementation
|
||||
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 };
|
||||
int64_t paneId{ -1 };
|
||||
til::CoordType cursorX{ 0 };
|
||||
til::CoordType cursorY{ 0 };
|
||||
til::CoordType history{ 0 };
|
||||
};
|
||||
|
||||
struct DiscoverPanes : public Command
|
||||
@ -104,8 +101,8 @@ namespace winrt::TerminalApp::implementation
|
||||
std::wstring GetCommand() override;
|
||||
bool ResultHandler(const std::wstring& result, TmuxControl& tmux) override;
|
||||
|
||||
int sessionId{ -1 };
|
||||
int windowId{ -1 };
|
||||
int64_t sessionId{ -1 };
|
||||
int64_t windowId{ -1 };
|
||||
bool newWindow{ false };
|
||||
};
|
||||
|
||||
@ -115,7 +112,7 @@ namespace winrt::TerminalApp::implementation
|
||||
std::wstring GetCommand() override;
|
||||
bool ResultHandler(const std::wstring& result, TmuxControl& tmux) override;
|
||||
|
||||
int sessionId{ -1 };
|
||||
int64_t sessionId{ -1 };
|
||||
};
|
||||
|
||||
struct KillPane : public Command
|
||||
@ -123,7 +120,7 @@ namespace winrt::TerminalApp::implementation
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int paneId{ -1 };
|
||||
int64_t paneId{ -1 };
|
||||
};
|
||||
|
||||
struct KillWindow : public Command
|
||||
@ -131,7 +128,7 @@ namespace winrt::TerminalApp::implementation
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int windowId{ -1 };
|
||||
int64_t windowId{ -1 };
|
||||
};
|
||||
|
||||
struct ListPanes : public Command
|
||||
@ -140,8 +137,8 @@ namespace winrt::TerminalApp::implementation
|
||||
std::wstring GetCommand() override;
|
||||
bool ResultHandler(const std::wstring& result, TmuxControl& tmux) override;
|
||||
|
||||
int windowId{ -1 };
|
||||
int history{ 2000 };
|
||||
int64_t windowId{ -1 };
|
||||
til::CoordType history{ 2000 };
|
||||
};
|
||||
|
||||
struct ListWindow : public Command
|
||||
@ -150,8 +147,8 @@ namespace winrt::TerminalApp::implementation
|
||||
std::wstring GetCommand() override;
|
||||
bool ResultHandler(const std::wstring& result, TmuxControl& tmux) override;
|
||||
|
||||
int windowId{ -1 };
|
||||
int sessionId{ -1 };
|
||||
int64_t windowId{ -1 };
|
||||
int64_t sessionId{ -1 };
|
||||
};
|
||||
|
||||
struct NewWindow : public Command
|
||||
@ -165,18 +162,18 @@ namespace winrt::TerminalApp::implementation
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int width{ 0 };
|
||||
int height{ 0 };
|
||||
int paneId{ -1 };
|
||||
til::CoordType width{ 0 };
|
||||
til::CoordType height{ 0 };
|
||||
int64_t paneId{ -1 };
|
||||
};
|
||||
|
||||
struct ResizeWindow : public Command
|
||||
{
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
int width{ 0 };
|
||||
int height{ 0 };
|
||||
int windowId{ -1 };
|
||||
til::CoordType width{ 0 };
|
||||
til::CoordType height{ 0 };
|
||||
int64_t windowId{ -1 };
|
||||
};
|
||||
|
||||
struct SelectWindow : public Command
|
||||
@ -184,7 +181,7 @@ namespace winrt::TerminalApp::implementation
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int windowId{ -1 };
|
||||
int64_t windowId{ -1 };
|
||||
};
|
||||
|
||||
struct SelectPane : public Command
|
||||
@ -192,7 +189,7 @@ namespace winrt::TerminalApp::implementation
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int paneId{ -1 };
|
||||
int64_t paneId{ -1 };
|
||||
};
|
||||
|
||||
struct SendKey : public Command
|
||||
@ -200,7 +197,7 @@ namespace winrt::TerminalApp::implementation
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int paneId{ -1 };
|
||||
int64_t paneId{ -1 };
|
||||
std::wstring keys;
|
||||
wchar_t key{ '\0' };
|
||||
};
|
||||
@ -218,12 +215,12 @@ namespace winrt::TerminalApp::implementation
|
||||
public:
|
||||
std::wstring GetCommand() override;
|
||||
|
||||
int paneId{ -1 };
|
||||
SplitDirection direction{ SplitDirection::Left };
|
||||
int64_t paneId{ -1 };
|
||||
winrt::Microsoft::Terminal::Settings::Model::SplitDirection direction{ winrt::Microsoft::Terminal::Settings::Model::SplitDirection::Left };
|
||||
};
|
||||
|
||||
// Layout structs
|
||||
enum TmuxLayoutType : int
|
||||
enum class TmuxLayoutType
|
||||
{
|
||||
SINGLE_PANE,
|
||||
SPLIT_HORIZONTAL,
|
||||
@ -232,27 +229,27 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
struct TmuxPaneLayout
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int left;
|
||||
int top;
|
||||
int id;
|
||||
til::CoordType width;
|
||||
til::CoordType height;
|
||||
til::CoordType left;
|
||||
til::CoordType top;
|
||||
int64_t id;
|
||||
};
|
||||
|
||||
struct TmuxWindowLayout
|
||||
{
|
||||
TmuxLayoutType type{ SINGLE_PANE };
|
||||
TmuxLayoutType type = TmuxLayoutType::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 };
|
||||
int64_t sessionId = 0;
|
||||
int64_t windowId = 0;
|
||||
til::CoordType width = 0;
|
||||
til::CoordType height = 0;
|
||||
til::CoordType history = 0;
|
||||
bool active = false;
|
||||
std::wstring name;
|
||||
std::wstring layoutChecksum;
|
||||
std::vector<TmuxWindowLayout> layout;
|
||||
@ -260,21 +257,21 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
struct TmuxPane
|
||||
{
|
||||
int sessionId;
|
||||
int windowId;
|
||||
int paneId;
|
||||
int cursorX;
|
||||
int cursorY;
|
||||
bool active;
|
||||
int64_t sessionId = 0;
|
||||
int64_t windowId = 0;
|
||||
int64_t paneId = 0;
|
||||
til::CoordType cursorX = 0;
|
||||
til::CoordType cursorY = 0;
|
||||
bool active = false;
|
||||
};
|
||||
|
||||
struct AttachedPane
|
||||
{
|
||||
int windowId;
|
||||
int paneId;
|
||||
int64_t windowId = 0;
|
||||
int64_t paneId = 0;
|
||||
winrt::Microsoft::Terminal::Control::TermControl control;
|
||||
winrt::Microsoft::Terminal::TerminalConnection::TmuxConnection connection;
|
||||
bool initialized{ false };
|
||||
bool initialized = false;
|
||||
};
|
||||
|
||||
// Private methods
|
||||
@ -283,20 +280,19 @@ namespace winrt::TerminalApp::implementation
|
||||
void _SetupProfile();
|
||||
void _CreateNewTabMenu();
|
||||
|
||||
float _ComputeSplitSize(int newSize, int originSize, SplitDirection direction) const;
|
||||
TerminalApp::Tab _GetTab(int windowId) const;
|
||||
float _ComputeSplitSize(til::CoordType newSize, til::CoordType originSize, winrt::Microsoft::Terminal::Settings::Model::SplitDirection direction) const;
|
||||
winrt::com_ptr<Tab> _GetTab(int64_t 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);
|
||||
void _SendOutput(int64_t paneId, const std::wstring& text);
|
||||
void _Output(int64_t paneId, const std::wstring& result);
|
||||
void _CloseWindow(int64_t windowId);
|
||||
void _RenameWindow(int64_t windowId, const std::wstring& name);
|
||||
void _NewWindowFinalize(int64_t windowId, int64_t paneId, const std::wstring& windowName);
|
||||
void _SplitPaneFinalize(int64_t windowId, int64_t paneId);
|
||||
std::shared_ptr<Pane> _NewPane(int64_t windowId, int64_t paneId);
|
||||
|
||||
bool _SyncPaneState(std::vector<TmuxPane> panes, int history);
|
||||
bool _SyncPaneState(std::vector<TmuxPane> panes, til::CoordType 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);
|
||||
@ -304,32 +300,32 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
// 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 _CapturePane(int64_t paneId, til::CoordType cursorX, til::CoordType cursorY, til::CoordType history);
|
||||
void _DiscoverPanes(int64_t sessionId, int64_t windowId, bool newWindow);
|
||||
void _DiscoverWindows(int64_t sessionId);
|
||||
void _KillPane(int64_t paneId);
|
||||
void _KillWindow(int64_t windowId);
|
||||
void _ListWindow(int64_t sessionId, int64_t windowId);
|
||||
void _ListPanes(int64_t windowId, til::CoordType 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 _ResizePane(int64_t paneId, til::CoordType width, til::CoordType height);
|
||||
void _ResizeWindow(int64_t windowId, til::CoordType width, til::CoordType height);
|
||||
void _SelectPane(int64_t paneId);
|
||||
void _SelectWindow(int64_t windowId);
|
||||
void _SendKey(int64_t paneId, const std::wstring keys);
|
||||
void _SetOption(const std::wstring& option);
|
||||
void _SplitPane(std::shared_ptr<Pane> pane, SplitDirection direction);
|
||||
void _SplitPane(std::shared_ptr<Pane> pane, winrt::Microsoft::Terminal::Settings::Model::SplitDirection direction);
|
||||
|
||||
void _CommandHandler(const std::wstring& result);
|
||||
void _SendCommand(std::unique_ptr<Command> cmd);
|
||||
void _ScheduleCommand();
|
||||
|
||||
// Private variables
|
||||
TerminalPage& _page; // Non-owning, because TerminalPage owns us
|
||||
State _state{ State::INIT };
|
||||
CommandState _cmdState{ CommandState::READY };
|
||||
Event _event;
|
||||
TerminalPage& _page;
|
||||
winrt::Microsoft::Terminal::Settings::Model::Profile _profile{ nullptr };
|
||||
winrt::Microsoft::Terminal::Control::TermControl _control{ nullptr };
|
||||
TerminalApp::Tab _controlTab{ nullptr };
|
||||
@ -343,27 +339,26 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
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;
|
||||
std::unordered_map<int64_t, AttachedPane> _attachedPanes;
|
||||
std::unordered_map<int64_t, winrt::com_ptr<Tab>> _attachedWindows;
|
||||
std::unordered_map<int64_t, std::wstring> _outputBacklog;
|
||||
|
||||
int _sessionId{ -1 };
|
||||
int64_t _sessionId{ -1 };
|
||||
|
||||
int _terminalWidth{ 0 };
|
||||
int _terminalHeight{ 0 };
|
||||
til::CoordType _terminalWidth{ 0 };
|
||||
til::CoordType _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 };
|
||||
std::pair<std::shared_ptr<Pane>, winrt::Microsoft::Terminal::Settings::Model::SplitDirection> _splittingPane{ nullptr, winrt::Microsoft::Terminal::Settings::Model::SplitDirection::Right };
|
||||
|
||||
int _activePaneId{ -1 };
|
||||
int _activeWindowId{ -1 };
|
||||
int64_t _activePaneId{ -1 };
|
||||
int64_t _activeWindowId{ -1 };
|
||||
|
||||
std::function<void(const std::wstring_view string)> _Print;
|
||||
bool _inUse{ false };
|
||||
std::mutex _inUseMutex;
|
||||
std::atomic<bool> _inUse{ false };
|
||||
};
|
||||
}
|
||||
|
||||
@ -142,6 +142,20 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
auto pfnWindowSizeChanged = [this](auto&& PH1, auto&& PH2) { _terminalWindowSizeChanged(std::forward<decltype(PH1)>(PH1), std::forward<decltype(PH2)>(PH2)); };
|
||||
_terminal->SetWindowSizeChangedCallback(pfnWindowSizeChanged);
|
||||
|
||||
_terminal->SetEnterTmuxControlCallback([this]() -> std::function<bool(wchar_t)> {
|
||||
const auto args = winrt::make_self<EnterTmuxControlEventArgs>();
|
||||
EnterTmuxControl.raise(*this, *args);
|
||||
if (auto inputCallback = args->InputCallback())
|
||||
{
|
||||
return [inputCallback = std::move(inputCallback)](wchar_t ch) -> bool {
|
||||
const auto c16 = static_cast<char16_t>(ch);
|
||||
inputCallback({ &c16, 1 });
|
||||
return true;
|
||||
};
|
||||
}
|
||||
return nullptr;
|
||||
});
|
||||
|
||||
// MSFT 33353327: Initialize the renderer in the ctor instead of Initialize().
|
||||
// We need the renderer to be ready to accept new engines before the SwapChainPanel is ready to go.
|
||||
// If we wait, a screen reader may try to get the AutomationPeer (aka the UIA Engine), and we won't be able to attach
|
||||
@ -1565,6 +1579,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
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.
|
||||
@ -2928,9 +2943,4 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
{
|
||||
_terminal->PreviewText(input);
|
||||
}
|
||||
|
||||
void ControlCore::SetTmuxControlHandlerProducer(ITermDispatch::StringHandlerProducer producer)
|
||||
{
|
||||
_terminal->SetTmuxControlHandlerProducer(producer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,8 +41,6 @@ namespace ControlUnitTests
|
||||
class ControlInteractivityTests;
|
||||
};
|
||||
|
||||
using Microsoft::Console::VirtualTerminal::ITermDispatch;
|
||||
|
||||
#define RUNTIME_SETTING(type, name, setting) \
|
||||
private: \
|
||||
std::optional<type> _runtime##name{ std::nullopt }; \
|
||||
@ -268,7 +266,6 @@ 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());
|
||||
@ -300,10 +297,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
til::typed_event<IInspectable, Control::SearchMissingCommandEventArgs> SearchMissingCommand;
|
||||
til::typed_event<> RefreshQuickFixUI;
|
||||
til::typed_event<IInspectable, Control::WindowSizeChangedEventArgs> WindowSizeChanged;
|
||||
|
||||
til::typed_event<IInspectable, Control::EnterTmuxControlEventArgs> EnterTmuxControl;
|
||||
til::typed_event<> CloseTerminalRequested;
|
||||
til::typed_event<> RestartTerminalRequested;
|
||||
|
||||
til::typed_event<> Attached;
|
||||
// clang-format on
|
||||
|
||||
@ -466,7 +462,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
friend class ControlUnitTests::ControlInteractivityTests;
|
||||
bool _inUnitTests{ false };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Control::factory_implementation
|
||||
|
||||
@ -187,7 +187,6 @@ namespace Microsoft.Terminal.Control
|
||||
Boolean ShouldShowSelectOutput();
|
||||
|
||||
void OpenCWD();
|
||||
void SetTmuxControlHandlerProducer(TmuxDCSHandlerProducer producer);
|
||||
|
||||
void ClearQuickFix();
|
||||
|
||||
@ -203,6 +202,7 @@ namespace Microsoft.Terminal.Control
|
||||
event Windows.Foundation.TypedEventHandler<Object, SearchMissingCommandEventArgs> SearchMissingCommand;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> RefreshQuickFixUI;
|
||||
event Windows.Foundation.TypedEventHandler<Object, WindowSizeChangedEventArgs> WindowSizeChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, EnterTmuxControlEventArgs> EnterTmuxControl;
|
||||
|
||||
// These events are always called from the UI thread (bugs aside)
|
||||
event Windows.Foundation.TypedEventHandler<Object, FontSizeChangedArgs> FontSizeChanged;
|
||||
|
||||
@ -21,3 +21,4 @@
|
||||
#include "StringSentEventArgs.g.cpp"
|
||||
#include "SearchMissingCommandEventArgs.g.cpp"
|
||||
#include "WindowSizeChangedEventArgs.g.cpp"
|
||||
#include "EnterTmuxControlEventArgs.g.cpp"
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include "StringSentEventArgs.g.h"
|
||||
#include "SearchMissingCommandEventArgs.g.h"
|
||||
#include "WindowSizeChangedEventArgs.g.h"
|
||||
#include "EnterTmuxControlEventArgs.g.h"
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
{
|
||||
@ -265,6 +266,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
WINRT_PROPERTY(int32_t, Width);
|
||||
WINRT_PROPERTY(int32_t, Height);
|
||||
};
|
||||
|
||||
struct EnterTmuxControlEventArgs : public EnterTmuxControlEventArgsT<EnterTmuxControlEventArgs>
|
||||
{
|
||||
til::property<TmuxControlInputCallback> InputCallback;
|
||||
};
|
||||
}
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Control::factory_implementation
|
||||
|
||||
@ -159,4 +159,11 @@ namespace Microsoft.Terminal.Control
|
||||
Int32 Width;
|
||||
Int32 Height;
|
||||
}
|
||||
|
||||
delegate void TmuxControlInputCallback(Char[] input);
|
||||
|
||||
runtimeclass EnterTmuxControlEventArgs
|
||||
{
|
||||
void InputCallback(TmuxControlInputCallback callback);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1423,11 +1423,6 @@ 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;
|
||||
}
|
||||
|
||||
@ -4092,8 +4087,4 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
_core.ForceCursorVisible(cursorVisibility == CursorDisplayState::Shown);
|
||||
}
|
||||
}
|
||||
void TermControl::SetTmuxControlHandlerProducer(winrt::Microsoft::Terminal::Control::TmuxDCSHandlerProducer producer)
|
||||
{
|
||||
_tmuxDCSHandlerProducer = producer;
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,7 +120,6 @@ 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);
|
||||
@ -233,6 +232,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
BUBBLED_FORWARDED_TYPED_EVENT(RestartTerminalRequested, IInspectable, IInspectable);
|
||||
BUBBLED_FORWARDED_TYPED_EVENT(WriteToClipboard, IInspectable, Control::WriteToClipboardEventArgs);
|
||||
BUBBLED_FORWARDED_TYPED_EVENT(PasteFromClipboard, IInspectable, Control::PasteFromClipboardEventArgs);
|
||||
BUBBLED_FORWARDED_TYPED_EVENT(EnterTmuxControl, IInspectable, Control::EnterTmuxControlEventArgs);
|
||||
|
||||
// clang-format on
|
||||
|
||||
@ -256,7 +256,6 @@ 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
|
||||
{
|
||||
|
||||
@ -74,6 +74,7 @@ namespace Microsoft.Terminal.Control
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> ReadOnlyChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> FocusFollowMouseRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, WindowSizeChangedEventArgs> WindowSizeChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, EnterTmuxControlEventArgs> EnterTmuxControl;
|
||||
|
||||
event Windows.Foundation.TypedEventHandler<Object, CompletionsChangedEventArgs> CompletionsChanged;
|
||||
|
||||
@ -166,6 +167,5 @@ namespace Microsoft.Terminal.Control
|
||||
void ClearQuickFix();
|
||||
|
||||
void Detach();
|
||||
void SetTmuxControlHandlerProducer(TmuxDCSHandlerProducer producer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,12 +253,6 @@ 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);
|
||||
@ -1276,6 +1270,11 @@ void Microsoft::Terminal::Core::Terminal::SetSearchMissingCommandCallback(std::f
|
||||
_pfnSearchMissingCommand.swap(pfn);
|
||||
}
|
||||
|
||||
void Terminal::SetEnterTmuxControlCallback(std::function<std::function<bool(wchar_t)>()> pfn) noexcept
|
||||
{
|
||||
_pfnEnterTmuxControl = std::move(pfn);
|
||||
}
|
||||
|
||||
void Microsoft::Terminal::Core::Terminal::SetClearQuickFixCallback(std::function<void()> pfn) noexcept
|
||||
{
|
||||
_pfnClearQuickFix.swap(pfn);
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
#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>
|
||||
@ -129,7 +128,6 @@ 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
|
||||
@ -155,14 +153,12 @@ public:
|
||||
void ShowWindow(bool showOrHide) override;
|
||||
void UseAlternateScreenBuffer(const TextAttribute& attrs) override;
|
||||
void UseMainScreenBuffer() override;
|
||||
|
||||
bool IsVtInputEnabled() const noexcept override;
|
||||
void NotifyBufferRotation(const int delta) override;
|
||||
void NotifyShellIntegrationMark() override;
|
||||
|
||||
void InvokeCompletions(std::wstring_view menuJson, unsigned int replaceLength) override;
|
||||
|
||||
void SearchMissingCommand(const std::wstring_view command) override;
|
||||
std::function<bool(wchar_t)> EnterTmuxControl() override;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
@ -232,6 +228,7 @@ public:
|
||||
void SetPlayMidiNoteCallback(std::function<void(const int, const int, const std::chrono::microseconds)> pfn) noexcept;
|
||||
void CompletionsChangedCallback(std::function<void(std::wstring_view, unsigned int)> pfn) noexcept;
|
||||
void SetSearchMissingCommandCallback(std::function<void(std::wstring_view, const til::CoordType)> pfn) noexcept;
|
||||
void SetEnterTmuxControlCallback(std::function<std::function<bool(wchar_t)>()> pfn) noexcept;
|
||||
void SetClearQuickFixCallback(std::function<void()> pfn) noexcept;
|
||||
void SetWindowSizeChangedCallback(std::function<void(int32_t, int32_t)> pfn) noexcept;
|
||||
void SetSearchHighlights(const std::vector<til::point_span>& highlights) noexcept;
|
||||
@ -340,6 +337,7 @@ private:
|
||||
std::function<void(const int, const int, const std::chrono::microseconds)> _pfnPlayMidiNote;
|
||||
std::function<void(std::wstring_view, unsigned int)> _pfnCompletionsChanged;
|
||||
std::function<void(std::wstring_view, const til::CoordType)> _pfnSearchMissingCommand;
|
||||
std::function<std::function<bool(wchar_t)>()> _pfnEnterTmuxControl;
|
||||
std::function<void()> _pfnClearQuickFix;
|
||||
std::function<void(int32_t, int32_t)> _pfnWindowSizeChanged;
|
||||
|
||||
|
||||
@ -364,6 +364,11 @@ void Terminal::SearchMissingCommand(const std::wstring_view command)
|
||||
}
|
||||
}
|
||||
|
||||
std::function<bool(wchar_t)> Terminal::EnterTmuxControl()
|
||||
{
|
||||
return _pfnEnterTmuxControl ? _pfnEnterTmuxControl() : nullptr;
|
||||
}
|
||||
|
||||
void Terminal::NotifyBufferRotation(const int delta)
|
||||
{
|
||||
// Update our selection, so it doesn't move as the buffer is cycled
|
||||
|
||||
@ -427,7 +427,14 @@ void ConhostInternalGetSet::InvokeCompletions(std::wstring_view /*menuJson*/, un
|
||||
{
|
||||
// Not implemented for conhost.
|
||||
}
|
||||
|
||||
void ConhostInternalGetSet::SearchMissingCommand(std::wstring_view /*missingCommand*/)
|
||||
{
|
||||
// Not implemented for conhost.
|
||||
}
|
||||
|
||||
std::function<bool(wchar_t)> ConhostInternalGetSet::EnterTmuxControl()
|
||||
{
|
||||
// Not implemented for conhost.
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -71,6 +71,7 @@ public:
|
||||
void InvokeCompletions(std::wstring_view menuJson, unsigned int replaceLength) override;
|
||||
|
||||
void SearchMissingCommand(std::wstring_view missingCommand) override;
|
||||
std::function<bool(wchar_t)> EnterTmuxControl() override;
|
||||
|
||||
private:
|
||||
Microsoft::Console::IIoProvider& _io;
|
||||
|
||||
@ -24,9 +24,6 @@ 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
|
||||
{
|
||||
@ -197,7 +194,6 @@ public:
|
||||
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)
|
||||
|
||||
@ -90,5 +90,6 @@ namespace Microsoft::Console::VirtualTerminal
|
||||
virtual void InvokeCompletions(std::wstring_view menuJson, unsigned int replaceLength) = 0;
|
||||
|
||||
virtual void SearchMissingCommand(const std::wstring_view command) = 0;
|
||||
virtual std::function<bool(wchar_t)> EnterTmuxControl() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
@ -4767,20 +4767,5 @@ ITermDispatch::StringHandler AdaptDispatch::EnterTmuxControl(const VTParameters
|
||||
{
|
||||
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;
|
||||
return _api.EnterTmuxControl();
|
||||
}
|
||||
|
||||
@ -191,7 +191,6 @@ 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
|
||||
@ -330,7 +329,6 @@ 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,
|
||||
|
||||
@ -181,7 +181,6 @@ public:
|
||||
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
|
||||
|
||||
@ -224,6 +224,12 @@ public:
|
||||
Log::Comment(L"SearchMissingCommand MOCK called...");
|
||||
}
|
||||
|
||||
std::function<bool(wchar_t)> EnterTmuxControl() override
|
||||
{
|
||||
Log::Comment(L"EnterTmuxControl MOCK called...");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void PrepData()
|
||||
{
|
||||
PrepData(CursorDirection::UP); // if called like this, the cursor direction doesn't matter.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user