Skip to content

Commit

Permalink
It was at this point that I realized how fucked I was
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Aug 17, 2022
1 parent a3d3389 commit e1bd3e9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Pane::Pane(const Profile& profile, const TermControl& control, const bool lastFo

_connectionStateChangedToken = _control.ConnectionStateChanged({ this, &Pane::_ControlConnectionStateChangedHandler });
_warningBellToken = _control.WarningBell({ this, &Pane::_ControlWarningBellHandler });
_triggerHitToken = _control.TriggerHit({ this, &Pane::_ControlTriggerHitHandler });

// On the first Pane's creation, lookup resources we'll use to theme the
// Pane, including the brushed to use for the focused/unfocused border
Expand Down Expand Up @@ -1138,6 +1139,21 @@ void Pane::_ControlWarningBellHandler(const winrt::Windows::Foundation::IInspect
}
}

void Pane::_ControlTriggerHitHandler(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const winrt::Microsoft::Terminal::Control::TriggerHitArgs& eventArgs)
{
if (!_IsLeaf())
{
return;
}
if (_profile)
{
auto triggers = _profile.Triggers();
auto trigger = triggers.GetAt(eventArgs.Index());
auto action = trigger.EvaluateMatch(eventArgs.Matches(), nullptr);
}
}

// Event Description:
// - Called when our control gains focus. We'll use this to trigger our GotFocus
// callback. The tab that's hosting us should have registered a callback which
Expand Down Expand Up @@ -1586,6 +1602,7 @@ void Pane::_CloseChild(const bool closeFirst, const bool isDetaching)
// Add our new event handler before revoking the old one.
_connectionStateChangedToken = _control.ConnectionStateChanged({ this, &Pane::_ControlConnectionStateChangedHandler });
_warningBellToken = _control.WarningBell({ this, &Pane::_ControlWarningBellHandler });
_triggerHitToken = _control.TriggerHit({ this, &Pane::_ControlTriggerHitHandler });

// Revoke the old event handlers. Remove both the handlers for the panes
// themselves closing, and remove their handlers for their controls
Expand All @@ -1601,6 +1618,7 @@ void Pane::_CloseChild(const bool closeFirst, const bool isDetaching)
{
p->_control.ConnectionStateChanged(p->_connectionStateChangedToken);
p->_control.WarningBell(p->_warningBellToken);
p->_control.TriggerHit(p->_triggerHitToken);
}
});
}
Expand All @@ -1609,6 +1627,7 @@ void Pane::_CloseChild(const bool closeFirst, const bool isDetaching)
remainingChild->Closed(remainingChildClosedToken);
remainingChild->_control.ConnectionStateChanged(remainingChild->_connectionStateChangedToken);
remainingChild->_control.WarningBell(remainingChild->_warningBellToken);
remainingChild->_control.TriggerHit(remainingChild->_triggerHitToken);

// If we or either of our children was focused, we want to take that
// focus from them.
Expand Down Expand Up @@ -1690,6 +1709,7 @@ void Pane::_CloseChild(const bool closeFirst, const bool isDetaching)
{
p->_control.ConnectionStateChanged(p->_connectionStateChangedToken);
p->_control.WarningBell(p->_warningBellToken);
p->_control.TriggerHit(p->_triggerHitToken);
}
});
}
Expand Down Expand Up @@ -2445,6 +2465,8 @@ std::pair<std::shared_ptr<Pane>, std::shared_ptr<Pane>> Pane::_Split(SplitDirect
_connectionStateChangedToken.value = 0;
_control.WarningBell(_warningBellToken);
_warningBellToken.value = 0;
_control.TriggerHit(_triggerHitToken);
_triggerHitToken.value = 0;

// Remove our old GotFocus handler from the control. We don't want the
// control telling us that it's now focused, we want it telling its new
Expand Down
4 changes: 4 additions & 0 deletions src/cascadia/TerminalApp/Pane.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class Pane : public std::enable_shared_from_this<Pane>
WINRT_CALLBACK(LostFocus, winrt::delegate<std::shared_ptr<Pane>>);
WINRT_CALLBACK(PaneRaiseBell, winrt::Windows::Foundation::EventHandler<bool>);
WINRT_CALLBACK(Detached, winrt::delegate<std::shared_ptr<Pane>>);
WINRT_CALLBACK(TriggerAction, winrt::delegate<std::shared_ptr<Pane>>);

private:
struct PanePoint;
Expand Down Expand Up @@ -236,6 +237,7 @@ class Pane : public std::enable_shared_from_this<Pane>
winrt::event_token _firstClosedToken{ 0 };
winrt::event_token _secondClosedToken{ 0 };
winrt::event_token _warningBellToken{ 0 };
winrt::event_token _triggerHitToken{ 0 };

winrt::Windows::UI::Xaml::UIElement::GotFocus_revoker _gotFocusRevoker;
winrt::Windows::UI::Xaml::UIElement::LostFocus_revoker _lostFocusRevoker;
Expand Down Expand Up @@ -289,6 +291,8 @@ class Pane : public std::enable_shared_from_this<Pane>
const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
void _ControlLostFocusHandler(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::UI::Xaml::RoutedEventArgs& e);
void _ControlTriggerHitHandler(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Microsoft::Terminal::Control::TriggerHitArgs& e);

std::pair<float, float> _CalcChildrenSizes(const float fullSize) const;
SnapChildrenSizeResult _CalcSnappedChildrenSizes(const bool widthOrHeight, const float fullSize) const;
Expand Down

0 comments on commit e1bd3e9

Please sign in to comment.