using System;
using Spectre.Console.Internal;
namespace Spectre.Console
{
///
/// A console capable of writing ANSI escape sequences.
///
public static partial class AnsiConsole
{
private static readonly Lazy _console = new Lazy(() =>
{
return Create(new AnsiConsoleSettings
{
Ansi = AnsiSupport.Detect,
ColorSystem = ColorSystemSupport.Detect,
Out = System.Console.Out,
});
});
///
/// Gets the current renderer.
///
public static IAnsiConsole Console => _console.Value;
///
/// Gets the console's capabilities.
///
public static Capabilities Capabilities => Console.Capabilities;
///
/// Gets the buffer width of the console.
///
public static int Width
{
get => Console.Width;
}
///
/// Gets the buffer height of the console.
///
public static int Height
{
get => Console.Height;
}
///
/// Gets or sets the foreground color.
///
public static Color Foreground
{
get => Console.Foreground;
set => Console.SetColor(value, true);
}
///
/// Gets or sets the background color.
///
public static Color Background
{
get => Console.Background;
set => Console.SetColor(value, false);
}
///
/// Gets or sets the text decoration.
///
public static Decoration Decoration
{
get => Console.Decoration;
set => Console.Decoration = value;
}
///
/// Creates a new instance
/// from the provided settings.
///
/// The settings to use.
/// An instance.
public static IAnsiConsole Create(AnsiConsoleSettings settings)
{
return ConsoleBuilder.Build(settings);
}
///
/// Resets colors and text decorations.
///
public static void Reset()
{
Console.Reset();
}
///
/// Resets the current applied text decorations.
///
public static void ResetDecoration()
{
Console.ResetDecoration();
}
///
/// Resets the current applied foreground and background colors.
///
public static void ResetColors()
{
Console.ResetColors();
}
}
}