mirror of
https://github.com/microsoft/terminal.git
synced 2026-07-08 18:16:28 +00:00
Fix settings error text legibility in High Contrast mode (#20098)
Closes #18147 `SystemErrorTextColor` doesn't adapt to High Contrast themes, so the error details in the "Failed to reload settings" dialog are illegible (yellow on cream in HC White, for example). Fix: skip the `ErrorTextBrush` foreground override when High Contrast is active, letting the text inherit the system HC text color from its parent element. This matches the existing HC detection pattern used in `TermControl.cpp` and `MainPage.cpp`. Validated manually on High Contrast White and Night sky themes. Co-authored-by: SushaanthSrinivasan <SushaanthSrinivasan@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
dadde2fb11
commit
a325a2fa5a
@@ -108,13 +108,19 @@ static Documents::Run _BuildErrorRun(const winrt::hstring& text, const ResourceD
|
|||||||
Documents::Run textRun;
|
Documents::Run textRun;
|
||||||
textRun.Text(text);
|
textRun.Text(text);
|
||||||
|
|
||||||
// Color the text red (light theme) or yellow (dark theme) based on the system theme
|
// GH #18147 - In High Contrast mode, don't override the foreground.
|
||||||
auto key = winrt::box_value(L"ErrorTextBrush");
|
// Let the text inherit the system HC text color from its parent element,
|
||||||
if (resources.HasKey(key))
|
// since SystemErrorTextColor doesn't adapt to High Contrast themes.
|
||||||
|
if (!winrt::Windows::UI::ViewManagement::AccessibilitySettings{}.HighContrast())
|
||||||
{
|
{
|
||||||
auto g = resources.Lookup(key);
|
// Color the text red (light theme) or yellow (dark theme) based on the system theme
|
||||||
auto brush = g.try_as<winrt::Windows::UI::Xaml::Media::Brush>();
|
auto key = winrt::box_value(L"ErrorTextBrush");
|
||||||
textRun.Foreground(brush);
|
if (resources.HasKey(key))
|
||||||
|
{
|
||||||
|
auto g = resources.Lookup(key);
|
||||||
|
auto brush = g.try_as<winrt::Windows::UI::Xaml::Media::Brush>();
|
||||||
|
textRun.Foreground(brush);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return textRun;
|
return textRun;
|
||||||
|
|||||||
Reference in New Issue
Block a user