Skip to content

Commit

Permalink
(cake-buildGH-2852) Move ConsoleColorEx to Constants
Browse files Browse the repository at this point in the history
  • Loading branch information
augustoproiete committed Dec 13, 2020
1 parent d4ee164 commit 8eb5e5e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
2 changes: 2 additions & 0 deletions src/Cake.Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace Cake.Core
{
internal static class Constants
{
public const ConsoleColor DefaultConsoleColor = (ConsoleColor)(-1);

public static readonly Version LatestBreakingChange = new Version(0, 26, 0);
public static readonly Version LatestPotentialBreakingChange = new Version(1, 0, 0);

Expand Down
5 changes: 2 additions & 3 deletions src/Cake.Core/Diagnostics/Console/AnsiConsoleRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System;
using System.Collections.Generic;
using Cake.Core.Diagnostics.Console;
using Cake.Core.Diagnostics.Formatting;

namespace Cake.Core.Diagnostics
Expand All @@ -25,7 +24,7 @@ public AnsiConsoleRenderer(IConsole console)

_ansiLookup = new Dictionary<ConsoleColor, string>
{
{ ConsoleColorEx.Default, string.Empty }, // Default
{ Constants.DefaultConsoleColor, string.Empty }, // Default
{ ConsoleColor.DarkGray, "\u001b[30;1m" }, // Bright black
{ ConsoleColor.Red, "\u001b[31;1m" }, // Bright red
{ ConsoleColor.Green, "\u001b[32;1m" }, // Bright green
Expand All @@ -46,7 +45,7 @@ public AnsiConsoleRenderer(IConsole console)

_ansiBackgroundLookup = new Dictionary<ConsoleColor, string>
{
{ ConsoleColorEx.Default, string.Empty }, // Default
{ Constants.DefaultConsoleColor, string.Empty }, // Default
{ ConsoleColor.DarkGray, "\u001b[40;1m" }, // Bright black
{ ConsoleColor.Red, "\u001b[41;1m" }, // Bright red
{ ConsoleColor.Green, "\u001b[42;1m" }, // Bright green
Expand Down
9 changes: 0 additions & 9 deletions src/Cake.Core/Diagnostics/Console/ConsoleColorEx.cs

This file was deleted.

3 changes: 1 addition & 2 deletions src/Cake.Core/Diagnostics/Console/ConsolePalette.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System;
using System.Collections.Generic;
using Cake.Core.Diagnostics.Console;

namespace Cake.Core.Diagnostics
{
Expand All @@ -29,7 +28,7 @@ internal sealed class ConsolePalette
var background = console.BackgroundColor;
if ((int)background < 0 || console.SupportAnsiEscapeCodes)
{
background = ConsoleColorEx.Default;
background = Constants.DefaultConsoleColor;
}

return new Dictionary<LogLevel, ConsolePalette>
Expand Down
9 changes: 4 additions & 5 deletions src/Cake.Core/Diagnostics/Console/ConsoleRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System;
using System.Collections.Generic;
using Cake.Core.Diagnostics.Console;
using Cake.Core.Diagnostics.Formatting;

namespace Cake.Core.Diagnostics
Expand Down Expand Up @@ -63,24 +62,24 @@ private void SetPalette(FormatToken token, ConsolePalette palette, bool colorize
{
if (colorize && token is PropertyToken)
{
if (palette.ArgumentBackground != ConsoleColorEx.Default)
if (palette.ArgumentBackground != Constants.DefaultConsoleColor)
{
_console.BackgroundColor = palette.ArgumentBackground;
}

if (palette.ArgumentForeground != ConsoleColorEx.Default)
if (palette.ArgumentForeground != Constants.DefaultConsoleColor)
{
_console.ForegroundColor = palette.ArgumentForeground;
}
}
else
{
if (palette.Background != ConsoleColorEx.Default)
if (palette.Background != Constants.DefaultConsoleColor)
{
_console.BackgroundColor = palette.Background;
}

if (palette.Foreground != ConsoleColorEx.Default)
if (palette.Foreground != Constants.DefaultConsoleColor)
{
_console.ForegroundColor = palette.Foreground;
}
Expand Down

0 comments on commit 8eb5e5e

Please sign in to comment.