diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 72ca7293e..31babfcea 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -154,6 +154,17 @@ "description": "Sets how the background image aligns to the boundaries of the window when unfocused. Possible values: \"center\", \"left\", \"top\", \"right\", \"bottom\", \"topLeft\", \"topRight\", \"bottomLeft\", \"bottomRight\"", "type": "string" }, + "intenseTextStyle": { + "default": "all", + "description": "Controls how 'intense' text is rendered. Values are \"bold\", \"bright\", \"all\" and \"none\"", + "enum": [ + "none", + "bold", + "bright", + "all" + ], + "type": "string" + }, "experimental.retroTerminalEffect": { "description": "When set to true, enable retro terminal effects when unfocused. This is an experimental feature, and its continued existence is not guaranteed.", "type": "boolean" diff --git a/src/buffer/out/TextAttribute.cpp b/src/buffer/out/TextAttribute.cpp index c406f10ba..c44724846 100644 --- a/src/buffer/out/TextAttribute.cpp +++ b/src/buffer/out/TextAttribute.cpp @@ -95,16 +95,18 @@ bool TextAttribute::IsLegacy() const noexcept // - defaultFgColor: the default foreground color rgb value. // - defaultBgColor: the default background color rgb value. // - reverseScreenMode: true if the screen mode is reversed. -// - blinkingIsFaint: true if blinking should be interpreted as faint. +// - blinkingIsFaint: true if blinking should be interpreted as faint. (defaults to false) +// - boldIsBright: true if "bold" should be interpreted as bright. (defaults to true) // Return Value: // - the foreground and background colors that should be displayed. std::pair TextAttribute::CalculateRgbColors(const std::array& colorTable, const COLORREF defaultFgColor, const COLORREF defaultBgColor, const bool reverseScreenMode, - const bool blinkingIsFaint) const noexcept + const bool blinkingIsFaint, + const bool boldIsBright) const noexcept { - auto fg = _foreground.GetColor(colorTable, defaultFgColor, IsBold()); + auto fg = _foreground.GetColor(colorTable, defaultFgColor, boldIsBright && IsBold()); auto bg = _background.GetColor(colorTable, defaultBgColor); if (IsFaint() || (IsBlinking() && blinkingIsFaint)) { diff --git a/src/buffer/out/TextAttribute.hpp b/src/buffer/out/TextAttribute.hpp index 8bb1ff243..00f8a2266 100644 --- a/src/buffer/out/TextAttribute.hpp +++ b/src/buffer/out/TextAttribute.hpp @@ -68,7 +68,8 @@ public: const COLORREF defaultFgColor, const COLORREF defaultBgColor, const bool reverseScreenMode = false, - const bool blinkingIsFaint = false) const noexcept; + const bool blinkingIsFaint = false, + const bool boldIsBright = true) const noexcept; bool IsLeadingByte() const noexcept; bool IsTrailingByte() const noexcept; diff --git a/src/buffer/out/ut_textbuffer/TextAttributeTests.cpp b/src/buffer/out/ut_textbuffer/TextAttributeTests.cpp index d0f0362d3..65aba47f7 100644 --- a/src/buffer/out/ut_textbuffer/TextAttributeTests.cpp +++ b/src/buffer/out/ut_textbuffer/TextAttributeTests.cpp @@ -22,6 +22,7 @@ class TextAttributeTests TEST_METHOD(TestTextAttributeColorGetters); TEST_METHOD(TestReverseDefaultColors); TEST_METHOD(TestRoundtripDefaultColors); + TEST_METHOD(TestBoldAsBright); std::array _colorTable; COLORREF _defaultFg = RGB(1, 2, 3); @@ -263,3 +264,56 @@ void TextAttributeTests::TestRoundtripDefaultColors() // Reset the legacy default colors to white on black. TextAttribute::SetLegacyDefaultAttributes(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); } + +void TextAttributeTests::TestBoldAsBright() +{ + const COLORREF darkBlack = til::at(_colorTable, 0); + const COLORREF brightBlack = til::at(_colorTable, 8); + const COLORREF darkGreen = til::at(_colorTable, 2); + + TextAttribute attr{}; + + // verify that calculated foreground/background are the same as the direct + // values when not bold + VERIFY_IS_FALSE(attr.IsBold()); + + VERIFY_ARE_EQUAL(_defaultFg, attr.GetForeground().GetColor(_colorTable, _defaultFg)); + VERIFY_ARE_EQUAL(_defaultBg, attr.GetBackground().GetColor(_colorTable, _defaultBg)); + VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, true)); + VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, false)); + + // with bold set, calculated foreground/background values shouldn't change for the default colors. + attr.SetBold(true); + VERIFY_IS_TRUE(attr.IsBold()); + VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, true)); + VERIFY_ARE_EQUAL(std::make_pair(_defaultFg, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, false)); + + attr.SetIndexedForeground(0); + VERIFY_IS_TRUE(attr.IsBold()); + + Log::Comment(L"Foreground should be bright black when bold is bright is enabled"); + VERIFY_ARE_EQUAL(std::make_pair(brightBlack, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, true)); + + Log::Comment(L"Foreground should be dark black when bold is bright is disabled"); + VERIFY_ARE_EQUAL(std::make_pair(darkBlack, _defaultBg), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, false)); + + attr.SetIndexedBackground(2); + VERIFY_IS_TRUE(attr.IsBold()); + + Log::Comment(L"background should be unaffected by 'bold is bright'"); + VERIFY_ARE_EQUAL(std::make_pair(brightBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, true)); + VERIFY_ARE_EQUAL(std::make_pair(darkBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, false)); + + attr.SetBold(false); + VERIFY_IS_FALSE(attr.IsBold()); + Log::Comment(L"when not bold, 'bold is bright' changes nothing"); + VERIFY_ARE_EQUAL(std::make_pair(darkBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, true)); + VERIFY_ARE_EQUAL(std::make_pair(darkBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, false)); + + Log::Comment(L"When set to a bright color, and bold, 'bold is bright' changes nothing"); + attr.SetBold(true); + attr.SetIndexedForeground(8); + VERIFY_IS_TRUE(attr.IsBold()); + VERIFY_ARE_EQUAL(std::make_pair(brightBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, true)); + VERIFY_ARE_EQUAL(std::make_pair(brightBlack, darkGreen), attr.CalculateRgbColors(_colorTable, _defaultFg, _defaultBg, false, false, false)); +} diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index ac7bf1b07..7ee396a3c 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -264,6 +264,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation _renderEngine->SetPixelShaderPath(_settings.PixelShaderPath()); _renderEngine->SetForceFullRepaintRendering(_settings.ForceFullRepaintRendering()); _renderEngine->SetSoftwareRendering(_settings.SoftwareRendering()); + _renderEngine->SetIntenseIsBold(_settings.IntenseIsBold()); _updateAntiAliasingMode(_renderEngine.get()); @@ -600,6 +601,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation _renderEngine->SetForceFullRepaintRendering(_settings.ForceFullRepaintRendering()); _renderEngine->SetSoftwareRendering(_settings.SoftwareRendering()); + _updateAntiAliasingMode(_renderEngine.get()); // Refresh our font with the renderer @@ -629,6 +631,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation _renderEngine->SetSelectionBackground(til::color{ newAppearance.SelectionBackground() }); _renderEngine->SetRetroTerminalEffect(newAppearance.RetroTerminalEffect()); _renderEngine->SetPixelShaderPath(newAppearance.PixelShaderPath()); + _renderEngine->SetIntenseIsBold(_settings.IntenseIsBold()); _renderer->TriggerRedrawAll(); } } diff --git a/src/cascadia/TerminalControl/IControlAppearance.idl b/src/cascadia/TerminalControl/IControlAppearance.idl index 88de9e4b6..a0fa0a0ad 100644 --- a/src/cascadia/TerminalControl/IControlAppearance.idl +++ b/src/cascadia/TerminalControl/IControlAppearance.idl @@ -11,6 +11,8 @@ namespace Microsoft.Terminal.Control Windows.UI.Xaml.Media.Stretch BackgroundImageStretchMode; Windows.UI.Xaml.HorizontalAlignment BackgroundImageHorizontalAlignment; Windows.UI.Xaml.VerticalAlignment BackgroundImageVerticalAlignment; + Boolean IntenseIsBold; + // IntenseIsBright is in Core Appearance // Experimental settings Boolean RetroTerminalEffect; diff --git a/src/cascadia/TerminalCore/ICoreAppearance.idl b/src/cascadia/TerminalCore/ICoreAppearance.idl index 99148c265..5300ec674 100644 --- a/src/cascadia/TerminalCore/ICoreAppearance.idl +++ b/src/cascadia/TerminalCore/ICoreAppearance.idl @@ -66,5 +66,6 @@ namespace Microsoft.Terminal.Core Microsoft.Terminal.Core.Color CursorColor; CursorStyle CursorShape; UInt32 CursorHeight; + Boolean IntenseIsBright; }; } diff --git a/src/cascadia/TerminalCore/Terminal.cpp b/src/cascadia/TerminalCore/Terminal.cpp index 53ca70878..016de5e60 100644 --- a/src/cascadia/TerminalCore/Terminal.cpp +++ b/src/cascadia/TerminalCore/Terminal.cpp @@ -52,7 +52,8 @@ Terminal::Terminal() : _selection{ std::nullopt }, _taskbarState{ 0 }, _taskbarProgress{ 0 }, - _trimBlockSelection{ false } + _trimBlockSelection{ false }, + _intenseIsBright{ true } { auto dispatch = std::make_unique(*this); auto engine = std::make_unique(std::move(dispatch)); @@ -173,6 +174,7 @@ void Terminal::UpdateAppearance(const ICoreAppearance& appearance) til::color newBackgroundColor{ appearance.DefaultBackground() }; _defaultBg = newBackgroundColor.with_alpha(0); _defaultFg = appearance.DefaultForeground(); + _intenseIsBright = appearance.IntenseIsBright(); for (int i = 0; i < 16; i++) { diff --git a/src/cascadia/TerminalCore/Terminal.hpp b/src/cascadia/TerminalCore/Terminal.hpp index aeabebc3b..27e26b7f2 100644 --- a/src/cascadia/TerminalCore/Terminal.hpp +++ b/src/cascadia/TerminalCore/Terminal.hpp @@ -282,6 +282,7 @@ private: bool _suppressApplicationTitle; bool _bracketedPasteMode; bool _trimBlockSelection; + bool _intenseIsBright; size_t _taskbarState; size_t _taskbarProgress; diff --git a/src/cascadia/TerminalCore/terminalrenderdata.cpp b/src/cascadia/TerminalCore/terminalrenderdata.cpp index 9c4436029..84b00eadf 100644 --- a/src/cascadia/TerminalCore/terminalrenderdata.cpp +++ b/src/cascadia/TerminalCore/terminalrenderdata.cpp @@ -50,7 +50,8 @@ std::pair Terminal::GetAttributeColors(const TextAttribute& _defaultFg, _defaultBg, _screenReversed, - _blinkingState.IsBlinkingFaint()); + _blinkingState.IsBlinkingFaint(), + _intenseIsBright); colors.first |= 0xff000000; // We only care about alpha for the default BG (which enables acrylic) // If the bg isn't the default bg color, or reverse video is enabled, make it fully opaque. diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.cpp b/src/cascadia/TerminalSettingsEditor/Appearances.cpp index 8306b3ee5..db7f1c16b 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.cpp +++ b/src/cascadia/TerminalSettingsEditor/Appearances.cpp @@ -131,6 +131,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation const auto backgroundImgCheckboxTooltip{ ToolTipService::GetToolTip(UseDesktopImageCheckBox()) }; Automation::AutomationProperties::SetFullDescription(UseDesktopImageCheckBox(), unbox_value(backgroundImgCheckboxTooltip)); + + INITIALIZE_BINDABLE_ENUM_SETTING(IntenseTextStyle, IntenseTextStyle, winrt::Microsoft::Terminal::Settings::Model::IntenseStyle, L"Appearance_IntenseTextStyle", L"Content"); } // Method Description: @@ -256,6 +258,24 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"ShowAllFonts" }); _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"UsingMonospaceFont" }); } + else if (settingName == L"IntenseTextStyle") + { + _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentIntenseTextStyle" }); + } + // YOU THERE ADDING A NEW APPEARANCE SETTING + // Make sure you add a block like + // + // else if (settingName == L"MyNewSetting") + // { + // _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentMyNewSetting" }); + // } + // + // To make sure that changes to the AppearanceViewModel will + // propagate back up to the actual UI (in Appearances). The + // CurrentMyNewSetting properties are the ones that are bound in + // XAML. If you don't do this right (or only raise a property + // changed for "MyNewSetting"), then things like the reset + // button won't work right. }); // make sure to send all the property changed events once here @@ -271,6 +291,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentFontFace" }); _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"ShowAllFonts" }); _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"UsingMonospaceFont" }); + _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentIntenseTextStyle" }); } } diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.h b/src/cascadia/TerminalSettingsEditor/Appearances.h index 6860b0361..f6fa4b3d6 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.h +++ b/src/cascadia/TerminalSettingsEditor/Appearances.h @@ -92,6 +92,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation OBSERVABLE_PROJECTED_SETTING(_appearance, BackgroundImageOpacity); OBSERVABLE_PROJECTED_SETTING(_appearance, BackgroundImageStretchMode); OBSERVABLE_PROJECTED_SETTING(_appearance, BackgroundImageAlignment); + OBSERVABLE_PROJECTED_SETTING(_appearance, IntenseTextStyle); private: Model::AppearanceConfig _appearance; @@ -136,6 +137,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation GETSET_BINDABLE_ENUM_SETTING(BackgroundImageStretchMode, Windows::UI::Xaml::Media::Stretch, Appearance, BackgroundImageStretchMode); + GETSET_BINDABLE_ENUM_SETTING(IntenseTextStyle, Microsoft::Terminal::Settings::Model::IntenseStyle, Appearance, IntenseTextStyle); + private: bool _ShowAllFonts; void _UpdateBIAlignmentControl(const int32_t val); diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.idl b/src/cascadia/TerminalSettingsEditor/Appearances.idl index ddc83abed..fe2450b6d 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.idl +++ b/src/cascadia/TerminalSettingsEditor/Appearances.idl @@ -45,6 +45,7 @@ namespace Microsoft.Terminal.Settings.Editor OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Double, BackgroundImageOpacity); OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Windows.UI.Xaml.Media.Stretch, BackgroundImageStretchMode); OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Microsoft.Terminal.Settings.Model.ConvergedAlignment, BackgroundImageAlignment); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Microsoft.Terminal.Settings.Model.IntenseStyle, IntenseTextStyle); } [default_interface] runtimeclass Appearances : Windows.UI.Xaml.Controls.UserControl, Windows.UI.Xaml.Data.INotifyPropertyChanged @@ -73,5 +74,8 @@ namespace Microsoft.Terminal.Settings.Editor IInspectable CurrentFontFace { get; }; Windows.UI.Xaml.Controls.Slider BIOpacitySlider { get; }; + + IInspectable CurrentIntenseTextStyle; + Windows.Foundation.Collections.IObservableVector IntenseTextStyleList { get; }; } } diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.xaml b/src/cascadia/TerminalSettingsEditor/Appearances.xaml index d49de2051..a2f715fd2 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.xaml +++ b/src/cascadia/TerminalSettingsEditor/Appearances.xaml @@ -428,5 +428,23 @@ + + + + + + + + + + + diff --git a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw index 26eefd38b..6c37bcaf0 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw @@ -1186,4 +1186,28 @@ Shortcut The label for a "key chord listener" control that sets the keys a key binding is bound to. - \ No newline at end of file + + Text Formatting + Header for a control to how text is formatted + + + Intense Text Format + Header for a control to select how "intense" text is formatted (bold, bright, both or none) + + + None + An option to choose from for the "intense text format" setting. When selected, "intense" text will not be rendered differently + + + Bold + An option to choose from for the "intense text format" setting. When selected, "intense" text will be rendered as bold text + + + Bright + An option to choose from for the "intense text format" setting. When selected, "intense" text will be rendered in a brighter color + + + Both + An option to choose from for the "intense text format" setting. When selected, "intense" text will be rendered as both bold text and in a brighter color + + diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp index a7343a51b..67eb279ea 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.cpp @@ -25,6 +25,7 @@ static constexpr std::string_view BackgroundImageStretchModeKey{ "backgroundImag static constexpr std::string_view BackgroundImageAlignmentKey{ "backgroundImageAlignment" }; static constexpr std::string_view RetroTerminalEffectKey{ "experimental.retroTerminalEffect" }; static constexpr std::string_view PixelShaderPathKey{ "experimental.pixelShaderPath" }; +static constexpr std::string_view IntenseTextStyleKey{ "intenseTextStyle" }; winrt::Microsoft::Terminal::Settings::Model::implementation::AppearanceConfig::AppearanceConfig(const winrt::weak_ref sourceProfile) : _sourceProfile(sourceProfile) @@ -48,6 +49,7 @@ winrt::com_ptr AppearanceConfig::CopyAppearance(const winrt::c appearance->_BackgroundImageAlignment = sourceAppearance->_BackgroundImageAlignment; appearance->_RetroTerminalEffect = sourceAppearance->_RetroTerminalEffect; appearance->_PixelShaderPath = sourceAppearance->_PixelShaderPath; + appearance->_IntenseTextStyle = sourceAppearance->_IntenseTextStyle; return appearance; } @@ -68,6 +70,7 @@ Json::Value AppearanceConfig::ToJson() const JsonUtils::SetValueForKey(json, BackgroundImageAlignmentKey, _BackgroundImageAlignment); JsonUtils::SetValueForKey(json, RetroTerminalEffectKey, _RetroTerminalEffect); JsonUtils::SetValueForKey(json, PixelShaderPathKey, _PixelShaderPath); + JsonUtils::SetValueForKey(json, IntenseTextStyleKey, _IntenseTextStyle); return json; } @@ -98,6 +101,7 @@ void AppearanceConfig::LayerJson(const Json::Value& json) JsonUtils::GetValueForKey(json, BackgroundImageAlignmentKey, _BackgroundImageAlignment); JsonUtils::GetValueForKey(json, RetroTerminalEffectKey, _RetroTerminalEffect); JsonUtils::GetValueForKey(json, PixelShaderPathKey, _PixelShaderPath); + JsonUtils::GetValueForKey(json, IntenseTextStyleKey, _IntenseTextStyle); } winrt::Microsoft::Terminal::Settings::Model::Profile AppearanceConfig::SourceProfile() diff --git a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h index cdcdc9613..10be9644d 100644 --- a/src/cascadia/TerminalSettingsModel/AppearanceConfig.h +++ b/src/cascadia/TerminalSettingsModel/AppearanceConfig.h @@ -52,6 +52,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::IAppearanceConfig, bool, RetroTerminalEffect, false); INHERITABLE_SETTING(Model::IAppearanceConfig, hstring, PixelShaderPath, L""); + INHERITABLE_SETTING(Model::IAppearanceConfig, Model::IntenseStyle, IntenseTextStyle, Model::IntenseStyle::All); private: winrt::weak_ref _sourceProfile; diff --git a/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp b/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp index de64a749a..f2a6c9326 100644 --- a/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp @@ -348,6 +348,7 @@ winrt::Microsoft::Terminal::Settings::Model::Profile CascadiaSettings::Duplicate DUPLICATE_SETTING_MACRO_SUB(appearance, target, SelectionBackground); DUPLICATE_SETTING_MACRO_SUB(appearance, target, CursorColor); DUPLICATE_SETTING_MACRO_SUB(appearance, target, PixelShaderPath); + DUPLICATE_SETTING_MACRO_SUB(appearance, target, IntenseTextStyle); DUPLICATE_SETTING_MACRO_SUB(appearance, target, BackgroundImagePath); DUPLICATE_SETTING_MACRO_SUB(appearance, target, BackgroundImageOpacity); DUPLICATE_SETTING_MACRO_SUB(appearance, target, BackgroundImageStretchMode); diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp index b8a2e5f52..e0c9d2b45 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp @@ -43,6 +43,7 @@ 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(Microsoft::Terminal::Settings::Model::IntenseStyle, IntenseTextStyle); // 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 b9ca05ae1..c597c6a77 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.h +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.h @@ -40,6 +40,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation static winrt::Windows::Foundation::Collections::IMap TextAntialiasingMode(); static winrt::Windows::Foundation::Collections::IMap CursorStyle(); static winrt::Windows::Foundation::Collections::IMap FontWeight(); + static winrt::Windows::Foundation::Collections::IMap IntenseTextStyle(); }; } diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.idl b/src/cascadia/TerminalSettingsModel/EnumMappings.idl index 7b9e6609e..4a7bb593b 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.idl +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.idl @@ -22,5 +22,6 @@ namespace Microsoft.Terminal.Settings.Model static Windows.Foundation.Collections.IMap TextAntialiasingMode { get; }; static Windows.Foundation.Collections.IMap CursorStyle { get; }; static Windows.Foundation.Collections.IMap FontWeight { get; }; + static Windows.Foundation.Collections.IMap IntenseTextStyle { get; }; } } diff --git a/src/cascadia/TerminalSettingsModel/IAppearanceConfig.idl b/src/cascadia/TerminalSettingsModel/IAppearanceConfig.idl index 2b5cbbd52..b33cf23e7 100644 --- a/src/cascadia/TerminalSettingsModel/IAppearanceConfig.idl +++ b/src/cascadia/TerminalSettingsModel/IAppearanceConfig.idl @@ -22,6 +22,14 @@ namespace Microsoft.Terminal.Settings.Model Vertical_Bottom = 0x20 }; + [flags] + enum IntenseStyle + { + Bold = 0x1, + Bright = 0x2, + All = 0xffffffff + }; + interface IAppearanceConfig { Microsoft.Terminal.Settings.Model.Profile SourceProfile { get; }; @@ -42,5 +50,6 @@ namespace Microsoft.Terminal.Settings.Model INHERITABLE_APPEARANCE_SETTING(Boolean, RetroTerminalEffect); INHERITABLE_APPEARANCE_SETTING(String, PixelShaderPath); + INHERITABLE_APPEARANCE_SETTING(IntenseStyle, IntenseTextStyle); }; } diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp index 124975fb8..d5202f1d2 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.cpp @@ -202,6 +202,9 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation _RetroTerminalEffect = appearance.RetroTerminalEffect(); _PixelShaderPath = winrt::hstring{ wil::ExpandEnvironmentStringsW(appearance.PixelShaderPath().c_str()) }; + + _IntenseIsBold = WI_IsFlagSet(appearance.IntenseTextStyle(), Microsoft::Terminal::Settings::Model::IntenseStyle::Bold); + _IntenseIsBright = WI_IsFlagSet(appearance.IntenseTextStyle(), Microsoft::Terminal::Settings::Model::IntenseStyle::Bright); } // Method Description: diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.h b/src/cascadia/TerminalSettingsModel/TerminalSettings.h index 66e805589..bda1f24cd 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.h @@ -116,6 +116,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation // passed to the terminal only upon creation. INHERITABLE_SETTING(Model::TerminalSettings, Windows::Foundation::IReference, StartingTabColor, nullptr); + INHERITABLE_SETTING(Model::TerminalSettings, bool, IntenseIsBright); + // ------------------------ End of Core Settings ----------------------- INHERITABLE_SETTING(Model::TerminalSettings, hstring, ProfileName); @@ -154,6 +156,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation INHERITABLE_SETTING(Model::TerminalSettings, bool, ForceVTInput, false); INHERITABLE_SETTING(Model::TerminalSettings, hstring, PixelShaderPath); + INHERITABLE_SETTING(Model::TerminalSettings, bool, IntenseIsBold); private: std::optional> _ColorTable; diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h index bed14cc81..2466c8dd9 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h @@ -468,3 +468,13 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::MonitorBehavior) pair_type{ "toMouse", ValueType::ToMouse }, }; }; + +JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::IntenseStyle) +{ + static constexpr std::array mappings = { + pair_type{ "none", AllClear }, + pair_type{ "bold", ValueType::Bold }, + pair_type{ "bright", ValueType::Bright }, + pair_type{ "all", AllSet }, + }; +}; diff --git a/src/cascadia/UnitTests_Control/MockControlSettings.h b/src/cascadia/UnitTests_Control/MockControlSettings.h index 94b8f2a99..d84006589 100644 --- a/src/cascadia/UnitTests_Control/MockControlSettings.h +++ b/src/cascadia/UnitTests_Control/MockControlSettings.h @@ -46,6 +46,7 @@ namespace ControlUnitTests WINRT_PROPERTY(bool, TrimBlockSelection, false); WINRT_PROPERTY(bool, DetectURLs, true); + WINRT_PROPERTY(bool, IntenseIsBright, true); // ------------------------ End of Core Settings ----------------------- WINRT_PROPERTY(winrt::hstring, ProfileName); @@ -85,6 +86,7 @@ namespace ControlUnitTests WINRT_PROPERTY(IFontFeatureMap, FontFeatures); WINRT_PROPERTY(IFontAxesMap, FontAxes); + WINRT_PROPERTY(bool, IntenseIsBold, true); private: std::array _ColorTable; diff --git a/src/cascadia/UnitTests_TerminalCore/MockTermSettings.h b/src/cascadia/UnitTests_TerminalCore/MockTermSettings.h index 96f98bc8b..2c23d2217 100644 --- a/src/cascadia/UnitTests_TerminalCore/MockTermSettings.h +++ b/src/cascadia/UnitTests_TerminalCore/MockTermSettings.h @@ -73,6 +73,8 @@ namespace TerminalCoreUnitTests void TrimBlockSelection(bool) {} void DetectURLs(bool) {} + WINRT_PROPERTY(bool, IntenseIsBright, true); + private: int32_t _historySize; int32_t _initialRows; diff --git a/src/renderer/dx/DxRenderer.cpp b/src/renderer/dx/DxRenderer.cpp index e40a40ffd..d01d99364 100644 --- a/src/renderer/dx/DxRenderer.cpp +++ b/src/renderer/dx/DxRenderer.cpp @@ -94,6 +94,7 @@ DxEngine::DxEngine() : _dpi{ USER_DEFAULT_SCREEN_DPI }, _scale{ 1.0f }, _prevScale{ 1.0f }, + _intenseIsBold{ true }, _chainMode{ SwapChainMode::ForComposition }, _customLayout{}, _customRenderer{ ::Microsoft::WRL::Make() }, @@ -1032,6 +1033,17 @@ try } CATCH_LOG() +void DxEngine::SetIntenseIsBold(bool enable) noexcept +try +{ + if (_intenseIsBold != enable) + { + _intenseIsBold = enable; + LOG_IF_FAILED(InvalidateAll()); + } +} +CATCH_LOG() + HANDLE DxEngine::GetSwapChainHandle() { if (!_swapChainHandle) @@ -1960,7 +1972,7 @@ CATCH_RETURN() if (_drawingContext) { _drawingContext->forceGrayscaleAA = _ShouldForceGrayscaleAA(); - _drawingContext->useBoldFont = textAttributes.IsBold(); + _drawingContext->useBoldFont = _intenseIsBold && textAttributes.IsBold(); _drawingContext->useItalicFont = textAttributes.IsItalic(); } diff --git a/src/renderer/dx/DxRenderer.hpp b/src/renderer/dx/DxRenderer.hpp index 6fdf2fe7f..9c96e7f06 100644 --- a/src/renderer/dx/DxRenderer.hpp +++ b/src/renderer/dx/DxRenderer.hpp @@ -129,6 +129,7 @@ namespace Microsoft::Console::Render void SetSelectionBackground(const COLORREF color, const float alpha = 0.5f) noexcept; void SetAntialiasingMode(const D2D1_TEXT_ANTIALIAS_MODE antialiasingMode) noexcept; void SetDefaultTextBackgroundOpacity(const float opacity) noexcept; + void SetIntenseIsBold(const bool opacity) noexcept; void UpdateHyperlinkHoveredId(const uint16_t hoveredId) noexcept; @@ -257,6 +258,7 @@ namespace Microsoft::Console::Render D2D1_TEXT_ANTIALIAS_MODE _antialiasingMode; float _defaultTextBackgroundOpacity; + bool _intenseIsBold; // DirectX constant buffers need to be a multiple of 16; align to pad the size. __declspec(align(16)) struct