Repository: microsoft/terminal (language: cpp)

Issue:
ColorTool does not set the default background color
<!--
This bug tracker is monitored by Windows Terminal development team and other technical folks.

**Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**.
Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue.

Please use this form and describe your issue, concisely but precisely, with as much detail as possible.

-->

# Environment

Microsoft Windows [Version 10.0.18362.145]
Windows Terminal built off master today, with ColorTool built off master today

I've built them both using release, Windows Terminal is deployed (Windows Terminal (Dev Build) launched from Start Menu).

# Steps to reproduce

ColorTool.exe -c
ColorTool.exe {any iterm scheme}

![bug_report_1](https://user-images.githubusercontent.com/235505/59067428-7a375880-8866-11e9-8610-0d362b559409.PNG)
![bug_report_2](https://user-images.githubusercontent.com/235505/59067429-7acfef00-8866-11e9-9e30-15755f5547a2.PNG)

# Expected behavior

Color scheme should be set in local Windows Terminal instance.

# Actual behavior

Its not getting set.

Note that I tried this out in a regular PowerShell instance launched from Start Menu and it seems to do what it's supposed to (at least from what I can tell), in that it sets the color scheme. I noted that the background color doesn't appear to be correct, which when I searched for ColorTool bug reports, I found #1150 which seems to be consistent with the behavior that I was seeing.



Discussion / hints:
Try `colortool -x`. Colortool needs that flag to be able to set the colors in a way a terminal (via conpty) can understand.
No change. When I read the documentation, I thought -x was for WSL.

![bug_report_4](https://user-images.githubusercontent.com/235505/59071423-68a87d80-8873-11e9-9206-ee5148d50fce.PNG)

By the way, when running colortool directly in a PowerShell window, then running WSL (Ubuntu in this case) using "wsl," colors seem nicely preserved.
![bug_report_5](https://user-images.githubusercontent.com/235505/59071480-aefddc80-8873-11e9-8fd7-7e93494401e7.PNG)

Sorry, I'm not a windows terminal guru so I might be missing something obvious here.

Edit: just to make sure its apples to apples regarding the first report, ran -x in a cmd.exe tab as well. No change. 
![bug_report_6](https://user-images.githubusercontent.com/235505/59071715-a9ed5d00-8874-11e9-9e6a-6bb7474d758c.PNG)



Ohhhhh, I see what's wrong here - colortool isn't setting the _default_ background color in the `-x` scenario. We only just added support for the needed VT sequence to do that (#891), so colortool should be updated too. 
+1, 
ColorTool.exe can change the background color of normal/default Windows console windows, but not Windows Terminal Preview.
> +1

Incidentally, you can detect this state by the issue still being open. :smile:
@zadjii-msft This

`/mnt/c/Users/roman/installed/ColorTool$ ./ColorTool.exe -x schemes/solarized_light.itermcolors`

changes background color in bash.exe.

This
`/mnt/c/Users/roman/installed/ColorTool$ ./ColorTool.exe -x iTerm2-Color-Schemes/schemes/Terminal\ Basic.itermcolors`

does not changes background color.

`Terminal Basic` taken from https://github.com/mbadolato/iTerm2-Color-Schemes.
I think I'm running into this issue.  Attempting to use ColorTool to change the background of the 'One Half Dark' color scheme to black instead of grey in the Windows Terminal preview, and nothing is happening.

Yeah this one does not work in Windows Terminal Preview...
> Yeah this one does not work in Windows Terminal Preview...

Incidentally, you can detect this state by the issue still being open. 😄

Fix patch:
diff --git a/src/tools/ColorTool/ColorTool/ColorScheme.cs b/src/tools/ColorTool/ColorTool/ColorScheme.cs
index b7490cd3c78..16132dd8d97 100644
--- a/src/tools/ColorTool/ColorTool/ColorScheme.cs
+++ b/src/tools/ColorTool/ColorTool/ColorScheme.cs
@@ -39,6 +39,10 @@ public ColorScheme(string name, uint[] colorTable, ConsoleAttributes consoleAttr
 
         public Color this[int index] => UIntToColor(ColorTable[index]);
 
+        public Color Foreground => UIntToColor(ConsoleAttributes.Foreground.Value);
+        public Color Background => UIntToColor(ConsoleAttributes.Background.Value);
+        public Color Cursor => UIntToColor(ConsoleAttributes.Cursor.Value);
+
         private static Color UIntToColor(uint color)
         {
             byte r = (byte)(color >> 0);
diff --git a/src/tools/ColorTool/ColorTool/ConsoleAttributes.cs b/src/tools/ColorTool/ColorTool/ConsoleAttributes.cs
index b3dc72a77d9..f09ff8beca6 100644
--- a/src/tools/ColorTool/ColorTool/ConsoleAttributes.cs
+++ b/src/tools/ColorTool/ColorTool/ConsoleAttributes.cs
@@ -10,17 +10,19 @@ namespace ColorTool
     /// </summary>
     public readonly struct ConsoleAttributes
     {
-        public ConsoleAttributes(uint? background, uint? foreground, uint? popupBackground, uint? popupForeground)
+        public ConsoleAttributes(uint? background, uint? foreground, uint? popupBackground, uint? popupForeground, uint? cursor)
         {
             Background = background;
             Foreground = foreground;
             PopupBackground = popupBackground;
             PopupForeground = popupForeground;
+            Cursor = cursor;
         }
 
         public uint? Foreground { get; }
         public uint? Background { get; }
         public uint? PopupForeground { get; }
         public uint? PopupBackground { get; }
+        public uint? Cursor { get; }
     }
 }
diff --git a/src/tools/ColorTool/ColorTool/ConsoleTargets/DefaultConsoleTarget.cs b/src/tools/ColorTool/ColorTool/ConsoleTargets/DefaultConsoleTarget.cs
index 1ac00c32e9f..fa8e1047168 100644
--- a/src/tools/ColorTool/ColorTool/ConsoleTargets/DefaultConsoleTarget.cs
+++ b/src/tools/ColorTool/ColorTool/ConsoleTargets/DefaultConsoleTarget.cs
@@ -21,11 +21,39 @@ public void ApplyColorScheme(ColorScheme colorScheme, bool quietMode)
                 string valueName = "ColorTable" + (i < 10 ? "0" : "") + i;
                 consoleKey.SetValue(valueName, colorScheme.ColorTable[i], RegistryValueKind.DWord);
             }
-            if(colorScheme.ScreenColorAttributes is ushort screenColors)
+            if (colorScheme.ConsoleAttributes.Cursor.HasValue)
             {
+                consoleKey.SetValue("CursorColor", colorScheme.ConsoleAttributes.Cursor, RegistryValueKind.DWord);
+            }
+            else
+            {
+                consoleKey.SetValue("CursorColor", -1, RegistryValueKind.DWord);
+            }
+            if (colorScheme.ScreenColorAttributes is ushort screenColors)
+            {
+                ushort fgidx = (ushort)(screenColors & 0xF);
+                ushort bgidx = (ushort)(screenColors >> 4);
+
                 consoleKey.SetValue("ScreenColors", screenColors, RegistryValueKind.DWord);
+
+                if (colorScheme.ColorTable[fgidx] != colorScheme.ConsoleAttributes.Foreground.Value)
+                {
+                    consoleKey.SetValue("DefaultForeground", colorScheme.ConsoleAttributes.Foreground.Value, RegistryValueKind.DWord);
+                }
+                else
+                {
+                    consoleKey.SetValue("DefaultForeground", -1, RegistryValueKind.DWord);
+                }
+                if (colorScheme.ColorTable[bgidx] != colorScheme.ConsoleAttributes.Background.Value)
+                {
+                    consoleKey.SetValue("DefaultBackground", colorScheme.ConsoleAttributes.Background.Value, RegistryValueKind.DWord);
+                }
+                else
+                {
+                    consoleKey.SetValue("DefaultBackground", -1, RegistryValueKind.DWord);
+                }
             }
-            if(colorScheme.PopupColorAttributes is ushort popupColors)
+            if (colorScheme.PopupColorAttributes is ushort popupColors)
             {
                 consoleKey.SetValue("PopupColors", popupColors, RegistryValueKind.DWord);
             }
diff --git a/src/tools/ColorTool/ColorTool/ConsoleTargets/TerminalSchemeConsoleTarget.cs b/src/tools/ColorTool/ColorTool/ConsoleTargets/TerminalSchemeConsoleTarget.cs
index a3746085de8..8bacf9d7f8b 100644
--- a/src/tools/ColorTool/ColorTool/ConsoleTargets/TerminalSchemeConsoleTarget.cs
+++ b/src/tools/ColorTool/ColorTool/ConsoleTargets/TerminalSchemeConsoleTarget.cs
@@ -48,6 +48,10 @@ public void ApplyColorScheme(ColorScheme colorScheme, bool quietMode)
             {
                 writeColorItem(colorScheme.ConsoleAttributes.Background.Value, "background", false);
             }
+            if (colorScheme.ConsoleAttributes.Cursor.HasValue)
+            {
+                writeColorItem(colorScheme.ConsoleAttributes.Cursor.Value, "cursorColor", false);
+            }
             for (int i = 0; i < colors.Length; i++)
             {
                 writeColorItem(colorScheme.ColorTable[i], colors[i], i == colors.Length - 1);
diff --git a/src/tools/ColorTool/ColorTool/ConsoleTargets/VirtualTerminalConsoleTarget.cs b/src/tools/ColorTool/ColorTool/ConsoleTargets/VirtualTerminalConsoleTarget.cs
index 6784be0f7fb..177b3c1611d 100644
--- a/src/tools/ColorTool/ColorTool/ConsoleTargets/VirtualTerminalConsoleTarget.cs
+++ b/src/tools/ColorTool/ColorTool/ConsoleTargets/VirtualTerminalConsoleTarget.cs
@@ -38,32 +38,40 @@ class VirtualTerminalConsoleTarget : IConsoleTarget
 
         public void ApplyColorScheme(ColorScheme colorScheme, bool quietMode)
         {
-            IntPtr hOut = GetStdOutputHandle();
-            uint originalMode;
-            uint requestedMode;
-            bool succeeded = GetConsoleMode(hOut, out originalMode);
-            if (succeeded)
+            Program.DoInVTMode(() =>
             {
-                requestedMode = originalMode | (uint)ConsoleAPI.ConsoleOutputModes.ENABLE_VIRTUAL_TERMINAL_PROCESSING;
-                SetConsoleMode(hOut, requestedMode);
-            }
+                if (colorScheme.ConsoleAttributes.Foreground.HasValue)
+                {
+                    Color color = colorScheme.Foreground;
+                    string s = $"\x1b]10;rgb:{color.R:X2}/{color.G:X2}/{color.B:X2}\x1b\\";
+                    Console.Write(s);
+                }
+                if (colorScheme.ConsoleAttributes.Background.HasValue)
+                {
+                    Color color = colorScheme.Background;
+                    string s = $"\x1b]11;rgb:{color.R:X2}/{color.G:X2}/{color.B:X2}\x1b\\";
+                    Console.Write(s);
+                }
+                if (colorScheme.ConsoleAttributes.Cursor.HasValue)
+                {
+                    Color color = colorScheme.Cursor;
+                    string s = $"\x1b]12;rgb:{color.R:X2}/{color.G:X2}/{color.B:X2}\x1b\\";
+                    Console.Write(s);
+                }
 
-            for (int i = 0; i < colorScheme.ColorTable.Length; i++)
-            {
-                int vtIndex = VirtualTerminalIndices[i];
-                Color color = colorScheme[i];
-                string s = $"\x1b]4;{vtIndex};rgb:{color.R:X}/{color.G:X}/{color.B:X}\x7";
-                Console.Write(s);
-            }
-            if (!quietMode)
-            {
-                ColorTable.PrintTableWithVt();
-            }
+                for (int i = 0; i < colorScheme.ColorTable.Length; i++)
+                {
+                    int vtIndex = VirtualTerminalIndices[i];
+                    Color color = colorScheme[i];
+                    string s = $"\x1b]4;{vtIndex};rgb:{color.R:X2}/{color.G:X2}/{color.B:X2}\x7";
+                    Console.Write(s);
+                }
 
-            if (succeeded)
-            {
-                SetConsoleMode(hOut, originalMode);
-            }
+                if (!quietMode)
+                {
+                    ColorTable.PrintTableWithVt();
+                }
+            });
         }
     }
 }
diff --git a/src/tools/ColorTool/ColorTool/Program.cs b/src/tools/ColorTool/ColorTool/Program.cs
index 92fd1f44940..cd1c283d566 100644
--- a/src/tools/ColorTool/ColorTool/Program.cs
+++ b/src/tools/ColorTool/ColorTool/Program.cs
@@ -5,6 +5,7 @@
 
 using ColorTool.ConsoleTargets;
 using ColorTool.SchemeWriters;
+using static ColorTool.ConsoleAPI;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -123,6 +124,24 @@ private static void OutputUsage()
             Console.WriteLine(Resources.OutputUsage);
         }
 
+        public static bool DoInVTMode(Action VTAction)
+        {
+            IntPtr hOut = GetStdOutputHandle();
+            uint requestedMode;
+            uint originalConsoleMode;
+            bool succeeded = GetConsoleMode(hOut, out originalConsoleMode);
+            if (succeeded)
+            {
+                requestedMode = originalConsoleMode | (uint)ConsoleAPI.ConsoleOutputModes.ENABLE_VIRTUAL_TERMINAL_PROCESSING;
+                SetConsoleMode(hOut, requestedMode);
+            }
+
+            VTAction();
+
+            if (succeeded) SetConsoleMode(hOut, originalConsoleMode);
+            return succeeded;
+        }
+
         private static void Version()
         {
             var assembly = System.Reflection.Assembly.GetExecutingAssembly();
diff --git a/src/tools/ColorTool/ColorTool/SchemeManager.cs b/src/tools/ColorTool/ColorTool/SchemeManager.cs
index 0e37cb65256..016c5507248 100644
--- a/src/tools/ColorTool/ColorTool/SchemeManager.cs
+++ b/src/tools/ColorTool/ColorTool/SchemeManager.cs
@@ -54,37 +54,35 @@ public static void PrintSchemes()
 
             if (Directory.Exists(schemeDirectory))
             {
-                IntPtr handle = GetStdOutputHandle();
-                GetConsoleMode(handle, out var mode);
-                SetConsoleMode(handle, mode | 0x4);
-
-                int consoleWidth = Console.WindowWidth;
-                string fgText = " gYw ";
-                foreach (string schemeName in Directory.GetFiles(schemeDirectory).Select(Path.GetFileName))
+                Program.DoInVTMode(() =>
                 {
-                    ColorScheme colorScheme = GetScheme(schemeName, false);
-                    if (colorScheme != null)
+                    int consoleWidth = Console.WindowWidth;
+                    string fgText = " gYw ";
+                    foreach (string schemeName in Directory.GetFiles(schemeDirectory).Select(Path.GetFileName))
                     {
-                        string colors = string.Empty;
-                        for (var index = 0; index < 8; index++)
+                        ColorScheme colorScheme = GetScheme(schemeName, false);
+                        if (colorScheme != null)
                         {
-                            var color = colorScheme[index];
-                            // Set the background color to the color in the scheme, plus some text to show how it looks
-                            colors += $"\x1b[48;2;{color.R};{color.G};{color.B}m{fgText}";
-                        }
-                        // Align scheme colors right, or on newline if it doesn't fit
-                        int schemeTextLength = fgText.Length * 8;
-                        int bufferLength = consoleWidth - (schemeName.Length + schemeTextLength);
+                            string colors = string.Empty;
+                            for (var index = 0; index < 8; index++)
+                            {
+                                var color = colorScheme[index];
+                                // Set the background color to the color in the scheme, plus some text to show how it looks
+                                colors += $"\x1b[48;2;{color.R};{color.G};{color.B}m{fgText}";
+                            }
+                            // Align scheme colors right, or on newline if it doesn't fit
+                            int schemeTextLength = fgText.Length * 8;
+                            int bufferLength = consoleWidth - (schemeName.Length + schemeTextLength);
 
-                        string bufferString = bufferLength >= 0
-                            ? new string(' ', bufferLength)
-                            : "\n" + new string(' ', consoleWidth - schemeTextLength);
+                            string bufferString = bufferLength >= 0
+                                ? new string(' ', bufferLength)
+                                : "\n" + new string(' ', consoleWidth - schemeTextLength);
 
-                        string outputString = schemeName + bufferString + colors;
-                        Console.WriteLine(outputString);
-                        Console.ResetColor();
+                            string outputString = schemeName + bufferString + colors + "\x1b[0m";
+                            Console.WriteLine(outputString);
+                        }
                     }
-                }
+                });
             }
         }
 
@@ -102,4 +100,4 @@ public static IEnumerable<ISchemeParser> GetParsers()
                 .Select(t => (ISchemeParser)Activator.CreateInstance(t));
         }
     }
