mirror of
https://github.com/microsoft/terminal.git
synced 2026-04-06 14:19:45 +00:00
Compare commits
7 Commits
dev/lhecke
...
dev/migrie
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35aba0cdc1 | ||
|
|
8cdd3f069f | ||
|
|
e66f904c01 | ||
|
|
2d8aa850d7 | ||
|
|
07342f5c77 | ||
|
|
53a6e73582 | ||
|
|
49f967af54 |
@@ -2518,6 +2518,7 @@ std::pair<std::shared_ptr<Pane>, std::shared_ptr<Pane>> Pane::_Split(SplitDirect
|
||||
_profile = nullptr;
|
||||
_control = { nullptr };
|
||||
_firstChild->_isDefTermSession = _isDefTermSession;
|
||||
_firstChild->_broadcastEnabled = _broadcastEnabled;
|
||||
}
|
||||
|
||||
_splitState = actualSplitType;
|
||||
@@ -3173,6 +3174,9 @@ void Pane::EnableBroadcast(bool enabled)
|
||||
if (_IsLeaf())
|
||||
{
|
||||
_broadcastEnabled = enabled;
|
||||
_control.CursorVisibility(enabled ?
|
||||
CursorDisplayState::Shown :
|
||||
CursorDisplayState::Default);
|
||||
UpdateVisuals();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -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() })
|
||||
@@ -4698,6 +4682,21 @@ namespace winrt::TerminalApp::implementation
|
||||
// the settings, change active panes, etc.
|
||||
_activated = activated;
|
||||
_updateThemeColors();
|
||||
|
||||
if (const auto& tab{ _GetFocusedTabImpl() })
|
||||
{
|
||||
if (tab->TabStatus().IsInputBroadcastActive())
|
||||
{
|
||||
tab->GetRootPane()->WalkTree([activated](const auto& p) {
|
||||
if (const auto& control{ p->GetTerminalControl() })
|
||||
{
|
||||
control.CursorVisibility(activated ?
|
||||
Microsoft::Terminal::Control::CursorDisplayState::Shown :
|
||||
Microsoft::Terminal::Control::CursorDisplayState::Default);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
winrt::fire_and_forget TerminalPage::_ControlCompletionsChangedHandler(const IInspectable sender,
|
||||
|
||||
@@ -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*/) {
|
||||
@@ -1051,8 +1050,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// _cursorTimer doesn't exist, and it would never turn on the
|
||||
// cursor. To mitigate, we'll initialize the cursor's 'on' state
|
||||
// with `_focused` here.
|
||||
_core.CursorOn(_focused || DisplayCursorWhileBlurred);
|
||||
if (DisplayCursorWhileBlurred)
|
||||
_core.CursorOn(_focused || _displayCursorWhileBlurred());
|
||||
if (_displayCursorWhileBlurred())
|
||||
{
|
||||
_cursorTimer->Start();
|
||||
}
|
||||
@@ -1968,7 +1967,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
TSFInputControl().NotifyFocusLeave();
|
||||
}
|
||||
|
||||
if (_cursorTimer && !DisplayCursorWhileBlurred)
|
||||
if (_cursorTimer && !_displayCursorWhileBlurred())
|
||||
{
|
||||
_cursorTimer->Stop();
|
||||
_core.CursorOn(false);
|
||||
@@ -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
|
||||
@@ -3660,4 +3682,45 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
SelectionContextMenu().Hide();
|
||||
_core.ContextMenuSelectOutput();
|
||||
}
|
||||
|
||||
// Should the text cursor be displayed, even when the control isn't focused?
|
||||
// n.b. "blur" is the opposite of "focus".
|
||||
bool TermControl::_displayCursorWhileBlurred() const noexcept
|
||||
{
|
||||
return CursorVisibility() == Control::CursorDisplayState::Shown;
|
||||
}
|
||||
Control::CursorDisplayState TermControl::CursorVisibility() const noexcept
|
||||
{
|
||||
return _cursorVisibility;
|
||||
}
|
||||
void TermControl::CursorVisibility(Control::CursorDisplayState cursorVisibility)
|
||||
{
|
||||
_cursorVisibility = cursorVisibility;
|
||||
if (!_initializedTerminal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_displayCursorWhileBlurred())
|
||||
{
|
||||
// If we should be ALWAYS displaying the cursor, turn it on and start blinking.
|
||||
_core.CursorOn(true);
|
||||
if (_cursorTimer.has_value())
|
||||
{
|
||||
_cursorTimer->Start();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, if we're unfocused, then turn the cursor off and stop
|
||||
// blinking. (if we're focused, then we're already doing the right
|
||||
// thing)
|
||||
const auto focused = FocusState() != FocusState::Unfocused;
|
||||
if (!focused && _cursorTimer.has_value())
|
||||
{
|
||||
_cursorTimer->Stop();
|
||||
}
|
||||
_core.CursorOn(focused);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,6 +160,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
TerminalConnection::ITerminalConnection Connection();
|
||||
void Connection(const TerminalConnection::ITerminalConnection& connection);
|
||||
|
||||
Control::CursorDisplayState CursorVisibility() const noexcept;
|
||||
void CursorVisibility(Control::CursorDisplayState cursorVisibility);
|
||||
|
||||
// -------------------------------- WinRT Events ---------------------------------
|
||||
// clang-format off
|
||||
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
|
||||
@@ -177,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);
|
||||
@@ -194,9 +197,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Xaml::Media::Brush, BackgroundBrush, _PropertyChangedHandlers, nullptr);
|
||||
|
||||
public:
|
||||
til::property<bool> DisplayCursorWhileBlurred{ false };
|
||||
|
||||
private:
|
||||
friend struct TermControlT<TermControl>; // friend our parent so it can bind private event handlers
|
||||
|
||||
@@ -258,6 +258,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
Windows::Foundation::Collections::IObservableVector<Windows::UI::Xaml::Controls::ICommandBarElement> _originalSelectedPrimaryElements{ nullptr };
|
||||
Windows::Foundation::Collections::IObservableVector<Windows::UI::Xaml::Controls::ICommandBarElement> _originalSelectedSecondaryElements{ nullptr };
|
||||
|
||||
Control::CursorDisplayState _cursorVisibility{ Control::CursorDisplayState::Default };
|
||||
|
||||
inline bool _IsClosing() const noexcept
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
@@ -376,6 +378,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
void _SelectCommandHandler(const IInspectable& sender, const IInspectable& args);
|
||||
void _SelectOutputHandler(const IInspectable& sender, const IInspectable& args);
|
||||
bool _displayCursorWhileBlurred() const noexcept;
|
||||
|
||||
void _customPasteFromClipboard(const IInspectable&, const Control::PasteFromClipboardEventArgs& args);
|
||||
|
||||
struct Revokers
|
||||
{
|
||||
|
||||
@@ -12,6 +12,12 @@ import "ControlCore.idl";
|
||||
namespace Microsoft.Terminal.Control
|
||||
{
|
||||
|
||||
enum CursorDisplayState
|
||||
{
|
||||
Default,
|
||||
Shown
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass TermControl : Windows.UI.Xaml.Controls.UserControl,
|
||||
IDirectKeyListener,
|
||||
IMouseWheelListener,
|
||||
@@ -121,7 +127,7 @@ namespace Microsoft.Terminal.Control
|
||||
// opacity set by the settings should call this instead.
|
||||
Double BackgroundOpacity { get; };
|
||||
|
||||
Boolean DisplayCursorWhileBlurred;
|
||||
CursorDisplayState CursorVisibility;
|
||||
|
||||
Windows.UI.Xaml.Media.Brush BackgroundBrush { get; };
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
_previewControl = Control::TermControl(settings, settings, *_previewConnection);
|
||||
_previewControl.IsEnabled(false);
|
||||
_previewControl.AllowFocusWhenDisabled(false);
|
||||
_previewControl.DisplayCursorWhileBlurred(true);
|
||||
_previewControl.CursorVisibility(Microsoft::Terminal::Control::CursorDisplayState::Shown);
|
||||
ControlPreview().Child(_previewControl);
|
||||
}
|
||||
|
||||
|
||||
@@ -436,6 +436,7 @@
|
||||
{ "command": { "action": "swapPane", "direction": "previousInOrder"} },
|
||||
{ "command": { "action": "swapPane", "direction": "nextInOrder"} },
|
||||
{ "command": { "action": "swapPane", "direction": "first" } },
|
||||
{ "command": "toggleBroadcastInput" },
|
||||
{ "command": "togglePaneZoom" },
|
||||
{ "command": "toggleSplitOrientation" },
|
||||
{ "command": "toggleReadOnlyMode" },
|
||||
|
||||
Reference in New Issue
Block a user