From 227ec3777a216613c3796991d9bc01db6d184d24 Mon Sep 17 00:00:00 2001 From: PankajBhojwani Date: Mon, 24 May 2021 15:51:03 -0700 Subject: [PATCH] Add a setting to flash the pane when BEL is emitted (#9270) ## Summary of the Pull Request Adds a new bellStyle called `window`. When `window` is set and a BEL is emitted, we flash the pane that emitted it. Additionally, changes bellStyle in the SUI to a list of checkboxes instead of radio buttons, to match bellStyle being a flag-enum. Deprecates 'BellStyle::Visual' in the schema, but still allows it to be set in the json (it maps to `Window | Taskbar`) ## References #6700 ## PR Checklist * [ ] Closes #xxx * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema updated. * [x] I work here ## Validation Steps Performed GIF in Teams --- doc/cascadia/profiles.schema.json | 8 +- src/cascadia/TerminalApp/Pane.cpp | 9 +- src/cascadia/TerminalControl/TermControl.cpp | 44 ++++++- src/cascadia/TerminalControl/TermControl.h | 7 ++ src/cascadia/TerminalControl/TermControl.idl | 2 + src/cascadia/TerminalControl/TermControl.xaml | 3 + .../TerminalControlLib.vcxproj | 7 ++ src/cascadia/TerminalControl/XamlLights.cpp | 107 ++++++++++++++++++ src/cascadia/TerminalControl/XamlLights.h | 49 ++++++++ src/cascadia/TerminalControl/XamlLights.idl | 13 +++ .../TerminalSettingsEditor/Profiles.cpp | 29 ++++- .../TerminalSettingsEditor/Profiles.h | 7 +- .../TerminalSettingsEditor/Profiles.idl | 8 +- .../TerminalSettingsEditor/Profiles.xaml | 11 +- .../Resources/en-US/Resources.resw | 7 ++ .../TerminalSettingsModel/EnumMappings.cpp | 1 - .../TerminalSettingsModel/EnumMappings.h | 1 - .../TerminalSettingsModel/EnumMappings.idl | 1 - .../TerminalSettingsModel/JsonUtils.h | 3 +- .../TerminalSettingsModel/Profile.idl | 4 +- .../TerminalSettingsSerializationHelpers.h | 6 +- 21 files changed, 305 insertions(+), 22 deletions(-) create mode 100644 src/cascadia/TerminalControl/XamlLights.cpp create mode 100644 src/cascadia/TerminalControl/XamlLights.h create mode 100644 src/cascadia/TerminalControl/XamlLights.idl diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 0604698dc..36eddccd2 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -37,7 +37,8 @@ "type": "string", "enum": [ "audible", - "visual" + "window", + "taskbar" ] } }, @@ -45,7 +46,8 @@ "type": "string", "enum": [ "audible", - "visual", + "taskbar", + "window", "all", "none" ] @@ -1194,7 +1196,7 @@ }, "bellStyle": { "default": "audible", - "description": "Controls what happens when the application emits a BEL character. When set to \"all\", the Terminal will play a sound and flash the taskbar icon. An array of specific behaviors can also be used. Supported array values include `audible` and `visual`. When set to \"none\", nothing will happen.", + "description": "Controls what happens when the application emits a BEL character. When set to \"all\", the Terminal will play a sound, flash the taskbar icon (if the terminal window is not in focus) and flash the window. An array of specific behaviors can also be used. Supported array values include `audible`, `window` and `taskbar`. When set to \"none\", nothing will happen.", "$ref": "#/definitions/BellStyle" }, "closeOnExit": { diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index 537a006b9..e875622de 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -378,8 +378,13 @@ void Pane::_ControlWarningBellHandler(const winrt::Windows::Foundation::IInspect PlaySound(soundAlias, NULL, SND_ALIAS_ID | SND_ASYNC | SND_SENTRY); } - // raise the event with the bool value corresponding to the visual flag - _PaneRaiseBellHandlers(nullptr, WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual)); + if (WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Window)) + { + _control.BellLightOn(); + } + + // raise the event with the bool value corresponding to the taskbar flag + _PaneRaiseBellHandlers(nullptr, WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Taskbar)); } } } diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 639c52c85..df458b539 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -58,7 +58,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation _lastAutoScrollUpdateTime{ std::nullopt }, _cursorTimer{}, _blinkTimer{}, - _searchBox{ nullptr } + _searchBox{ nullptr }, + _bellLightAnimation{ Window::Current().Compositor().CreateScalarKeyFrameAnimation() } { InitializeComponent(); @@ -167,6 +168,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation _autoScrollTimer.Interval(AutoScrollUpdateInterval); _autoScrollTimer.Tick({ this, &TermControl::_UpdateAutoScroll }); + // Add key frames and a duration to our bell light animation + _bellLightAnimation.InsertKeyFrame(0.0, 2.0); + _bellLightAnimation.InsertKeyFrame(1.0, 1.0); + _bellLightAnimation.Duration(winrt::Windows::Foundation::TimeSpan(std::chrono::milliseconds(TerminalWarningBellInterval))); + _ApplyUISettings(_settings); } @@ -2376,6 +2382,42 @@ namespace winrt::Microsoft::Terminal::Control::implementation return _core->TaskbarProgress(); } + void TermControl::BellLightOn() + { + Windows::Foundation::Numerics::float2 zeroSize{ 0, 0 }; + // If the grid has 0 size or if the bell timer is + // already active, do nothing + if (RootGrid().ActualSize() != zeroSize && !_bellLightTimer) + { + // Start the timer, when the timer ticks we switch off the light + DispatcherTimer invertTimer; + invertTimer.Interval(std::chrono::milliseconds(TerminalWarningBellInterval)); + invertTimer.Tick({ get_weak(), &TermControl::_BellLightOff }); + invertTimer.Start(); + _bellLightTimer.emplace(std::move(invertTimer)); + + // Switch on the light and animate the intensity to fade out + VisualBellLight::SetIsTarget(RootGrid(), true); + BellLight().CompositionLight().StartAnimation(L"Intensity", _bellLightAnimation); + } + } + + void TermControl::_BellLightOff(Windows::Foundation::IInspectable const& /* sender */, + Windows::Foundation::IInspectable const& /* e */) + { + if (_bellLightTimer) + { + // Stop the timer and switch off the light + _bellLightTimer->Stop(); + _bellLightTimer.reset(); + + if (!_closing) + { + VisualBellLight::SetIsTarget(RootGrid(), false); + } + } + } + // Method Description: // - Checks whether the control is in a read-only mode (in this mode node input is sent to connection). // Return Value: diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index 4ce2fe777..684ac3a1a 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -4,6 +4,7 @@ #pragma once #include "TermControl.g.h" +#include "XamlLights.h" #include "EventArgs.h" #include "../../renderer/base/Renderer.hpp" #include "../../renderer/dx/DxRenderer.hpp" @@ -99,6 +100,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation const winrt::hstring& padding, const uint32_t dpi); + void BellLightOn(); + bool ReadOnly() const noexcept; void ToggleReadOnly(); @@ -171,8 +174,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation Windows::UI::Xaml::DispatcherTimer _autoScrollTimer; std::optional _lastAutoScrollUpdateTime; + winrt::Windows::UI::Composition::ScalarKeyFrameAnimation _bellLightAnimation; + std::optional _cursorTimer; std::optional _blinkTimer; + std::optional _bellLightTimer; event_token _coreOutputEventToken; @@ -209,6 +215,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation void _CursorTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e); void _BlinkTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e); + void _BellLightOff(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e); void _SetEndSelectionPointAtCursor(Windows::Foundation::Point const& cursorPosition); diff --git a/src/cascadia/TerminalControl/TermControl.idl b/src/cascadia/TerminalControl/TermControl.idl index 3c49de0cc..1a043e95b 100644 --- a/src/cascadia/TerminalControl/TermControl.idl +++ b/src/cascadia/TerminalControl/TermControl.idl @@ -63,6 +63,8 @@ namespace Microsoft.Terminal.Control void ToggleShaderEffects(); void SendInput(String input); + void BellLightOn(); + Boolean ReadOnly { get; }; void ToggleReadOnly(); } diff --git a/src/cascadia/TerminalControl/TermControl.xaml b/src/cascadia/TerminalControl/TermControl.xaml index 70330614b..94aa92c5f 100644 --- a/src/cascadia/TerminalControl/TermControl.xaml +++ b/src/cascadia/TerminalControl/TermControl.xaml @@ -33,6 +33,9 @@ --> + + + diff --git a/src/cascadia/TerminalControl/TerminalControlLib.vcxproj b/src/cascadia/TerminalControl/TerminalControlLib.vcxproj index 5220de3e4..e52161fb9 100644 --- a/src/cascadia/TerminalControl/TerminalControlLib.vcxproj +++ b/src/cascadia/TerminalControl/TerminalControlLib.vcxproj @@ -43,6 +43,9 @@ SearchBoxControl.xaml + + XamlLights.idl + TermControl.xaml @@ -76,6 +79,9 @@ SearchBoxControl.xaml + + XamlLights.idl + TermControl.xaml @@ -102,6 +108,7 @@ SearchBoxControl.xaml + TermControl.xaml diff --git a/src/cascadia/TerminalControl/XamlLights.cpp b/src/cascadia/TerminalControl/XamlLights.cpp new file mode 100644 index 000000000..2bf8b1e83 --- /dev/null +++ b/src/cascadia/TerminalControl/XamlLights.cpp @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include "pch.h" +#include "TermControl.h" +#include "XamlLights.h" +#include "VisualBellLight.g.cpp" + +using namespace winrt::Windows::UI::Xaml; +using namespace winrt::Windows::UI::Xaml::Media; + +namespace winrt::Microsoft::Terminal::Control::implementation +{ + DependencyProperty VisualBellLight::_IsTargetProperty{ nullptr }; + + VisualBellLight::VisualBellLight() + { + _InitializeProperties(); + } + + void VisualBellLight::_InitializeProperties() + { + // Initialize any dependency properties here. + // This performs a lazy load on these properties, instead of + // initializing them when the DLL loads. + if (!_IsTargetProperty) + { + _IsTargetProperty = + DependencyProperty::RegisterAttached( + L"IsTarget", + winrt::xaml_typename(), + winrt::xaml_typename(), + PropertyMetadata{ winrt::box_value(false), PropertyChangedCallback{ &VisualBellLight::OnIsTargetChanged } }); + } + } + + // Method Description: + // - This function is called when the first target UIElement is shown on the screen, + // this enables delaying composition object creation until it's actually necessary. + // Arguments: + // - newElement: unused + void VisualBellLight::OnConnected(UIElement const& /* newElement */) + { + if (!CompositionLight()) + { + auto spotLight{ Window::Current().Compositor().CreateAmbientLight() }; + spotLight.Color(Windows::UI::Colors::White()); + CompositionLight(spotLight); + } + } + + // Method Description: + // - This function is called when there are no more target UIElements on the screen + // - Disposes of composition resources when no longer in use + // Arguments: + // - oldElement: unused + void VisualBellLight::OnDisconnected(UIElement const& /* oldElement */) + { + if (CompositionLight()) + { + CompositionLight(nullptr); + } + } + + winrt::hstring VisualBellLight::GetId() + { + return VisualBellLight::GetIdStatic(); + } + + void VisualBellLight::OnIsTargetChanged(DependencyObject const& d, DependencyPropertyChangedEventArgs const& e) + { + const auto uielem{ d.try_as() }; + const auto brush{ d.try_as() }; + + if (!uielem && !brush) + { + // terminate early + return; + } + + const auto isAdding = winrt::unbox_value(e.NewValue()); + const auto id = GetIdStatic(); + + if (isAdding) + { + if (uielem) + { + XamlLight::AddTargetElement(id, uielem); + } + else + { + XamlLight::AddTargetBrush(id, brush); + } + } + else + { + if (uielem) + { + XamlLight::RemoveTargetElement(id, uielem); + } + else + { + XamlLight::RemoveTargetBrush(id, brush); + } + } + } +} diff --git a/src/cascadia/TerminalControl/XamlLights.h b/src/cascadia/TerminalControl/XamlLights.h new file mode 100644 index 000000000..c0542f716 --- /dev/null +++ b/src/cascadia/TerminalControl/XamlLights.h @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once + +#include "cppwinrt_utils.h" +#include "VisualBellLight.g.h" + +namespace winrt::Microsoft::Terminal::Control::implementation +{ + struct VisualBellLight : VisualBellLightT + { + VisualBellLight(); + + winrt::hstring GetId(); + + static Windows::UI::Xaml::DependencyProperty IsTargetProperty() { return _IsTargetProperty; } + + static bool GetIsTarget(Windows::UI::Xaml::DependencyObject const& target) + { + return winrt::unbox_value(target.GetValue(_IsTargetProperty)); + } + + static void SetIsTarget(Windows::UI::Xaml::DependencyObject const& target, bool value) + { + target.SetValue(_IsTargetProperty, winrt::box_value(value)); + } + + void OnConnected(Windows::UI::Xaml::UIElement const& newElement); + void OnDisconnected(Windows::UI::Xaml::UIElement const& oldElement); + + static void OnIsTargetChanged(Windows::UI::Xaml::DependencyObject const& d, Windows::UI::Xaml::DependencyPropertyChangedEventArgs const& e); + + inline static winrt::hstring GetIdStatic() + { + // This specifies the unique name of the light. In most cases you should use the type's full name. + return winrt::xaml_typename().Name; + } + + private: + static void _InitializeProperties(); + static Windows::UI::Xaml::DependencyProperty _IsTargetProperty; + }; +} + +namespace winrt::Microsoft::Terminal::Control::factory_implementation +{ + BASIC_FACTORY(VisualBellLight); +} diff --git a/src/cascadia/TerminalControl/XamlLights.idl b/src/cascadia/TerminalControl/XamlLights.idl new file mode 100644 index 000000000..78a536c4a --- /dev/null +++ b/src/cascadia/TerminalControl/XamlLights.idl @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +namespace Microsoft.Terminal.Control +{ + [default_interface] runtimeclass VisualBellLight : Windows.UI.Xaml.Media.XamlLight + { + VisualBellLight(); + static Windows.UI.Xaml.DependencyProperty IsTargetProperty { get; }; + static Boolean GetIsTarget(Windows.UI.Xaml.DependencyObject target); + static void SetIsTarget(Windows.UI.Xaml.DependencyObject target, Boolean value); + } +} diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.cpp b/src/cascadia/TerminalSettingsEditor/Profiles.cpp index 03da1e3d2..15838cb3e 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.cpp +++ b/src/cascadia/TerminalSettingsEditor/Profiles.cpp @@ -450,7 +450,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER(BackgroundImageStretchMode, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch, L"Profile_BackgroundImageStretchMode", L"Content"); INITIALIZE_BINDABLE_ENUM_SETTING(AntiAliasingMode, TextAntialiasingMode, winrt::Microsoft::Terminal::Control::TextAntialiasingMode, L"Profile_AntialiasingMode", L"Content"); INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER(CloseOnExitMode, CloseOnExitMode, winrt::Microsoft::Terminal::Settings::Model::CloseOnExitMode, L"Profile_CloseOnExit", L"Content"); - INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER(BellStyle, BellStyle, winrt::Microsoft::Terminal::Settings::Model::BellStyle, L"Profile_BellStyle", L"Content"); INITIALIZE_BINDABLE_ENUM_SETTING(ScrollState, ScrollbarState, winrt::Microsoft::Terminal::Control::ScrollbarState, L"Profile_ScrollbarVisibility", L"Content"); // manually add Custom FontWeight option. Don't add it to the Map @@ -591,7 +590,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } else if (settingName == L"BellStyle") { - _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentBellStyle" }); + _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"IsBellStyleFlagSet" }); } else if (settingName == L"ScrollState") { @@ -655,6 +654,32 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _State.Profile().ColorSchemeName(val.Name()); } + bool Profiles::IsBellStyleFlagSet(const uint32_t flag) + { + return (WI_EnumValue(_State.Profile().BellStyle()) & flag) == flag; + } + + void Profiles::SetBellStyleAudible(winrt::Windows::Foundation::IReference on) + { + auto currentStyle = State().Profile().BellStyle(); + WI_UpdateFlag(currentStyle, Model::BellStyle::Audible, winrt::unbox_value(on)); + State().Profile().BellStyle(currentStyle); + } + + void Profiles::SetBellStyleWindow(winrt::Windows::Foundation::IReference on) + { + auto currentStyle = State().Profile().BellStyle(); + WI_UpdateFlag(currentStyle, Model::BellStyle::Window, winrt::unbox_value(on)); + State().Profile().BellStyle(currentStyle); + } + + void Profiles::SetBellStyleTaskbar(winrt::Windows::Foundation::IReference on) + { + auto currentStyle = State().Profile().BellStyle(); + WI_UpdateFlag(currentStyle, Model::BellStyle::Taskbar, winrt::unbox_value(on)); + State().Profile().BellStyle(currentStyle); + } + void Profiles::DeleteConfirmation_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/) { auto state{ winrt::get_self(_State) }; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.h b/src/cascadia/TerminalSettingsEditor/Profiles.h index 61a334c56..90fe65351 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.h +++ b/src/cascadia/TerminalSettingsEditor/Profiles.h @@ -177,6 +177,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation Model::ColorScheme CurrentColorScheme(); void CurrentColorScheme(const Model::ColorScheme& val); + // bell style bits + bool IsBellStyleFlagSet(const uint32_t flag); + void SetBellStyleAudible(winrt::Windows::Foundation::IReference on); + void SetBellStyleWindow(winrt::Windows::Foundation::IReference on); + void SetBellStyleTaskbar(winrt::Windows::Foundation::IReference on); + fire_and_forget BackgroundImage_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); fire_and_forget Commandline_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); fire_and_forget StartingDirectory_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); @@ -203,7 +209,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation GETSET_BINDABLE_ENUM_SETTING(BackgroundImageStretchMode, Windows::UI::Xaml::Media::Stretch, State().Profile, BackgroundImageStretchMode); GETSET_BINDABLE_ENUM_SETTING(AntiAliasingMode, Microsoft::Terminal::Control::TextAntialiasingMode, State().Profile, AntialiasingMode); GETSET_BINDABLE_ENUM_SETTING(CloseOnExitMode, Microsoft::Terminal::Settings::Model::CloseOnExitMode, State().Profile, CloseOnExit); - GETSET_BINDABLE_ENUM_SETTING(BellStyle, Microsoft::Terminal::Settings::Model::BellStyle, State().Profile, BellStyle); GETSET_BINDABLE_ENUM_SETTING(ScrollState, Microsoft::Terminal::Control::ScrollbarState, State().Profile, ScrollState); private: diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.idl b/src/cascadia/TerminalSettingsEditor/Profiles.idl index e9e0f5104..7c9b2e94f 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.idl +++ b/src/cascadia/TerminalSettingsEditor/Profiles.idl @@ -102,6 +102,11 @@ namespace Microsoft.Terminal.Settings.Editor Profiles(); ProfilePageNavigationState State { get; }; + Boolean IsBellStyleFlagSet(UInt32 flag); + void SetBellStyleAudible(Windows.Foundation.IReference on); + void SetBellStyleWindow(Windows.Foundation.IReference on); + void SetBellStyleTaskbar(Windows.Foundation.IReference on); + IInspectable CurrentCursorShape; Boolean IsVintageCursor { get; }; Windows.Foundation.Collections.IObservableVector CursorShapeList { get; }; @@ -115,9 +120,6 @@ namespace Microsoft.Terminal.Settings.Editor IInspectable CurrentCloseOnExitMode; Windows.Foundation.Collections.IObservableVector CloseOnExitModeList { get; }; - IInspectable CurrentBellStyle; - Windows.Foundation.Collections.IObservableVector BellStyleList { get; }; - IInspectable CurrentScrollState; Windows.Foundation.Collections.IObservableVector ScrollStateList { get; }; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.xaml b/src/cascadia/TerminalSettingsEditor/Profiles.xaml index b5a629d9c..68c592d5b 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles.xaml @@ -775,9 +775,14 @@ ClearSettingValue="{x:Bind State.Profile.ClearBellStyle}" HasSettingValue="{x:Bind State.Profile.HasBellStyle, Mode=OneWay}" SettingOverrideSource="{x:Bind State.Profile.BellStyleOverrideSource, Mode=OneWay}"> - + + + + + diff --git a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw index e9f68ea2a..611491389 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw @@ -905,8 +905,15 @@ Visual (flash taskbar) + + + Flash taskbar An option to choose from for the "bell style" setting. When selected, a visual notification is used to notify the user. In this case, the taskbar is flashed. + + Flash window + An option to choose from for the "bell style" setting. When selected, a visual notification is used to notify the user. In this case, the window is flashed. + Add new Button label that creates a new color scheme. diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp index 14dd008cf..b8a2e5f52 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp @@ -43,7 +43,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation DEFINE_ENUM_MAP(Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode); DEFINE_ENUM_MAP(Microsoft::Terminal::Control::TextAntialiasingMode, TextAntialiasingMode); DEFINE_ENUM_MAP(Microsoft::Terminal::Core::CursorStyle, CursorStyle); - DEFINE_ENUM_MAP(Model::BellStyle, BellStyle); // FontWeight is special because the JsonUtils::ConversionTrait for it // creates a FontWeight object, but we need to use the uint16_t value. diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.h b/src/cascadia/TerminalSettingsModel/EnumMappings.h index de54adf39..b9ca05ae1 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.h +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.h @@ -39,7 +39,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation static winrt::Windows::Foundation::Collections::IMap BackgroundImageStretchMode(); static winrt::Windows::Foundation::Collections::IMap TextAntialiasingMode(); static winrt::Windows::Foundation::Collections::IMap CursorStyle(); - static winrt::Windows::Foundation::Collections::IMap BellStyle(); static winrt::Windows::Foundation::Collections::IMap FontWeight(); }; } diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.idl b/src/cascadia/TerminalSettingsModel/EnumMappings.idl index 257962c59..7b9e6609e 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.idl +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.idl @@ -21,7 +21,6 @@ namespace Microsoft.Terminal.Settings.Model static Windows.Foundation.Collections.IMap BackgroundImageStretchMode { get; }; static Windows.Foundation.Collections.IMap TextAntialiasingMode { get; }; static Windows.Foundation.Collections.IMap CursorStyle { get; }; - static Windows.Foundation.Collections.IMap BellStyle { get; }; static Windows.Foundation.Collections.IMap FontWeight { get; }; } } diff --git a/src/cascadia/TerminalSettingsModel/JsonUtils.h b/src/cascadia/TerminalSettingsModel/JsonUtils.h index 591688ba4..efb3c0764 100644 --- a/src/cascadia/TerminalSettingsModel/JsonUtils.h +++ b/src/cascadia/TerminalSettingsModel/JsonUtils.h @@ -632,7 +632,8 @@ namespace Microsoft::Terminal::Settings::Model::JsonUtils for (const auto& pair : TBase::mappings) { if (pair.second != AllClear && - (val & pair.second) == pair.second) + (val & pair.second) == pair.second && + WI_IsSingleFlagSet(pair.second)) { json.append(BaseEnumMapper::ToJson(pair.second)); } diff --git a/src/cascadia/TerminalSettingsModel/Profile.idl b/src/cascadia/TerminalSettingsModel/Profile.idl index ed5903703..ceee66d5a 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.idl +++ b/src/cascadia/TerminalSettingsModel/Profile.idl @@ -30,8 +30,10 @@ namespace Microsoft.Terminal.Settings.Model [flags] enum BellStyle { + // !! If you update this, you must update the values in TerminalSettingsEditor/Profiles.xaml Audible = 0x1, - Visual = 0x2, + Window = 0x2, + Taskbar = 0x4, All = 0xffffffff }; diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h index 12938e4ca..bed14cc81 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h @@ -50,10 +50,12 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Control::ScrollbarState) JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::BellStyle) { - static constexpr std::array mappings = { + static constexpr std::array mappings = { pair_type{ "none", AllClear }, pair_type{ "audible", ValueType::Audible }, - pair_type{ "visual", ValueType::Visual }, + pair_type{ "visual", ValueType::Window | ValueType::Taskbar }, + pair_type{ "window", ValueType::Window }, + pair_type{ "taskbar", ValueType::Taskbar }, pair_type{ "all", AllSet }, };