Skip to content

Need to re-implement ConsoleColorProxy #1607

Closed

Description

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

Originally posted by Andy Jordan (@andschwa) in #1459 (comment)

Activity

  1. ghost added
    Needs: TriageMaintainer attention needed!
    on Oct 29, 2021
  2. andyleejordan commented on Oct 29, 2021

    @andyleejordan
    MemberAuthor

    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; }
    }
    }
    }
    */

  3. andyleejordan commented on Feb 4, 2022

    @andyleejordan
    MemberAuthor

    Sydney Smith (@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).

  4. andyleejordan commented on Feb 4, 2022

    @andyleejordan
    MemberAuthor

    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.

  5. SeeminglyScience commented on Feb 4, 2022

    @SeeminglyScience
    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

  6. andyleejordan commented on Feb 4, 2022

    @andyleejordan
    MemberAuthor

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

  7. SeeminglyScience commented on Feb 4, 2022

    @SeeminglyScience
    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;

  8. andyleejordan commented on Feb 4, 2022

    @andyleejordan
    MemberAuthor

    I'm down to try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions