mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Change default colors, and show highlighted text properly
This commit is contained in:
@@ -72,6 +72,20 @@ namespace Microsoft.PowerShell
|
||||
|
||||
public class PSConsoleReadlineOptions
|
||||
{
|
||||
#if CORECLR
|
||||
public const ConsoleColor DefaultCommentForegroundColor = ConsoleColor.Magenta;
|
||||
public const ConsoleColor DefaultKeywordForegroundColor = ConsoleColor.Green;
|
||||
public const ConsoleColor DefaultStringForegroundColor = ConsoleColor.DarkCyan;
|
||||
public const ConsoleColor DefaultOperatorForegroundColor = ConsoleColor.Gray;
|
||||
public const ConsoleColor DefaultVariableForegroundColor = ConsoleColor.Green;
|
||||
public const ConsoleColor DefaultCommandForegroundColor = ConsoleColor.Yellow;
|
||||
public const ConsoleColor DefaultParameterForegroundColor = ConsoleColor.Green;
|
||||
public const ConsoleColor DefaultTypeForegroundColor = ConsoleColor.Gray;
|
||||
public const ConsoleColor DefaultNumberForegroundColor = ConsoleColor.White;
|
||||
public const ConsoleColor DefaultMemberForegroundColor = ConsoleColor.Gray;
|
||||
public const ConsoleColor DefaultEmphasisForegroundColor = ConsoleColor.Cyan;
|
||||
public const ConsoleColor DefaultErrorForegroundColor = ConsoleColor.Red;
|
||||
#else
|
||||
public const ConsoleColor DefaultCommentForegroundColor = ConsoleColor.DarkGreen;
|
||||
public const ConsoleColor DefaultKeywordForegroundColor = ConsoleColor.Green;
|
||||
public const ConsoleColor DefaultStringForegroundColor = ConsoleColor.DarkCyan;
|
||||
@@ -84,7 +98,7 @@ namespace Microsoft.PowerShell
|
||||
public const ConsoleColor DefaultMemberForegroundColor = ConsoleColor.Gray;
|
||||
public const ConsoleColor DefaultEmphasisForegroundColor = ConsoleColor.Cyan;
|
||||
public const ConsoleColor DefaultErrorForegroundColor = ConsoleColor.Red;
|
||||
|
||||
#endif
|
||||
|
||||
public const EditMode DefaultEditMode = EditMode.Windows;
|
||||
|
||||
|
||||
@@ -472,8 +472,14 @@ namespace Microsoft.PowerShell
|
||||
// to invert only the lower 3 bits to change the color is somewhat
|
||||
// but looks best with the 2 default color schemes - starting PowerShell
|
||||
// from it's shortcut or from a cmd shortcut.
|
||||
#if CORECLR
|
||||
ConsoleColor tempColor = ((int)foregroundColor == -1) ? ConsoleColor.White : foregroundColor;
|
||||
foregroundColor = ((int)backgroundColor == -1) ? ConsoleColor.Black : backgroundColor;
|
||||
backgroundColor = tempColor;
|
||||
#else
|
||||
foregroundColor = (ConsoleColor)((int)foregroundColor ^ 7);
|
||||
backgroundColor = (ConsoleColor)((int)backgroundColor ^ 7);
|
||||
#endif
|
||||
}
|
||||
|
||||
charInfo.ForegroundColor = foregroundColor;
|
||||
|
||||
@@ -19,8 +19,16 @@ namespace Microsoft.PowerShell
|
||||
var buffer = ReadBufferLines(start, count);
|
||||
for (int i = 0; i < buffer.Length; i++)
|
||||
{
|
||||
#if CORECLR
|
||||
ConsoleColor tempColor = (int)buffer[i].ForegroundColor == -1
|
||||
? ConsoleColor.White : buffer[i].ForegroundColor;
|
||||
buffer[i].ForegroundColor = (int)buffer[i].BackgroundColor == -1
|
||||
? ConsoleColor.Black : buffer[i].BackgroundColor;
|
||||
buffer[i].BackgroundColor = tempColor;
|
||||
#else
|
||||
buffer[i].ForegroundColor = (ConsoleColor)((int)buffer[i].ForegroundColor ^ 7);
|
||||
buffer[i].BackgroundColor = (ConsoleColor)((int)buffer[i].BackgroundColor ^ 7);
|
||||
#endif
|
||||
}
|
||||
_singleton._console.WriteBufferLines(buffer, ref start, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user