mirror of
https://github.com/spectreconsole/spectre.console.git
synced 2025-12-26 15:57:58 +01:00
This is far from complete, but it's a start and it will enable us to create things like tables and other complex objects in the long run.
110 lines
2.9 KiB
C#
110 lines
2.9 KiB
C#
using System;
|
|
using Spectre.Console.Internal;
|
|
|
|
namespace Spectre.Console
|
|
{
|
|
/// <summary>
|
|
/// A console capable of writing ANSI escape sequences.
|
|
/// </summary>
|
|
public static partial class AnsiConsole
|
|
{
|
|
private static readonly Lazy<IAnsiConsole> _console = new Lazy<IAnsiConsole>(() =>
|
|
{
|
|
return Create(new AnsiConsoleSettings
|
|
{
|
|
Ansi = AnsiSupport.Detect,
|
|
ColorSystem = ColorSystemSupport.Detect,
|
|
Out = System.Console.Out,
|
|
});
|
|
});
|
|
|
|
/// <summary>
|
|
/// Gets the current renderer.
|
|
/// </summary>
|
|
public static IAnsiConsole Console => _console.Value;
|
|
|
|
/// <summary>
|
|
/// Gets the console's capabilities.
|
|
/// </summary>
|
|
public static Capabilities Capabilities => Console.Capabilities;
|
|
|
|
/// <summary>
|
|
/// Gets the buffer width of the console.
|
|
/// </summary>
|
|
public static int Width
|
|
{
|
|
get => Console.Width;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the buffer height of the console.
|
|
/// </summary>
|
|
public static int Height
|
|
{
|
|
get => Console.Height;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the foreground color.
|
|
/// </summary>
|
|
public static Color Foreground
|
|
{
|
|
get => Console.Foreground;
|
|
set => Console.SetColor(value, true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the background color.
|
|
/// </summary>
|
|
public static Color Background
|
|
{
|
|
get => Console.Background;
|
|
set => Console.SetColor(value, false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the style.
|
|
/// </summary>
|
|
public static Styles Style
|
|
{
|
|
get => Console.Style;
|
|
set => Console.Style = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a new <see cref="IAnsiConsole"/> instance
|
|
/// from the provided settings.
|
|
/// </summary>
|
|
/// <param name="settings">The settings to use.</param>
|
|
/// <returns>An <see cref="IAnsiConsole"/> instance.</returns>
|
|
public static IAnsiConsole Create(AnsiConsoleSettings settings)
|
|
{
|
|
return ConsoleBuilder.Build(settings);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resets colors and styles to the default ones.
|
|
/// </summary>
|
|
public static void Reset()
|
|
{
|
|
Console.Reset();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resets the current style back to the default one.
|
|
/// </summary>
|
|
public static void ResetStyle()
|
|
{
|
|
Console.ResetStyle();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resets the foreground and background colors to the default ones.
|
|
/// </summary>
|
|
public static void ResetColors()
|
|
{
|
|
Console.ResetColors();
|
|
}
|
|
}
|
|
}
|