mirror of
https://github.com/microsoft/terminal.git
synced 2026-02-04 05:35:20 +00:00
this isn't the dumbest
This commit is contained in:
@@ -2866,22 +2866,6 @@ namespace winrt::TerminalApp::implementation
|
||||
// - Paste text from the Windows Clipboard to the focused terminal
|
||||
void TerminalPage::_PasteText()
|
||||
{
|
||||
// First, check if we're in broadcast input mode. If so, let's tell all
|
||||
// the controls to paste.
|
||||
if (const auto& tab{ _GetFocusedTabImpl() })
|
||||
{
|
||||
if (tab->TabStatus().IsInputBroadcastActive())
|
||||
{
|
||||
tab->GetRootPane()->WalkTree([](auto&& pane) {
|
||||
if (auto control = pane->GetTerminalControl())
|
||||
{
|
||||
control.PasteTextFromClipboard();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// The focused tab wasn't in broadcast mode. No matter. Just ask the
|
||||
// current one to paste.
|
||||
if (const auto& control{ _GetActiveControl() })
|
||||
|
||||
@@ -95,6 +95,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
_revokers.interactivityOpenHyperlink = _interactivity.OpenHyperlink(winrt::auto_revoke, { get_weak(), &TermControl::_HyperlinkHandler });
|
||||
_revokers.interactivityScrollPositionChanged = _interactivity.ScrollPositionChanged(winrt::auto_revoke, { get_weak(), &TermControl::_ScrollPositionChanged });
|
||||
_revokers.ContextMenuRequested = _interactivity.ContextMenuRequested(winrt::auto_revoke, { get_weak(), &TermControl::_contextMenuHandler });
|
||||
_revokers.PasteFromClipboard = _interactivity.PasteFromClipboard(winrt::auto_revoke, { get_weak(), &TermControl::_customPasteFromClipboard });
|
||||
|
||||
// "Bubbled" events - ones we want to handle, by raising our own event.
|
||||
_revokers.CopyToClipboard = _core.CopyToClipboard(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleCopyToClipboard });
|
||||
@@ -107,8 +108,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
_revokers.CompletionsChanged = _core.CompletionsChanged(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleCompletionsChanged });
|
||||
_revokers.RestartTerminalRequested = _core.RestartTerminalRequested(winrt::auto_revoke, { get_weak(), &TermControl::_bubbleRestartTerminalRequested });
|
||||
|
||||
_revokers.PasteFromClipboard = _interactivity.PasteFromClipboard(winrt::auto_revoke, { get_weak(), &TermControl::_bubblePasteFromClipboard });
|
||||
|
||||
// Initialize the terminal only once the swapchainpanel is loaded - that
|
||||
// way, we'll be able to query the real pixel size it got on layout
|
||||
_layoutUpdatedRevoker = SwapChainPanel().LayoutUpdated(winrt::auto_revoke, [this](auto /*s*/, auto /*e*/) {
|
||||
@@ -2925,6 +2924,29 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
_core.PasteText(text);
|
||||
}
|
||||
|
||||
// Methog Description:
|
||||
// - Event handler for the interactivity's PasteFromClipboard event. This is
|
||||
// triggered when the control itself wants to ask for a paste. Think:
|
||||
// right-click-to-paste.
|
||||
// - Instead of just bubbling this up to the app for it to fill, we will
|
||||
// create a different event, with _our_ callback in it. That'll let us
|
||||
// call our _StringSentHandlers if required.
|
||||
void TermControl::_customPasteFromClipboard(const IInspectable&, const Control::PasteFromClipboardEventArgs& args)
|
||||
{
|
||||
// RELPACE the handler we were given with a new handler _we_ implemented.
|
||||
auto clipboardDataHandler = [weak = get_weak()](std::wstring_view text) {
|
||||
if (const auto control{ weak.get() })
|
||||
{
|
||||
control->_pasteTextWithBroadcast(winrt::hstring{ text });
|
||||
}
|
||||
};
|
||||
|
||||
// send paste event up to TermApp
|
||||
_PasteFromClipboardHandlers(*this,
|
||||
winrt::make<PasteFromClipboardEventArgs>(clipboardDataHandler,
|
||||
args.BracketedPasteEnabled()));
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Handle the DragOver event. We'll signal that the drag operation we
|
||||
// support is the "copy" operation, and we'll also customize the
|
||||
|
||||
@@ -180,8 +180,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
BUBBLED_FORWARDED_TYPED_EVENT(CompletionsChanged, IInspectable, Control::CompletionsChangedEventArgs);
|
||||
BUBBLED_FORWARDED_TYPED_EVENT(RestartTerminalRequested, IInspectable, IInspectable);
|
||||
|
||||
BUBBLED_FORWARDED_TYPED_EVENT(PasteFromClipboard, IInspectable, Control::PasteFromClipboardEventArgs);
|
||||
|
||||
TYPED_EVENT(PasteFromClipboard, IInspectable, Control::PasteFromClipboardEventArgs);
|
||||
TYPED_EVENT(OpenHyperlink, IInspectable, Control::OpenHyperlinkEventArgs);
|
||||
TYPED_EVENT(RaiseNotice, IInspectable, Control::NoticeEventArgs);
|
||||
TYPED_EVENT(HidePointerCursor, IInspectable, IInspectable);
|
||||
@@ -380,6 +380,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
void _SelectOutputHandler(const IInspectable& sender, const IInspectable& args);
|
||||
bool _displayCursorWhileBlurred() const noexcept;
|
||||
|
||||
void _customPasteFromClipboard(const IInspectable&, const Control::PasteFromClipboardEventArgs& args);
|
||||
|
||||
struct Revokers
|
||||
{
|
||||
Control::ControlCore::ScrollPositionChanged_revoker coreScrollPositionChanged;
|
||||
|
||||
Reference in New Issue
Block a user