Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

rkeithhill
Copy link
Collaborator

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:

image

After this change:

image

@rkeithhill
Copy link
Collaborator Author

BTW I want to add support for something like this $GitPromptSettings.BranchColor.Foreground = 0xFF6600. Internally on systems that support ANSI, I'd try to convert that to an ANSI seq like ${e}[38;2;255;102;0m.


AnsiConsole = $Host.UI.SupportsVirtualTerminal -or ($Env:ConEmuANSI -eq "ON")
$str = "${fg}${bg}${txt}${e}0m"
Copy link
Collaborator Author

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'
Copy link
Collaborator Author

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.

@rkeithhill
Copy link
Collaborator Author

I think I will close this in favor of #513 which rounds out the desired functionality for 1.0.0 - better organized $GitPromptSettings and better factored Write-GitStatus functions.

@rkeithhill rkeithhill closed this Jan 1, 2018
@rkeithhill rkeithhill deleted the rkeithhill/settings-only-update branch May 14, 2018 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant