Skip to content

Need to re-implement ConsoleColorProxy #1607

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

Closed
andyleejordan opened this issue Oct 29, 2021 · 7 comments · Fixed by #1711
Closed

Need to re-implement ConsoleColorProxy #1607

andyleejordan opened this issue Oct 29, 2021 · 7 comments · Fixed by #1711
Assignees

Comments

@andyleejordan
Copy link
Member

From Rob: we need to go implement this with @SteveL-MSFT and @daxian-dbw's help because it's an "obscure" interface.

Originally posted by @andschwa in #1459 (comment)

@ghost ghost added the Needs: Triage Maintainer attention needed! label Oct 29, 2021
@andyleejordan
Copy link
Member Author

It's currently disabled:

/*
using System;
using System.Management.Automation.Host;
namespace Microsoft.PowerShell.EditorServices.Services.PowerShell.Host
{
internal class ConsoleColorProxy
{
internal ConsoleColorProxy(EditorServicesConsolePSHostUserInterface hostUserInterface)
{
if (hostUserInterface == null) throw new ArgumentNullException();
_hostUserInterface = hostUserInterface;
}
/// <summary>
/// The Accent Color for Formatting
/// </summary>
public ConsoleColor FormatAccentColor
{
get
{ return _hostUserInterface.FormatAccentColor; }
set
{ _hostUserInterface.FormatAccentColor = value; }
}
/// <summary>
/// The Accent Color for Error
/// </summary>
public ConsoleColor ErrorAccentColor
{
get
{ return _hostUserInterface.ErrorAccentColor; }
set
{ _hostUserInterface.ErrorAccentColor = value; }
}
/// <summary>
/// The ForegroundColor for Error
/// </summary>
public ConsoleColor ErrorForegroundColor
{
get
{ return _hostUserInterface.ErrorForegroundColor; }
set
{ _hostUserInterface.ErrorForegroundColor = value; }
}
/// <summary>
/// The BackgroundColor for Error
/// </summary>
public ConsoleColor ErrorBackgroundColor
{
get
{ return _hostUserInterface.ErrorBackgroundColor; }
set
{ _hostUserInterface.ErrorBackgroundColor = value; }
}
/// <summary>
/// The ForegroundColor for Warning
/// </summary>
public ConsoleColor WarningForegroundColor
{
get
{ return _hostUserInterface.WarningForegroundColor; }
set
{ _hostUserInterface.WarningForegroundColor = value; }
}
/// <summary>
/// The BackgroundColor for Warning
/// </summary>
public ConsoleColor WarningBackgroundColor
{
get
{ return _hostUserInterface.WarningBackgroundColor; }
set
{ _hostUserInterface.WarningBackgroundColor = value; }
}
/// <summary>
/// The ForegroundColor for Debug
/// </summary>
public ConsoleColor DebugForegroundColor
{
get
{ return _hostUserInterface.DebugForegroundColor; }
set
{ _hostUserInterface.DebugForegroundColor = value; }
}
/// <summary>
/// The BackgroundColor for Debug
/// </summary>
public ConsoleColor DebugBackgroundColor
{
get
{ return _hostUserInterface.DebugBackgroundColor; }
set
{ _hostUserInterface.DebugBackgroundColor = value; }
}
/// <summary>
/// The ForegroundColor for Verbose
/// </summary>
public ConsoleColor VerboseForegroundColor
{
get
{ return _hostUserInterface.VerboseForegroundColor; }
set
{ _hostUserInterface.VerboseForegroundColor = value; }
}
/// <summary>
/// The BackgroundColor for Verbose
/// </summary>
public ConsoleColor VerboseBackgroundColor
{
get
{ return _hostUserInterface.VerboseBackgroundColor; }
set
{ _hostUserInterface.VerboseBackgroundColor = value; }
}
/// <summary>
/// The ForegroundColor for Progress
/// </summary>
public ConsoleColor ProgressForegroundColor
{
get
{ return _hostUserInterface.ProgressForegroundColor; }
set
{ _hostUserInterface.ProgressForegroundColor = value; }
}
/// <summary>
/// The BackgroundColor for Progress
/// </summary>
public ConsoleColor ProgressBackgroundColor
{
get
{ return _hostUserInterface.ProgressBackgroundColor; }
set
{ _hostUserInterface.ProgressBackgroundColor = value; }
}
}
}
*/

@andyleejordan
Copy link
Member Author

@SydneyhSmith We need to figure out if this is the "old-school" colors and if so, do we actually need to support it? Because as it is, the console has colors (since everything is modern now and ANSI color escape sequence based, which all works).

@andyleejordan andyleejordan removed this from the Committed milestone Feb 4, 2022
@andyleejordan
Copy link
Member Author

Ok, so yes, this would really only fix color support on ancient (read: near end-of-life) Windows platforms such as Windows Server 2012R2). This is not a priority.

@SeeminglyScience
Copy link
Collaborator

I believe it's all color formatting in Windows PowerShell and also some in later versions (even on modern OSes)

Like if you do this:

$Host.psobject.Properties.Add(
    [psnoteproperty]::new(
        'PrivateData',
        [pscustomobject]@{
            ErrorBackgroundColor = [ConsoleColor]::Black
            ErrorForegroundColor = [ConsoleColor]::DarkCyan
            ErrorAccentColor = [ConsoleColor]::Cyan
            FormatAccentColor = [ConsoleColor]::Green
            WarningForegroundColor = [ConsoleColor]::Yellow
            WarningBackgroundColor = [ConsoleColor]::Black
            DebugForegroundColor = [ConsoleColor]::Yellow
            DebugBackgroundColor = [ConsoleColor]::Black
            VerboseForegroundColor = [ConsoleColor]::Yellow
            VerboseBackgroundColor = [ConsoleColor]::Black
            ProgressForegroundColor = [ConsoleColor]::Black
            ProgressBackgroundColor = [ConsoleColor]::Yellow
        }))

Error formatting is fixed even in 7.3

@andyleejordan
Copy link
Member Author

Is this something perhaps more easily fixed than Rob's comment led me to believe?

@SeeminglyScience
Copy link
Collaborator

I think it used to be pretty complicated to implement. Now though I think we route so much though ConsoleHost that I'm pretty sure we can directly surface it's PrivateData without even having to implement our own.

e.g. I think we can just do PrivateData => _internalHost.PrivateData;

@andyleejordan
Copy link
Member Author

I'm down to try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants