Skip to content

New colors supported by PS7 (#1064) #1077

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

Merged
merged 5 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions PowerShellEditorServices.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if ($PSVersionTable.PSEdition -ne "Core") {

task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestPowerShellApi {

$requiredSdkVersion = "2.0.0"
$minRequiredSdkVersion = "2.0.0"

$dotnetPath = "$PSScriptRoot/.dotnet"
$dotnetExePath = if ($script:IsUnix) { "$dotnetPath/dotnet" } else { "$dotnetPath/dotnet.exe" }
Expand All @@ -54,8 +54,11 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestP
if ($dotnetExePath) {
# dotnet --version can return a semver that System.Version can't handle
# e.g.: 2.1.300-preview-01. The replace operator is used to remove any build suffix.
$version = (& $dotnetExePath --version) -replace '[+-].*$',''
if ([version]$version -ge [version]$requiredSdkVersion) {
$version = [version]((& $dotnetExePath --version) -replace '[+-].*$','')
$maxRequiredSdkVersion = [version]::Parse("3.0.0")

# $minRequiredSdkVersion <= version < $maxRequiredSdkVersion
if ($version -ge [version]$minRequiredSdkVersion -and $version -lt $maxRequiredSdkVersion) {
$script:dotnetExe = $dotnetExePath
}
else {
Expand All @@ -70,7 +73,7 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestP

if ($script:dotnetExe -eq $null) {

Write-Host "`n### Installing .NET CLI $requiredSdkVersion...`n" -ForegroundColor Green
Write-Host "`n### Installing .NET CLI $minRequiredSdkVersion...`n" -ForegroundColor Green

# The install script is platform-specific
$installScriptExt = if ($script:IsUnix) { "sh" } else { "ps1" }
Expand All @@ -81,10 +84,10 @@ task SetupDotNet -Before Clean, Build, TestHost, TestServer, TestProtocol, TestP
$env:DOTNET_INSTALL_DIR = "$PSScriptRoot/.dotnet"

if (!$script:IsUnix) {
& $installScriptPath -Version $requiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR"
& $installScriptPath -Version $minRequiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR"
}
else {
& /bin/bash $installScriptPath -Version $requiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR"
& /bin/bash $installScriptPath -Version $minRequiredSdkVersion -InstallDir "$env:DOTNET_INSTALL_DIR"
$env:PATH = $dotnetExeDir + [System.IO.Path]::PathSeparator + $env:PATH
}

Expand Down
32 changes: 32 additions & 0 deletions src/PowerShellEditorServices/Session/Host/EditorServicesPSHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,38 @@ internal ConsoleColorProxy(EditorServicesPSHostUserInterface hostUserInterface)
_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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,9 @@ private void WriteDebuggerBanner(DebuggerStopEventArgs eventArgs)

internal static ConsoleColor BackgroundColor { get; set; }

internal ConsoleColor FormatAccentColor { get; set; } = ConsoleColor.Green;
internal ConsoleColor ErrorAccentColor { get; set; } = ConsoleColor.Cyan;

internal ConsoleColor ErrorForegroundColor { get; set; } = ConsoleColor.Red;
internal ConsoleColor ErrorBackgroundColor { get; set; } = BackgroundColor;

Expand Down