From 888e1572d2bc2f3c2ee513f76f761bf58e2c9172 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 20 Oct 2021 16:33:22 -0500 Subject: [PATCH] more cleanup, 5 todo!s left --- .../TerminalApp/ActionPreviewHandlers.cpp | 90 +++++++++---------- src/cascadia/TerminalControl/ControlCore.cpp | 9 -- src/cascadia/TerminalControl/ControlCore.h | 2 - src/cascadia/TerminalControl/TermControl.cpp | 19 ++-- src/cascadia/TerminalControl/TermControl.h | 6 +- src/cascadia/TerminalControl/TermControl.idl | 1 - 6 files changed, 57 insertions(+), 70 deletions(-) diff --git a/src/cascadia/TerminalApp/ActionPreviewHandlers.cpp b/src/cascadia/TerminalApp/ActionPreviewHandlers.cpp index 96c9bd814..0b8e9d6bc 100644 --- a/src/cascadia/TerminalApp/ActionPreviewHandlers.cpp +++ b/src/cascadia/TerminalApp/ActionPreviewHandlers.cpp @@ -94,56 +94,56 @@ namespace winrt::TerminalApp::implementation // the preview color changes, we only need to be able to restore the last one. _restorePreviewFuncs.clear(); - _ApplyToActiveControls([&](const auto& control) { - // Get the settings of the focused control and stash them - const auto& controlSettings = control.Settings().as(); - // Make sure to recurse up to the root - if you're doing - // this while you're currently previewing a SetColorScheme - // action, then the parent of the control's settings is _the - // last preview TerminalSettings we inserted! We don't want - // to save that one! - auto originalSettings = controlSettings.GetParent(); - while (originalSettings.GetParent() != nullptr) - { - originalSettings = originalSettings.GetParent(); - } - // Create a new child for those settings - TerminalSettingsCreateResult fake{ originalSettings }; - const auto& childStruct = TerminalSettings::CreateWithParent(fake); - // Modify the child to have the applied color scheme - childStruct.DefaultSettings().ApplyColorScheme(scheme); + _ApplyToActiveControls([&](const auto& /*control*/) { + // // Get the settings of the focused control and stash them + // const auto& controlSettings = control.Settings().as(); + // // Make sure to recurse up to the root - if you're doing + // // this while you're currently previewing a SetColorScheme + // // action, then the parent of the control's settings is _the + // // last preview TerminalSettings we inserted! We don't want + // // to save that one! + // auto originalSettings = controlSettings.GetParent(); + // while (originalSettings.GetParent() != nullptr) + // { + // originalSettings = originalSettings.GetParent(); + // } + // // Create a new child for those settings + // TerminalSettingsCreateResult fake{ originalSettings }; + // const auto& childStruct = TerminalSettings::CreateWithParent(fake); + // // Modify the child to have the applied color scheme + // childStruct.DefaultSettings().ApplyColorScheme(scheme); - // Insert that new child as the parent of the control's settings - controlSettings.SetParent(childStruct.DefaultSettings()); - control.UpdateControlSettings(controlSettings); + // // Insert that new child as the parent of the control's settings + // controlSettings.SetParent(childStruct.DefaultSettings()); + // control.UpdateControlSettings(controlSettings); - // Take a copy of the inputs, since they are pointers anyways. - _restorePreviewFuncs.emplace_back([=]() { - //// Get the runtime settings of the focused control - //const auto& controlSettings{ control.Settings().as() }; + // // Take a copy of the inputs, since they are pointers anyways. + // _restorePreviewFuncs.emplace_back([=]() { + // //// Get the runtime settings of the focused control + // //const auto& controlSettings{ control.Settings().as() }; - //// Get the control's root settings, the ones that we actually - //// assigned to it. - //auto parentSettings{ controlSettings.GetParent() }; - //while (parentSettings.GetParent() != nullptr) - //{ - // parentSettings = parentSettings.GetParent(); - //} + // //// Get the control's root settings, the ones that we actually + // //// assigned to it. + // //auto parentSettings{ controlSettings.GetParent() }; + // //while (parentSettings.GetParent() != nullptr) + // //{ + // // parentSettings = parentSettings.GetParent(); + // //} - //// If the root settings are the same as the ones we stashed, - //// then reset the parent of the runtime settings to the stashed - //// settings. This condition might be false if the settings - //// hot-reloaded while the palette was open. In that case, we - //// don't want to reset the settings to what they were _before_ - //// the hot-reload. - //if (originalSettings == parentSettings) - //{ - // // Set the original settings as the parent of the control's settings - // control.Settings().as().SetParent(originalSettings); - //} + // //// If the root settings are the same as the ones we stashed, + // //// then reset the parent of the runtime settings to the stashed + // //// settings. This condition might be false if the settings + // //// hot-reloaded while the palette was open. In that case, we + // //// don't want to reset the settings to what they were _before_ + // //// the hot-reload. + // //if (originalSettings == parentSettings) + // //{ + // // // Set the original settings as the parent of the control's settings + // // control.Settings().as().SetParent(originalSettings); + // //} - control.UpdateControlSettings(control.Settings()); - }); + // control.UpdateControlSettings(control.Settings()); + // }); }); } } diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index 28feff697..700bb9db6 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -1310,15 +1310,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation } } - // void ControlCore::SetBackgroundOpacity(const double opacity) - // { - // if (_renderEngine) - // { - // auto lock = _terminal->LockForWriting(); - // _renderEngine->SetDefaultTextBackgroundOpacity(::base::saturated_cast(opacity)); - // } - // } - // Method Description: // - Asynchronously close our connection. The Connection will likely wait // until the attached process terminates before Close returns. If that's diff --git a/src/cascadia/TerminalControl/ControlCore.h b/src/cascadia/TerminalControl/ControlCore.h index e7dcf5b5b..e184ce347 100644 --- a/src/cascadia/TerminalControl/ControlCore.h +++ b/src/cascadia/TerminalControl/ControlCore.h @@ -58,7 +58,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation void UpdateSettings(const Control::IControlSettings& settings, const IControlAppearance& newAppearance); void ApplyAppearance(const bool& focused); - // void UpdateAppearance(const Control::IControlAppearance& newAppearance); Control::IControlSettings Settings() { auto l = std::unique_lock{ _settingsLock }; @@ -81,7 +80,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation uint16_t FontWeight() const noexcept; til::color BackgroundColor() const; - // void SetBackgroundOpacity(const double opacity); void SendInput(const winrt::hstring& wstr); void PasteText(const winrt::hstring& hstr); diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index d25bd972a..91805f1e0 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -281,8 +281,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation return; } - // _core.UpdateSettings(settings); // TODO! - // Update our control settings _ApplyUISettings(); } @@ -2362,15 +2360,20 @@ namespace winrt::Microsoft::Terminal::Control::implementation IControlSettings TermControl::Settings() const { - // TODO! maybe get rid of + // We still need this in a couple places: + // - Pane.cpp uses this for parsing out the StartingTitle, Commandline, + // etc for Pane::GetTerminalArgsForPane. + // - TerminalTab::_CreateToolTipTitle uses the ProfileName for the + // tooltip for the tab. + // + // These both happen on the UI thread right now. In the future, when we + // have to hop across the process boundary to get at the core settings, + // it may make sense to cache these values inside the TermControl + // itself, so it can do the hop once when it's first setup, rather than + // when it's needed by the UI thread. return _core.Settings(); } - IControlAppearance TermControl::UnfocusedAppearance() const - { - return _core.UnfocusedAppearance(); - } - Windows::Foundation::IReference TermControl::TabColor() noexcept { // NOTE TO FUTURE READERS: TabColor is down in the Core for the diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index 9c71262e8..e08b0455a 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -32,6 +32,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation winrt::fire_and_forget UpdateControlSettings(Control::IControlSettings settings); winrt::fire_and_forget UpdateControlSettings(Control::IControlSettings settings, Control::IControlAppearance unfocusedAppearance); + IControlSettings Settings() const; hstring GetProfileName() const; @@ -91,11 +92,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation Windows::UI::Xaml::Automation::Peers::AutomationPeer OnCreateAutomationPeer(); const Windows::UI::Xaml::Thickness GetPadding(); - IControlSettings Settings() const; - // void Settings(IControlSettings newSettings); - IControlAppearance UnfocusedAppearance() const; - // void UnfocusedAppearance(IControlAppearance newSettings); - static Windows::Foundation::Size GetProposedDimensions(IControlSettings const& settings, const uint32_t dpi); static Windows::Foundation::Size GetProposedDimensions(const winrt::Windows::Foundation::Size& initialSizeInChars, const int32_t& fontSize, diff --git a/src/cascadia/TerminalControl/TermControl.idl b/src/cascadia/TerminalControl/TermControl.idl index 8b9fb2dab..a87cdc8ed 100644 --- a/src/cascadia/TerminalControl/TermControl.idl +++ b/src/cascadia/TerminalControl/TermControl.idl @@ -26,7 +26,6 @@ namespace Microsoft.Terminal.Control void UpdateControlSettings(IControlSettings settings, IControlAppearance unfocusedAppearance); Microsoft.Terminal.Control.IControlSettings Settings { get; }; - Microsoft.Terminal.Control.IControlAppearance UnfocusedAppearance { get; }; event FontSizeChangedEventArgs FontSizeChanged; event Windows.Foundation.TypedEventHandler TitleChanged;