-
Notifications
You must be signed in to change notification settings - Fork 234
Add customize output color enhancement #654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,4 @@ install: | |
|
||
script: | ||
- ulimit -n 4096 | ||
- powershell -File scripts/travis.ps1 | ||
- powershell -File scripts/travis.ps1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
using Microsoft.PowerShell.EditorServices.Session; | ||
using Microsoft.PowerShell.EditorServices.Utility; | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Management.Automation; | ||
using System.Management.Automation.Host; | ||
using System.Management.Automation.Runspaces; | ||
|
@@ -78,14 +79,165 @@ public override string Name | |
} | ||
|
||
/// <summary> | ||
/// | ||
/// | ||
/// </summary> | ||
public class ConsoleColorProxy | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SeeminglyScience Sorry I delete my comments in your review, afterwards I notice that the error I get with travis was from public members. I didn't notice that it work with internal members. And when I pushed that change AppVeyor worked I don't know why it was stuck for 20 minute. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AppVeyor and Travis sometimes have issues (not our issues) and it's just a matter of restarting the build and it works. 😀 |
||
{ | ||
private EditorServicesPSHostUserInterface _hostUserInterface; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColorProxy(EditorServicesPSHostUserInterface hostUserInterface) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
{ | ||
if (hostUserInterface == null) throw new ArgumentNullException("hostUserInterface"); | ||
_hostUserInterface = hostUserInterface; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you either remove these summaries or add like "The ForegroundColor for Errors" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add text, I think that your configuration of travis doesn't accept warning from XML documentation for public members There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good! |
||
public ConsoleColor ErrorForegroundColor | ||
{ | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the diagnostic suppressions ( |
||
get | ||
{ return _hostUserInterface.ErrorForegroundColor; } | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
set | ||
{ _hostUserInterface.ErrorForegroundColor = value; } | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor ErrorBackgroundColor | ||
{ | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
get | ||
{ return _hostUserInterface.ErrorBackgroundColor; } | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
set | ||
{ _hostUserInterface.ErrorBackgroundColor = value; } | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor WarningForegroundColor | ||
{ | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
get | ||
{ return _hostUserInterface.WarningForegroundColor; } | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
set | ||
{ _hostUserInterface.WarningForegroundColor = value; } | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor WarningBackgroundColor | ||
{ | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
get | ||
{ return _hostUserInterface.WarningBackgroundColor; } | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
set | ||
{ _hostUserInterface.WarningBackgroundColor = value; } | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor DebugForegroundColor | ||
{ | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
get | ||
{ return _hostUserInterface.DebugForegroundColor; } | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
set | ||
{ _hostUserInterface.DebugForegroundColor = value; } | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor DebugBackgroundColor | ||
{ | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
get | ||
{ return _hostUserInterface.DebugBackgroundColor; } | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
set | ||
{ _hostUserInterface.DebugBackgroundColor = value; } | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor VerboseForegroundColor | ||
{ | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
get | ||
{ return _hostUserInterface.VerboseForegroundColor; } | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
set | ||
{ _hostUserInterface.VerboseForegroundColor = value; } | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor VerboseBackgroundColor | ||
{ | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
get | ||
{ return _hostUserInterface.VerboseBackgroundColor; } | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
set | ||
{ _hostUserInterface.VerboseBackgroundColor = value; } | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor ProgressForegroundColor | ||
{ | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
get | ||
{ return _hostUserInterface.ProgressForegroundColor; } | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
set | ||
{ _hostUserInterface.ProgressForegroundColor = value; } | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor ProgressBackgroundColor | ||
{ | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
get | ||
{ return _hostUserInterface.ProgressBackgroundColor; } | ||
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | ||
set | ||
{ _hostUserInterface.ProgressBackgroundColor = value; } | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Return the actual console host object so that the user can get at | ||
/// the unproxied methods. | ||
/// </summary> | ||
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; | ||
|
||
/// <summary> | ||
/// | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -529,7 +529,8 @@ public override void WriteDebugLine(string message) | |
DebugMessagePrefix + message, | ||
true, | ||
OutputType.Debug, | ||
foregroundColor: ConsoleColor.Yellow); | ||
foregroundColor: this.DebugForegroundColor, | ||
backgroundColor: this.DebugBackgroundColor); | ||
} | ||
|
||
/// <summary> | ||
|
@@ -542,7 +543,8 @@ public override void WriteVerboseLine(string message) | |
VerboseMessagePrefix + message, | ||
true, | ||
OutputType.Verbose, | ||
foregroundColor: ConsoleColor.Blue); | ||
foregroundColor: this.VerboseForegroundColor, | ||
backgroundColor: this.VerboseBackgroundColor); | ||
} | ||
|
||
/// <summary> | ||
|
@@ -555,7 +557,8 @@ public override void WriteWarningLine(string message) | |
WarningMessagePrefix + message, | ||
true, | ||
OutputType.Warning, | ||
foregroundColor: ConsoleColor.Yellow); | ||
foregroundColor: this.WarningForegroundColor, | ||
backgroundColor: this.WarningBackgroundColor); | ||
} | ||
|
||
/// <summary> | ||
|
@@ -568,7 +571,8 @@ public override void WriteErrorLine(string value) | |
value, | ||
true, | ||
OutputType.Error, | ||
ConsoleColor.Red); | ||
foregroundColor: this.ErrorForegroundColor, | ||
backgroundColor: this.ErrorBackgroundColor); | ||
} | ||
|
||
/// <summary> | ||
|
@@ -684,6 +688,60 @@ private void WriteDebuggerBanner(DebuggerStopEventArgs eventArgs) | |
} | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public static ConsoleColor BackgroundColor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the color properties here can be |
||
{ | ||
get; | ||
set; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should follow the same style as below (e.g. |
||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor ErrorForegroundColor { get; set; } = ConsoleColor.Red; | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor ErrorBackgroundColor { get; set; } = BackgroundColor; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor WarningForegroundColor { get; set; } = ConsoleColor.Yellow; | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor WarningBackgroundColor { get; set; } = BackgroundColor; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor DebugForegroundColor { get; set; } = ConsoleColor.Yellow; | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor DebugBackgroundColor { get; set; } = BackgroundColor; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor VerboseForegroundColor { get; set; } = ConsoleColor.Yellow; | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor VerboseBackgroundColor { get; set; } = BackgroundColor; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor ProgressForegroundColor { get; set; } = ConsoleColor.Yellow; | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public ConsoleColor ProgressBackgroundColor { get; set; } = ConsoleColor.DarkCyan; | ||
|
||
private async Task StartReplLoop(CancellationToken cancellationToken) | ||
{ | ||
do | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed after the
SuppressMessage
attributes are removed.