Patrik Svensson 8e4f33bba4 Added initial support for rendering composites
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.
2020-07-30 22:55:42 +02:00

36 lines
1021 B
C#

using System;
namespace Spectre.Console.Internal
{
internal static class ConsoleBuilder
{
public static IAnsiConsole Build(AnsiConsoleSettings settings)
{
if (settings is null)
{
throw new ArgumentNullException(nameof(settings));
}
var buffer = settings.Out ?? System.Console.Out;
var supportsAnsi = settings.Ansi == AnsiSupport.Detect
? AnsiDetector.Detect(true)
: settings.Ansi == AnsiSupport.Yes;
var colorSystem = settings.ColorSystem == ColorSystemSupport.Detect
? ColorSystemDetector.Detect(supportsAnsi)
: (ColorSystem)settings.ColorSystem;
if (supportsAnsi)
{
return new AnsiConsoleRenderer(buffer, colorSystem)
{
Style = Styles.None,
};
}
return new FallbackConsoleRenderer(buffer, colorSystem);
}
}
}