From 7fb7d64b91ce40f030bc43e97fa2e9408f759a7f Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 1 Sep 2021 16:38:58 -0500 Subject: [PATCH] These are things I might need for #997 --- src/cascadia/TerminalApp/Pane.cpp | 5 +++++ src/cascadia/TerminalApp/Pane.h | 1 + src/cascadia/TerminalApp/TerminalTab.cpp | 12 ++++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index f15ace73c6a..1cba51874af 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -1014,6 +1014,11 @@ TermControl Pane::GetTerminalControl() const return _IsLeaf() ? _control.try_as() : nullptr; } +Controls::UserControl Pane::GetUserControl() const +{ + return _IsLeaf() ? _control : nullptr; +} + // Method Description: // - Recursively remove the "Active" state from this Pane and all it's children. // - Updates our visuals to match our new state, including highlighting our borders. diff --git a/src/cascadia/TerminalApp/Pane.h b/src/cascadia/TerminalApp/Pane.h index 413dd8e64ad..ddafc8642d1 100644 --- a/src/cascadia/TerminalApp/Pane.h +++ b/src/cascadia/TerminalApp/Pane.h @@ -52,6 +52,7 @@ class Pane : public std::enable_shared_from_this const bool lastFocused = false); std::shared_ptr GetActivePane(); + winrt::Windows::UI::Xaml::Controls::UserControl GetUserControl() const; winrt::Microsoft::Terminal::Control::TermControl GetTerminalControl() const; winrt::Microsoft::Terminal::Settings::Model::Profile GetFocusedProfile(); diff --git a/src/cascadia/TerminalApp/TerminalTab.cpp b/src/cascadia/TerminalApp/TerminalTab.cpp index 3021d63651a..a84d0b1cd91 100644 --- a/src/cascadia/TerminalApp/TerminalTab.cpp +++ b/src/cascadia/TerminalApp/TerminalTab.cpp @@ -430,7 +430,10 @@ namespace winrt::TerminalApp::implementation winrt::fire_and_forget TerminalTab::Scroll(const int delta) { auto control = GetActiveTerminalControl(); - + if (!control) + { + co_return; + } co_await winrt::resume_foreground(control.Dispatcher()); const auto currentOffset = control.ScrollOffset(); @@ -1269,7 +1272,12 @@ namespace winrt::TerminalApp::implementation // - The tab's color, if any std::optional TerminalTab::GetTabColor() { - const auto currControlColor{ GetActiveTerminalControl().TabColor() }; + const auto& termControl{ GetActiveTerminalControl() }; + if (!termControl) + { + return std::nullopt; + } + const auto currControlColor{ termControl.TabColor() }; std::optional controlTabColor; if (currControlColor != nullptr) {