Add an implicit operator to convert from Color to Style (#1160)

This commit is contained in:
Cédric Luthi
2023-05-10 15:20:12 +02:00
committed by GitHub
parent 3ec0fee795
commit 6acf9b8c63
16 changed files with 95 additions and 73 deletions

View File

@ -153,7 +153,7 @@ public sealed class Calendar : JustInTimeRenderable, IHasCulture, IHasTableBorde
_useSafeBorder = true;
_borderStyle = null;
_culture = CultureInfo.InvariantCulture;
_highlightStyle = new Style(foreground: Color.Blue);
_highlightStyle = Color.Blue;
_showHeader = true;
_calendarEvents = new ListWithCallback<CalendarEvent>(() => MarkAsDirty());
}

View File

@ -13,27 +13,27 @@ public sealed class ExceptionStyle
/// <summary>
/// Gets or sets the exception color.
/// </summary>
public Style Exception { get; set; } = new Style(Color.White);
public Style Exception { get; set; } = Color.White;
/// <summary>
/// Gets or sets the method color.
/// </summary>
public Style Method { get; set; } = new Style(Color.Yellow);
public Style Method { get; set; } = Color.Yellow;
/// <summary>
/// Gets or sets the parameter type color.
/// </summary>
public Style ParameterType { get; set; } = new Style(Color.Blue);
public Style ParameterType { get; set; } = Color.Blue;
/// <summary>
/// Gets or sets the parameter name color.
/// </summary>
public Style ParameterName { get; set; } = new Style(Color.Silver);
public Style ParameterName { get; set; } = Color.Silver;
/// <summary>
/// Gets or sets the parenthesis color.
/// </summary>
public Style Parenthesis { get; set; } = new Style(Color.Silver);
public Style Parenthesis { get; set; } = Color.Silver;
/// <summary>
/// Gets or sets the path color.
@ -43,15 +43,15 @@ public sealed class ExceptionStyle
/// <summary>
/// Gets or sets the line number color.
/// </summary>
public Style LineNumber { get; set; } = new Style(Color.Blue);
public Style LineNumber { get; set; } = Color.Blue;
/// <summary>
/// Gets or sets the color for dimmed text such as "at" or "in".
/// </summary>
public Style Dimmed { get; set; } = new Style(Color.Grey);
public Style Dimmed { get; set; } = Color.Grey;
/// <summary>
/// Gets or sets the color for non emphasized items.
/// </summary>
public Style NonEmphasized { get; set; } = new Style(Color.Silver);
public Style NonEmphasized { get; set; } = Color.Silver;
}

View File

@ -16,9 +16,9 @@ internal sealed class ProgressBar : Renderable, IHasCulture
public bool IsIndeterminate { get; set; }
public CultureInfo? Culture { get; set; }
public Style CompletedStyle { get; set; } = new Style(foreground: Color.Yellow);
public Style FinishedStyle { get; set; } = new Style(foreground: Color.Green);
public Style RemainingStyle { get; set; } = new Style(foreground: Color.Grey);
public Style CompletedStyle { get; set; } = Color.Yellow;
public Style FinishedStyle { get; set; } = Color.Green;
public Style RemainingStyle { get; set; } = Color.Grey;
public Style IndeterminateStyle { get; set; } = DefaultPulseStyle;
internal static Style DefaultPulseStyle { get; } = new Style(foreground: Color.DodgerBlue1, background: Color.Grey23);

View File

@ -2,8 +2,8 @@ namespace Spectre.Console;
internal static class TableRenderer
{
private static readonly Style _defaultHeadingStyle = new Style(Color.Silver);
private static readonly Style _defaultCaptionStyle = new Style(Color.Grey);
private static readonly Style _defaultHeadingStyle = Color.Silver;
private static readonly Style _defaultCaptionStyle = Color.Grey;
public static List<Segment> Render(TableRendererContext context, List<int> columnWidths)
{