Repository: microsoft/terminal (language: cpp)

Issue:
"Magenta" is called "Purple" in WT
### Windows Terminal version (or Windows build number)

All versions

### Other Software

_No response_

### Steps to reproduce

Terminal calls "Magenta" by the wrong name, instead it is called "Purple".

### Expected Behavior

The expected behavior is calling it "Magenta" instead of "Purple".

### Actual Behavior

Terminal calls the color in question "Purple", instead of "Magenta".


Discussion / hints:
I apologize for the simplicity of this report, but the form submission really doesn't cover trivial issues.

I also understand that it is possible nobody on the team wants to handle the GUI implications of handling non-English translations, but I would accept a proposed fix of the settings.json parser also accepting "Magenta" as a string, since it will now always have to also accept "Purple" to not break legacy configurations.
Incorrect. It is called magenta in the 8 and 16 color systems, and these are industry standard technical terms. Similarly, you do not say a printer uses cyan, purple, yellow, and black.
Huh. No one else has complained about this since we shipped the Terminal more than 2 years ago now. I suppose we _could_ also accept magenta as a key. Probably no harm in that.
@zadjii-msft I'm actually surprised no one has hit this particular issue. In my case, along with #11457, it may mean nobody has tried to automate porting color schemes to WT. Or, alternatively, they have, and none of their schemes worked, and they just gave up instead of figuring out why they didn't work.

> No one else has complained about this since we shipped the Terminal more than 2 years ago now

We have actually discussed this before, but didn't really commit to fixing it: https://github.com/microsoft/terminal/issues/2641#issuecomment-528348251
/me goes off to register `@MikeVsMike`

Fair enough.

Fix patch:
diff --git a/src/cascadia/TerminalSettingsModel/ColorScheme.cpp b/src/cascadia/TerminalSettingsModel/ColorScheme.cpp
index 0d55c405b79..62f405e48fb 100644
--- a/src/cascadia/TerminalSettingsModel/ColorScheme.cpp
+++ b/src/cascadia/TerminalSettingsModel/ColorScheme.cpp
@@ -21,24 +21,30 @@ static constexpr std::string_view BackgroundKey{ "background" };
 static constexpr std::string_view SelectionBackgroundKey{ "selectionBackground" };
 static constexpr std::string_view CursorColorKey{ "cursorColor" };
 
-static constexpr std::array<std::string_view, 16> TableColors = {
-    "black",
-    "red",
-    "green",
-    "yellow",
-    "blue",
-    "purple",
-    "cyan",
-    "white",
-    "brightBlack",
-    "brightRed",
-    "brightGreen",
-    "brightYellow",
-    "brightBlue",
-    "brightPurple",
-    "brightCyan",
-    "brightWhite"
-};
+static constexpr size_t ColorSchemeExpectedSize = 16;
+static constexpr std::array<std::pair<std::string_view, size_t>, 18> TableColorsMapping{ {
+    // Primary color mappings
+    { "black", 0 },
+    { "red", 1 },
+    { "green", 2 },
+    { "yellow", 3 },
+    { "blue", 4 },
+    { "purple", 5 },
+    { "cyan", 6 },
+    { "white", 7 },
+    { "brightBlack", 8 },
+    { "brightRed", 9 },
+    { "brightGreen", 10 },
+    { "brightYellow", 11 },
+    { "brightBlue", 12 },
+    { "brightPurple", 13 },
+    { "brightCyan", 14 },
+    { "brightWhite", 15 },
+
+    // Alternate color mappings (GH#11456)
+    { "magenta", 5 },
+    { "brightMagenta", 13 },
+} };
 
 ColorScheme::ColorScheme() noexcept :
     ColorScheme{ winrt::hstring{} }
@@ -98,11 +104,18 @@ bool ColorScheme::_layerJson(const Json::Value& json)
     JsonUtils::GetValueForKey(json, CursorColorKey, _CursorColor);
 
     // Required fields
-    for (unsigned int i = 0; i < TableColors.size(); ++i)
+    size_t colorCount = 0;
+    for (const auto& [key, index] : TableColorsMapping)
     {
-        isValid &= JsonUtils::GetValueForKey(json, til::at(TableColors, i), til::at(_table, i));
+        colorCount += JsonUtils::GetValueForKey(json, key, til::at(_table, index));
+        if (colorCount == ColorSchemeExpectedSize)
+        {
+            break;
+        }
     }
 
+    isValid &= (colorCount == 16); // Valid schemes should have exactly 16 colors
+
     return isValid;
 }
 
@@ -122,9 +135,10 @@ Json::Value ColorScheme::ToJson() const
     JsonUtils::SetValueForKey(json, SelectionBackgroundKey, _SelectionBackground);
     JsonUtils::SetValueForKey(json, CursorColorKey, _CursorColor);
 
-    for (unsigned int i = 0; i < TableColors.size(); ++i)
+    for (size_t i = 0; i < ColorSchemeExpectedSize; ++i)
     {
-        JsonUtils::SetValueForKey(json, til::at(TableColors, i), til::at(_table, i));
+        const auto& key = til::at(TableColorsMapping, i).first;
+        JsonUtils::SetValueForKey(json, key, til::at(_table, i));
     }
 
     return json;


Test patch: