You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
We need a way to customize output color for error/warning, etc #651
Port ConsoleColorProxy and the PrivateData member from ConsoleHost in pwsh to EditorServicesPSHost.PrivateData
The link for EditorServicesPSHost.PrivateData redirect here, I should create this file and copy/past ConsoleColorProxy class and PrivateData member in it, or this file already exist ?
Edit
Nevermind I just found PrivateData. Sorry but my english comprehension is not perfect but what do you mean by "Port ConsoleColorProxy ..." ? I guess that it's not just a copy/past, right ?
No problem :) Port usually means "take that and add it to this" sometimes it does mean actually copy/paste. However I think it's a little bit more work than copy/paste.
First copy paste those classes over into EditorServicesPSHost.PrivateData, then try to build and see what you need to fix to get those classes to work in PSES(PowerShell Editor Services).
Then, follow Patrick Meinecke (@SeeminglyScience)'s next step and Change the Write* methods in EditorServicesPSHostUserInterface to use the new colors.
@tylerl0706 Ok ! But I have to copy ConsoleColorProxy class into the override or above like in ConsoleHost ?
Edit
I can't use ConsoleHostUserInterface due to his level of restriction I tried using Microsoft.PowerShell.EditorServices.Console; but it doesn't work. Which import should I use to prevent this error ?
@tylerl0706 The problem is that EditorServicesPSHostUserInterface doesn't contain any color method so when I replace ConsoleHostUserInterface I have this error :
Session/Host/EditorServicesPSHost.cs(99,45): error CS1061: 'EditorServicesPSHostUserInterface' doesn't contain any definition for 'ErrorForegroundColor' and no extension method 'ErrorForegroundColor' accepting first argument of type 'EditorServicesPSHostUserInterface' has been found
Should I use WriteErrorLine instead of ErrorForegroundColoror ErrorBackgroundColor?
For example
public ConsoleColor ErrorBackgroundColor
{
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
get
{ return _hostUserInterface.Write.backgroundColor; }
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
set
{ _hostUserInterface.Write.backgroundColor = value; }
}
something like that ?
(Sorry for asking so many questions ^^")
@tylerl0706 Console.BackgroundColor doesn't exist in Microsoft.PowerShell.EditorServices.Console. Where is BackgroundColor exactly ? I will add it to Console.
Edit
I found it I think it's
public static ConsoleColor BackgroundColor
{
get;
set;
}
Tell me if I'm wrong. I added it to EditorServicesPSHostUserInterface
Edit 2
I changed all the WriteOutput method for Debug, Error, Verbose and Warning :
I'm on mac and I'm trying to launch the extension with F5, it propose me several process to attach my extension (zsh, adobe, cloud, etc...) which one should I use ?
Edit 2
I did it somehow by using code-insiders --extensionDevelopmentPath="/Users/My/vscode-powershell" but then I don't know how it works exactly I tried to change some background value for warning but it change nothing so I don't know if this is the code or the way I test it.
I just tested it by deleting the message but it's just my way to test it that doesn't work. How can I print warning or error by using PWSH Editor Services ?
Activity
[-]We need a way to customize colors[/-][+]We need a way to customize output color for error/warning, etc[/+]TylerLeonhardt commentedon Apr 10, 2018
Thanks Joel! I reasonable request indeed.
SeeminglyScience commentedon Apr 11, 2018
If anyone is interested in picking this up the general idea is to
Port ConsoleColorProxy and the PrivateData member from
ConsoleHostin pwsh to EditorServicesPSHost.PrivateDataChange the Write* methods in EditorServicesPSHostUserInterface to use the new colors
KeroroLulu commentedon Apr 17, 2018
I would like to work on it ! Can I be assign ?
TylerLeonhardt commentedon Apr 18, 2018
B.G. (@KeroroLulu) you can work on any issue at any time you'd like :)
We don't usually 'assign' work. You can freely start and submit a Pull Request when you're ready to get feedback!
Once the PR looks good, we will merge it in!
KeroroLulu commentedon Apr 18, 2018
@tylerl0706 Thank you :)
I'm not used to stuff like that, so if I have any questions I'll ask you !
TylerLeonhardt commentedon Apr 18, 2018
You can always ask questions too!
Let me know if you have any 👍
KeroroLulu commentedon Apr 18, 2018
@tylerl0706 In the instructions
The link for EditorServicesPSHost.PrivateData redirect here, I should create this file and copy/past ConsoleColorProxy class and PrivateData member in it, or this file already exist ?
Edit
Nevermind I just found PrivateData. Sorry but my english comprehension is not perfect but what do you mean by "Port ConsoleColorProxy ..." ? I guess that it's not just a copy/past, right ?
TylerLeonhardt commentedon Apr 18, 2018
No problem :) Port usually means "take that and add it to this" sometimes it does mean actually copy/paste. However I think it's a little bit more work than copy/paste.
First copy paste those classes over into
EditorServicesPSHost.PrivateData, then try to build and see what you need to fix to get those classes to work inPSES(PowerShell Editor Services).Then, follow Patrick Meinecke (@SeeminglyScience)'s next step and Change the Write* methods in EditorServicesPSHostUserInterface to use the new colors.
KeroroLulu commentedon Apr 18, 2018
@tylerl0706 Ok ! But I have to copy ConsoleColorProxy class into the override or above like in ConsoleHost ?
Edit
I can't use ConsoleHostUserInterface due to his level of restriction I tried using Microsoft.PowerShell.EditorServices.Console; but it doesn't work. Which import should I use to prevent this error ?
TylerLeonhardt commentedon Apr 18, 2018
What was the error that you got?
KeroroLulu commentedon Apr 18, 2018
@tylerl0706 My powershell is in french but by translating we got :
Session/Host/EditorServicesPSHost.cs(89,38): error CS0122: 'ConsoleHostUserInterface' is unreachable because of its level of protectionI think that's because ConsoleHostUserInterface is in Powershell and not in Powershell Editor Service
1 remaining item
KeroroLulu commentedon Apr 19, 2018
@tylerl0706 The problem is that
EditorServicesPSHostUserInterfacedoesn't contain any color method so when I replaceConsoleHostUserInterfaceI have this error :Session/Host/EditorServicesPSHost.cs(99,45): error CS1061: 'EditorServicesPSHostUserInterface' doesn't contain any definition for 'ErrorForegroundColor' and no extension method 'ErrorForegroundColor' accepting first argument of type 'EditorServicesPSHostUserInterface' has been foundShould I use
WriteErrorLineinstead ofErrorForegroundColororErrorBackgroundColor?For example
something like that ?
(Sorry for asking so many questions ^^")
TylerLeonhardt commentedon Apr 19, 2018
You should be able to add these that I see in ConsoleHostUserInterface:
https://github.com/PowerShell/PowerShell/blob/c1c5344a8897262433141ecbc13bb06ac2c4bbef/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs#L1359-L1376
to
EditorServicesPSHostUserInterfaceTylerLeonhardt commentedon Apr 19, 2018
And then don't forget to edit these to use those values instead of the hardcoded ones 🙂
PowerShellEditorServices/src/PowerShellEditorServices/Session/Host/EditorServicesPSHostUserInterface.cs
Line 526 in a0761cf
Ask all the questions you need. You've got this 💪 you're going to fix this issue 😃
KeroroLulu commentedon Apr 19, 2018
@tylerl0706 Console.BackgroundColor doesn't exist in Microsoft.PowerShell.EditorServices.Console. Where is BackgroundColor exactly ? I will add it to Console.
Edit
I found it I think it's
Tell me if I'm wrong. I added it to
EditorServicesPSHostUserInterfaceEdit 2
I changed all the
WriteOutputmethod for Debug, Error, Verbose and Warning :tell me if I did nothing wrong with the Invoke-Build there's no error. I would like to test it but I don't really know how.
And finally WriteProgress I don't know if I have to change something for the color or if it's ok.
TylerLeonhardt commentedon Apr 19, 2018
That's great B.G. (@KeroroLulu)!
Here's what you can do to test:
Right now, the best way to do this is by building and launching the vscode powershell extension.
Follow these instructions to test your code out:
https://github.com/PowerShell/vscode-powershell/blob/master/docs/development.md
KeroroLulu commentedon Apr 19, 2018
@tylerl0706 Should I add Unit Test to my code ?
Edit
I'm on mac and I'm trying to launch the extension with F5, it propose me several process to attach my extension (zsh, adobe, cloud, etc...) which one should I use ?
Edit 2
I did it somehow by using
code-insiders --extensionDevelopmentPath="/Users/My/vscode-powershell"but then I don't know how it works exactly I tried to change some background value for warning but it change nothing so I don't know if this is the code or the way I test it.Add customize output color enhancement (PowerShell#651)
TylerLeonhardt commentedon Apr 19, 2018
B.G. (@KeroroLulu) does
$Host.PrivateDatagive you anything?KeroroLulu commentedon Apr 19, 2018
It gives me :
I just tested it by deleting the message but it's just my way to test it that doesn't work. How can I print warning or error by using PWSH Editor Services ?
TylerLeonhardt commentedon Apr 19, 2018
If you change
$Host.PrivateData.ErrorForegroundColorin the integrated terminal to DarkCyan, and do a:Write-Error "foo"does it still print in red or dark cyan?
Note this will only work if you made the correct changes to the
Write*function here:PowerShellEditorServices/src/PowerShellEditorServices/Session/Host/EditorServicesPSHostUserInterface.cs
Line 565 in a0761cf
to use the
this.ErrorForegroundColor(I think it's called) instead of "Red"You're getting there! 😄
KeroroLulu commentedon Apr 19, 2018
@tylerl0706 Well I changed it in
EditorServicesPSHostInterfaceBut it doesn't change in my pwsh
Here's my
WriteOutputI did my
Invoke-Build Buildand there's no errorEdit
It's really strange, I change my
WriteOutputBut my error foreground color is still red !
Edit 2
Nevermind !! It works that was just a little problem from my installation :)
I will do the Pull Request !
Add customize output color enhancement (PowerShell#651)
TylerLeonhardt commentedon Apr 20, 2018
That's great B.G. (@KeroroLulu)!! 🎉 🎉
Add customize output color enhancement (#654)