Update upgrade notification message (#10777)

This commit is contained in:
Steve Lee
2019-10-17 10:19:38 -07:00
committed by Dongbo Wang
parent 82cafd1b21
commit cb66974b25
2 changed files with 33 additions and 7 deletions
@@ -62,7 +62,33 @@ namespace Microsoft.PowerShell
? ManagedEntranceStrings.StableUpdateNotificationMessage
: ManagedEntranceStrings.PreviewUpdateNotificationMessage;
string notificationMsg = string.Format(CultureInfo.CurrentCulture, notificationMsgTemplate, releaseTag);
string notificationColor = string.Empty;
string resetColor = string.Empty;
string line2Padding = string.Empty;
string line3Padding = string.Empty;
// We calculate how much whitespace we need to make it look nice
if (hostUI.SupportsVirtualTerminal)
{
// Use Warning Color
notificationColor = "\x1B[7m";
resetColor = "\x1B[0m";
// The first line is longest, if the message changes, this needs to be updated
int line1Length = notificationMsgTemplate.IndexOf('\n');
int line2Length = notificationMsgTemplate.IndexOf('\n', line1Length + 1);
int line3Length = notificationMsgTemplate.IndexOf('\n', line2Length + 1);
line3Length -= line2Length + 1;
line2Length -= line1Length + 1;
line2Padding = line2Padding.PadRight(line1Length - line2Length + releaseTag.Length);
// 3 represents the extra placeholder in the template
line3Padding = line3Padding.PadRight(line1Length - line3Length + 3);
}
string notificationMsg = string.Format(CultureInfo.CurrentCulture, notificationMsgTemplate, releaseTag, notificationColor, resetColor, line2Padding, line3Padding);
hostUI.WriteLine(notificationMsg);
}
}
@@ -128,15 +128,15 @@ Type 'help' to get help.</value>
<value>Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadLine for compatibility purposes. If you want to re-enable it, run 'Import-Module PSReadLine'.</value>
</data>
<data name="PreviewUpdateNotificationMessage" xml:space="preserve">
<value>!! A new PowerShell preview release is available: v{0} !!
Upgrade now, or check out the release page at:
https://github.com/PowerShell/PowerShell/releases/tag/v{0}
<value> {1} A new PowerShell preview release is available: v{0} {2}
{1} Upgrade now, or check out the release page at:{3}{2}
{1} https://aka.ms/PowerShell-Release?tag=v{0} {4}{2}
</value>
</data>
<data name="StableUpdateNotificationMessage" xml:space="preserve">
<value>!! A new PowerShell stable release is available: v{0} !!
Upgrade now, or check out the release page at:
https://github.com/PowerShell/PowerShell/releases/tag/v{0}
<value> {1} A new PowerShell stable release is available: v{0} {2}
{1} Upgrade now, or check out the release page at:{3}{2}
{1} https://aka.ms/PowerShell-Release?tag=v{0} {4}{2}
</value>
</data>
<data name="UsageHelp" xml:space="preserve">