-}
\ No newline at end of file
+}
diff --git a/src/tools/ColorTool/ColorTool/SchemeParsers/IniSchemeParser.cs b/src/tools/ColorTool/ColorTool/SchemeParsers/IniSchemeParser.cs
index c5605a2b3a4..0cdb061040a 100644
--- a/src/tools/ColorTool/ColorTool/SchemeParsers/IniSchemeParser.cs
+++ b/src/tools/ColorTool/ColorTool/SchemeParsers/IniSchemeParser.cs
@@ -4,11 +4,11 @@
 //
 
 using System;
+using System.Collections.Generic;
+using System.IO;
 using System.Linq;
-using System.Text;
 using System.Runtime.InteropServices;
-using System.IO;
-using System.Collections.Generic;
+using System.Text;
 using static ColorTool.ConsoleAPI;
 
 namespace ColorTool.SchemeParsers
@@ -56,6 +56,7 @@ public override ColorScheme ParseScheme(string schemeName, bool reportErrors = f
             uint? backgroundColor = null;
             uint? popupForegroundColor = null;
             uint? popupBackgroundColor = null;
+            uint? cursorColor = null;
 
             for (int i = 0; i < ColorTableSize; i++)
             {
@@ -85,7 +86,7 @@ public override ColorScheme ParseScheme(string schemeName, bool reportErrors = f
                         colorTable[i] = ParseColor(tableStrings[i]);
                     }
 
-                    if (ReadAttributes("popup", out var foreground, out var background))
+                    if (ReadAttributes("popup", out var foreground, out var background, out var cursor))
                     {
                         var foregroundIndex = (ColorNames as IList<string>).IndexOf(foreground);
                         var backgroundIndex = (ColorNames as IList<string>).IndexOf(background);
@@ -96,15 +97,30 @@ public override ColorScheme ParseScheme(string schemeName, bool reportErrors = f
                         }
                     }
 
-                    if (ReadAttributes("screen", out foreground, out background))
+                    if (ReadAttributes("screen", out foreground, out background, out cursor))
                     {
                         var foregroundIndex = (ColorNames as IList<string>).IndexOf(foreground);
                         var backgroundIndex = (ColorNames as IList<string>).IndexOf(background);
-                        if (foregroundIndex != -1 && backgroundIndex != -1)
+                        if (foregroundIndex != -1)
                         {
                             foregroundColor = colorTable[foregroundIndex];
+                        }
+                        else
+                        {
+                            foregroundColor = ParseColor(foreground);
+                        }
+                        if (backgroundIndex != -1)
+                        {
                             backgroundColor = colorTable[backgroundIndex];
                         }
+                        else
+                        {
+                            backgroundColor = ParseColor(background);
+                        }
+                        if (cursor.Length > 1)
+                        {
+                            cursorColor = ParseColor(cursor);
+                        }
                     }
                 }
                 catch (Exception /*e*/)
@@ -120,7 +136,7 @@ public override ColorScheme ParseScheme(string schemeName, bool reportErrors = f
 
             if (colorTable != null)
             {
-                var consoleAttributes = new ConsoleAttributes(backgroundColor, foregroundColor, popupBackgroundColor, popupForegroundColor);
+                var consoleAttributes = new ConsoleAttributes(backgroundColor, foregroundColor, popupBackgroundColor, popupForegroundColor, cursorColor);
                 return new ColorScheme(ExtractSchemeName(schemeName), colorTable, consoleAttributes);
             }
             else
@@ -128,24 +144,29 @@ public override ColorScheme ParseScheme(string schemeName, bool reportErrors = f
                 return null;
             }
 
-            bool ReadAttributes(string section, out string foreground, out string background)
+            bool ReadAttributes(string section, out string foreground, out string background, out string cursor)
             {
                 foreground = null;
                 background = null;
+                cursor = null;
 
                 StringBuilder buffer = new StringBuilder(512);
                 GetPrivateProfileString(section, "FOREGROUND", null, buffer, 512, filename);
                 foreground = buffer.ToString();
-                if (!ColorNames.Contains(foreground))
+                if (foreground.Length <= 1)
                     return false;
 
 
                 buffer = new StringBuilder(512);
                 GetPrivateProfileString(section, "BACKGROUND", null, buffer, 512, filename);
                 background = buffer.ToString();
-                if (!ColorNames.Contains(background))
+                if (background.Length <= 1)
                     return false;
 
+                buffer = new StringBuilder(512);
+                GetPrivateProfileString(section, "CURSOR", null, buffer, 512, filename);
+                cursor = buffer.ToString();
+
                 return true;
             }
         }
diff --git a/src/tools/ColorTool/ColorTool/SchemeParsers/JsonParser.cs b/src/tools/ColorTool/ColorTool/SchemeParsers/JsonParser.cs
index f5c385ccb77..c98cca02925 100644
--- a/src/tools/ColorTool/ColorTool/SchemeParsers/JsonParser.cs
+++ b/src/tools/ColorTool/ColorTool/SchemeParsers/JsonParser.cs
@@ -94,7 +94,7 @@ public override ColorScheme ParseScheme(string schemeName, bool reportErrors = f
                     }
                 }
 
