namespace Spectre.Console.Rendering;
///
/// Represents render options.
///
/// The capabilities.
/// The console size.
public record class RenderOptions(IReadOnlyCapabilities Capabilities, Size ConsoleSize)
{
///
/// Gets the current color system.
///
public ColorSystem ColorSystem => Capabilities.ColorSystem;
///
/// Gets a value indicating whether or not VT/Ansi codes are supported.
///
public bool Ansi => Capabilities.Ansi;
///
/// Gets a value indicating whether or not unicode is supported.
///
public bool Unicode => Capabilities.Unicode;
///
/// Gets the current justification.
///
public Justify? Justification { get; init; }
///
/// Gets the requested height.
///
public int? Height { get; init; }
///
/// Gets a value indicating whether the context want items to render without
/// line breaks and return a single line where applicable.
///
internal bool SingleLine { get; init; }
///
/// Creates a instance from a .
///
/// The console.
/// The capabilities, or null to use the provided console's capabilities.
/// A representing the provided .
public static RenderOptions Create(IAnsiConsole console, IReadOnlyCapabilities? capabilities = null)
{
if (console is null)
{
throw new ArgumentNullException(nameof(console));
}
return new RenderOptions(
capabilities ?? console.Profile.Capabilities,
new Size(console.Profile.Width, console.Profile.Height))
{
Justification = null,
Height = null,
SingleLine = false,
};
}
}