Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable the setting to adjust the colors of indistinguishable text #13343

Merged
9 commits merged into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsModel/MTSMSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Author(s):
X(hstring, ColorSchemeName, "colorScheme", L"Campbell") \
X(hstring, BackgroundImagePath, "backgroundImage") \
X(Model::IntenseStyle, IntenseTextStyle, "intenseTextStyle", Model::IntenseStyle::Bright) \
X(bool, AdjustIndistinguishableColors, "adjustIndistinguishableColors", true)
X(bool, AdjustIndistinguishableColors, "adjustIndistinguishableColors", false)

// Intentionally omitted Appearance settings:
// * ForegroundKey, BackgroundKey, SelectionBackgroundKey, CursorColorKey: all optional colors
Expand Down
5 changes: 1 addition & 4 deletions src/features.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@
<feature>
<name>Feature_AdjustIndistinguishableText</name>
<description>If enabled, the foreground color will, when necessary, be automatically adjusted to make it more visible.</description>
<stage>AlwaysDisabled</stage>
<alwaysEnabledBrandingTokens>
<brandingToken>Dev</brandingToken>
</alwaysEnabledBrandingTokens>
<stage>AlwaysEnabled</stage>
</feature>

<feature>
Expand Down
17 changes: 10 additions & 7 deletions src/renderer/base/RenderSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,25 @@ std::pair<COLORREF, COLORREF> RenderSettings::GetAttributeColors(const TextAttri
const auto swapFgAndBg = attr.IsReverseVideo() ^ GetRenderMode(Mode::ScreenReversed);

// We want to nudge the foreground color to make it more perceivable only for the
// default color pairs within the color table
// default color pairs within the color table, and only if there's no additional text attributes

// The reason we don't want to nudge when there's additional attributes is because of certain
// interactions like "bright" + "reverse". We cannot nudge after reversing because we, as of now,
PankajBhojwani marked this conversation as resolved.
Show resolved Hide resolved
// have no easy way to calculate what the bright background is when the background is default. We
// also cannot nudge before reversing because then we are reversing the resultant background rather
// than the resultant foreground, and this can lead to weird situations where certain regions of
// text have different backgrounds.
if (Feature_AdjustIndistinguishableText::IsEnabled() &&
GetRenderMode(Mode::DistinguishableColors) &&
!dimFg &&
!brightenFg &&
!attr.IsInvisible() &&
(fgTextColor.IsDefault() || fgTextColor.IsLegacy()) &&
(bgTextColor.IsDefault() || bgTextColor.IsLegacy()))
{
const auto bgIndex = bgTextColor.IsDefault() ? AdjustedBgIndex : bgTextColor.GetIndex();
auto fgIndex = fgTextColor.IsDefault() ? AdjustedFgIndex : fgTextColor.GetIndex();

if (fgTextColor.IsIndex16() && (fgIndex < 8) && brightenFg)
{
// There is a special case for intense here - we need to get the bright version of the foreground color
fgIndex += 8;
}

if (swapFgAndBg)
{
const auto fg = _adjustedForegroundColors[fgIndex][bgIndex];
Expand Down