-                var consoleAttributes = new ConsoleAttributes(screenBackground, screenForeground, popupBackground, popupForeground);
+                var consoleAttributes = new ConsoleAttributes(screenBackground, screenForeground, popupBackground, popupForeground, null);
                 return new ColorScheme(ExtractSchemeName(schemeName), colorTable, consoleAttributes);
             }
             catch (Exception /*e*/)
diff --git a/src/tools/ColorTool/ColorTool/SchemeParsers/XmlSchemeParser.cs b/src/tools/ColorTool/ColorTool/SchemeParsers/XmlSchemeParser.cs
index d33c82f466f..3d45bd552c7 100644
--- a/src/tools/ColorTool/ColorTool/SchemeParsers/XmlSchemeParser.cs
+++ b/src/tools/ColorTool/ColorTool/SchemeParsers/XmlSchemeParser.cs
@@ -37,6 +37,7 @@ class XmlSchemeParser : SchemeParserBase
 
         private const string ForegroundKey = "Foreground Color";
         private const string BackgroundKey = "Background Color";
+        private const string CursorKey = "Cursor Color";
         private const string RedKey = "Red Component";
         private const string GreenKey = "Green Component";
         private const string BlueKey = "Blue Component";
@@ -53,7 +54,7 @@ public override ColorScheme ParseScheme(string schemeName, bool reportErrors = f
             XmlNodeList children = root.ChildNodes;
 
             uint[] colorTable = new uint[ColorTableSize];
-            uint? fgColor = null, bgColor = null;
+            uint? fgColor = null, bgColor = null, cursorColor = null;
             int colorsFound = 0;
             bool success = false;
             foreach (var tableEntry in children.OfType<XmlNode>().Where(_ => _.Name == "key"))
@@ -65,6 +66,7 @@ public override ColorScheme ParseScheme(string schemeName, bool reportErrors = f
                 if (!success) { break; }
                 else if (tableEntry.InnerText == ForegroundKey) { fgColor = rgb; }
                 else if (tableEntry.InnerText == BackgroundKey) { bgColor = rgb; }
+                else if (tableEntry.InnerText == CursorKey) { cursorColor = rgb; }
                 else if (-1 != (index = Array.IndexOf(PListColorNames, tableEntry.InnerText)))
                 { colorTable[index] = rgb; colorsFound++; }
             }
@@ -81,7 +83,7 @@ public override ColorScheme ParseScheme(string schemeName, bool reportErrors = f
                 return null;
             }
 
-            var consoleAttributes = new ConsoleAttributes(bgColor, fgColor, null, null);
+            var consoleAttributes = new ConsoleAttributes(bgColor, fgColor, null, null, cursorColor);
             return new ColorScheme(ExtractSchemeName(schemeName), colorTable, consoleAttributes);
         }
 
