using System;
using System.Collections.Generic;
namespace Spectre.Console
{
///
/// Contains extension methods for .
///
public static class StyleExtensions
{
///
/// Creates a new style from the specified one with
/// the specified foreground color.
///
/// The style.
/// The foreground color.
/// The same instance so that multiple calls can be chained.
public static Style Foreground(this Style style, Color color)
{
if (style is null)
{
throw new ArgumentNullException(nameof(style));
}
return new Style(
foreground: color,
background: style.Background,
decoration: style.Decoration);
}
///
/// Creates a new style from the specified one with
/// the specified background color.
///
/// The style.
/// The background color.
/// The same instance so that multiple calls can be chained.
public static Style Background(this Style style, Color color)
{
if (style is null)
{
throw new ArgumentNullException(nameof(style));
}
return new Style(
foreground: style.Foreground,
background: color,
decoration: style.Decoration);
}
///
/// Creates a new style from the specified one with
/// the specified text decoration.
///
/// The style.
/// The text decoration.
/// The same instance so that multiple calls can be chained.
public static Style Decoration(this Style style, Decoration decoration)
{
if (style is null)
{
throw new ArgumentNullException(nameof(style));
}
return new Style(
foreground: style.Foreground,
background: style.Background,
decoration: decoration);
}
///
/// Creates a new style from the specified one with
/// the specified link.
///
/// The style.
/// The link.
/// The same instance so that multiple calls can be chained.
public static Style Link(this Style style, string link)
{
if (style is null)
{
throw new ArgumentNullException(nameof(style));
}
return new Style(
foreground: style.Foreground,
background: style.Background,
decoration: style.Decoration,
link: link);
}
internal static Style Combine(this Style style, IEnumerable