diff --git a/.travis.yml b/.travis.yml
index d1611f7b9..1356e9224 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -26,4 +26,4 @@ install:
script:
- ulimit -n 4096
- - powershell -File scripts/travis.ps1
\ No newline at end of file
+ - powershell -File scripts/travis.ps1
diff --git a/src/PowerShellEditorServices/Session/Host/EditorServicesPSHost.cs b/src/PowerShellEditorServices/Session/Host/EditorServicesPSHost.cs
index d524396c6..33925f044 100644
--- a/src/PowerShellEditorServices/Session/Host/EditorServicesPSHost.cs
+++ b/src/PowerShellEditorServices/Session/Host/EditorServicesPSHost.cs
@@ -77,15 +77,140 @@ public override string Name
get { return this.hostDetails.Name; }
}
+ internal class ConsoleColorProxy
+ {
+ private EditorServicesPSHostUserInterface _hostUserInterface;
+
+ internal ConsoleColorProxy(EditorServicesPSHostUserInterface hostUserInterface)
+ {
+ if (hostUserInterface == null) throw new ArgumentNullException("hostUserInterface");
+ _hostUserInterface = hostUserInterface;
+ }
+
+ ///
+ /// The ForegroundColor for Error
+ ///
+ public ConsoleColor ErrorForegroundColor
+ {
+ get
+ { return _hostUserInterface.ErrorForegroundColor; }
+ set
+ { _hostUserInterface.ErrorForegroundColor = value; }
+ }
+
+ ///
+ /// The BackgroundColor for Error
+ ///
+ public ConsoleColor ErrorBackgroundColor
+ {
+ get
+ { return _hostUserInterface.ErrorBackgroundColor; }
+ set
+ { _hostUserInterface.ErrorBackgroundColor = value; }
+ }
+
+ ///
+ /// The ForegroundColor for Warning
+ ///
+ public ConsoleColor WarningForegroundColor
+ {
+ get
+ { return _hostUserInterface.WarningForegroundColor; }
+ set
+ { _hostUserInterface.WarningForegroundColor = value; }
+ }
+
+ ///
+ /// The BackgroundColor for Warning
+ ///
+ public ConsoleColor WarningBackgroundColor
+ {
+ get
+ { return _hostUserInterface.WarningBackgroundColor; }
+ set
+ { _hostUserInterface.WarningBackgroundColor = value; }
+ }
+
+ ///
+ /// The ForegroundColor for Debug
+ ///
+ public ConsoleColor DebugForegroundColor
+ {
+ get
+ { return _hostUserInterface.DebugForegroundColor; }
+ set
+ { _hostUserInterface.DebugForegroundColor = value; }
+ }
+
+ ///
+ /// The BackgroundColor for Debug
+ ///
+ public ConsoleColor DebugBackgroundColor
+ {
+ get
+ { return _hostUserInterface.DebugBackgroundColor; }
+ set
+ { _hostUserInterface.DebugBackgroundColor = value; }
+ }
+
+ ///
+ /// The ForegroundColor for Verbose
+ ///
+ public ConsoleColor VerboseForegroundColor
+ {
+ get
+ { return _hostUserInterface.VerboseForegroundColor; }
+ set
+ { _hostUserInterface.VerboseForegroundColor = value; }
+ }
+
+ ///
+ /// The BackgroundColor for Verbose
+ ///
+ public ConsoleColor VerboseBackgroundColor
+ {
+ get
+ { return _hostUserInterface.VerboseBackgroundColor; }
+ set
+ { _hostUserInterface.VerboseBackgroundColor = value; }
+ }
+
+ ///
+ /// The ForegroundColor for Progress
+ ///
+ public ConsoleColor ProgressForegroundColor
+ {
+ get
+ { return _hostUserInterface.ProgressForegroundColor; }
+ set
+ { _hostUserInterface.ProgressForegroundColor = value; }
+ }
+
+ ///
+ /// The BackgroundColor for Progress
+ ///
+ public ConsoleColor ProgressBackgroundColor
+ {
+ get
+ { return _hostUserInterface.ProgressBackgroundColor; }
+ set
+ { _hostUserInterface.ProgressBackgroundColor = value; }
+ }
+ }
+
///
- ///
+ /// Return the actual console host object so that the user can get at
+ /// the unproxied methods.
///
public override PSObject PrivateData
{
- // There is no PrivateData yet but by returning an empty object we can get past PowerShell's
- // check for $host.PrivateData["window"] which errors on the null returned by default.
- get { return new PSObject(); }
+ get
+ {
+ if (hostUserInterface == null) return null;
+ return _consoleColorProxy ?? (_consoleColorProxy = PSObject.AsPSObject(new ConsoleColorProxy(hostUserInterface)));
+ }
}
+ private PSObject _consoleColorProxy;
///
///
diff --git a/src/PowerShellEditorServices/Session/Host/EditorServicesPSHostUserInterface.cs b/src/PowerShellEditorServices/Session/Host/EditorServicesPSHostUserInterface.cs
index e5006f0f7..2aceaaf10 100644
--- a/src/PowerShellEditorServices/Session/Host/EditorServicesPSHostUserInterface.cs
+++ b/src/PowerShellEditorServices/Session/Host/EditorServicesPSHostUserInterface.cs
@@ -529,7 +529,8 @@ public override void WriteDebugLine(string message)
DebugMessagePrefix + message,
true,
OutputType.Debug,
- foregroundColor: ConsoleColor.Yellow);
+ foregroundColor: this.DebugForegroundColor,
+ backgroundColor: this.DebugBackgroundColor);
}
///
@@ -542,7 +543,8 @@ public override void WriteVerboseLine(string message)
VerboseMessagePrefix + message,
true,
OutputType.Verbose,
- foregroundColor: ConsoleColor.Blue);
+ foregroundColor: this.VerboseForegroundColor,
+ backgroundColor: this.VerboseBackgroundColor);
}
///
@@ -555,7 +557,8 @@ public override void WriteWarningLine(string message)
WarningMessagePrefix + message,
true,
OutputType.Warning,
- foregroundColor: ConsoleColor.Yellow);
+ foregroundColor: this.WarningForegroundColor,
+ backgroundColor: this.WarningBackgroundColor);
}
///
@@ -568,7 +571,8 @@ public override void WriteErrorLine(string value)
value,
true,
OutputType.Error,
- ConsoleColor.Red);
+ foregroundColor: this.ErrorForegroundColor,
+ backgroundColor: this.ErrorBackgroundColor);
}
///
@@ -684,6 +688,23 @@ private void WriteDebuggerBanner(DebuggerStopEventArgs eventArgs)
}
}
+ internal static ConsoleColor BackgroundColor { get; set; }
+
+ internal ConsoleColor ErrorForegroundColor { get; set; } = ConsoleColor.Red;
+ internal ConsoleColor ErrorBackgroundColor { get; set; } = BackgroundColor;
+
+ internal ConsoleColor WarningForegroundColor { get; set; } = ConsoleColor.Yellow;
+ internal ConsoleColor WarningBackgroundColor { get; set; } = BackgroundColor;
+
+ internal ConsoleColor DebugForegroundColor { get; set; } = ConsoleColor.Yellow;
+ internal ConsoleColor DebugBackgroundColor { get; set; } = BackgroundColor;
+
+ internal ConsoleColor VerboseForegroundColor { get; set; } = ConsoleColor.Yellow;
+ internal ConsoleColor VerboseBackgroundColor { get; set; } = BackgroundColor;
+
+ internal ConsoleColor ProgressForegroundColor { get; set; } = ConsoleColor.Yellow;
+ internal ConsoleColor ProgressBackgroundColor { get; set; } = ConsoleColor.DarkCyan;
+
private async Task StartReplLoop(CancellationToken cancellationToken)
{
do