diff --git a/src/tools/ColorTool/schemes/campbell-legacy.ini b/src/tools/ColorTool/schemes/campbell-legacy.ini
index 0374bbb4e9e..6f384025c62 100644
--- a/src/tools/ColorTool/schemes/campbell-legacy.ini
+++ b/src/tools/ColorTool/schemes/campbell-legacy.ini
@@ -16,6 +16,14 @@ BRIGHT_MAGENTA = 198,2,253
 BRIGHT_YELLOW = 255,247,149
 BRIGHT_WHITE = 240,239,241
 
+[screen]
+FOREGROUND = DARK_WHITE
+BACKGROUND = DARK_BLACK
+
+[popup]
+FOREGROUND = DARK_MAGENTA
+BACKGROUND = BRIGHT_WHITE
+
 [info]
 name = Campbell-Legacy
-author = paulcam
\ No newline at end of file
+author = paulcam
diff --git a/src/tools/ColorTool/schemes/campbell.ini b/src/tools/ColorTool/schemes/campbell.ini
index 6ce99f6f3bc..92357ed4e13 100644
--- a/src/tools/ColorTool/schemes/campbell.ini
+++ b/src/tools/ColorTool/schemes/campbell.ini
@@ -1,21 +1,29 @@
 [table]
-DARK_BLACK =           12,12,12 
-DARK_BLUE =           0,55,218     
-DARK_GREEN =           19,161,14        
-DARK_CYAN =           58,150,221         
-DARK_RED =           197,15,31     
-DARK_MAGENTA =           136,23,152            
-DARK_YELLOW =           193,156,0          
-DARK_WHITE =           204,204,204            
-BRIGHT_BLACK =           118,118,118              
-BRIGHT_BLUE =           59,120,255           
-BRIGHT_GREEN =           22,198,12          
-BRIGHT_CYAN =           97,214,214           
-BRIGHT_RED =           231,72,86        
-BRIGHT_MAGENTA =           180,0,158            
-BRIGHT_YELLOW =           249,241,165               
-BRIGHT_WHITE =           242,242,242    
+DARK_BLACK = 12,12,12
+DARK_BLUE = 0,55,218
+DARK_GREEN = 19,161,14
+DARK_CYAN = 58,150,221
+DARK_RED = 197,15,31
+DARK_MAGENTA = 136,23,152
+DARK_YELLOW = 193,156,0
+DARK_WHITE = 204,204,204
+BRIGHT_BLACK = 118,118,118
+BRIGHT_BLUE = 59,120,255
+BRIGHT_GREEN = 22,198,12
+BRIGHT_CYAN = 97,214,214
+BRIGHT_RED = 231,72,86
+BRIGHT_MAGENTA = 180,0,158
+BRIGHT_YELLOW = 249,241,165
+BRIGHT_WHITE = 242,242,242
+
+[screen]
+FOREGROUND = DARK_WHITE
+BACKGROUND = DARK_BLACK
+
+[popup]
+FOREGROUND = DARK_MAGENTA
+BACKGROUND = BRIGHT_WHITE
 
 [info]
 name = Campbell
-author = crloew
\ No newline at end of file
+author = crloew
diff --git a/src/tools/ColorTool/schemes/cmd-legacy.ini b/src/tools/ColorTool/schemes/cmd-legacy.ini
index 39ee2f4de00..0173da0bd3e 100644
--- a/src/tools/ColorTool/schemes/cmd-legacy.ini
+++ b/src/tools/ColorTool/schemes/cmd-legacy.ini
@@ -16,6 +16,14 @@ BRIGHT_MAGENTA = 255, 0, 255
 BRIGHT_YELLOW = 255, 255, 0
 BRIGHT_WHITE = 255, 255, 255
 
+[screen]
+FOREGROUND = DARK_WHITE
+BACKGROUND = DARK_BLACK
+
+[popup]
+FOREGROUND = DARK_MAGENTA
+BACKGROUND = BRIGHT_WHITE
+
 [info]
 name = cmd-legacy
-author = unknown
\ No newline at end of file
+author = unknown


Test patch: