From 56ed87c108fff0ffd7772eaef894eb12007ba8ee Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Sat, 20 Feb 2016 15:04:49 -0800 Subject: [PATCH] Respect Console.BackGround color This was bugging me. Instead of using the existing console's background color, we were hard-coding "Black." Now we just leave it alone. --- src/Microsoft.PowerShell.Linux.Host/main.cs | 2 +- src/Microsoft.PowerShell.Linux.Host/ui.cs | 23 ++++++++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.PowerShell.Linux.Host/main.cs b/src/Microsoft.PowerShell.Linux.Host/main.cs index aec3e215c6..e8605c79f5 100644 --- a/src/Microsoft.PowerShell.Linux.Host/main.cs +++ b/src/Microsoft.PowerShell.Linux.Host/main.cs @@ -518,7 +518,7 @@ OPTIONS prompt = "PS> "; } - this.myHost.UI.Write(ConsoleColor.White, ConsoleColor.Black, prompt); + this.myHost.UI.Write(ConsoleColor.White, Console.BackgroundColor, prompt); string cmd = consoleReadLine.Read(this.myHost.Runspace); this.Execute(cmd); } diff --git a/src/Microsoft.PowerShell.Linux.Host/ui.cs b/src/Microsoft.PowerShell.Linux.Host/ui.cs index c1c6626eaf..4d105d6556 100644 --- a/src/Microsoft.PowerShell.Linux.Host/ui.cs +++ b/src/Microsoft.PowerShell.Linux.Host/ui.cs @@ -54,7 +54,7 @@ namespace Microsoft.PowerShell.Linux.Host { this.Write( ConsoleColor.White, - ConsoleColor.Black, + Console.BackgroundColor, caption + System.Environment.NewLine + message + " "); Dictionary results = new Dictionary(); @@ -96,7 +96,7 @@ namespace Microsoft.PowerShell.Linux.Host // Write the caption and message strings in Blue. this.WriteLine( ConsoleColor.Blue, - ConsoleColor.Black, + Console.BackgroundColor, caption + System.Environment.NewLine + message + System.Environment.NewLine); // Convert the choice collection into something that is @@ -124,7 +124,7 @@ namespace Microsoft.PowerShell.Linux.Host // chosen, or the loop is interrupted with ctrl-C. while (true) { - this.WriteLine(ConsoleColor.Cyan, ConsoleColor.Black, sb.ToString()); + this.WriteLine(ConsoleColor.Cyan, Console.BackgroundColor, sb.ToString()); string data = Console.ReadLine().Trim().ToUpper(); // If the choice string was empty, use the default selection. @@ -170,7 +170,7 @@ namespace Microsoft.PowerShell.Linux.Host // Write the caption and message strings in Blue. this.WriteLine( ConsoleColor.Blue, - ConsoleColor.Black, + Console.BackgroundColor, caption + System.Environment.NewLine + message + System.Environment.NewLine); // Convert the choice collection into something that is @@ -217,7 +217,7 @@ namespace Microsoft.PowerShell.Linux.Host this.WriteLine( ConsoleColor.Cyan, - ConsoleColor.Black, + Console.BackgroundColor, sb.ToString()); // Read prompts until a match is made, the default is // chosen, or the loop is interrupted with ctrl-C. @@ -226,7 +226,7 @@ namespace Microsoft.PowerShell.Linux.Host { ReadNext: string prompt = string.Format(CultureInfo.CurrentCulture, "Choice[{0}]:", results.Count); - this.Write(ConsoleColor.Cyan, ConsoleColor.Black, prompt); + this.Write(ConsoleColor.Cyan, Console.BackgroundColor, prompt); string data = Console.ReadLine().Trim().ToUpper(); // If the choice string was empty, no more choices have been made. @@ -352,7 +352,6 @@ ReadNext: Console.ForegroundColor = foregroundColor; Console.BackgroundColor = backgroundColor; Console.Write(value); - //Console.Write(value); Console.ResetColor(); } @@ -361,7 +360,7 @@ ReadNext: /// Writes a line of characters to the output display of the host /// with foreground and background colors and appends a newline (carriage return). /// - /// The forground color of the display. + /// The foreground color of the display. /// The background color of the display. /// The line to be written. public override void WriteLine( @@ -383,7 +382,7 @@ ReadNext: { this.WriteLine( ConsoleColor.Yellow, - ConsoleColor.Black, + Console.BackgroundColor, String.Format(CultureInfo.CurrentCulture, "DEBUG: {0}", message)); } @@ -396,7 +395,7 @@ ReadNext: { this.WriteLine( ConsoleColor.Red, - ConsoleColor.Black, + Console.BackgroundColor, value); } @@ -454,7 +453,7 @@ ReadNext: { this.WriteLine( ConsoleColor.Green, - ConsoleColor.Black, + Console.BackgroundColor, String.Format(CultureInfo.CurrentCulture, "VERBOSE: {0}", message)); } @@ -466,7 +465,7 @@ ReadNext: { this.WriteLine( ConsoleColor.Yellow, - ConsoleColor.Black, + Console.BackgroundColor, String.Format(CultureInfo.CurrentCulture, "WARNING: {0}", message)); }