-
-
Notifications
You must be signed in to change notification settings - Fork 803
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
WIP: Reorgs settings using PS v5 classes #499
Conversation
BTW I want to add support for something like this |
|
||
AnsiConsole = $Host.UI.SupportsVirtualTerminal -or ($Env:ConEmuANSI -eq "ON") | ||
$str = "${fg}${bg}${txt}${e}0m" |
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.
Update to not append ansi terminator if both fg and bg are $null (or empty).
@@ -24,10 +24,31 @@ $AnsiEscape = [char]27 + "[" | |||
$ColorTranslatorType = 'System.Drawing.ColorTranslator' -as [Type] | |||
$ColorType = 'System.Drawing.Color' -as [Type] | |||
|
|||
function EscapseAnsiString([string]$AnsiString) { | |||
if ($PSVersionTable.PSVersion.Major -ge 6) { | |||
$res = $AnsiString -replace "$([char]0x1B)", '`e' |
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.
Pick either [char]0x1b
or [char]27
and stay consistent.
I think I will close this in favor of #513 which rounds out the desired functionality for |
This is based on the existing
develop
branch approach to rendering ANSI. The other approaches I tried aren't there yet. Add-Type is too slow on PS Core. Using C# source code is a pain to get built and working cross-platform.This approach uses v5 classes so we would have to drop support for v3/v4. This seems reasonable to me as the primary points of this branch are to support cross-platform PowerShell Core and ANSI.
Before this change, looking at the
$GitPromptSettings
results in:After this change: