mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-04 10:35:27 +08:00 
			
		
		
		
	Use file scoped namespace declarations
This commit is contained in:
		
				
					committed by
					
						
						Phil Scott
					
				
			
			
				
	
			
			
			
						parent
						
							1dbaf50935
						
					
				
				
					commit
					ec1188b837
				
			@@ -1,40 +1,39 @@
 | 
			
		||||
using System;
 | 
			
		||||
using Spectre.Console.Rendering;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console.Advanced
 | 
			
		||||
namespace Spectre.Console.Advanced;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class AnsiConsoleExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
    /// Writes a VT/Ansi control code sequence to the console (if supported).
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class AnsiConsoleExtensions
 | 
			
		||||
    /// <param name="console">The console to write to.</param>
 | 
			
		||||
    /// <param name="sequence">The VT/Ansi control code sequence to write.</param>
 | 
			
		||||
    public static void WriteAnsi(this IAnsiConsole console, string sequence)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes a VT/Ansi control code sequence to the console (if supported).
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to write to.</param>
 | 
			
		||||
        /// <param name="sequence">The VT/Ansi control code sequence to write.</param>
 | 
			
		||||
        public static void WriteAnsi(this IAnsiConsole console, string sequence)
 | 
			
		||||
        if (console is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (console is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(console));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (console.Profile.Capabilities.Ansi)
 | 
			
		||||
            {
 | 
			
		||||
                console.Write(new ControlCode(sequence));
 | 
			
		||||
            }
 | 
			
		||||
            throw new ArgumentNullException(nameof(console));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the VT/ANSI control code sequence for a <see cref="IRenderable"/>.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console.</param>
 | 
			
		||||
        /// <param name="renderable">The renderable to the VT/ANSI control code sequence for.</param>
 | 
			
		||||
        /// <returns>The VT/ANSI control code sequence.</returns>
 | 
			
		||||
        public static string ToAnsi(this IAnsiConsole console, IRenderable renderable)
 | 
			
		||||
        if (console.Profile.Capabilities.Ansi)
 | 
			
		||||
        {
 | 
			
		||||
            return AnsiBuilder.Build(console, renderable);
 | 
			
		||||
            console.Write(new ControlCode(sequence));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Gets the VT/ANSI control code sequence for a <see cref="IRenderable"/>.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console.</param>
 | 
			
		||||
    /// <param name="renderable">The renderable to the VT/ANSI control code sequence for.</param>
 | 
			
		||||
    /// <returns>The VT/ANSI control code sequence.</returns>
 | 
			
		||||
    public static string ToAnsi(this IAnsiConsole console, IRenderable renderable)
 | 
			
		||||
    {
 | 
			
		||||
        return AnsiBuilder.Build(console, renderable);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,81 +1,80 @@
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IAlignable"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class AlignableExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IAlignable"/>.
 | 
			
		||||
    /// Sets the alignment for an <see cref="IAlignable"/> object.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class AlignableExtensions
 | 
			
		||||
    /// <typeparam name="T">The alignable object type.</typeparam>
 | 
			
		||||
    /// <param name="obj">The alignable object.</param>
 | 
			
		||||
    /// <param name="alignment">The alignment.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Alignment<T>(this T obj, Justify? alignment)
 | 
			
		||||
        where T : class, IAlignable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the alignment for an <see cref="IAlignable"/> object.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">The alignable object type.</typeparam>
 | 
			
		||||
        /// <param name="obj">The alignable object.</param>
 | 
			
		||||
        /// <param name="alignment">The alignment.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Alignment<T>(this T obj, Justify? alignment)
 | 
			
		||||
            where T : class, IAlignable
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Alignment = alignment;
 | 
			
		||||
            return obj;
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the <see cref="IAlignable"/> object to be left aligned.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">The alignable type.</typeparam>
 | 
			
		||||
        /// <param name="obj">The alignable object.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T LeftAligned<T>(this T obj)
 | 
			
		||||
            where T : class, IAlignable
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Alignment = Justify.Left;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the <see cref="IAlignable"/> object to be centered.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">The alignable type.</typeparam>
 | 
			
		||||
        /// <param name="obj">The alignable object.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Centered<T>(this T obj)
 | 
			
		||||
            where T : class, IAlignable
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Alignment = Justify.Center;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the <see cref="IAlignable"/> object to be right aligned.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">The alignable type.</typeparam>
 | 
			
		||||
        /// <param name="obj">The alignable object.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T RightAligned<T>(this T obj)
 | 
			
		||||
            where T : class, IAlignable
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Alignment = Justify.Right;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
        obj.Alignment = alignment;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the <see cref="IAlignable"/> object to be left aligned.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">The alignable type.</typeparam>
 | 
			
		||||
    /// <param name="obj">The alignable object.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T LeftAligned<T>(this T obj)
 | 
			
		||||
        where T : class, IAlignable
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Alignment = Justify.Left;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the <see cref="IAlignable"/> object to be centered.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">The alignable type.</typeparam>
 | 
			
		||||
    /// <param name="obj">The alignable object.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Centered<T>(this T obj)
 | 
			
		||||
        where T : class, IAlignable
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Alignment = Justify.Center;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the <see cref="IAlignable"/> object to be right aligned.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">The alignable type.</typeparam>
 | 
			
		||||
    /// <param name="obj">The alignable object.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T RightAligned<T>(this T obj)
 | 
			
		||||
        where T : class, IAlignable
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Alignment = Justify.Right;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,32 +1,31 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static partial class AnsiConsoleExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
    /// Writes an exception to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static partial class AnsiConsoleExtensions
 | 
			
		||||
    /// <param name="console">The console.</param>
 | 
			
		||||
    /// <param name="exception">The exception to write to the console.</param>
 | 
			
		||||
    /// <param name="format">The exception format options.</param>
 | 
			
		||||
    public static void WriteException(this IAnsiConsole console, Exception exception, ExceptionFormats format = ExceptionFormats.Default)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes an exception to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console.</param>
 | 
			
		||||
        /// <param name="exception">The exception to write to the console.</param>
 | 
			
		||||
        /// <param name="format">The exception format options.</param>
 | 
			
		||||
        public static void WriteException(this IAnsiConsole console, Exception exception, ExceptionFormats format = ExceptionFormats.Default)
 | 
			
		||||
        {
 | 
			
		||||
            console.Write(exception.GetRenderable(format));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes an exception to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console.</param>
 | 
			
		||||
        /// <param name="exception">The exception to write to the console.</param>
 | 
			
		||||
        /// <param name="settings">The exception settings.</param>
 | 
			
		||||
        public static void WriteException(this IAnsiConsole console, Exception exception, ExceptionSettings settings)
 | 
			
		||||
        {
 | 
			
		||||
            console.Write(exception.GetRenderable(settings));
 | 
			
		||||
        }
 | 
			
		||||
        console.Write(exception.GetRenderable(format));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Writes an exception to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console.</param>
 | 
			
		||||
    /// <param name="exception">The exception to write to the console.</param>
 | 
			
		||||
    /// <param name="settings">The exception settings.</param>
 | 
			
		||||
    public static void WriteException(this IAnsiConsole console, Exception exception, ExceptionSettings settings)
 | 
			
		||||
    {
 | 
			
		||||
        console.Write(exception.GetRenderable(settings));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,35 +1,34 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static partial class AnsiConsoleExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
    /// Runs the specified function in exclusive mode.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static partial class AnsiConsoleExtensions
 | 
			
		||||
    /// <typeparam name="T">The result type.</typeparam>
 | 
			
		||||
    /// <param name="console">The console.</param>
 | 
			
		||||
    /// <param name="func">The func to run in exclusive mode.</param>
 | 
			
		||||
    /// <returns>The result of the function.</returns>
 | 
			
		||||
    public static T RunExclusive<T>(this IAnsiConsole console, Func<T> func)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Runs the specified function in exclusive mode.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">The result type.</typeparam>
 | 
			
		||||
        /// <param name="console">The console.</param>
 | 
			
		||||
        /// <param name="func">The func to run in exclusive mode.</param>
 | 
			
		||||
        /// <returns>The result of the function.</returns>
 | 
			
		||||
        public static T RunExclusive<T>(this IAnsiConsole console, Func<T> func)
 | 
			
		||||
        {
 | 
			
		||||
            return console.ExclusivityMode.Run(func);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Runs the specified function in exclusive mode asynchronously.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">The result type.</typeparam>
 | 
			
		||||
        /// <param name="console">The console.</param>
 | 
			
		||||
        /// <param name="func">The func to run in exclusive mode.</param>
 | 
			
		||||
        /// <returns>The result of the function.</returns>
 | 
			
		||||
        public static Task<T> RunExclusive<T>(this IAnsiConsole console, Func<Task<T>> func)
 | 
			
		||||
        {
 | 
			
		||||
            return console.ExclusivityMode.RunAsync(func);
 | 
			
		||||
        }
 | 
			
		||||
        return console.ExclusivityMode.Run(func);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Runs the specified function in exclusive mode asynchronously.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">The result type.</typeparam>
 | 
			
		||||
    /// <param name="console">The console.</param>
 | 
			
		||||
    /// <param name="func">The func to run in exclusive mode.</param>
 | 
			
		||||
    /// <returns>The result of the function.</returns>
 | 
			
		||||
    public static Task<T> RunExclusive<T>(this IAnsiConsole console, Func<Task<T>> func)
 | 
			
		||||
    {
 | 
			
		||||
        return console.ExclusivityMode.RunAsync(func);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -5,103 +5,102 @@ using System.Linq;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static partial class AnsiConsoleExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static partial class AnsiConsoleExtensions
 | 
			
		||||
    internal static async Task<string> ReadLine(this IAnsiConsole console, Style? style, bool secret, IEnumerable<string>? items = null, CancellationToken cancellationToken = default)
 | 
			
		||||
    {
 | 
			
		||||
        internal static async Task<string> ReadLine(this IAnsiConsole console, Style? style, bool secret, IEnumerable<string>? items = null, CancellationToken cancellationToken = default)
 | 
			
		||||
        if (console is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (console is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(console));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            style ??= Style.Plain;
 | 
			
		||||
            var text = string.Empty;
 | 
			
		||||
 | 
			
		||||
            var autocomplete = new List<string>(items ?? Enumerable.Empty<string>());
 | 
			
		||||
 | 
			
		||||
            while (true)
 | 
			
		||||
            {
 | 
			
		||||
                var rawKey = await console.Input.ReadKeyAsync(true, cancellationToken).ConfigureAwait(false);
 | 
			
		||||
                if (rawKey == null)
 | 
			
		||||
                {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                var key = rawKey.Value;
 | 
			
		||||
                if (key.Key == ConsoleKey.Enter)
 | 
			
		||||
                {
 | 
			
		||||
                    return text;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (key.Key == ConsoleKey.Tab && autocomplete.Count > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    var replace = AutoComplete(autocomplete, text);
 | 
			
		||||
                    if (!string.IsNullOrEmpty(replace))
 | 
			
		||||
                    {
 | 
			
		||||
                        // Render the suggestion
 | 
			
		||||
                        console.Write("\b \b".Repeat(text.Length), style);
 | 
			
		||||
                        console.Write(replace);
 | 
			
		||||
                        text = replace;
 | 
			
		||||
                        continue;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (key.Key == ConsoleKey.Backspace)
 | 
			
		||||
                {
 | 
			
		||||
                    if (text.Length > 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        text = text.Substring(0, text.Length - 1);
 | 
			
		||||
                        console.Write("\b \b");
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (!char.IsControl(key.KeyChar))
 | 
			
		||||
                {
 | 
			
		||||
                    text += key.KeyChar.ToString();
 | 
			
		||||
                    console.Write(secret ? "*" : key.KeyChar.ToString(), style);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            throw new ArgumentNullException(nameof(console));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static string AutoComplete(List<string> autocomplete, string text)
 | 
			
		||||
        style ??= Style.Plain;
 | 
			
		||||
        var text = string.Empty;
 | 
			
		||||
 | 
			
		||||
        var autocomplete = new List<string>(items ?? Enumerable.Empty<string>());
 | 
			
		||||
 | 
			
		||||
        while (true)
 | 
			
		||||
        {
 | 
			
		||||
            var found = autocomplete.Find(i => i == text);
 | 
			
		||||
            var replace = string.Empty;
 | 
			
		||||
 | 
			
		||||
            if (found == null)
 | 
			
		||||
            var rawKey = await console.Input.ReadKeyAsync(true, cancellationToken).ConfigureAwait(false);
 | 
			
		||||
            if (rawKey == null)
 | 
			
		||||
            {
 | 
			
		||||
                // Get the closest match
 | 
			
		||||
                var next = autocomplete.Find(i => i.StartsWith(text, true, CultureInfo.InvariantCulture));
 | 
			
		||||
                if (next != null)
 | 
			
		||||
                {
 | 
			
		||||
                    replace = next;
 | 
			
		||||
                }
 | 
			
		||||
                else if (string.IsNullOrEmpty(text))
 | 
			
		||||
                {
 | 
			
		||||
                    // Use the first item
 | 
			
		||||
                    replace = autocomplete[0];
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                // Get the next match
 | 
			
		||||
                var index = autocomplete.IndexOf(found) + 1;
 | 
			
		||||
                if (index >= autocomplete.Count)
 | 
			
		||||
                {
 | 
			
		||||
                    index = 0;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                replace = autocomplete[index];
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return replace;
 | 
			
		||||
            var key = rawKey.Value;
 | 
			
		||||
            if (key.Key == ConsoleKey.Enter)
 | 
			
		||||
            {
 | 
			
		||||
                return text;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (key.Key == ConsoleKey.Tab && autocomplete.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                var replace = AutoComplete(autocomplete, text);
 | 
			
		||||
                if (!string.IsNullOrEmpty(replace))
 | 
			
		||||
                {
 | 
			
		||||
                    // Render the suggestion
 | 
			
		||||
                    console.Write("\b \b".Repeat(text.Length), style);
 | 
			
		||||
                    console.Write(replace);
 | 
			
		||||
                    text = replace;
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (key.Key == ConsoleKey.Backspace)
 | 
			
		||||
            {
 | 
			
		||||
                if (text.Length > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    text = text.Substring(0, text.Length - 1);
 | 
			
		||||
                    console.Write("\b \b");
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (!char.IsControl(key.KeyChar))
 | 
			
		||||
            {
 | 
			
		||||
                text += key.KeyChar.ToString();
 | 
			
		||||
                console.Write(secret ? "*" : key.KeyChar.ToString(), style);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    private static string AutoComplete(List<string> autocomplete, string text)
 | 
			
		||||
    {
 | 
			
		||||
        var found = autocomplete.Find(i => i == text);
 | 
			
		||||
        var replace = string.Empty;
 | 
			
		||||
 | 
			
		||||
        if (found == null)
 | 
			
		||||
        {
 | 
			
		||||
            // Get the closest match
 | 
			
		||||
            var next = autocomplete.Find(i => i.StartsWith(text, true, CultureInfo.InvariantCulture));
 | 
			
		||||
            if (next != null)
 | 
			
		||||
            {
 | 
			
		||||
                replace = next;
 | 
			
		||||
            }
 | 
			
		||||
            else if (string.IsNullOrEmpty(text))
 | 
			
		||||
            {
 | 
			
		||||
                // Use the first item
 | 
			
		||||
                replace = autocomplete[0];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            // Get the next match
 | 
			
		||||
            var index = autocomplete.IndexOf(found) + 1;
 | 
			
		||||
            if (index >= autocomplete.Count)
 | 
			
		||||
            {
 | 
			
		||||
                index = 0;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            replace = autocomplete[index];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return replace;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,32 +1,31 @@
 | 
			
		||||
using System;
 | 
			
		||||
using Spectre.Console.Rendering;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static partial class AnsiConsoleExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
    /// Creates a new <see cref="LiveDisplay"/> instance for the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static partial class AnsiConsoleExtensions
 | 
			
		||||
    /// <param name="console">The console.</param>
 | 
			
		||||
    /// <param name="target">The target renderable to update.</param>
 | 
			
		||||
    /// <returns>A <see cref="LiveDisplay"/> instance.</returns>
 | 
			
		||||
    public static LiveDisplay Live(this IAnsiConsole console, IRenderable target)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a new <see cref="LiveDisplay"/> instance for the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console.</param>
 | 
			
		||||
        /// <param name="target">The target renderable to update.</param>
 | 
			
		||||
        /// <returns>A <see cref="LiveDisplay"/> instance.</returns>
 | 
			
		||||
        public static LiveDisplay Live(this IAnsiConsole console, IRenderable target)
 | 
			
		||||
        if (console is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (console is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(console));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (target is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(target));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return new LiveDisplay(console, target);
 | 
			
		||||
            throw new ArgumentNullException(nameof(console));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (target is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(target));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return new LiveDisplay(console, target);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,77 +1,76 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static partial class AnsiConsoleExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
    /// Writes the specified markup to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static partial class AnsiConsoleExtensions
 | 
			
		||||
    /// <param name="console">The console to write to.</param>
 | 
			
		||||
    /// <param name="format">A composite format string.</param>
 | 
			
		||||
    /// <param name="args">An array of objects to write.</param>
 | 
			
		||||
    public static void Markup(this IAnsiConsole console, string format, params object[] args)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the specified markup to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to write to.</param>
 | 
			
		||||
        /// <param name="format">A composite format string.</param>
 | 
			
		||||
        /// <param name="args">An array of objects to write.</param>
 | 
			
		||||
        public static void Markup(this IAnsiConsole console, string format, params object[] args)
 | 
			
		||||
        {
 | 
			
		||||
            Markup(console, CultureInfo.CurrentCulture, format, args);
 | 
			
		||||
        }
 | 
			
		||||
        Markup(console, CultureInfo.CurrentCulture, format, args);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the specified markup to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to write to.</param>
 | 
			
		||||
        /// <param name="provider">An object that supplies culture-specific formatting information.</param>
 | 
			
		||||
        /// <param name="format">A composite format string.</param>
 | 
			
		||||
        /// <param name="args">An array of objects to write.</param>
 | 
			
		||||
        public static void Markup(this IAnsiConsole console, IFormatProvider provider, string format, params object[] args)
 | 
			
		||||
        {
 | 
			
		||||
            Markup(console, string.Format(provider, format, args));
 | 
			
		||||
        }
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Writes the specified markup to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console to write to.</param>
 | 
			
		||||
    /// <param name="provider">An object that supplies culture-specific formatting information.</param>
 | 
			
		||||
    /// <param name="format">A composite format string.</param>
 | 
			
		||||
    /// <param name="args">An array of objects to write.</param>
 | 
			
		||||
    public static void Markup(this IAnsiConsole console, IFormatProvider provider, string format, params object[] args)
 | 
			
		||||
    {
 | 
			
		||||
        Markup(console, string.Format(provider, format, args));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the specified markup to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to write to.</param>
 | 
			
		||||
        /// <param name="value">The value to write.</param>
 | 
			
		||||
        public static void Markup(this IAnsiConsole console, string value)
 | 
			
		||||
        {
 | 
			
		||||
            console.Write(MarkupParser.Parse(value));
 | 
			
		||||
        }
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Writes the specified markup to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console to write to.</param>
 | 
			
		||||
    /// <param name="value">The value to write.</param>
 | 
			
		||||
    public static void Markup(this IAnsiConsole console, string value)
 | 
			
		||||
    {
 | 
			
		||||
        console.Write(MarkupParser.Parse(value));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the specified markup, followed by the current line terminator, to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to write to.</param>
 | 
			
		||||
        /// <param name="format">A composite format string.</param>
 | 
			
		||||
        /// <param name="args">An array of objects to write.</param>
 | 
			
		||||
        public static void MarkupLine(this IAnsiConsole console, string format, params object[] args)
 | 
			
		||||
        {
 | 
			
		||||
            MarkupLine(console, CultureInfo.CurrentCulture, format, args);
 | 
			
		||||
        }
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Writes the specified markup, followed by the current line terminator, to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console to write to.</param>
 | 
			
		||||
    /// <param name="format">A composite format string.</param>
 | 
			
		||||
    /// <param name="args">An array of objects to write.</param>
 | 
			
		||||
    public static void MarkupLine(this IAnsiConsole console, string format, params object[] args)
 | 
			
		||||
    {
 | 
			
		||||
        MarkupLine(console, CultureInfo.CurrentCulture, format, args);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the specified markup, followed by the current line terminator, to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to write to.</param>
 | 
			
		||||
        /// <param name="value">The value to write.</param>
 | 
			
		||||
        public static void MarkupLine(this IAnsiConsole console, string value)
 | 
			
		||||
        {
 | 
			
		||||
            Markup(console, value + Environment.NewLine);
 | 
			
		||||
        }
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Writes the specified markup, followed by the current line terminator, to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console to write to.</param>
 | 
			
		||||
    /// <param name="value">The value to write.</param>
 | 
			
		||||
    public static void MarkupLine(this IAnsiConsole console, string value)
 | 
			
		||||
    {
 | 
			
		||||
        Markup(console, value + Environment.NewLine);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the specified markup, followed by the current line terminator, to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to write to.</param>
 | 
			
		||||
        /// <param name="provider">An object that supplies culture-specific formatting information.</param>
 | 
			
		||||
        /// <param name="format">A composite format string.</param>
 | 
			
		||||
        /// <param name="args">An array of objects to write.</param>
 | 
			
		||||
        public static void MarkupLine(this IAnsiConsole console, IFormatProvider provider, string format, params object[] args)
 | 
			
		||||
        {
 | 
			
		||||
            Markup(console, provider, format + Environment.NewLine, args);
 | 
			
		||||
        }
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Writes the specified markup, followed by the current line terminator, to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console to write to.</param>
 | 
			
		||||
    /// <param name="provider">An object that supplies culture-specific formatting information.</param>
 | 
			
		||||
    /// <param name="format">A composite format string.</param>
 | 
			
		||||
    /// <param name="args">An array of objects to write.</param>
 | 
			
		||||
    public static void MarkupLine(this IAnsiConsole console, IFormatProvider provider, string format, params object[] args)
 | 
			
		||||
    {
 | 
			
		||||
        Markup(console, provider, format + Environment.NewLine, args);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,40 +1,39 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static partial class AnsiConsoleExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
    /// Creates a new <see cref="Progress"/> instance for the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static partial class AnsiConsoleExtensions
 | 
			
		||||
    /// <param name="console">The console.</param>
 | 
			
		||||
    /// <returns>A <see cref="Progress"/> instance.</returns>
 | 
			
		||||
    public static Progress Progress(this IAnsiConsole console)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a new <see cref="Progress"/> instance for the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console.</param>
 | 
			
		||||
        /// <returns>A <see cref="Progress"/> instance.</returns>
 | 
			
		||||
        public static Progress Progress(this IAnsiConsole console)
 | 
			
		||||
        if (console is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (console is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(console));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return new Progress(console);
 | 
			
		||||
            throw new ArgumentNullException(nameof(console));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a new <see cref="Status"/> instance for the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console.</param>
 | 
			
		||||
        /// <returns>A <see cref="Status"/> instance.</returns>
 | 
			
		||||
        public static Status Status(this IAnsiConsole console)
 | 
			
		||||
        {
 | 
			
		||||
            if (console is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(console));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return new Status(console);
 | 
			
		||||
        }
 | 
			
		||||
        return new Progress(console);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Creates a new <see cref="Status"/> instance for the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console.</param>
 | 
			
		||||
    /// <returns>A <see cref="Status"/> instance.</returns>
 | 
			
		||||
    public static Status Status(this IAnsiConsole console)
 | 
			
		||||
    {
 | 
			
		||||
        if (console is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(console));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return new Status(console);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,55 +1,54 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static partial class AnsiConsoleExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
    /// Displays a prompt to the user.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static partial class AnsiConsoleExtensions
 | 
			
		||||
    /// <typeparam name="T">The prompt result type.</typeparam>
 | 
			
		||||
    /// <param name="console">The console.</param>
 | 
			
		||||
    /// <param name="prompt">The prompt to display.</param>
 | 
			
		||||
    /// <returns>The prompt input result.</returns>
 | 
			
		||||
    public static T Prompt<T>(this IAnsiConsole console, IPrompt<T> prompt)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Displays a prompt to the user.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">The prompt result type.</typeparam>
 | 
			
		||||
        /// <param name="console">The console.</param>
 | 
			
		||||
        /// <param name="prompt">The prompt to display.</param>
 | 
			
		||||
        /// <returns>The prompt input result.</returns>
 | 
			
		||||
        public static T Prompt<T>(this IAnsiConsole console, IPrompt<T> prompt)
 | 
			
		||||
        if (prompt is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (prompt is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(prompt));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return prompt.Show(console);
 | 
			
		||||
            throw new ArgumentNullException(nameof(prompt));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Displays a prompt to the user.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">The prompt result type.</typeparam>
 | 
			
		||||
        /// <param name="console">The console.</param>
 | 
			
		||||
        /// <param name="prompt">The prompt markup text.</param>
 | 
			
		||||
        /// <returns>The prompt input result.</returns>
 | 
			
		||||
        public static T Ask<T>(this IAnsiConsole console, string prompt)
 | 
			
		||||
        {
 | 
			
		||||
            return new TextPrompt<T>(prompt).Show(console);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Displays a prompt with two choices, yes or no.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console.</param>
 | 
			
		||||
        /// <param name="prompt">The prompt markup text.</param>
 | 
			
		||||
        /// <param name="defaultValue">Specifies the default answer.</param>
 | 
			
		||||
        /// <returns><c>true</c> if the user selected "yes", otherwise <c>false</c>.</returns>
 | 
			
		||||
        public static bool Confirm(this IAnsiConsole console, string prompt, bool defaultValue = true)
 | 
			
		||||
        {
 | 
			
		||||
            return new ConfirmationPrompt(prompt)
 | 
			
		||||
            {
 | 
			
		||||
                DefaultValue = defaultValue,
 | 
			
		||||
            }
 | 
			
		||||
            .Show(console);
 | 
			
		||||
        }
 | 
			
		||||
        return prompt.Show(console);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Displays a prompt to the user.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">The prompt result type.</typeparam>
 | 
			
		||||
    /// <param name="console">The console.</param>
 | 
			
		||||
    /// <param name="prompt">The prompt markup text.</param>
 | 
			
		||||
    /// <returns>The prompt input result.</returns>
 | 
			
		||||
    public static T Ask<T>(this IAnsiConsole console, string prompt)
 | 
			
		||||
    {
 | 
			
		||||
        return new TextPrompt<T>(prompt).Show(console);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Displays a prompt with two choices, yes or no.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console.</param>
 | 
			
		||||
    /// <param name="prompt">The prompt markup text.</param>
 | 
			
		||||
    /// <param name="defaultValue">Specifies the default answer.</param>
 | 
			
		||||
    /// <returns><c>true</c> if the user selected "yes", otherwise <c>false</c>.</returns>
 | 
			
		||||
    public static bool Confirm(this IAnsiConsole console, string prompt, bool defaultValue = true)
 | 
			
		||||
    {
 | 
			
		||||
        return new ConfirmationPrompt(prompt)
 | 
			
		||||
        {
 | 
			
		||||
            DefaultValue = defaultValue,
 | 
			
		||||
        }
 | 
			
		||||
        .Show(console);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,32 +1,31 @@
 | 
			
		||||
using System;
 | 
			
		||||
using Spectre.Console.Rendering;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static partial class AnsiConsoleExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
    /// Renders the specified object to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static partial class AnsiConsoleExtensions
 | 
			
		||||
    /// <param name="console">The console to render to.</param>
 | 
			
		||||
    /// <param name="renderable">The object to render.</param>
 | 
			
		||||
    [Obsolete("Consider using IAnsiConsole.Write instead.")]
 | 
			
		||||
    public static void Render(this IAnsiConsole console, IRenderable renderable)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Renders the specified object to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to render to.</param>
 | 
			
		||||
        /// <param name="renderable">The object to render.</param>
 | 
			
		||||
        [Obsolete("Consider using IAnsiConsole.Write instead.")]
 | 
			
		||||
        public static void Render(this IAnsiConsole console, IRenderable renderable)
 | 
			
		||||
        if (console is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (console is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(console));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (renderable is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(renderable));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            console.Write(renderable);
 | 
			
		||||
            throw new ArgumentNullException(nameof(console));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (renderable is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(renderable));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        console.Write(renderable);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,48 +1,47 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static partial class AnsiConsoleExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
    /// Switches to an alternate screen buffer if the terminal supports it.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static partial class AnsiConsoleExtensions
 | 
			
		||||
    /// <param name="console">The console.</param>
 | 
			
		||||
    /// <param name="action">The action to execute within the alternate screen buffer.</param>
 | 
			
		||||
    public static void AlternateScreen(this IAnsiConsole console, Action action)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Switches to an alternate screen buffer if the terminal supports it.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console.</param>
 | 
			
		||||
        /// <param name="action">The action to execute within the alternate screen buffer.</param>
 | 
			
		||||
        public static void AlternateScreen(this IAnsiConsole console, Action action)
 | 
			
		||||
        if (console is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (console is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(console));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (!console.Profile.Capabilities.Ansi)
 | 
			
		||||
            {
 | 
			
		||||
                throw new NotSupportedException("Alternate buffers are not supported since your terminal does not support ANSI.");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (!console.Profile.Capabilities.AlternateBuffer)
 | 
			
		||||
            {
 | 
			
		||||
                throw new NotSupportedException("Alternate buffers are not supported by your terminal.");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            console.ExclusivityMode.Run<object?>(() =>
 | 
			
		||||
            {
 | 
			
		||||
                // Switch to alternate screen
 | 
			
		||||
                console.Write(new ControlCode("\u001b[?1049h\u001b[H"));
 | 
			
		||||
 | 
			
		||||
                // Execute custom action
 | 
			
		||||
                action();
 | 
			
		||||
 | 
			
		||||
                // Switch back to primary screen
 | 
			
		||||
                console.Write(new ControlCode("\u001b[?1049l"));
 | 
			
		||||
 | 
			
		||||
                // Dummy result
 | 
			
		||||
                return null;
 | 
			
		||||
            });
 | 
			
		||||
            throw new ArgumentNullException(nameof(console));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!console.Profile.Capabilities.Ansi)
 | 
			
		||||
        {
 | 
			
		||||
            throw new NotSupportedException("Alternate buffers are not supported since your terminal does not support ANSI.");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!console.Profile.Capabilities.AlternateBuffer)
 | 
			
		||||
        {
 | 
			
		||||
            throw new NotSupportedException("Alternate buffers are not supported by your terminal.");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        console.ExclusivityMode.Run<object?>(() =>
 | 
			
		||||
        {
 | 
			
		||||
            // Switch to alternate screen
 | 
			
		||||
            console.Write(new ControlCode("\u001b[?1049h\u001b[H"));
 | 
			
		||||
 | 
			
		||||
            // Execute custom action
 | 
			
		||||
            action();
 | 
			
		||||
 | 
			
		||||
            // Switch back to primary screen
 | 
			
		||||
            console.Write(new ControlCode("\u001b[?1049l"));
 | 
			
		||||
 | 
			
		||||
            // Dummy result
 | 
			
		||||
            return null;
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,110 +1,109 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static partial class AnsiConsoleExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IAnsiConsole"/>.
 | 
			
		||||
    /// Creates a recorder for the specified console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static partial class AnsiConsoleExtensions
 | 
			
		||||
    /// <param name="console">The console to record.</param>
 | 
			
		||||
    /// <returns>A recorder for the specified console.</returns>
 | 
			
		||||
    public static Recorder CreateRecorder(this IAnsiConsole console)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a recorder for the specified console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to record.</param>
 | 
			
		||||
        /// <returns>A recorder for the specified console.</returns>
 | 
			
		||||
        public static Recorder CreateRecorder(this IAnsiConsole console)
 | 
			
		||||
        {
 | 
			
		||||
            return new Recorder(console);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Clears the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to clear.</param>
 | 
			
		||||
        public static void Clear(this IAnsiConsole console)
 | 
			
		||||
        {
 | 
			
		||||
            if (console is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(console));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            console.Clear(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the specified string value to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to write to.</param>
 | 
			
		||||
        /// <param name="text">The text to write.</param>
 | 
			
		||||
        public static void Write(this IAnsiConsole console, string text)
 | 
			
		||||
        {
 | 
			
		||||
            if (console is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(console));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            console.Write(new Text(text, Style.Plain));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the specified string value to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to write to.</param>
 | 
			
		||||
        /// <param name="text">The text to write.</param>
 | 
			
		||||
        /// <param name="style">The text style or <see cref="Style.Plain"/> if <see langword="null"/>.</param>
 | 
			
		||||
        public static void Write(this IAnsiConsole console, string text, Style? style)
 | 
			
		||||
        {
 | 
			
		||||
            if (console is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(console));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            console.Write(new Text(text, style));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes an empty line to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to write to.</param>
 | 
			
		||||
        public static void WriteLine(this IAnsiConsole console)
 | 
			
		||||
        {
 | 
			
		||||
            if (console is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(console));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            console.Write(Text.NewLine);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the specified string value, followed by the current line terminator, to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to write to.</param>
 | 
			
		||||
        /// <param name="text">The text to write.</param>
 | 
			
		||||
        public static void WriteLine(this IAnsiConsole console, string text)
 | 
			
		||||
        {
 | 
			
		||||
            WriteLine(console, text, Style.Plain);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Writes the specified string value, followed by the current line terminator, to the console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="console">The console to write to.</param>
 | 
			
		||||
        /// <param name="text">The text to write.</param>
 | 
			
		||||
        /// <param name="style">The text style or <see cref="Style.Plain"/> if <see langword="null"/>.</param>
 | 
			
		||||
        public static void WriteLine(this IAnsiConsole console, string text, Style? style)
 | 
			
		||||
        {
 | 
			
		||||
            if (console is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(console));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (text is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(text));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            console.Write(text + Environment.NewLine, style);
 | 
			
		||||
        }
 | 
			
		||||
        return new Recorder(console);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Clears the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console to clear.</param>
 | 
			
		||||
    public static void Clear(this IAnsiConsole console)
 | 
			
		||||
    {
 | 
			
		||||
        if (console is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(console));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        console.Clear(true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Writes the specified string value to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console to write to.</param>
 | 
			
		||||
    /// <param name="text">The text to write.</param>
 | 
			
		||||
    public static void Write(this IAnsiConsole console, string text)
 | 
			
		||||
    {
 | 
			
		||||
        if (console is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(console));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        console.Write(new Text(text, Style.Plain));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Writes the specified string value to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console to write to.</param>
 | 
			
		||||
    /// <param name="text">The text to write.</param>
 | 
			
		||||
    /// <param name="style">The text style or <see cref="Style.Plain"/> if <see langword="null"/>.</param>
 | 
			
		||||
    public static void Write(this IAnsiConsole console, string text, Style? style)
 | 
			
		||||
    {
 | 
			
		||||
        if (console is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(console));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        console.Write(new Text(text, style));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Writes an empty line to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console to write to.</param>
 | 
			
		||||
    public static void WriteLine(this IAnsiConsole console)
 | 
			
		||||
    {
 | 
			
		||||
        if (console is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(console));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        console.Write(Text.NewLine);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Writes the specified string value, followed by the current line terminator, to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console to write to.</param>
 | 
			
		||||
    /// <param name="text">The text to write.</param>
 | 
			
		||||
    public static void WriteLine(this IAnsiConsole console, string text)
 | 
			
		||||
    {
 | 
			
		||||
        WriteLine(console, text, Style.Plain);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Writes the specified string value, followed by the current line terminator, to the console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="console">The console to write to.</param>
 | 
			
		||||
    /// <param name="text">The text to write.</param>
 | 
			
		||||
    /// <param name="style">The text style or <see cref="Style.Plain"/> if <see langword="null"/>.</param>
 | 
			
		||||
    public static void WriteLine(this IAnsiConsole console, string text, Style? style)
 | 
			
		||||
    {
 | 
			
		||||
        if (console is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(console));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (text is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(text));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        console.Write(text + Environment.NewLine, style);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,259 +1,258 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="BarChart"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class BarChartExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="BarChart"/>.
 | 
			
		||||
    /// Adds an item to the bar chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class BarChartExtensions
 | 
			
		||||
    /// <param name="chart">The bar chart.</param>
 | 
			
		||||
    /// <param name="label">The item label.</param>
 | 
			
		||||
    /// <param name="value">The item value.</param>
 | 
			
		||||
    /// <param name="color">The item color.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BarChart AddItem(this BarChart chart, string label, double value, Color? color = null)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds an item to the bar chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The bar chart.</param>
 | 
			
		||||
        /// <param name="label">The item label.</param>
 | 
			
		||||
        /// <param name="value">The item value.</param>
 | 
			
		||||
        /// <param name="color">The item color.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BarChart AddItem(this BarChart chart, string label, double value, Color? color = null)
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            chart.Data.Add(new BarChartItem(label, value, color));
 | 
			
		||||
            return chart;
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds an item to the bar chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">A type that implements <see cref="IBarChartItem"/>.</typeparam>
 | 
			
		||||
        /// <param name="chart">The bar chart.</param>
 | 
			
		||||
        /// <param name="item">The item.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BarChart AddItem<T>(this BarChart chart, T item)
 | 
			
		||||
            where T : IBarChartItem
 | 
			
		||||
        chart.Data.Add(new BarChartItem(label, value, color));
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds an item to the bar chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">A type that implements <see cref="IBarChartItem"/>.</typeparam>
 | 
			
		||||
    /// <param name="chart">The bar chart.</param>
 | 
			
		||||
    /// <param name="item">The item.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BarChart AddItem<T>(this BarChart chart, T item)
 | 
			
		||||
        where T : IBarChartItem
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (item is BarChartItem barChartItem)
 | 
			
		||||
            {
 | 
			
		||||
                chart.Data.Add(barChartItem);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                chart.Data.Add(
 | 
			
		||||
                    new BarChartItem(
 | 
			
		||||
                        item.Label,
 | 
			
		||||
                        item.Value,
 | 
			
		||||
                        item.Color));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return chart;
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds multiple items to the bar chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">A type that implements <see cref="IBarChartItem"/>.</typeparam>
 | 
			
		||||
        /// <param name="chart">The bar chart.</param>
 | 
			
		||||
        /// <param name="items">The items.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BarChart AddItems<T>(this BarChart chart, IEnumerable<T> items)
 | 
			
		||||
            where T : IBarChartItem
 | 
			
		||||
        if (item is BarChartItem barChartItem)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (items is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(items));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (var item in items)
 | 
			
		||||
            {
 | 
			
		||||
                AddItem(chart, item);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return chart;
 | 
			
		||||
            chart.Data.Add(barChartItem);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            chart.Data.Add(
 | 
			
		||||
                new BarChartItem(
 | 
			
		||||
                    item.Label,
 | 
			
		||||
                    item.Value,
 | 
			
		||||
                    item.Color));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds multiple items to the bar chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">A type that implements <see cref="IBarChartItem"/>.</typeparam>
 | 
			
		||||
        /// <param name="chart">The bar chart.</param>
 | 
			
		||||
        /// <param name="items">The items.</param>
 | 
			
		||||
        /// <param name="converter">The converter that converts instances of <c>T</c> to <see cref="BarChartItem"/>.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BarChart AddItems<T>(this BarChart chart, IEnumerable<T> items, Func<T, BarChartItem> converter)
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds multiple items to the bar chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">A type that implements <see cref="IBarChartItem"/>.</typeparam>
 | 
			
		||||
    /// <param name="chart">The bar chart.</param>
 | 
			
		||||
    /// <param name="items">The items.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BarChart AddItems<T>(this BarChart chart, IEnumerable<T> items)
 | 
			
		||||
        where T : IBarChartItem
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (items is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(items));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (converter is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(converter));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (var item in items)
 | 
			
		||||
            {
 | 
			
		||||
                chart.Data.Add(converter(item));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return chart;
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the width of the bar chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The bar chart.</param>
 | 
			
		||||
        /// <param name="width">The bar chart width.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BarChart Width(this BarChart chart, int? width)
 | 
			
		||||
        if (items is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            chart.Width = width;
 | 
			
		||||
            return chart;
 | 
			
		||||
            throw new ArgumentNullException(nameof(items));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the label of the bar chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The bar chart.</param>
 | 
			
		||||
        /// <param name="label">The bar chart label.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BarChart Label(this BarChart chart, string? label)
 | 
			
		||||
        foreach (var item in items)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            chart.Label = label;
 | 
			
		||||
            return chart;
 | 
			
		||||
            AddItem(chart, item);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Shows values next to each bar in the bar chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The bar chart.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BarChart ShowValues(this BarChart chart)
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds multiple items to the bar chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">A type that implements <see cref="IBarChartItem"/>.</typeparam>
 | 
			
		||||
    /// <param name="chart">The bar chart.</param>
 | 
			
		||||
    /// <param name="items">The items.</param>
 | 
			
		||||
    /// <param name="converter">The converter that converts instances of <c>T</c> to <see cref="BarChartItem"/>.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BarChart AddItems<T>(this BarChart chart, IEnumerable<T> items, Func<T, BarChartItem> converter)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            return ShowValues(chart, true);
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Hides values next to each bar in the bar chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The bar chart.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BarChart HideValues(this BarChart chart)
 | 
			
		||||
        if (items is null)
 | 
			
		||||
        {
 | 
			
		||||
            return ShowValues(chart, false);
 | 
			
		||||
            throw new ArgumentNullException(nameof(items));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets whether or not values should be shown
 | 
			
		||||
        /// next to each bar.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The bar chart.</param>
 | 
			
		||||
        /// <param name="show">Whether or not values should be shown next to each bar.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BarChart ShowValues(this BarChart chart, bool show)
 | 
			
		||||
        if (converter is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            chart.ShowValues = show;
 | 
			
		||||
            return chart;
 | 
			
		||||
            throw new ArgumentNullException(nameof(converter));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Aligns the label to the left.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The bar chart.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BarChart LeftAlignLabel(this BarChart chart)
 | 
			
		||||
        foreach (var item in items)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            chart.LabelAlignment = Justify.Left;
 | 
			
		||||
            return chart;
 | 
			
		||||
            chart.Data.Add(converter(item));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Centers the label.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The bar chart.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BarChart CenterLabel(this BarChart chart)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
            chart.LabelAlignment = Justify.Center;
 | 
			
		||||
            return chart;
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the width of the bar chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The bar chart.</param>
 | 
			
		||||
    /// <param name="width">The bar chart width.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BarChart Width(this BarChart chart, int? width)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Aligns the label to the right.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The bar chart.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BarChart RightAlignLabel(this BarChart chart)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
        chart.Width = width;
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
            chart.LabelAlignment = Justify.Right;
 | 
			
		||||
            return chart;
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the label of the bar chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The bar chart.</param>
 | 
			
		||||
    /// <param name="label">The bar chart label.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BarChart Label(this BarChart chart, string? label)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the max fixed value for the chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The bar chart.</param>
 | 
			
		||||
        /// <param name="maxValue">Max value for the chart.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BarChart WithMaxValue(this BarChart chart, double maxValue)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
        chart.Label = label;
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
            chart.MaxValue = maxValue;
 | 
			
		||||
            return chart;
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Shows values next to each bar in the bar chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The bar chart.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BarChart ShowValues(this BarChart chart)
 | 
			
		||||
    {
 | 
			
		||||
        return ShowValues(chart, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Hides values next to each bar in the bar chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The bar chart.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BarChart HideValues(this BarChart chart)
 | 
			
		||||
    {
 | 
			
		||||
        return ShowValues(chart, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets whether or not values should be shown
 | 
			
		||||
    /// next to each bar.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The bar chart.</param>
 | 
			
		||||
    /// <param name="show">Whether or not values should be shown next to each bar.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BarChart ShowValues(this BarChart chart, bool show)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        chart.ShowValues = show;
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Aligns the label to the left.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The bar chart.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BarChart LeftAlignLabel(this BarChart chart)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        chart.LabelAlignment = Justify.Left;
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Centers the label.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The bar chart.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BarChart CenterLabel(this BarChart chart)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        chart.LabelAlignment = Justify.Center;
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Aligns the label to the right.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The bar chart.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BarChart RightAlignLabel(this BarChart chart)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        chart.LabelAlignment = Justify.Right;
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the max fixed value for the chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The bar chart.</param>
 | 
			
		||||
    /// <param name="maxValue">Max value for the chart.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BarChart WithMaxValue(this BarChart chart, double maxValue)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        chart.MaxValue = maxValue;
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,31 +1,30 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console.Rendering
 | 
			
		||||
namespace Spectre.Console.Rendering;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="BoxBorder"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class BoxExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="BoxBorder"/>.
 | 
			
		||||
    /// Gets the safe border for a border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class BoxExtensions
 | 
			
		||||
    /// <param name="border">The border to get the safe border for.</param>
 | 
			
		||||
    /// <param name="safe">Whether or not to return the safe border.</param>
 | 
			
		||||
    /// <returns>The safe border if one exist, otherwise the original border.</returns>
 | 
			
		||||
    public static BoxBorder GetSafeBorder(this BoxBorder border, bool safe)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the safe border for a border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="border">The border to get the safe border for.</param>
 | 
			
		||||
        /// <param name="safe">Whether or not to return the safe border.</param>
 | 
			
		||||
        /// <returns>The safe border if one exist, otherwise the original border.</returns>
 | 
			
		||||
        public static BoxBorder GetSafeBorder(this BoxBorder border, bool safe)
 | 
			
		||||
        if (border is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (border is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(border));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (safe && border.SafeBorder != null)
 | 
			
		||||
            {
 | 
			
		||||
                border = border.SafeBorder;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return border;
 | 
			
		||||
            throw new ArgumentNullException(nameof(border));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (safe && border.SafeBorder != null)
 | 
			
		||||
        {
 | 
			
		||||
            border = border.SafeBorder;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return border;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -2,304 +2,303 @@ using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="BreakdownChart"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class BreakdownChartExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="BreakdownChart"/>.
 | 
			
		||||
    /// Adds an item to the breakdown chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class BreakdownChartExtensions
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <param name="label">The item label.</param>
 | 
			
		||||
    /// <param name="value">The item value.</param>
 | 
			
		||||
    /// <param name="color">The item color.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart AddItem(this BreakdownChart chart, string label, double value, Color color)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds an item to the breakdown chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <param name="label">The item label.</param>
 | 
			
		||||
        /// <param name="value">The item value.</param>
 | 
			
		||||
        /// <param name="color">The item color.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart AddItem(this BreakdownChart chart, string label, double value, Color color)
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            chart.Data.Add(new BreakdownChartItem(label, value, color));
 | 
			
		||||
            return chart;
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds an item to the breakdown chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">A type that implements <see cref="IBreakdownChartItem"/>.</typeparam>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <param name="item">The item.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart AddItem<T>(this BreakdownChart chart, T item)
 | 
			
		||||
            where T : IBreakdownChartItem
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (item is BreakdownChartItem chartItem)
 | 
			
		||||
            {
 | 
			
		||||
                chart.Data.Add(chartItem);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                chart.Data.Add(
 | 
			
		||||
                    new BreakdownChartItem(
 | 
			
		||||
                        item.Label,
 | 
			
		||||
                        item.Value,
 | 
			
		||||
                        item.Color));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return chart;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds multiple items to the breakdown chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">A type that implements <see cref="IBreakdownChartItem"/>.</typeparam>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <param name="items">The items.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart AddItems<T>(this BreakdownChart chart, IEnumerable<T> items)
 | 
			
		||||
            where T : IBreakdownChartItem
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (items is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(items));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (var item in items)
 | 
			
		||||
            {
 | 
			
		||||
                AddItem(chart, item);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return chart;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds multiple items to the breakdown chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">A type that implements <see cref="IBarChartItem"/>.</typeparam>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <param name="items">The items.</param>
 | 
			
		||||
        /// <param name="converter">The converter that converts instances of <c>T</c> to <see cref="IBreakdownChartItem"/>.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart AddItems<T>(this BreakdownChart chart, IEnumerable<T> items, Func<T, IBreakdownChartItem> converter)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (items is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(items));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (converter is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(converter));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (var item in items)
 | 
			
		||||
            {
 | 
			
		||||
                chart.Data.Add(converter(item));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return chart;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the width of the breakdown chart.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <param name="width">The breakdown chart width.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart Width(this BreakdownChart chart, int? width)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            chart.Width = width;
 | 
			
		||||
            return chart;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Tags will be shown.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <param name="func">The value formatter to use.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart UseValueFormatter(this BreakdownChart chart, Func<double, CultureInfo, string>? func)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            chart.ValueFormatter = func;
 | 
			
		||||
            return chart;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Tags will be shown.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <param name="func">The value formatter to use.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart UseValueFormatter(this BreakdownChart chart, Func<double, string>? func)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            chart.ValueFormatter = func != null
 | 
			
		||||
                ? (value, _) => func(value)
 | 
			
		||||
                : null;
 | 
			
		||||
 | 
			
		||||
            return chart;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Tags will be shown.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart ShowPercentage(this BreakdownChart chart)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            chart.ValueFormatter = (value, culture) => string.Format(culture, "{0}%", value);
 | 
			
		||||
 | 
			
		||||
            return chart;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Tags will be shown.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart ShowTags(this BreakdownChart chart)
 | 
			
		||||
        {
 | 
			
		||||
            return ShowTags(chart, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Tags will be not be shown.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart HideTags(this BreakdownChart chart)
 | 
			
		||||
        {
 | 
			
		||||
            return ShowTags(chart, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets whether or not tags will be shown.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <param name="show">Whether or not tags will be shown.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart ShowTags(this BreakdownChart chart, bool show)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            chart.ShowTags = show;
 | 
			
		||||
            return chart;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Tag values will be shown.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart ShowTagValues(this BreakdownChart chart)
 | 
			
		||||
        {
 | 
			
		||||
            return ShowTagValues(chart, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Tag values will be not be shown.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart HideTagValues(this BreakdownChart chart)
 | 
			
		||||
        {
 | 
			
		||||
            return ShowTagValues(chart, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets whether or not tag values will be shown.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <param name="show">Whether or not tag values will be shown.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart ShowTagValues(this BreakdownChart chart, bool show)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            chart.ShowTagValues = show;
 | 
			
		||||
            return chart;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Chart and tags is rendered in compact mode.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart Compact(this BreakdownChart chart)
 | 
			
		||||
        {
 | 
			
		||||
            return Compact(chart, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Chart and tags is rendered in full size mode.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart FullSize(this BreakdownChart chart)
 | 
			
		||||
        {
 | 
			
		||||
            return Compact(chart, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets whether or not the chart and tags should be rendered in compact mode.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
        /// <param name="compact">Whether or not the chart and tags should be rendered in compact mode.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static BreakdownChart Compact(this BreakdownChart chart, bool compact)
 | 
			
		||||
        {
 | 
			
		||||
            if (chart is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            chart.Compact = compact;
 | 
			
		||||
            return chart;
 | 
			
		||||
        }
 | 
			
		||||
        chart.Data.Add(new BreakdownChartItem(label, value, color));
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds an item to the breakdown chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">A type that implements <see cref="IBreakdownChartItem"/>.</typeparam>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <param name="item">The item.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart AddItem<T>(this BreakdownChart chart, T item)
 | 
			
		||||
        where T : IBreakdownChartItem
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (item is BreakdownChartItem chartItem)
 | 
			
		||||
        {
 | 
			
		||||
            chart.Data.Add(chartItem);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            chart.Data.Add(
 | 
			
		||||
                new BreakdownChartItem(
 | 
			
		||||
                    item.Label,
 | 
			
		||||
                    item.Value,
 | 
			
		||||
                    item.Color));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds multiple items to the breakdown chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">A type that implements <see cref="IBreakdownChartItem"/>.</typeparam>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <param name="items">The items.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart AddItems<T>(this BreakdownChart chart, IEnumerable<T> items)
 | 
			
		||||
        where T : IBreakdownChartItem
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (items is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(items));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach (var item in items)
 | 
			
		||||
        {
 | 
			
		||||
            AddItem(chart, item);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds multiple items to the breakdown chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">A type that implements <see cref="IBarChartItem"/>.</typeparam>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <param name="items">The items.</param>
 | 
			
		||||
    /// <param name="converter">The converter that converts instances of <c>T</c> to <see cref="IBreakdownChartItem"/>.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart AddItems<T>(this BreakdownChart chart, IEnumerable<T> items, Func<T, IBreakdownChartItem> converter)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (items is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(items));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (converter is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(converter));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach (var item in items)
 | 
			
		||||
        {
 | 
			
		||||
            chart.Data.Add(converter(item));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the width of the breakdown chart.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <param name="width">The breakdown chart width.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart Width(this BreakdownChart chart, int? width)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        chart.Width = width;
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Tags will be shown.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <param name="func">The value formatter to use.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart UseValueFormatter(this BreakdownChart chart, Func<double, CultureInfo, string>? func)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        chart.ValueFormatter = func;
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Tags will be shown.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <param name="func">The value formatter to use.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart UseValueFormatter(this BreakdownChart chart, Func<double, string>? func)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        chart.ValueFormatter = func != null
 | 
			
		||||
            ? (value, _) => func(value)
 | 
			
		||||
            : null;
 | 
			
		||||
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Tags will be shown.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart ShowPercentage(this BreakdownChart chart)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        chart.ValueFormatter = (value, culture) => string.Format(culture, "{0}%", value);
 | 
			
		||||
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Tags will be shown.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart ShowTags(this BreakdownChart chart)
 | 
			
		||||
    {
 | 
			
		||||
        return ShowTags(chart, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Tags will be not be shown.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart HideTags(this BreakdownChart chart)
 | 
			
		||||
    {
 | 
			
		||||
        return ShowTags(chart, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets whether or not tags will be shown.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <param name="show">Whether or not tags will be shown.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart ShowTags(this BreakdownChart chart, bool show)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        chart.ShowTags = show;
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Tag values will be shown.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart ShowTagValues(this BreakdownChart chart)
 | 
			
		||||
    {
 | 
			
		||||
        return ShowTagValues(chart, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Tag values will be not be shown.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart HideTagValues(this BreakdownChart chart)
 | 
			
		||||
    {
 | 
			
		||||
        return ShowTagValues(chart, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets whether or not tag values will be shown.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <param name="show">Whether or not tag values will be shown.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart ShowTagValues(this BreakdownChart chart, bool show)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        chart.ShowTagValues = show;
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Chart and tags is rendered in compact mode.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart Compact(this BreakdownChart chart)
 | 
			
		||||
    {
 | 
			
		||||
        return Compact(chart, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Chart and tags is rendered in full size mode.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart FullSize(this BreakdownChart chart)
 | 
			
		||||
    {
 | 
			
		||||
        return Compact(chart, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets whether or not the chart and tags should be rendered in compact mode.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="chart">The breakdown chart.</param>
 | 
			
		||||
    /// <param name="compact">Whether or not the chart and tags should be rendered in compact mode.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static BreakdownChart Compact(this BreakdownChart chart, bool compact)
 | 
			
		||||
    {
 | 
			
		||||
        if (chart is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(chart));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        chart.Compact = compact;
 | 
			
		||||
        return chart;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,132 +1,131 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="Calendar"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class CalendarExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="Calendar"/>.
 | 
			
		||||
    /// Adds a calendar event.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class CalendarExtensions
 | 
			
		||||
    /// <param name="calendar">The calendar to add the calendar event to.</param>
 | 
			
		||||
    /// <param name="date">The calendar event date.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Calendar AddCalendarEvent(this Calendar calendar, DateTime date)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a calendar event.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="calendar">The calendar to add the calendar event to.</param>
 | 
			
		||||
        /// <param name="date">The calendar event date.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Calendar AddCalendarEvent(this Calendar calendar, DateTime date)
 | 
			
		||||
        {
 | 
			
		||||
            return AddCalendarEvent(calendar, string.Empty, date.Year, date.Month, date.Day);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a calendar event.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="calendar">The calendar to add the calendar event to.</param>
 | 
			
		||||
        /// <param name="description">The calendar event description.</param>
 | 
			
		||||
        /// <param name="date">The calendar event date.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Calendar AddCalendarEvent(this Calendar calendar, string description, DateTime date)
 | 
			
		||||
        {
 | 
			
		||||
            return AddCalendarEvent(calendar, description, date.Year, date.Month, date.Day);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a calendar event.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="calendar">The calendar to add the calendar event to.</param>
 | 
			
		||||
        /// <param name="year">The year of the calendar event.</param>
 | 
			
		||||
        /// <param name="month">The month of the calendar event.</param>
 | 
			
		||||
        /// <param name="day">The day of the calendar event.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Calendar AddCalendarEvent(this Calendar calendar, int year, int month, int day)
 | 
			
		||||
        {
 | 
			
		||||
            return AddCalendarEvent(calendar, string.Empty, year, month, day);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a calendar event.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="calendar">The calendar.</param>
 | 
			
		||||
        /// <param name="description">The calendar event description.</param>
 | 
			
		||||
        /// <param name="year">The year of the calendar event.</param>
 | 
			
		||||
        /// <param name="month">The month of the calendar event.</param>
 | 
			
		||||
        /// <param name="day">The day of the calendar event.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Calendar AddCalendarEvent(this Calendar calendar, string description, int year, int month, int day)
 | 
			
		||||
        {
 | 
			
		||||
            if (calendar is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(calendar));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            calendar.CalendarEvents.Add(new CalendarEvent(description, year, month, day));
 | 
			
		||||
            return calendar;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the calendar's highlight <see cref="Style"/>.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="calendar">The calendar.</param>
 | 
			
		||||
        /// <param name="style">The highlight style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Calendar HighlightStyle(this Calendar calendar, Style? style)
 | 
			
		||||
        {
 | 
			
		||||
            if (calendar is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(calendar));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            calendar.HightlightStyle = style ?? Style.Plain;
 | 
			
		||||
            return calendar;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the calendar's header <see cref="Style"/>.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="calendar">The calendar.</param>
 | 
			
		||||
        /// <param name="style">The header style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Calendar HeaderStyle(this Calendar calendar, Style? style)
 | 
			
		||||
        {
 | 
			
		||||
            if (calendar is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(calendar));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            calendar.HeaderStyle = style ?? Style.Plain;
 | 
			
		||||
            return calendar;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Shows the calendar header.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="calendar">The calendar.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Calendar ShowHeader(this Calendar calendar)
 | 
			
		||||
        {
 | 
			
		||||
            if (calendar is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(calendar));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            calendar.ShowHeader = true;
 | 
			
		||||
            return calendar;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Hides the calendar header.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="calendar">The calendar.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Calendar HideHeader(this Calendar calendar)
 | 
			
		||||
        {
 | 
			
		||||
            if (calendar is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(calendar));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            calendar.ShowHeader = false;
 | 
			
		||||
            return calendar;
 | 
			
		||||
        }
 | 
			
		||||
        return AddCalendarEvent(calendar, string.Empty, date.Year, date.Month, date.Day);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds a calendar event.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="calendar">The calendar to add the calendar event to.</param>
 | 
			
		||||
    /// <param name="description">The calendar event description.</param>
 | 
			
		||||
    /// <param name="date">The calendar event date.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Calendar AddCalendarEvent(this Calendar calendar, string description, DateTime date)
 | 
			
		||||
    {
 | 
			
		||||
        return AddCalendarEvent(calendar, description, date.Year, date.Month, date.Day);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds a calendar event.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="calendar">The calendar to add the calendar event to.</param>
 | 
			
		||||
    /// <param name="year">The year of the calendar event.</param>
 | 
			
		||||
    /// <param name="month">The month of the calendar event.</param>
 | 
			
		||||
    /// <param name="day">The day of the calendar event.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Calendar AddCalendarEvent(this Calendar calendar, int year, int month, int day)
 | 
			
		||||
    {
 | 
			
		||||
        return AddCalendarEvent(calendar, string.Empty, year, month, day);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds a calendar event.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="calendar">The calendar.</param>
 | 
			
		||||
    /// <param name="description">The calendar event description.</param>
 | 
			
		||||
    /// <param name="year">The year of the calendar event.</param>
 | 
			
		||||
    /// <param name="month">The month of the calendar event.</param>
 | 
			
		||||
    /// <param name="day">The day of the calendar event.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Calendar AddCalendarEvent(this Calendar calendar, string description, int year, int month, int day)
 | 
			
		||||
    {
 | 
			
		||||
        if (calendar is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(calendar));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        calendar.CalendarEvents.Add(new CalendarEvent(description, year, month, day));
 | 
			
		||||
        return calendar;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the calendar's highlight <see cref="Style"/>.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="calendar">The calendar.</param>
 | 
			
		||||
    /// <param name="style">The highlight style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Calendar HighlightStyle(this Calendar calendar, Style? style)
 | 
			
		||||
    {
 | 
			
		||||
        if (calendar is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(calendar));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        calendar.HightlightStyle = style ?? Style.Plain;
 | 
			
		||||
        return calendar;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the calendar's header <see cref="Style"/>.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="calendar">The calendar.</param>
 | 
			
		||||
    /// <param name="style">The header style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Calendar HeaderStyle(this Calendar calendar, Style? style)
 | 
			
		||||
    {
 | 
			
		||||
        if (calendar is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(calendar));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        calendar.HeaderStyle = style ?? Style.Plain;
 | 
			
		||||
        return calendar;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Shows the calendar header.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="calendar">The calendar.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Calendar ShowHeader(this Calendar calendar)
 | 
			
		||||
    {
 | 
			
		||||
        if (calendar is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(calendar));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        calendar.ShowHeader = true;
 | 
			
		||||
        return calendar;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Hides the calendar header.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="calendar">The calendar.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Calendar HideHeader(this Calendar calendar)
 | 
			
		||||
    {
 | 
			
		||||
        if (calendar is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(calendar));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        calendar.ShowHeader = false;
 | 
			
		||||
        return calendar;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,18 +1,17 @@
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="char"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class CharExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="char"/>.
 | 
			
		||||
    /// Gets the cell width of a character.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class CharExtensions
 | 
			
		||||
    /// <param name="character">The character to get the cell width of.</param>
 | 
			
		||||
    /// <returns>The cell width of the character.</returns>
 | 
			
		||||
    public static int GetCellWidth(this char character)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the cell width of a character.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="character">The character to get the cell width of.</param>
 | 
			
		||||
        /// <returns>The cell width of the character.</returns>
 | 
			
		||||
        public static int GetCellWidth(this char character)
 | 
			
		||||
        {
 | 
			
		||||
            return Cell.GetCellLength(character);
 | 
			
		||||
        }
 | 
			
		||||
        return Cell.GetCellLength(character);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,47 +1,46 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IColumn"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class ColumnExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IColumn"/>.
 | 
			
		||||
    /// Prevents a column from wrapping.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class ColumnExtensions
 | 
			
		||||
    /// <typeparam name="T">An object implementing <see cref="IColumn"/>.</typeparam>
 | 
			
		||||
    /// <param name="obj">The column.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T NoWrap<T>(this T obj)
 | 
			
		||||
        where T : class, IColumn
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Prevents a column from wrapping.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object implementing <see cref="IColumn"/>.</typeparam>
 | 
			
		||||
        /// <param name="obj">The column.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T NoWrap<T>(this T obj)
 | 
			
		||||
            where T : class, IColumn
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.NoWrap = true;
 | 
			
		||||
            return obj;
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the width of the column.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object implementing <see cref="IColumn"/>.</typeparam>
 | 
			
		||||
        /// <param name="obj">The column.</param>
 | 
			
		||||
        /// <param name="width">The column width.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Width<T>(this T obj, int? width)
 | 
			
		||||
            where T : class, IColumn
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Width = width;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
        obj.NoWrap = true;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the width of the column.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object implementing <see cref="IColumn"/>.</typeparam>
 | 
			
		||||
    /// <param name="obj">The column.</param>
 | 
			
		||||
    /// <param name="width">The column width.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Width<T>(this T obj, int? width)
 | 
			
		||||
        where T : class, IColumn
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Width = width;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,135 +1,134 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="ConfirmationPrompt"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class ConfirmationPromptExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="ConfirmationPrompt"/>.
 | 
			
		||||
    /// Show or hide choices.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class ConfirmationPromptExtensions
 | 
			
		||||
    /// <param name="obj">The prompt.</param>
 | 
			
		||||
    /// <param name="show">Whether or not the choices should be visible.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ConfirmationPrompt ShowChoices(this ConfirmationPrompt obj, bool show)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Show or hide choices.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="obj">The prompt.</param>
 | 
			
		||||
        /// <param name="show">Whether or not the choices should be visible.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ConfirmationPrompt ShowChoices(this ConfirmationPrompt obj, bool show)
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.ShowChoices = show;
 | 
			
		||||
            return obj;
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Shows choices.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="obj">The prompt.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ConfirmationPrompt ShowChoices(this ConfirmationPrompt obj)
 | 
			
		||||
        {
 | 
			
		||||
            return ShowChoices(obj, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Hides choices.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="obj">The prompt.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ConfirmationPrompt HideChoices(this ConfirmationPrompt obj)
 | 
			
		||||
        {
 | 
			
		||||
            return ShowChoices(obj, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Show or hide the default value.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="obj">The prompt.</param>
 | 
			
		||||
        /// <param name="show">Whether or not the default value should be visible.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ConfirmationPrompt ShowDefaultValue(this ConfirmationPrompt obj, bool show)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.ShowDefaultValue = show;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Shows the default value.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="obj">The prompt.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ConfirmationPrompt ShowDefaultValue(this ConfirmationPrompt obj)
 | 
			
		||||
        {
 | 
			
		||||
            return ShowDefaultValue(obj, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Hides the default value.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="obj">The prompt.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ConfirmationPrompt HideDefaultValue(this ConfirmationPrompt obj)
 | 
			
		||||
        {
 | 
			
		||||
            return ShowDefaultValue(obj, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the "invalid choice" message for the prompt.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="obj">The prompt.</param>
 | 
			
		||||
        /// <param name="message">The "invalid choice" message.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ConfirmationPrompt InvalidChoiceMessage(this ConfirmationPrompt obj, string message)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.InvalidChoiceMessage = message;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the character to interpret as "yes".
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="obj">The confirmation prompt.</param>
 | 
			
		||||
        /// <param name="character">The character to interpret as "yes".</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ConfirmationPrompt Yes(this ConfirmationPrompt obj, char character)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Yes = character;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the character to interpret as "no".
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="obj">The confirmation prompt.</param>
 | 
			
		||||
        /// <param name="character">The character to interpret as "no".</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ConfirmationPrompt No(this ConfirmationPrompt obj, char character)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.No = character;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
        obj.ShowChoices = show;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Shows choices.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The prompt.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ConfirmationPrompt ShowChoices(this ConfirmationPrompt obj)
 | 
			
		||||
    {
 | 
			
		||||
        return ShowChoices(obj, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Hides choices.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The prompt.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ConfirmationPrompt HideChoices(this ConfirmationPrompt obj)
 | 
			
		||||
    {
 | 
			
		||||
        return ShowChoices(obj, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Show or hide the default value.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The prompt.</param>
 | 
			
		||||
    /// <param name="show">Whether or not the default value should be visible.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ConfirmationPrompt ShowDefaultValue(this ConfirmationPrompt obj, bool show)
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.ShowDefaultValue = show;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Shows the default value.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The prompt.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ConfirmationPrompt ShowDefaultValue(this ConfirmationPrompt obj)
 | 
			
		||||
    {
 | 
			
		||||
        return ShowDefaultValue(obj, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Hides the default value.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The prompt.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ConfirmationPrompt HideDefaultValue(this ConfirmationPrompt obj)
 | 
			
		||||
    {
 | 
			
		||||
        return ShowDefaultValue(obj, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the "invalid choice" message for the prompt.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The prompt.</param>
 | 
			
		||||
    /// <param name="message">The "invalid choice" message.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ConfirmationPrompt InvalidChoiceMessage(this ConfirmationPrompt obj, string message)
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.InvalidChoiceMessage = message;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the character to interpret as "yes".
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The confirmation prompt.</param>
 | 
			
		||||
    /// <param name="character">The character to interpret as "yes".</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ConfirmationPrompt Yes(this ConfirmationPrompt obj, char character)
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Yes = character;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the character to interpret as "no".
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="obj">The confirmation prompt.</param>
 | 
			
		||||
    /// <param name="character">The character to interpret as "no".</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ConfirmationPrompt No(this ConfirmationPrompt obj, char character)
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.No = character;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,152 +1,151 @@
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IAnsiConsoleCursor"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class CursorExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IAnsiConsoleCursor"/>.
 | 
			
		||||
    /// Shows the cursor.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class CursorExtensions
 | 
			
		||||
    /// <param name="cursor">The cursor.</param>
 | 
			
		||||
    public static void Show(this IAnsiConsoleCursor cursor)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Shows the cursor.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="cursor">The cursor.</param>
 | 
			
		||||
        public static void Show(this IAnsiConsoleCursor cursor)
 | 
			
		||||
        if (cursor is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (cursor is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            cursor.Show(true);
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Hides the cursor.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="cursor">The cursor.</param>
 | 
			
		||||
        public static void Hide(this IAnsiConsoleCursor cursor)
 | 
			
		||||
        {
 | 
			
		||||
            if (cursor is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            cursor.Show(false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Moves the cursor up.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="cursor">The cursor.</param>
 | 
			
		||||
        public static void MoveUp(this IAnsiConsoleCursor cursor)
 | 
			
		||||
        {
 | 
			
		||||
            if (cursor is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            cursor.Move(CursorDirection.Up, 1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Moves the cursor up.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="cursor">The cursor.</param>
 | 
			
		||||
        /// <param name="steps">The number of steps to move the cursor.</param>
 | 
			
		||||
        public static void MoveUp(this IAnsiConsoleCursor cursor, int steps)
 | 
			
		||||
        {
 | 
			
		||||
            if (cursor is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            cursor.Move(CursorDirection.Up, steps);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Moves the cursor down.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="cursor">The cursor.</param>
 | 
			
		||||
        public static void MoveDown(this IAnsiConsoleCursor cursor)
 | 
			
		||||
        {
 | 
			
		||||
            if (cursor is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            cursor.Move(CursorDirection.Down, 1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Moves the cursor down.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="cursor">The cursor.</param>
 | 
			
		||||
        /// <param name="steps">The number of steps to move the cursor.</param>
 | 
			
		||||
        public static void MoveDown(this IAnsiConsoleCursor cursor, int steps)
 | 
			
		||||
        {
 | 
			
		||||
            if (cursor is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            cursor.Move(CursorDirection.Down, steps);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Moves the cursor to the left.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="cursor">The cursor.</param>
 | 
			
		||||
        public static void MoveLeft(this IAnsiConsoleCursor cursor)
 | 
			
		||||
        {
 | 
			
		||||
            if (cursor is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            cursor.Move(CursorDirection.Left, 1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Moves the cursor to the left.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="cursor">The cursor.</param>
 | 
			
		||||
        /// <param name="steps">The number of steps to move the cursor.</param>
 | 
			
		||||
        public static void MoveLeft(this IAnsiConsoleCursor cursor, int steps)
 | 
			
		||||
        {
 | 
			
		||||
            if (cursor is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            cursor.Move(CursorDirection.Left, steps);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Moves the cursor to the right.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="cursor">The cursor.</param>
 | 
			
		||||
        public static void MoveRight(this IAnsiConsoleCursor cursor)
 | 
			
		||||
        {
 | 
			
		||||
            if (cursor is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            cursor.Move(CursorDirection.Right, 1);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Moves the cursor to the right.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="cursor">The cursor.</param>
 | 
			
		||||
        /// <param name="steps">The number of steps to move the cursor.</param>
 | 
			
		||||
        public static void MoveRight(this IAnsiConsoleCursor cursor, int steps)
 | 
			
		||||
        {
 | 
			
		||||
            if (cursor is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            cursor.Move(CursorDirection.Right, steps);
 | 
			
		||||
        }
 | 
			
		||||
        cursor.Show(true);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Hides the cursor.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="cursor">The cursor.</param>
 | 
			
		||||
    public static void Hide(this IAnsiConsoleCursor cursor)
 | 
			
		||||
    {
 | 
			
		||||
        if (cursor is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        cursor.Show(false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Moves the cursor up.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="cursor">The cursor.</param>
 | 
			
		||||
    public static void MoveUp(this IAnsiConsoleCursor cursor)
 | 
			
		||||
    {
 | 
			
		||||
        if (cursor is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        cursor.Move(CursorDirection.Up, 1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Moves the cursor up.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="cursor">The cursor.</param>
 | 
			
		||||
    /// <param name="steps">The number of steps to move the cursor.</param>
 | 
			
		||||
    public static void MoveUp(this IAnsiConsoleCursor cursor, int steps)
 | 
			
		||||
    {
 | 
			
		||||
        if (cursor is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        cursor.Move(CursorDirection.Up, steps);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Moves the cursor down.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="cursor">The cursor.</param>
 | 
			
		||||
    public static void MoveDown(this IAnsiConsoleCursor cursor)
 | 
			
		||||
    {
 | 
			
		||||
        if (cursor is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        cursor.Move(CursorDirection.Down, 1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Moves the cursor down.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="cursor">The cursor.</param>
 | 
			
		||||
    /// <param name="steps">The number of steps to move the cursor.</param>
 | 
			
		||||
    public static void MoveDown(this IAnsiConsoleCursor cursor, int steps)
 | 
			
		||||
    {
 | 
			
		||||
        if (cursor is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        cursor.Move(CursorDirection.Down, steps);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Moves the cursor to the left.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="cursor">The cursor.</param>
 | 
			
		||||
    public static void MoveLeft(this IAnsiConsoleCursor cursor)
 | 
			
		||||
    {
 | 
			
		||||
        if (cursor is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        cursor.Move(CursorDirection.Left, 1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Moves the cursor to the left.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="cursor">The cursor.</param>
 | 
			
		||||
    /// <param name="steps">The number of steps to move the cursor.</param>
 | 
			
		||||
    public static void MoveLeft(this IAnsiConsoleCursor cursor, int steps)
 | 
			
		||||
    {
 | 
			
		||||
        if (cursor is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        cursor.Move(CursorDirection.Left, steps);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Moves the cursor to the right.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="cursor">The cursor.</param>
 | 
			
		||||
    public static void MoveRight(this IAnsiConsoleCursor cursor)
 | 
			
		||||
    {
 | 
			
		||||
        if (cursor is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        cursor.Move(CursorDirection.Right, 1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Moves the cursor to the right.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="cursor">The cursor.</param>
 | 
			
		||||
    /// <param name="steps">The number of steps to move the cursor.</param>
 | 
			
		||||
    public static void MoveRight(this IAnsiConsoleCursor cursor, int steps)
 | 
			
		||||
    {
 | 
			
		||||
        if (cursor is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new System.ArgumentNullException(nameof(cursor));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        cursor.Move(CursorDirection.Right, steps);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +1,26 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
internal static class DayOfWeekExtensions
 | 
			
		||||
{
 | 
			
		||||
    internal static class DayOfWeekExtensions
 | 
			
		||||
    public static string GetAbbreviatedDayName(this DayOfWeek day, CultureInfo culture)
 | 
			
		||||
    {
 | 
			
		||||
        public static string GetAbbreviatedDayName(this DayOfWeek day, CultureInfo culture)
 | 
			
		||||
        {
 | 
			
		||||
            culture ??= CultureInfo.InvariantCulture;
 | 
			
		||||
            return culture.DateTimeFormat
 | 
			
		||||
                .GetAbbreviatedDayName(day)
 | 
			
		||||
                .CapitalizeFirstLetter(culture);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static DayOfWeek GetNextWeekDay(this DayOfWeek day)
 | 
			
		||||
        {
 | 
			
		||||
            var next = (int)day + 1;
 | 
			
		||||
            if (next > (int)DayOfWeek.Saturday)
 | 
			
		||||
            {
 | 
			
		||||
                return DayOfWeek.Sunday;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return (DayOfWeek)next;
 | 
			
		||||
        }
 | 
			
		||||
        culture ??= CultureInfo.InvariantCulture;
 | 
			
		||||
        return culture.DateTimeFormat
 | 
			
		||||
            .GetAbbreviatedDayName(day)
 | 
			
		||||
            .CapitalizeFirstLetter(culture);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    public static DayOfWeek GetNextWeekDay(this DayOfWeek day)
 | 
			
		||||
    {
 | 
			
		||||
        var next = (int)day + 1;
 | 
			
		||||
        if (next > (int)DayOfWeek.Saturday)
 | 
			
		||||
        {
 | 
			
		||||
            return DayOfWeek.Sunday;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return (DayOfWeek)next;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,13 +1,12 @@
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
internal static class DictionaryExtensions
 | 
			
		||||
{
 | 
			
		||||
    internal static class DictionaryExtensions
 | 
			
		||||
    public static void Deconstruct<T1, T2>(this KeyValuePair<T1, T2> tuple, out T1 key, out T2 value)
 | 
			
		||||
    {
 | 
			
		||||
        public static void Deconstruct<T1, T2>(this KeyValuePair<T1, T2> tuple, out T1 key, out T2 value)
 | 
			
		||||
        {
 | 
			
		||||
            key = tuple.Key;
 | 
			
		||||
            value = tuple.Value;
 | 
			
		||||
        }
 | 
			
		||||
        key = tuple.Key;
 | 
			
		||||
        value = tuple.Value;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -2,131 +2,130 @@ using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
internal static class EnumerableExtensions
 | 
			
		||||
{
 | 
			
		||||
    internal static class EnumerableExtensions
 | 
			
		||||
    // List.Reverse clashes with IEnumerable<T>.Reverse, so this method only exists
 | 
			
		||||
    // so we won't have to cast List<T> to IEnumerable<T>.
 | 
			
		||||
    public static IEnumerable<T> ReverseEnumerable<T>(this IEnumerable<T> source)
 | 
			
		||||
    {
 | 
			
		||||
        // List.Reverse clashes with IEnumerable<T>.Reverse, so this method only exists
 | 
			
		||||
        // so we won't have to cast List<T> to IEnumerable<T>.
 | 
			
		||||
        public static IEnumerable<T> ReverseEnumerable<T>(this IEnumerable<T> source)
 | 
			
		||||
        if (source is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (source is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(source));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return source.Reverse();
 | 
			
		||||
            throw new ArgumentNullException(nameof(source));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static bool None<T>(this IEnumerable<T> source, Func<T, bool> predicate)
 | 
			
		||||
        {
 | 
			
		||||
            return !source.Any(predicate);
 | 
			
		||||
        }
 | 
			
		||||
        return source.Reverse();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        public static IEnumerable<T> Repeat<T>(this IEnumerable<T> source, int count)
 | 
			
		||||
        {
 | 
			
		||||
            while (count-- > 0)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (var item in source)
 | 
			
		||||
                {
 | 
			
		||||
                    yield return item;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    public static bool None<T>(this IEnumerable<T> source, Func<T, bool> predicate)
 | 
			
		||||
    {
 | 
			
		||||
        return !source.Any(predicate);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
        public static int IndexOf<T>(this IEnumerable<T> source, T item)
 | 
			
		||||
            where T : class
 | 
			
		||||
        {
 | 
			
		||||
            var index = 0;
 | 
			
		||||
            foreach (var candidate in source)
 | 
			
		||||
            {
 | 
			
		||||
                if (candidate == item)
 | 
			
		||||
                {
 | 
			
		||||
                    return index;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                index++;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static int GetCount<T>(this IEnumerable<T> source)
 | 
			
		||||
        {
 | 
			
		||||
            if (source is IList<T> list)
 | 
			
		||||
            {
 | 
			
		||||
                return list.Count;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (source is T[] array)
 | 
			
		||||
            {
 | 
			
		||||
                return array.Length;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return source.Count();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
 | 
			
		||||
    public static IEnumerable<T> Repeat<T>(this IEnumerable<T> source, int count)
 | 
			
		||||
    {
 | 
			
		||||
        while (count-- > 0)
 | 
			
		||||
        {
 | 
			
		||||
            foreach (var item in source)
 | 
			
		||||
            {
 | 
			
		||||
                action(item);
 | 
			
		||||
                yield return item;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static bool AnyTrue(this IEnumerable<bool> source)
 | 
			
		||||
        {
 | 
			
		||||
            return source.Any(b => b);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static IEnumerable<(int Index, bool First, bool Last, T Item)> Enumerate<T>(this IEnumerable<T> source)
 | 
			
		||||
        {
 | 
			
		||||
            if (source is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(source));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return Enumerate(source.GetEnumerator());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static IEnumerable<(int Index, bool First, bool Last, T Item)> Enumerate<T>(this IEnumerator<T> source)
 | 
			
		||||
        {
 | 
			
		||||
            if (source is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(source));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var first = true;
 | 
			
		||||
            var last = !source.MoveNext();
 | 
			
		||||
            T current;
 | 
			
		||||
 | 
			
		||||
            for (var index = 0; !last; index++)
 | 
			
		||||
            {
 | 
			
		||||
                current = source.Current;
 | 
			
		||||
                last = !source.MoveNext();
 | 
			
		||||
                yield return (index, first, last, current);
 | 
			
		||||
                first = false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static IEnumerable<TResult> SelectIndex<T, TResult>(this IEnumerable<T> source, Func<T, int, TResult> func)
 | 
			
		||||
        {
 | 
			
		||||
            return source.Select((value, index) => func(value, index));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#if !NET5_0
 | 
			
		||||
        public static IEnumerable<(TFirst First, TSecond Second)> Zip<TFirst, TSecond>(
 | 
			
		||||
            this IEnumerable<TFirst> source, IEnumerable<TSecond> first)
 | 
			
		||||
        {
 | 
			
		||||
            return source.Zip(first, (first, second) => (first, second));
 | 
			
		||||
        }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
        public static IEnumerable<(TFirst First, TSecond Second, TThird Third)> Zip<TFirst, TSecond, TThird>(
 | 
			
		||||
            this IEnumerable<TFirst> first, IEnumerable<TSecond> second, IEnumerable<TThird> third)
 | 
			
		||||
        {
 | 
			
		||||
            return first.Zip(second, (a, b) => (a, b))
 | 
			
		||||
                .Zip(third, (a, b) => (a.a, a.b, b));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    public static int IndexOf<T>(this IEnumerable<T> source, T item)
 | 
			
		||||
        where T : class
 | 
			
		||||
    {
 | 
			
		||||
        var index = 0;
 | 
			
		||||
        foreach (var candidate in source)
 | 
			
		||||
        {
 | 
			
		||||
            if (candidate == item)
 | 
			
		||||
            {
 | 
			
		||||
                return index;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            index++;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static int GetCount<T>(this IEnumerable<T> source)
 | 
			
		||||
    {
 | 
			
		||||
        if (source is IList<T> list)
 | 
			
		||||
        {
 | 
			
		||||
            return list.Count;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (source is T[] array)
 | 
			
		||||
        {
 | 
			
		||||
            return array.Length;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return source.Count();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
 | 
			
		||||
    {
 | 
			
		||||
        foreach (var item in source)
 | 
			
		||||
        {
 | 
			
		||||
            action(item);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static bool AnyTrue(this IEnumerable<bool> source)
 | 
			
		||||
    {
 | 
			
		||||
        return source.Any(b => b);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static IEnumerable<(int Index, bool First, bool Last, T Item)> Enumerate<T>(this IEnumerable<T> source)
 | 
			
		||||
    {
 | 
			
		||||
        if (source is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(source));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return Enumerate(source.GetEnumerator());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static IEnumerable<(int Index, bool First, bool Last, T Item)> Enumerate<T>(this IEnumerator<T> source)
 | 
			
		||||
    {
 | 
			
		||||
        if (source is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(source));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var first = true;
 | 
			
		||||
        var last = !source.MoveNext();
 | 
			
		||||
        T current;
 | 
			
		||||
 | 
			
		||||
        for (var index = 0; !last; index++)
 | 
			
		||||
        {
 | 
			
		||||
            current = source.Current;
 | 
			
		||||
            last = !source.MoveNext();
 | 
			
		||||
            yield return (index, first, last, current);
 | 
			
		||||
            first = false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static IEnumerable<TResult> SelectIndex<T, TResult>(this IEnumerable<T> source, Func<T, int, TResult> func)
 | 
			
		||||
    {
 | 
			
		||||
        return source.Select((value, index) => func(value, index));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#if !NET5_0_OR_GREATER
 | 
			
		||||
    public static IEnumerable<(TFirst First, TSecond Second)> Zip<TFirst, TSecond>(
 | 
			
		||||
        this IEnumerable<TFirst> source, IEnumerable<TSecond> first)
 | 
			
		||||
    {
 | 
			
		||||
        return source.Zip(first, (first, second) => (first, second));
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    public static IEnumerable<(TFirst First, TSecond Second, TThird Third)> Zip<TFirst, TSecond, TThird>(
 | 
			
		||||
        this IEnumerable<TFirst> first, IEnumerable<TSecond> second, IEnumerable<TThird> third)
 | 
			
		||||
    {
 | 
			
		||||
        return first.Zip(second, (a, b) => (a, b))
 | 
			
		||||
            .Zip(third, (a, b) => (a.a, a.b, b));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,51 +1,50 @@
 | 
			
		||||
using System;
 | 
			
		||||
using Spectre.Console.Rendering;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="Exception"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class ExceptionExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="Exception"/>.
 | 
			
		||||
    /// Gets a <see cref="IRenderable"/> representation of the exception.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class ExceptionExtensions
 | 
			
		||||
    /// <param name="exception">The exception to format.</param>
 | 
			
		||||
    /// <param name="format">The exception format options.</param>
 | 
			
		||||
    /// <returns>A <see cref="IRenderable"/> representing the exception.</returns>
 | 
			
		||||
    public static IRenderable GetRenderable(this Exception exception, ExceptionFormats format = ExceptionFormats.Default)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a <see cref="IRenderable"/> representation of the exception.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="exception">The exception to format.</param>
 | 
			
		||||
        /// <param name="format">The exception format options.</param>
 | 
			
		||||
        /// <returns>A <see cref="IRenderable"/> representing the exception.</returns>
 | 
			
		||||
        public static IRenderable GetRenderable(this Exception exception, ExceptionFormats format = ExceptionFormats.Default)
 | 
			
		||||
        if (exception is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (exception is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(exception));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return GetRenderable(exception, new ExceptionSettings
 | 
			
		||||
            {
 | 
			
		||||
                Format = format,
 | 
			
		||||
            });
 | 
			
		||||
            throw new ArgumentNullException(nameof(exception));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a <see cref="IRenderable"/> representation of the exception.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="exception">The exception to format.</param>
 | 
			
		||||
        /// <param name="settings">The exception settings.</param>
 | 
			
		||||
        /// <returns>A <see cref="IRenderable"/> representing the exception.</returns>
 | 
			
		||||
        public static IRenderable GetRenderable(this Exception exception, ExceptionSettings settings)
 | 
			
		||||
        return GetRenderable(exception, new ExceptionSettings
 | 
			
		||||
        {
 | 
			
		||||
            if (exception is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(exception));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (settings is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(settings));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return ExceptionFormatter.Format(exception, settings);
 | 
			
		||||
        }
 | 
			
		||||
            Format = format,
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Gets a <see cref="IRenderable"/> representation of the exception.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="exception">The exception to format.</param>
 | 
			
		||||
    /// <param name="settings">The exception settings.</param>
 | 
			
		||||
    /// <returns>A <see cref="IRenderable"/> representing the exception.</returns>
 | 
			
		||||
    public static IRenderable GetRenderable(this Exception exception, ExceptionSettings settings)
 | 
			
		||||
    {
 | 
			
		||||
        if (exception is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(exception));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (settings is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(settings));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return ExceptionFormatter.Format(exception, settings);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,47 +1,46 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IExpandable"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class ExpandableExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IExpandable"/>.
 | 
			
		||||
    /// Tells the specified object to not expand to the available area
 | 
			
		||||
    /// but take as little space as possible.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class ExpandableExtensions
 | 
			
		||||
    /// <typeparam name="T">The expandable object.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to collapse.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Collapse<T>(this T obj)
 | 
			
		||||
        where T : class, IExpandable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Tells the specified object to not expand to the available area
 | 
			
		||||
        /// but take as little space as possible.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">The expandable object.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to collapse.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Collapse<T>(this T obj)
 | 
			
		||||
            where T : class, IExpandable
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Expand = false;
 | 
			
		||||
            return obj;
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Tells the specified object to expand to the available area.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">The expandable object.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to expand.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Expand<T>(this T obj)
 | 
			
		||||
            where T : class, IExpandable
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Expand = true;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
        obj.Expand = false;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Tells the specified object to expand to the available area.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">The expandable object.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to expand.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Expand<T>(this T obj)
 | 
			
		||||
        where T : class, IExpandable
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Expand = true;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,27 +1,26 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="FigletText"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class FigletTextExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="FigletText"/>.
 | 
			
		||||
    /// Sets the color of the FIGlet text.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class FigletTextExtensions
 | 
			
		||||
    /// <param name="text">The text.</param>
 | 
			
		||||
    /// <param name="color">The color.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static FigletText Color(this FigletText text, Color? color)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the color of the FIGlet text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="text">The text.</param>
 | 
			
		||||
        /// <param name="color">The color.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static FigletText Color(this FigletText text, Color? color)
 | 
			
		||||
        if (text is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (text is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(text));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            text.Color = color ?? Console.Color.Default;
 | 
			
		||||
            return text;
 | 
			
		||||
            throw new ArgumentNullException(nameof(text));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        text.Color = color ?? Console.Color.Default;
 | 
			
		||||
        return text;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -2,116 +2,115 @@ using System;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using Spectre.Console.Rendering;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="Grid"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class GridExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="Grid"/>.
 | 
			
		||||
    /// Adds a column to the grid.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class GridExtensions
 | 
			
		||||
    /// <param name="grid">The grid to add the column to.</param>
 | 
			
		||||
    /// <param name="count">The number of columns to add.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Grid AddColumns(this Grid grid, int count)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a column to the grid.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="grid">The grid to add the column to.</param>
 | 
			
		||||
        /// <param name="count">The number of columns to add.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Grid AddColumns(this Grid grid, int count)
 | 
			
		||||
        if (grid is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (grid is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(grid));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            for (var index = 0; index < count; index++)
 | 
			
		||||
            {
 | 
			
		||||
                grid.AddColumn(new GridColumn());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return grid;
 | 
			
		||||
            throw new ArgumentNullException(nameof(grid));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a column to the grid.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="grid">The grid to add the column to.</param>
 | 
			
		||||
        /// <param name="columns">The columns to add.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Grid AddColumns(this Grid grid, params GridColumn[] columns)
 | 
			
		||||
        for (var index = 0; index < count; index++)
 | 
			
		||||
        {
 | 
			
		||||
            if (grid is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(grid));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (columns is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (var column in columns)
 | 
			
		||||
            {
 | 
			
		||||
                grid.AddColumn(column);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return grid;
 | 
			
		||||
            grid.AddColumn(new GridColumn());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds an empty row to the grid.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="grid">The grid to add the row to.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Grid AddEmptyRow(this Grid grid)
 | 
			
		||||
        {
 | 
			
		||||
            if (grid is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(grid));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var columns = new IRenderable[grid.Columns.Count];
 | 
			
		||||
            Enumerable.Range(0, grid.Columns.Count).ForEach(index => columns[index] = Text.Empty);
 | 
			
		||||
            grid.AddRow(columns);
 | 
			
		||||
 | 
			
		||||
            return grid;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a new row to the grid.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="grid">The grid to add the row to.</param>
 | 
			
		||||
        /// <param name="columns">The columns to add.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Grid AddRow(this Grid grid, params string[] columns)
 | 
			
		||||
        {
 | 
			
		||||
            if (grid is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(grid));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (columns is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            grid.AddRow(columns.Select(column => new Markup(column)).ToArray());
 | 
			
		||||
            return grid;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the grid width.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="grid">The grid.</param>
 | 
			
		||||
        /// <param name="width">The width.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Grid Width(this Grid grid, int? width)
 | 
			
		||||
        {
 | 
			
		||||
            if (grid is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(grid));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            grid.Width = width;
 | 
			
		||||
            return grid;
 | 
			
		||||
        }
 | 
			
		||||
        return grid;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds a column to the grid.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="grid">The grid to add the column to.</param>
 | 
			
		||||
    /// <param name="columns">The columns to add.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Grid AddColumns(this Grid grid, params GridColumn[] columns)
 | 
			
		||||
    {
 | 
			
		||||
        if (grid is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(grid));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (columns is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach (var column in columns)
 | 
			
		||||
        {
 | 
			
		||||
            grid.AddColumn(column);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return grid;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds an empty row to the grid.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="grid">The grid to add the row to.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Grid AddEmptyRow(this Grid grid)
 | 
			
		||||
    {
 | 
			
		||||
        if (grid is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(grid));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var columns = new IRenderable[grid.Columns.Count];
 | 
			
		||||
        Enumerable.Range(0, grid.Columns.Count).ForEach(index => columns[index] = Text.Empty);
 | 
			
		||||
        grid.AddRow(columns);
 | 
			
		||||
 | 
			
		||||
        return grid;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds a new row to the grid.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="grid">The grid to add the row to.</param>
 | 
			
		||||
    /// <param name="columns">The columns to add.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Grid AddRow(this Grid grid, params string[] columns)
 | 
			
		||||
    {
 | 
			
		||||
        if (grid is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(grid));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (columns is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        grid.AddRow(columns.Select(column => new Markup(column)).ToArray());
 | 
			
		||||
        return grid;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the grid width.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="grid">The grid.</param>
 | 
			
		||||
    /// <param name="width">The width.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Grid Width(this Grid grid, int? width)
 | 
			
		||||
    {
 | 
			
		||||
        if (grid is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(grid));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        grid.Width = width;
 | 
			
		||||
        return grid;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,84 +1,83 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IHasBorder"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class HasBorderExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IHasBorder"/>.
 | 
			
		||||
    /// Enables the safe border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class HasBorderExtensions
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to enable the safe border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T SafeBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasBorder
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Enables the safe border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to enable the safe border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T SafeBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasBorder
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.UseSafeBorder = true;
 | 
			
		||||
            return obj;
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Disables the safe border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to disable the safe border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T NoSafeBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasBorder
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.UseSafeBorder = false;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the border style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border style for.</param>
 | 
			
		||||
        /// <param name="style">The border style to set.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T BorderStyle<T>(this T obj, Style style)
 | 
			
		||||
            where T : class, IHasBorder
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.BorderStyle = style;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the border color.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border color for.</param>
 | 
			
		||||
        /// <param name="color">The border color to set.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T BorderColor<T>(this T obj, Color color)
 | 
			
		||||
            where T : class, IHasBorder
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.BorderStyle = (obj.BorderStyle ?? Style.Plain).Foreground(color);
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
        obj.UseSafeBorder = true;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Disables the safe border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to disable the safe border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T NoSafeBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasBorder
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.UseSafeBorder = false;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the border style.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border style for.</param>
 | 
			
		||||
    /// <param name="style">The border style to set.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T BorderStyle<T>(this T obj, Style style)
 | 
			
		||||
        where T : class, IHasBorder
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.BorderStyle = style;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the border color.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border color for.</param>
 | 
			
		||||
    /// <param name="color">The border color to set.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T BorderColor<T>(this T obj, Color color)
 | 
			
		||||
        where T : class, IHasBorder
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.BorderStyle = (obj.BorderStyle ?? Style.Plain).Foreground(color);
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,101 +1,100 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IHasBoxBorder"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class HasBoxBorderExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IHasBoxBorder"/>.
 | 
			
		||||
    /// Sets the border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class HasBoxBorderExtensions
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <param name="border">The border to use.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Border<T>(this T obj, BoxBorder border)
 | 
			
		||||
        where T : class, IHasBoxBorder
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <param name="border">The border to use.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Border<T>(this T obj, BoxBorder border)
 | 
			
		||||
            where T : class, IHasBoxBorder
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Border = border;
 | 
			
		||||
            return obj;
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Do not display a border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T NoBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasBoxBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, BoxBorder.None);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a square border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T SquareBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasBoxBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, BoxBorder.Square);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display an ASCII border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T AsciiBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasBoxBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, BoxBorder.Ascii);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a rounded border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T RoundedBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasBoxBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, BoxBorder.Rounded);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a heavy border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T HeavyBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasBoxBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, BoxBorder.Heavy);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a double border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T DoubleBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasBoxBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, BoxBorder.Double);
 | 
			
		||||
        }
 | 
			
		||||
        obj.Border = border;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Do not display a border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T NoBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasBoxBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, BoxBorder.None);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a square border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T SquareBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasBoxBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, BoxBorder.Square);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display an ASCII border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T AsciiBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasBoxBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, BoxBorder.Ascii);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a rounded border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T RoundedBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasBoxBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, BoxBorder.Rounded);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a heavy border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T HeavyBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasBoxBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, BoxBorder.Heavy);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a double border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T DoubleBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasBoxBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, BoxBorder.Double);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,66 +1,65 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IHasCulture"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class HasCultureExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IHasCulture"/>.
 | 
			
		||||
    /// Sets the culture.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class HasCultureExtensions
 | 
			
		||||
    /// <typeparam name="T">An object type with a culture.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the culture for.</param>
 | 
			
		||||
    /// <param name="culture">The culture to set.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Culture<T>(this T obj, CultureInfo culture)
 | 
			
		||||
        where T : class, IHasCulture
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the culture.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a culture.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the culture for.</param>
 | 
			
		||||
        /// <param name="culture">The culture to set.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Culture<T>(this T obj, CultureInfo culture)
 | 
			
		||||
            where T : class, IHasCulture
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (culture is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(culture));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Culture = culture;
 | 
			
		||||
            return obj;
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the culture.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a culture.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the culture for.</param>
 | 
			
		||||
        /// <param name="name">The culture to set.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Culture<T>(this T obj, string name)
 | 
			
		||||
            where T : class, IHasCulture
 | 
			
		||||
        if (culture is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (name is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(name));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return Culture(obj, CultureInfo.GetCultureInfo(name));
 | 
			
		||||
            throw new ArgumentNullException(nameof(culture));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the culture.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a culture.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the culture for.</param>
 | 
			
		||||
        /// <param name="culture">The culture to set.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Culture<T>(this T obj, int culture)
 | 
			
		||||
            where T : class, IHasCulture
 | 
			
		||||
        {
 | 
			
		||||
            return Culture(obj, CultureInfo.GetCultureInfo(culture));
 | 
			
		||||
        }
 | 
			
		||||
        obj.Culture = culture;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the culture.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a culture.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the culture for.</param>
 | 
			
		||||
    /// <param name="name">The culture to set.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Culture<T>(this T obj, string name)
 | 
			
		||||
        where T : class, IHasCulture
 | 
			
		||||
    {
 | 
			
		||||
        if (name is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(name));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return Culture(obj, CultureInfo.GetCultureInfo(name));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the culture.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a culture.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the culture for.</param>
 | 
			
		||||
    /// <param name="culture">The culture to set.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Culture<T>(this T obj, int culture)
 | 
			
		||||
        where T : class, IHasCulture
 | 
			
		||||
    {
 | 
			
		||||
        return Culture(obj, CultureInfo.GetCultureInfo(culture));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,245 +1,244 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IHasTableBorder"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class HasTableBorderExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IHasTableBorder"/>.
 | 
			
		||||
    /// Do not display a border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class HasTableBorderExtensions
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T NoBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Do not display a border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T NoBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.None);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a square border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T SquareBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.Square);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display an ASCII border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T AsciiBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.Ascii);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display another ASCII border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Ascii2Border<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.Ascii2);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display an ASCII border with a double header border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T AsciiDoubleHeadBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.AsciiDoubleHead);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a rounded border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T RoundedBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.Rounded);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a minimal border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T MinimalBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.Minimal);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a minimal border with a heavy head.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T MinimalHeavyHeadBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.MinimalHeavyHead);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a minimal border with a double header border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T MinimalDoubleHeadBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.MinimalDoubleHead);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a simple border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T SimpleBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.Simple);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a simple border with heavy lines.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T SimpleHeavyBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.SimpleHeavy);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a simple border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T HorizontalBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.Horizontal);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a heavy border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T HeavyBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.Heavy);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a border with a heavy edge.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T HeavyEdgeBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.HeavyEdge);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a border with a heavy header.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T HeavyHeadBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.HeavyHead);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a double border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T DoubleBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.Double);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a border with a double edge.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T DoubleEdgeBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.DoubleEdge);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Display a markdown border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T MarkdownBorder<T>(this T obj)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            return Border(obj, TableBorder.Markdown);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
        /// <param name="border">The border to use.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Border<T>(this T obj, TableBorder border)
 | 
			
		||||
            where T : class, IHasTableBorder
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Border = border;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
        return Border(obj, TableBorder.None);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a square border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T SquareBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.Square);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display an ASCII border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T AsciiBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.Ascii);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display another ASCII border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Ascii2Border<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.Ascii2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display an ASCII border with a double header border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T AsciiDoubleHeadBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.AsciiDoubleHead);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a rounded border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T RoundedBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.Rounded);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a minimal border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T MinimalBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.Minimal);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a minimal border with a heavy head.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T MinimalHeavyHeadBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.MinimalHeavyHead);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a minimal border with a double header border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T MinimalDoubleHeadBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.MinimalDoubleHead);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a simple border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T SimpleBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.Simple);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a simple border with heavy lines.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T SimpleHeavyBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.SimpleHeavy);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a simple border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T HorizontalBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.Horizontal);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a heavy border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T HeavyBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.Heavy);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a border with a heavy edge.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T HeavyEdgeBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.HeavyEdge);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a border with a heavy header.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T HeavyHeadBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.HeavyHead);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a double border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T DoubleBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.Double);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a border with a double edge.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T DoubleEdgeBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.DoubleEdge);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Display a markdown border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T MarkdownBorder<T>(this T obj)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        return Border(obj, TableBorder.Markdown);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object type with a border.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to set the border for.</param>
 | 
			
		||||
    /// <param name="border">The border to use.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Border<T>(this T obj, TableBorder border)
 | 
			
		||||
        where T : class, IHasTableBorder
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Border = border;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -3,215 +3,214 @@ using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using Spectre.Console.Rendering;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IHasTreeNodes"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class HasTreeNodeExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IHasTreeNodes"/>.
 | 
			
		||||
    /// Adds a tree node.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class HasTreeNodeExtensions
 | 
			
		||||
    /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to add the tree node to.</param>
 | 
			
		||||
    /// <param name="markup">The node's markup text.</param>
 | 
			
		||||
    /// <returns>The added tree node.</returns>
 | 
			
		||||
    public static TreeNode AddNode<T>(this T obj, string markup)
 | 
			
		||||
        where T : IHasTreeNodes
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a tree node.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to add the tree node to.</param>
 | 
			
		||||
        /// <param name="markup">The node's markup text.</param>
 | 
			
		||||
        /// <returns>The added tree node.</returns>
 | 
			
		||||
        public static TreeNode AddNode<T>(this T obj, string markup)
 | 
			
		||||
            where T : IHasTreeNodes
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (markup is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(markup));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return AddNode(obj, new Markup(markup));
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a tree node.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to add the tree node to.</param>
 | 
			
		||||
        /// <param name="renderable">The renderable to add.</param>
 | 
			
		||||
        /// <returns>The added tree node.</returns>
 | 
			
		||||
        public static TreeNode AddNode<T>(this T obj, IRenderable renderable)
 | 
			
		||||
            where T : IHasTreeNodes
 | 
			
		||||
        if (markup is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (renderable is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(renderable));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var node = new TreeNode(renderable);
 | 
			
		||||
            obj.Nodes.Add(node);
 | 
			
		||||
            return node;
 | 
			
		||||
            throw new ArgumentNullException(nameof(markup));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a tree node.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to add the tree node to.</param>
 | 
			
		||||
        /// <param name="node">The tree node to add.</param>
 | 
			
		||||
        /// <returns>The added tree node.</returns>
 | 
			
		||||
        public static TreeNode AddNode<T>(this T obj, TreeNode node)
 | 
			
		||||
            where T : IHasTreeNodes
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (node is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(node));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Nodes.Add(node);
 | 
			
		||||
            return node;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Add multiple tree nodes.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to add the tree nodes to.</param>
 | 
			
		||||
        /// <param name="nodes">The tree nodes to add.</param>
 | 
			
		||||
        public static void AddNodes<T>(this T obj, params string[] nodes)
 | 
			
		||||
            where T : IHasTreeNodes
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (nodes is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(nodes));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Nodes.AddRange(nodes.Select(node => new TreeNode(new Markup(node))));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Add multiple tree nodes.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to add the tree nodes to.</param>
 | 
			
		||||
        /// <param name="nodes">The tree nodes to add.</param>
 | 
			
		||||
        public static void AddNodes<T>(this T obj, IEnumerable<string> nodes)
 | 
			
		||||
            where T : IHasTreeNodes
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (nodes is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(nodes));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Nodes.AddRange(nodes.Select(node => new TreeNode(new Markup(node))));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Add multiple tree nodes.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to add the tree nodes to.</param>
 | 
			
		||||
        /// <param name="nodes">The tree nodes to add.</param>
 | 
			
		||||
        public static void AddNodes<T>(this T obj, params IRenderable[] nodes)
 | 
			
		||||
            where T : IHasTreeNodes
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (nodes is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(nodes));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Nodes.AddRange(nodes.Select(node => new TreeNode(node)));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Add multiple tree nodes.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to add the tree nodes to.</param>
 | 
			
		||||
        /// <param name="nodes">The tree nodes to add.</param>
 | 
			
		||||
        public static void AddNodes<T>(this T obj, IEnumerable<IRenderable> nodes)
 | 
			
		||||
            where T : IHasTreeNodes
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (nodes is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(nodes));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Nodes.AddRange(nodes.Select(node => new TreeNode(node)));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Add multiple tree nodes.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to add the tree nodes to.</param>
 | 
			
		||||
        /// <param name="nodes">The tree nodes to add.</param>
 | 
			
		||||
        public static void AddNodes<T>(this T obj, params TreeNode[] nodes)
 | 
			
		||||
            where T : IHasTreeNodes
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (nodes is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(nodes));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Nodes.AddRange(nodes);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Add multiple tree nodes.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
        /// <param name="obj">The object to add the tree nodes to.</param>
 | 
			
		||||
        /// <param name="nodes">The tree nodes to add.</param>
 | 
			
		||||
        public static void AddNodes<T>(this T obj, IEnumerable<TreeNode> nodes)
 | 
			
		||||
            where T : IHasTreeNodes
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (nodes is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(nodes));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Nodes.AddRange(nodes);
 | 
			
		||||
        }
 | 
			
		||||
        return AddNode(obj, new Markup(markup));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds a tree node.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to add the tree node to.</param>
 | 
			
		||||
    /// <param name="renderable">The renderable to add.</param>
 | 
			
		||||
    /// <returns>The added tree node.</returns>
 | 
			
		||||
    public static TreeNode AddNode<T>(this T obj, IRenderable renderable)
 | 
			
		||||
        where T : IHasTreeNodes
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (renderable is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(renderable));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var node = new TreeNode(renderable);
 | 
			
		||||
        obj.Nodes.Add(node);
 | 
			
		||||
        return node;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds a tree node.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to add the tree node to.</param>
 | 
			
		||||
    /// <param name="node">The tree node to add.</param>
 | 
			
		||||
    /// <returns>The added tree node.</returns>
 | 
			
		||||
    public static TreeNode AddNode<T>(this T obj, TreeNode node)
 | 
			
		||||
        where T : IHasTreeNodes
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (node is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(node));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Nodes.Add(node);
 | 
			
		||||
        return node;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Add multiple tree nodes.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to add the tree nodes to.</param>
 | 
			
		||||
    /// <param name="nodes">The tree nodes to add.</param>
 | 
			
		||||
    public static void AddNodes<T>(this T obj, params string[] nodes)
 | 
			
		||||
        where T : IHasTreeNodes
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (nodes is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(nodes));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Nodes.AddRange(nodes.Select(node => new TreeNode(new Markup(node))));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Add multiple tree nodes.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to add the tree nodes to.</param>
 | 
			
		||||
    /// <param name="nodes">The tree nodes to add.</param>
 | 
			
		||||
    public static void AddNodes<T>(this T obj, IEnumerable<string> nodes)
 | 
			
		||||
        where T : IHasTreeNodes
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (nodes is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(nodes));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Nodes.AddRange(nodes.Select(node => new TreeNode(new Markup(node))));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Add multiple tree nodes.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to add the tree nodes to.</param>
 | 
			
		||||
    /// <param name="nodes">The tree nodes to add.</param>
 | 
			
		||||
    public static void AddNodes<T>(this T obj, params IRenderable[] nodes)
 | 
			
		||||
        where T : IHasTreeNodes
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (nodes is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(nodes));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Nodes.AddRange(nodes.Select(node => new TreeNode(node)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Add multiple tree nodes.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to add the tree nodes to.</param>
 | 
			
		||||
    /// <param name="nodes">The tree nodes to add.</param>
 | 
			
		||||
    public static void AddNodes<T>(this T obj, IEnumerable<IRenderable> nodes)
 | 
			
		||||
        where T : IHasTreeNodes
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (nodes is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(nodes));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Nodes.AddRange(nodes.Select(node => new TreeNode(node)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Add multiple tree nodes.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to add the tree nodes to.</param>
 | 
			
		||||
    /// <param name="nodes">The tree nodes to add.</param>
 | 
			
		||||
    public static void AddNodes<T>(this T obj, params TreeNode[] nodes)
 | 
			
		||||
        where T : IHasTreeNodes
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (nodes is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(nodes));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Nodes.AddRange(nodes);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Add multiple tree nodes.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object with tree nodes.</typeparam>
 | 
			
		||||
    /// <param name="obj">The object to add the tree nodes to.</param>
 | 
			
		||||
    /// <param name="nodes">The tree nodes to add.</param>
 | 
			
		||||
    public static void AddNodes<T>(this T obj, IEnumerable<TreeNode> nodes)
 | 
			
		||||
        where T : IHasTreeNodes
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (nodes is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(nodes));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Nodes.AddRange(nodes);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,20 +1,19 @@
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
internal static class Int32Extensions
 | 
			
		||||
{
 | 
			
		||||
    internal static class Int32Extensions
 | 
			
		||||
    public static int Clamp(this int value, int min, int max)
 | 
			
		||||
    {
 | 
			
		||||
        public static int Clamp(this int value, int min, int max)
 | 
			
		||||
        if (value <= min)
 | 
			
		||||
        {
 | 
			
		||||
            if (value <= min)
 | 
			
		||||
            {
 | 
			
		||||
                return min;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (value >= max)
 | 
			
		||||
            {
 | 
			
		||||
                return max;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return value;
 | 
			
		||||
            return min;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (value >= max)
 | 
			
		||||
        {
 | 
			
		||||
            return max;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,38 +1,37 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
{
 | 
			
		||||
    internal static class ListExtensions
 | 
			
		||||
    {
 | 
			
		||||
        public static void RemoveLast<T>(this List<T> list)
 | 
			
		||||
        {
 | 
			
		||||
            if (list is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(list));
 | 
			
		||||
            }
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
            if (list.Count > 0)
 | 
			
		||||
            {
 | 
			
		||||
                list.RemoveAt(list.Count - 1);
 | 
			
		||||
            }
 | 
			
		||||
internal static class ListExtensions
 | 
			
		||||
{
 | 
			
		||||
    public static void RemoveLast<T>(this List<T> list)
 | 
			
		||||
    {
 | 
			
		||||
        if (list is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(list));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void AddOrReplaceLast<T>(this List<T> list, T item)
 | 
			
		||||
        if (list.Count > 0)
 | 
			
		||||
        {
 | 
			
		||||
            if (list is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(list));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (list.Count == 0)
 | 
			
		||||
            {
 | 
			
		||||
                list.Add(item);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                list[list.Count - 1] = item;
 | 
			
		||||
            }
 | 
			
		||||
            list.RemoveAt(list.Count - 1);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    public static void AddOrReplaceLast<T>(this List<T> list, T item)
 | 
			
		||||
    {
 | 
			
		||||
        if (list is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(list));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (list.Count == 0)
 | 
			
		||||
        {
 | 
			
		||||
            list.Add(item);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            list[list.Count - 1] = item;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,65 +1,64 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="LiveDisplay"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class LiveDisplayExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="LiveDisplay"/>.
 | 
			
		||||
    /// Sets whether or not auto clear is enabled.
 | 
			
		||||
    /// If enabled, the live display will be cleared when done.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class LiveDisplayExtensions
 | 
			
		||||
    /// <param name="live">The <see cref="LiveDisplay"/> instance.</param>
 | 
			
		||||
    /// <param name="enabled">Whether or not auto clear is enabled.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static LiveDisplay AutoClear(this LiveDisplay live, bool enabled)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets whether or not auto clear is enabled.
 | 
			
		||||
        /// If enabled, the live display will be cleared when done.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="live">The <see cref="LiveDisplay"/> instance.</param>
 | 
			
		||||
        /// <param name="enabled">Whether or not auto clear is enabled.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static LiveDisplay AutoClear(this LiveDisplay live, bool enabled)
 | 
			
		||||
        if (live is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (live is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(live));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            live.AutoClear = enabled;
 | 
			
		||||
 | 
			
		||||
            return live;
 | 
			
		||||
            throw new ArgumentNullException(nameof(live));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the vertical overflow strategy.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="live">The <see cref="LiveDisplay"/> instance.</param>
 | 
			
		||||
        /// <param name="overflow">The overflow strategy to use.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static LiveDisplay Overflow(this LiveDisplay live, VerticalOverflow overflow)
 | 
			
		||||
        {
 | 
			
		||||
            if (live is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(live));
 | 
			
		||||
            }
 | 
			
		||||
        live.AutoClear = enabled;
 | 
			
		||||
 | 
			
		||||
            live.Overflow = overflow;
 | 
			
		||||
 | 
			
		||||
            return live;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the vertical overflow cropping strategy.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="live">The <see cref="LiveDisplay"/> instance.</param>
 | 
			
		||||
        /// <param name="cropping">The overflow cropping strategy to use.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static LiveDisplay Cropping(this LiveDisplay live, VerticalOverflowCropping cropping)
 | 
			
		||||
        {
 | 
			
		||||
            if (live is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(live));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            live.Cropping = cropping;
 | 
			
		||||
 | 
			
		||||
            return live;
 | 
			
		||||
        }
 | 
			
		||||
        return live;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the vertical overflow strategy.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="live">The <see cref="LiveDisplay"/> instance.</param>
 | 
			
		||||
    /// <param name="overflow">The overflow strategy to use.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static LiveDisplay Overflow(this LiveDisplay live, VerticalOverflow overflow)
 | 
			
		||||
    {
 | 
			
		||||
        if (live is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(live));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        live.Overflow = overflow;
 | 
			
		||||
 | 
			
		||||
        return live;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the vertical overflow cropping strategy.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="live">The <see cref="LiveDisplay"/> instance.</param>
 | 
			
		||||
    /// <param name="cropping">The overflow cropping strategy to use.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static LiveDisplay Cropping(this LiveDisplay live, VerticalOverflowCropping cropping)
 | 
			
		||||
    {
 | 
			
		||||
        if (live is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(live));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        live.Cropping = cropping;
 | 
			
		||||
 | 
			
		||||
        return live;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,80 +1,79 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IOverflowable"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class OverflowableExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IOverflowable"/>.
 | 
			
		||||
    /// Folds any overflowing text.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class OverflowableExtensions
 | 
			
		||||
    /// <typeparam name="T">An object implementing <see cref="IOverflowable"/>.</typeparam>
 | 
			
		||||
    /// <param name="obj">The overflowable object instance.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Fold<T>(this T obj)
 | 
			
		||||
        where T : class, IOverflowable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Folds any overflowing text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object implementing <see cref="IOverflowable"/>.</typeparam>
 | 
			
		||||
        /// <param name="obj">The overflowable object instance.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Fold<T>(this T obj)
 | 
			
		||||
            where T : class, IOverflowable
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return Overflow(obj, Console.Overflow.Fold);
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Crops any overflowing text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object implementing <see cref="IOverflowable"/>.</typeparam>
 | 
			
		||||
        /// <param name="obj">The overflowable object instance.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Crop<T>(this T obj)
 | 
			
		||||
            where T : class, IOverflowable
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return Overflow(obj, Console.Overflow.Crop);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Crops any overflowing text and adds an ellipsis to the end.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object implementing <see cref="IOverflowable"/>.</typeparam>
 | 
			
		||||
        /// <param name="obj">The overflowable object instance.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Ellipsis<T>(this T obj)
 | 
			
		||||
            where T : class, IOverflowable
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return Overflow(obj, Console.Overflow.Ellipsis);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the overflow strategy.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object implementing <see cref="IOverflowable"/>.</typeparam>
 | 
			
		||||
        /// <param name="obj">The overflowable object instance.</param>
 | 
			
		||||
        /// <param name="overflow">The overflow strategy to use.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Overflow<T>(this T obj, Overflow overflow)
 | 
			
		||||
            where T : class, IOverflowable
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Overflow = overflow;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
        return Overflow(obj, Console.Overflow.Fold);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Crops any overflowing text.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object implementing <see cref="IOverflowable"/>.</typeparam>
 | 
			
		||||
    /// <param name="obj">The overflowable object instance.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Crop<T>(this T obj)
 | 
			
		||||
        where T : class, IOverflowable
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return Overflow(obj, Console.Overflow.Crop);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Crops any overflowing text and adds an ellipsis to the end.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object implementing <see cref="IOverflowable"/>.</typeparam>
 | 
			
		||||
    /// <param name="obj">The overflowable object instance.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Ellipsis<T>(this T obj)
 | 
			
		||||
        where T : class, IOverflowable
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return Overflow(obj, Console.Overflow.Ellipsis);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the overflow strategy.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object implementing <see cref="IOverflowable"/>.</typeparam>
 | 
			
		||||
    /// <param name="obj">The overflowable object instance.</param>
 | 
			
		||||
    /// <param name="overflow">The overflow strategy to use.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Overflow<T>(this T obj, Overflow overflow)
 | 
			
		||||
        where T : class, IOverflowable
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Overflow = overflow;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,131 +1,130 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IPaddable"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class PaddableExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IPaddable"/>.
 | 
			
		||||
    /// Sets the left padding.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class PaddableExtensions
 | 
			
		||||
    /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
    /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
    /// <param name="left">The left padding.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T PadLeft<T>(this T obj, int left)
 | 
			
		||||
        where T : class, IPaddable
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the left padding.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
        /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
        /// <param name="left">The left padding.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T PadLeft<T>(this T obj, int left)
 | 
			
		||||
            where T : class, IPaddable
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return Padding(obj, new Padding(left, obj.Padding.GetTopSafe(), obj.Padding.GetRightSafe(), obj.Padding.GetBottomSafe()));
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the top padding.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
        /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
        /// <param name="top">The top padding.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T PadTop<T>(this T obj, int top)
 | 
			
		||||
            where T : class, IPaddable
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return Padding(obj, new Padding(obj.Padding.GetLeftSafe(), top, obj.Padding.GetRightSafe(), obj.Padding.GetBottomSafe()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the right padding.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
        /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
        /// <param name="right">The right padding.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T PadRight<T>(this T obj, int right)
 | 
			
		||||
            where T : class, IPaddable
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return Padding(obj, new Padding(obj.Padding.GetLeftSafe(), obj.Padding.GetTopSafe(), right, obj.Padding.GetBottomSafe()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the bottom padding.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
        /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
        /// <param name="bottom">The bottom padding.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T PadBottom<T>(this T obj, int bottom)
 | 
			
		||||
            where T : class, IPaddable
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return Padding(obj, new Padding(obj.Padding.GetLeftSafe(), obj.Padding.GetTopSafe(), obj.Padding.GetRightSafe(), bottom));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the left, top, right and bottom padding.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
        /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
        /// <param name="left">The left padding to apply.</param>
 | 
			
		||||
        /// <param name="top">The top padding to apply.</param>
 | 
			
		||||
        /// <param name="right">The right padding to apply.</param>
 | 
			
		||||
        /// <param name="bottom">The bottom padding to apply.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Padding<T>(this T obj, int left, int top, int right, int bottom)
 | 
			
		||||
            where T : class, IPaddable
 | 
			
		||||
        {
 | 
			
		||||
            return Padding(obj, new Padding(left, top, right, bottom));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the horizontal and vertical padding.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
        /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
        /// <param name="horizontal">The left and right padding.</param>
 | 
			
		||||
        /// <param name="vertical">The top and bottom padding.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Padding<T>(this T obj, int horizontal, int vertical)
 | 
			
		||||
            where T : class, IPaddable
 | 
			
		||||
        {
 | 
			
		||||
            return Padding(obj, new Padding(horizontal, vertical));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the padding.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
        /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
        /// <param name="padding">The padding to apply.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static T Padding<T>(this T obj, Padding padding)
 | 
			
		||||
            where T : class, IPaddable
 | 
			
		||||
        {
 | 
			
		||||
            if (obj is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            obj.Padding = padding;
 | 
			
		||||
            return obj;
 | 
			
		||||
        }
 | 
			
		||||
        return Padding(obj, new Padding(left, obj.Padding.GetTopSafe(), obj.Padding.GetRightSafe(), obj.Padding.GetBottomSafe()));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the top padding.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
    /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
    /// <param name="top">The top padding.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T PadTop<T>(this T obj, int top)
 | 
			
		||||
        where T : class, IPaddable
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return Padding(obj, new Padding(obj.Padding.GetLeftSafe(), top, obj.Padding.GetRightSafe(), obj.Padding.GetBottomSafe()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the right padding.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
    /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
    /// <param name="right">The right padding.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T PadRight<T>(this T obj, int right)
 | 
			
		||||
        where T : class, IPaddable
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return Padding(obj, new Padding(obj.Padding.GetLeftSafe(), obj.Padding.GetTopSafe(), right, obj.Padding.GetBottomSafe()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the bottom padding.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
    /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
    /// <param name="bottom">The bottom padding.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T PadBottom<T>(this T obj, int bottom)
 | 
			
		||||
        where T : class, IPaddable
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return Padding(obj, new Padding(obj.Padding.GetLeftSafe(), obj.Padding.GetTopSafe(), obj.Padding.GetRightSafe(), bottom));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the left, top, right and bottom padding.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
    /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
    /// <param name="left">The left padding to apply.</param>
 | 
			
		||||
    /// <param name="top">The top padding to apply.</param>
 | 
			
		||||
    /// <param name="right">The right padding to apply.</param>
 | 
			
		||||
    /// <param name="bottom">The bottom padding to apply.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Padding<T>(this T obj, int left, int top, int right, int bottom)
 | 
			
		||||
        where T : class, IPaddable
 | 
			
		||||
    {
 | 
			
		||||
        return Padding(obj, new Padding(left, top, right, bottom));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the horizontal and vertical padding.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
    /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
    /// <param name="horizontal">The left and right padding.</param>
 | 
			
		||||
    /// <param name="vertical">The top and bottom padding.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Padding<T>(this T obj, int horizontal, int vertical)
 | 
			
		||||
        where T : class, IPaddable
 | 
			
		||||
    {
 | 
			
		||||
        return Padding(obj, new Padding(horizontal, vertical));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the padding.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <typeparam name="T">An object implementing <see cref="IPaddable"/>.</typeparam>
 | 
			
		||||
    /// <param name="obj">The paddable object instance.</param>
 | 
			
		||||
    /// <param name="padding">The padding to apply.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static T Padding<T>(this T obj, Padding padding)
 | 
			
		||||
        where T : class, IPaddable
 | 
			
		||||
    {
 | 
			
		||||
        if (obj is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(obj));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        obj.Padding = padding;
 | 
			
		||||
        return obj;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,48 +1,47 @@
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="Padding"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class PaddingExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="Padding"/>.
 | 
			
		||||
    /// Gets the left padding.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class PaddingExtensions
 | 
			
		||||
    /// <param name="padding">The padding.</param>
 | 
			
		||||
    /// <returns>The left padding or zero if <c>padding</c> is null.</returns>
 | 
			
		||||
    public static int GetLeftSafe(this Padding? padding)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the left padding.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="padding">The padding.</param>
 | 
			
		||||
        /// <returns>The left padding or zero if <c>padding</c> is null.</returns>
 | 
			
		||||
        public static int GetLeftSafe(this Padding? padding)
 | 
			
		||||
        {
 | 
			
		||||
            return padding?.Left ?? 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the right padding.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="padding">The padding.</param>
 | 
			
		||||
        /// <returns>The right padding or zero if <c>padding</c> is null.</returns>
 | 
			
		||||
        public static int GetRightSafe(this Padding? padding)
 | 
			
		||||
        {
 | 
			
		||||
            return padding?.Right ?? 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the top padding.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="padding">The padding.</param>
 | 
			
		||||
        /// <returns>The top padding or zero if <c>padding</c> is null.</returns>
 | 
			
		||||
        public static int GetTopSafe(this Padding? padding)
 | 
			
		||||
        {
 | 
			
		||||
            return padding?.Top ?? 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the bottom padding.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="padding">The padding.</param>
 | 
			
		||||
        /// <returns>The bottom padding or zero if <c>padding</c> is null.</returns>
 | 
			
		||||
        public static int GetBottomSafe(this Padding? padding)
 | 
			
		||||
        {
 | 
			
		||||
            return padding?.Bottom ?? 0;
 | 
			
		||||
        }
 | 
			
		||||
        return padding?.Left ?? 0;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Gets the right padding.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="padding">The padding.</param>
 | 
			
		||||
    /// <returns>The right padding or zero if <c>padding</c> is null.</returns>
 | 
			
		||||
    public static int GetRightSafe(this Padding? padding)
 | 
			
		||||
    {
 | 
			
		||||
        return padding?.Right ?? 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Gets the top padding.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="padding">The padding.</param>
 | 
			
		||||
    /// <returns>The top padding or zero if <c>padding</c> is null.</returns>
 | 
			
		||||
    public static int GetTopSafe(this Padding? padding)
 | 
			
		||||
    {
 | 
			
		||||
        return padding?.Top ?? 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Gets the bottom padding.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="padding">The padding.</param>
 | 
			
		||||
    /// <returns>The bottom padding or zero if <c>padding</c> is null.</returns>
 | 
			
		||||
    public static int GetBottomSafe(this Padding? padding)
 | 
			
		||||
    {
 | 
			
		||||
        return padding?.Bottom ?? 0;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,77 +1,76 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="Panel"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class PanelExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="Panel"/>.
 | 
			
		||||
    /// Sets the panel header.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class PanelExtensions
 | 
			
		||||
    /// <param name="panel">The panel.</param>
 | 
			
		||||
    /// <param name="text">The header text.</param>
 | 
			
		||||
    /// <param name="alignment">The header alignment.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Panel Header(this Panel panel, string text, Justify? alignment = null)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the panel header.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="panel">The panel.</param>
 | 
			
		||||
        /// <param name="text">The header text.</param>
 | 
			
		||||
        /// <param name="alignment">The header alignment.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Panel Header(this Panel panel, string text, Justify? alignment = null)
 | 
			
		||||
        if (panel is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (panel is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(panel));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (text is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(text));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            alignment ??= panel.Header?.Alignment;
 | 
			
		||||
            return Header(panel, new PanelHeader(text, alignment));
 | 
			
		||||
            throw new ArgumentNullException(nameof(panel));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the panel header alignment.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="panel">The panel.</param>
 | 
			
		||||
        /// <param name="alignment">The header alignment.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Panel HeaderAlignment(this Panel panel, Justify alignment)
 | 
			
		||||
        if (text is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (panel is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(panel));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (panel.Header != null)
 | 
			
		||||
            {
 | 
			
		||||
                // Update existing style
 | 
			
		||||
                panel.Header.Alignment = alignment;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                // Create header
 | 
			
		||||
                Header(panel, string.Empty, alignment);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return panel;
 | 
			
		||||
            throw new ArgumentNullException(nameof(text));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the panel header.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="panel">The panel.</param>
 | 
			
		||||
        /// <param name="header">The header to use.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Panel Header(this Panel panel, PanelHeader header)
 | 
			
		||||
        {
 | 
			
		||||
            if (panel is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(panel));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            panel.Header = header;
 | 
			
		||||
            return panel;
 | 
			
		||||
        }
 | 
			
		||||
        alignment ??= panel.Header?.Alignment;
 | 
			
		||||
        return Header(panel, new PanelHeader(text, alignment));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the panel header alignment.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="panel">The panel.</param>
 | 
			
		||||
    /// <param name="alignment">The header alignment.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Panel HeaderAlignment(this Panel panel, Justify alignment)
 | 
			
		||||
    {
 | 
			
		||||
        if (panel is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(panel));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (panel.Header != null)
 | 
			
		||||
        {
 | 
			
		||||
            // Update existing style
 | 
			
		||||
            panel.Header.Alignment = alignment;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            // Create header
 | 
			
		||||
            Header(panel, string.Empty, alignment);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return panel;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the panel header.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="panel">The panel.</param>
 | 
			
		||||
    /// <param name="header">The header to use.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Panel Header(this Panel panel, PanelHeader header)
 | 
			
		||||
    {
 | 
			
		||||
        if (panel is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(panel));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        panel.Header = header;
 | 
			
		||||
        return panel;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,54 +1,53 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="PercentageColumn"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class PercentageColumnExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="PercentageColumn"/>.
 | 
			
		||||
    /// Sets the style for a non-complete task.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class PercentageColumnExtensions
 | 
			
		||||
    /// <param name="column">The column.</param>
 | 
			
		||||
    /// <param name="style">The style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static PercentageColumn Style(this PercentageColumn column, Style style)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the style for a non-complete task.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="column">The column.</param>
 | 
			
		||||
        /// <param name="style">The style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static PercentageColumn Style(this PercentageColumn column, Style style)
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (style is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(style));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            column.Style = style;
 | 
			
		||||
            return column;
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the style for a completed task.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="column">The column.</param>
 | 
			
		||||
        /// <param name="style">The style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static PercentageColumn CompletedStyle(this PercentageColumn column, Style style)
 | 
			
		||||
        if (style is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (style is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(style));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            column.CompletedStyle = style;
 | 
			
		||||
            return column;
 | 
			
		||||
            throw new ArgumentNullException(nameof(style));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        column.Style = style;
 | 
			
		||||
        return column;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the style for a completed task.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="column">The column.</param>
 | 
			
		||||
    /// <param name="style">The style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static PercentageColumn CompletedStyle(this PercentageColumn column, Style style)
 | 
			
		||||
    {
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (style is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(style));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        column.CompletedStyle = style;
 | 
			
		||||
        return column;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,76 +1,75 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="ProgressBarColumn"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class ProgressBarColumnExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="ProgressBarColumn"/>.
 | 
			
		||||
    /// Sets the style of completed portions of the progress bar.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class ProgressBarColumnExtensions
 | 
			
		||||
    /// <param name="column">The column.</param>
 | 
			
		||||
    /// <param name="style">The style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ProgressBarColumn CompletedStyle(this ProgressBarColumn column, Style style)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the style of completed portions of the progress bar.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="column">The column.</param>
 | 
			
		||||
        /// <param name="style">The style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ProgressBarColumn CompletedStyle(this ProgressBarColumn column, Style style)
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (style is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(style));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            column.CompletedStyle = style;
 | 
			
		||||
            return column;
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the style of a finished progress bar.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="column">The column.</param>
 | 
			
		||||
        /// <param name="style">The style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ProgressBarColumn FinishedStyle(this ProgressBarColumn column, Style style)
 | 
			
		||||
        if (style is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (style is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(style));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            column.FinishedStyle = style;
 | 
			
		||||
            return column;
 | 
			
		||||
            throw new ArgumentNullException(nameof(style));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the style of remaining portions of the progress bar.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="column">The column.</param>
 | 
			
		||||
        /// <param name="style">The style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ProgressBarColumn RemainingStyle(this ProgressBarColumn column, Style style)
 | 
			
		||||
        {
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (style is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(style));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            column.RemainingStyle = style;
 | 
			
		||||
            return column;
 | 
			
		||||
        }
 | 
			
		||||
        column.CompletedStyle = style;
 | 
			
		||||
        return column;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the style of a finished progress bar.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="column">The column.</param>
 | 
			
		||||
    /// <param name="style">The style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ProgressBarColumn FinishedStyle(this ProgressBarColumn column, Style style)
 | 
			
		||||
    {
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (style is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(style));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        column.FinishedStyle = style;
 | 
			
		||||
        return column;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the style of remaining portions of the progress bar.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="column">The column.</param>
 | 
			
		||||
    /// <param name="style">The style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ProgressBarColumn RemainingStyle(this ProgressBarColumn column, Style style)
 | 
			
		||||
    {
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (style is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(style));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        column.RemainingStyle = style;
 | 
			
		||||
        return column;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,99 +1,98 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="Progress"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class ProgressExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="Progress"/>.
 | 
			
		||||
    /// Sets the columns to be used for an <see cref="Progress"/> instance.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class ProgressExtensions
 | 
			
		||||
    /// <param name="progress">The <see cref="Progress"/> instance.</param>
 | 
			
		||||
    /// <param name="columns">The columns to use.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Progress Columns(this Progress progress, params ProgressColumn[] columns)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the columns to be used for an <see cref="Progress"/> instance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="progress">The <see cref="Progress"/> instance.</param>
 | 
			
		||||
        /// <param name="columns">The columns to use.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Progress Columns(this Progress progress, params ProgressColumn[] columns)
 | 
			
		||||
        if (progress is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (progress is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(progress));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (columns is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (!columns.Any())
 | 
			
		||||
            {
 | 
			
		||||
                throw new InvalidOperationException("At least one column must be specified.");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            progress.Columns.Clear();
 | 
			
		||||
            progress.Columns.AddRange(columns);
 | 
			
		||||
 | 
			
		||||
            return progress;
 | 
			
		||||
            throw new ArgumentNullException(nameof(progress));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets whether or not auto refresh is enabled.
 | 
			
		||||
        /// If disabled, you will manually have to refresh the progress.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="progress">The <see cref="Progress"/> instance.</param>
 | 
			
		||||
        /// <param name="enabled">Whether or not auto refresh is enabled.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Progress AutoRefresh(this Progress progress, bool enabled)
 | 
			
		||||
        if (columns is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (progress is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(progress));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            progress.AutoRefresh = enabled;
 | 
			
		||||
 | 
			
		||||
            return progress;
 | 
			
		||||
            throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets whether or not auto clear is enabled.
 | 
			
		||||
        /// If enabled, the task tabled will be removed once
 | 
			
		||||
        /// all tasks have completed.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="progress">The <see cref="Progress"/> instance.</param>
 | 
			
		||||
        /// <param name="enabled">Whether or not auto clear is enabled.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Progress AutoClear(this Progress progress, bool enabled)
 | 
			
		||||
        if (!columns.Any())
 | 
			
		||||
        {
 | 
			
		||||
            if (progress is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(progress));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            progress.AutoClear = enabled;
 | 
			
		||||
 | 
			
		||||
            return progress;
 | 
			
		||||
            throw new InvalidOperationException("At least one column must be specified.");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets whether or not hide completed is enabled.
 | 
			
		||||
        /// If enabled, the task tabled will be removed once it is
 | 
			
		||||
        /// completed.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="progress">The <see cref="Progress"/> instance.</param>
 | 
			
		||||
        /// <param name="enabled">Whether or not hide completed is enabled.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Progress HideCompleted(this Progress progress, bool enabled)
 | 
			
		||||
        {
 | 
			
		||||
            if (progress is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(progress));
 | 
			
		||||
            }
 | 
			
		||||
        progress.Columns.Clear();
 | 
			
		||||
        progress.Columns.AddRange(columns);
 | 
			
		||||
 | 
			
		||||
            progress.HideCompleted = enabled;
 | 
			
		||||
 | 
			
		||||
            return progress;
 | 
			
		||||
        }
 | 
			
		||||
        return progress;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets whether or not auto refresh is enabled.
 | 
			
		||||
    /// If disabled, you will manually have to refresh the progress.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="progress">The <see cref="Progress"/> instance.</param>
 | 
			
		||||
    /// <param name="enabled">Whether or not auto refresh is enabled.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Progress AutoRefresh(this Progress progress, bool enabled)
 | 
			
		||||
    {
 | 
			
		||||
        if (progress is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(progress));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        progress.AutoRefresh = enabled;
 | 
			
		||||
 | 
			
		||||
        return progress;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets whether or not auto clear is enabled.
 | 
			
		||||
    /// If enabled, the task tabled will be removed once
 | 
			
		||||
    /// all tasks have completed.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="progress">The <see cref="Progress"/> instance.</param>
 | 
			
		||||
    /// <param name="enabled">Whether or not auto clear is enabled.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Progress AutoClear(this Progress progress, bool enabled)
 | 
			
		||||
    {
 | 
			
		||||
        if (progress is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(progress));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        progress.AutoClear = enabled;
 | 
			
		||||
 | 
			
		||||
        return progress;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets whether or not hide completed is enabled.
 | 
			
		||||
    /// If enabled, the task tabled will be removed once it is
 | 
			
		||||
    /// completed.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="progress">The <see cref="Progress"/> instance.</param>
 | 
			
		||||
    /// <param name="enabled">Whether or not hide completed is enabled.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Progress HideCompleted(this Progress progress, bool enabled)
 | 
			
		||||
    {
 | 
			
		||||
        if (progress is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(progress));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        progress.HideCompleted = enabled;
 | 
			
		||||
 | 
			
		||||
        return progress;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,78 +1,77 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="ProgressTask"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class ProgressTaskExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="ProgressTask"/>.
 | 
			
		||||
    /// Sets the task description.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class ProgressTaskExtensions
 | 
			
		||||
    /// <param name="task">The task.</param>
 | 
			
		||||
    /// <param name="description">The description.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ProgressTask Description(this ProgressTask task, string description)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the task description.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="task">The task.</param>
 | 
			
		||||
        /// <param name="description">The description.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ProgressTask Description(this ProgressTask task, string description)
 | 
			
		||||
        if (task is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (task is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(task));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            task.Description = description;
 | 
			
		||||
            return task;
 | 
			
		||||
            throw new ArgumentNullException(nameof(task));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the max value of the task.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="task">The task.</param>
 | 
			
		||||
        /// <param name="value">The max value.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ProgressTask MaxValue(this ProgressTask task, double value)
 | 
			
		||||
        {
 | 
			
		||||
            if (task is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(task));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            task.MaxValue = value;
 | 
			
		||||
            return task;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the value of the task.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="task">The task.</param>
 | 
			
		||||
        /// <param name="value">The value.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ProgressTask Value(this ProgressTask task, double value)
 | 
			
		||||
        {
 | 
			
		||||
            if (task is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(task));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            task.Value = value;
 | 
			
		||||
            return task;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets whether the task is considered indeterminate or not.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="task">The task.</param>
 | 
			
		||||
        /// <param name="indeterminate">Whether the task is considered indeterminate or not.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static ProgressTask IsIndeterminate(this ProgressTask task, bool indeterminate = true)
 | 
			
		||||
        {
 | 
			
		||||
            if (task is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(task));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            task.IsIndeterminate = indeterminate;
 | 
			
		||||
            return task;
 | 
			
		||||
        }
 | 
			
		||||
        task.Description = description;
 | 
			
		||||
        return task;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the max value of the task.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="task">The task.</param>
 | 
			
		||||
    /// <param name="value">The max value.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ProgressTask MaxValue(this ProgressTask task, double value)
 | 
			
		||||
    {
 | 
			
		||||
        if (task is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(task));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        task.MaxValue = value;
 | 
			
		||||
        return task;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the value of the task.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="task">The task.</param>
 | 
			
		||||
    /// <param name="value">The value.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ProgressTask Value(this ProgressTask task, double value)
 | 
			
		||||
    {
 | 
			
		||||
        if (task is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(task));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        task.Value = value;
 | 
			
		||||
        return task;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets whether the task is considered indeterminate or not.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="task">The task.</param>
 | 
			
		||||
    /// <param name="indeterminate">Whether the task is considered indeterminate or not.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static ProgressTask IsIndeterminate(this ProgressTask task, bool indeterminate = true)
 | 
			
		||||
    {
 | 
			
		||||
        if (task is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(task));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        task.IsIndeterminate = indeterminate;
 | 
			
		||||
        return task;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,32 +1,31 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="RemainingTimeColumn"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class RemainingTimeColumnExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="RemainingTimeColumn"/>.
 | 
			
		||||
    /// Sets the style of the remaining time text.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class RemainingTimeColumnExtensions
 | 
			
		||||
    /// <param name="column">The column.</param>
 | 
			
		||||
    /// <param name="style">The style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static RemainingTimeColumn Style(this RemainingTimeColumn column, Style style)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the style of the remaining time text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="column">The column.</param>
 | 
			
		||||
        /// <param name="style">The style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static RemainingTimeColumn Style(this RemainingTimeColumn column, Style style)
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (style is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(style));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            column.Style = style;
 | 
			
		||||
            return column;
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (style is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(style));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        column.Style = style;
 | 
			
		||||
        return column;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,62 +1,61 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="SpinnerColumn"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class SpinnerColumnExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="SpinnerColumn"/>.
 | 
			
		||||
    /// Sets the style of the spinner.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class SpinnerColumnExtensions
 | 
			
		||||
    /// <param name="column">The column.</param>
 | 
			
		||||
    /// <param name="style">The style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static SpinnerColumn Style(this SpinnerColumn column, Style? style)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the style of the spinner.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="column">The column.</param>
 | 
			
		||||
        /// <param name="style">The style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static SpinnerColumn Style(this SpinnerColumn column, Style? style)
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            column.Style = style;
 | 
			
		||||
            return column;
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the text that should be shown instead of the spinner
 | 
			
		||||
        /// once a task completes.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="column">The column.</param>
 | 
			
		||||
        /// <param name="text">The text.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static SpinnerColumn CompletedText(this SpinnerColumn column, string? text)
 | 
			
		||||
        {
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            column.CompletedText = text;
 | 
			
		||||
            return column;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the completed style of the spinner.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="column">The column.</param>
 | 
			
		||||
        /// <param name="style">The style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static SpinnerColumn CompletedStyle(this SpinnerColumn column, Style? style)
 | 
			
		||||
        {
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            column.CompletedStyle = style;
 | 
			
		||||
            return column;
 | 
			
		||||
        }
 | 
			
		||||
        column.Style = style;
 | 
			
		||||
        return column;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the text that should be shown instead of the spinner
 | 
			
		||||
    /// once a task completes.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="column">The column.</param>
 | 
			
		||||
    /// <param name="text">The text.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static SpinnerColumn CompletedText(this SpinnerColumn column, string? text)
 | 
			
		||||
    {
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        column.CompletedText = text;
 | 
			
		||||
        return column;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the completed style of the spinner.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="column">The column.</param>
 | 
			
		||||
    /// <param name="style">The style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static SpinnerColumn CompletedStyle(this SpinnerColumn column, Style? style)
 | 
			
		||||
    {
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        column.CompletedStyle = style;
 | 
			
		||||
        return column;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,61 +1,60 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="StatusContext"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class StatusContextExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="StatusContext"/>.
 | 
			
		||||
    /// Sets the status message.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class StatusContextExtensions
 | 
			
		||||
    /// <param name="context">The status context.</param>
 | 
			
		||||
    /// <param name="status">The status message.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static StatusContext Status(this StatusContext context, string status)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the status message.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="context">The status context.</param>
 | 
			
		||||
        /// <param name="status">The status message.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static StatusContext Status(this StatusContext context, string status)
 | 
			
		||||
        if (context is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (context is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(context));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            context.Status = status;
 | 
			
		||||
            return context;
 | 
			
		||||
            throw new ArgumentNullException(nameof(context));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the spinner.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="context">The status context.</param>
 | 
			
		||||
        /// <param name="spinner">The spinner.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static StatusContext Spinner(this StatusContext context, Spinner spinner)
 | 
			
		||||
        {
 | 
			
		||||
            if (context is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(context));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            context.Spinner = spinner;
 | 
			
		||||
            return context;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the spinner style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="context">The status context.</param>
 | 
			
		||||
        /// <param name="style">The spinner style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static StatusContext SpinnerStyle(this StatusContext context, Style? style)
 | 
			
		||||
        {
 | 
			
		||||
            if (context is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(context));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            context.SpinnerStyle = style;
 | 
			
		||||
            return context;
 | 
			
		||||
        }
 | 
			
		||||
        context.Status = status;
 | 
			
		||||
        return context;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the spinner.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="context">The status context.</param>
 | 
			
		||||
    /// <param name="spinner">The spinner.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static StatusContext Spinner(this StatusContext context, Spinner spinner)
 | 
			
		||||
    {
 | 
			
		||||
        if (context is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(context));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        context.Spinner = spinner;
 | 
			
		||||
        return context;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the spinner style.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="context">The status context.</param>
 | 
			
		||||
    /// <param name="style">The spinner style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static StatusContext SpinnerStyle(this StatusContext context, Style? style)
 | 
			
		||||
    {
 | 
			
		||||
        if (context is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(context));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        context.SpinnerStyle = style;
 | 
			
		||||
        return context;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,62 +1,61 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="Status"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class StatusExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="Status"/>.
 | 
			
		||||
    /// Sets whether or not auto refresh is enabled.
 | 
			
		||||
    /// If disabled, you will manually have to refresh the progress.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class StatusExtensions
 | 
			
		||||
    /// <param name="status">The <see cref="Status"/> instance.</param>
 | 
			
		||||
    /// <param name="enabled">Whether or not auto refresh is enabled.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Status AutoRefresh(this Status status, bool enabled)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets whether or not auto refresh is enabled.
 | 
			
		||||
        /// If disabled, you will manually have to refresh the progress.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="status">The <see cref="Status"/> instance.</param>
 | 
			
		||||
        /// <param name="enabled">Whether or not auto refresh is enabled.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Status AutoRefresh(this Status status, bool enabled)
 | 
			
		||||
        if (status is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (status is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(status));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            status.AutoRefresh = enabled;
 | 
			
		||||
            return status;
 | 
			
		||||
            throw new ArgumentNullException(nameof(status));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the spinner.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="status">The <see cref="Status"/> instance.</param>
 | 
			
		||||
        /// <param name="spinner">The spinner.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Status Spinner(this Status status, Spinner spinner)
 | 
			
		||||
        {
 | 
			
		||||
            if (status is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(status));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            status.Spinner = spinner;
 | 
			
		||||
            return status;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the spinner style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="status">The <see cref="Status"/> instance.</param>
 | 
			
		||||
        /// <param name="style">The spinner style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Status SpinnerStyle(this Status status, Style? style)
 | 
			
		||||
        {
 | 
			
		||||
            if (status is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(status));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            status.SpinnerStyle = style;
 | 
			
		||||
            return status;
 | 
			
		||||
        }
 | 
			
		||||
        status.AutoRefresh = enabled;
 | 
			
		||||
        return status;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the spinner.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="status">The <see cref="Status"/> instance.</param>
 | 
			
		||||
    /// <param name="spinner">The spinner.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Status Spinner(this Status status, Spinner spinner)
 | 
			
		||||
    {
 | 
			
		||||
        if (status is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(status));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        status.Spinner = spinner;
 | 
			
		||||
        return status;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the spinner style.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="status">The <see cref="Status"/> instance.</param>
 | 
			
		||||
    /// <param name="style">The spinner style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Status SpinnerStyle(this Status status, Style? style)
 | 
			
		||||
    {
 | 
			
		||||
        if (status is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(status));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        status.SpinnerStyle = style;
 | 
			
		||||
        return status;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,44 +1,43 @@
 | 
			
		||||
using System;
 | 
			
		||||
using Spectre.Console.Internal;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="Recorder"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class RecorderExtensions
 | 
			
		||||
{
 | 
			
		||||
    private static readonly TextEncoder _textEncoder = new TextEncoder();
 | 
			
		||||
    private static readonly HtmlEncoder _htmlEncoder = new HtmlEncoder();
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="Recorder"/>.
 | 
			
		||||
    /// Exports the recorded content as text.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class RecorderExtensions
 | 
			
		||||
    /// <param name="recorder">The recorder.</param>
 | 
			
		||||
    /// <returns>The recorded content as text.</returns>
 | 
			
		||||
    public static string ExportText(this Recorder recorder)
 | 
			
		||||
    {
 | 
			
		||||
        private static readonly TextEncoder _textEncoder = new TextEncoder();
 | 
			
		||||
        private static readonly HtmlEncoder _htmlEncoder = new HtmlEncoder();
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Exports the recorded content as text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="recorder">The recorder.</param>
 | 
			
		||||
        /// <returns>The recorded content as text.</returns>
 | 
			
		||||
        public static string ExportText(this Recorder recorder)
 | 
			
		||||
        if (recorder is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (recorder is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(recorder));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return recorder.Export(_textEncoder);
 | 
			
		||||
            throw new ArgumentNullException(nameof(recorder));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Exports the recorded content as HTML.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="recorder">The recorder.</param>
 | 
			
		||||
        /// <returns>The recorded content as HTML.</returns>
 | 
			
		||||
        public static string ExportHtml(this Recorder recorder)
 | 
			
		||||
        {
 | 
			
		||||
            if (recorder is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(recorder));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return recorder.Export(_htmlEncoder);
 | 
			
		||||
        }
 | 
			
		||||
        return recorder.Export(_textEncoder);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Exports the recorded content as HTML.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="recorder">The recorder.</param>
 | 
			
		||||
    /// <returns>The recorded content as HTML.</returns>
 | 
			
		||||
    public static string ExportHtml(this Recorder recorder)
 | 
			
		||||
    {
 | 
			
		||||
        if (recorder is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(recorder));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return recorder.Export(_htmlEncoder);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -2,46 +2,45 @@ using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Spectre.Console.Rendering;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="IRenderable"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class RenderableExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="IRenderable"/>.
 | 
			
		||||
    /// Gets the segments for a renderable using the specified console.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class RenderableExtensions
 | 
			
		||||
    /// <param name="renderable">The renderable.</param>
 | 
			
		||||
    /// <param name="console">The console.</param>
 | 
			
		||||
    /// <returns>An enumerable containing segments representing the specified <see cref="IRenderable"/>.</returns>
 | 
			
		||||
    public static IEnumerable<Segment> GetSegments(this IRenderable renderable, IAnsiConsole console)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the segments for a renderable using the specified console.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="renderable">The renderable.</param>
 | 
			
		||||
        /// <param name="console">The console.</param>
 | 
			
		||||
        /// <returns>An enumerable containing segments representing the specified <see cref="IRenderable"/>.</returns>
 | 
			
		||||
        public static IEnumerable<Segment> GetSegments(this IRenderable renderable, IAnsiConsole console)
 | 
			
		||||
        if (console is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (console is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(console));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (renderable is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(renderable));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var context = new RenderContext(console.Profile.Capabilities);
 | 
			
		||||
            var renderables = console.Pipeline.Process(context, new[] { renderable });
 | 
			
		||||
 | 
			
		||||
            return GetSegments(console, context, renderables);
 | 
			
		||||
            throw new ArgumentNullException(nameof(console));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static IEnumerable<Segment> GetSegments(IAnsiConsole console, RenderContext options, IEnumerable<IRenderable> renderables)
 | 
			
		||||
        if (renderable is null)
 | 
			
		||||
        {
 | 
			
		||||
            var result = new List<Segment>();
 | 
			
		||||
            foreach (var renderable in renderables)
 | 
			
		||||
            {
 | 
			
		||||
                result.AddRange(renderable.Render(options, console.Profile.Width));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return Segment.Merge(result);
 | 
			
		||||
            throw new ArgumentNullException(nameof(renderable));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var context = new RenderContext(console.Profile.Capabilities);
 | 
			
		||||
        var renderables = console.Pipeline.Process(context, new[] { renderable });
 | 
			
		||||
 | 
			
		||||
        return GetSegments(console, context, renderables);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    private static IEnumerable<Segment> GetSegments(IAnsiConsole console, RenderContext options, IEnumerable<IRenderable> renderables)
 | 
			
		||||
    {
 | 
			
		||||
        var result = new List<Segment>();
 | 
			
		||||
        foreach (var renderable in renderables)
 | 
			
		||||
        {
 | 
			
		||||
            result.AddRange(renderable.Render(options, console.Profile.Width));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return Segment.Merge(result);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,54 +1,53 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="RuleExtensions"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class RuleExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="RuleExtensions"/>.
 | 
			
		||||
    /// Sets the rule title.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class RuleExtensions
 | 
			
		||||
    /// <param name="rule">The rule.</param>
 | 
			
		||||
    /// <param name="title">The title.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Rule RuleTitle(this Rule rule, string title)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the rule title.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="rule">The rule.</param>
 | 
			
		||||
        /// <param name="title">The title.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Rule RuleTitle(this Rule rule, string title)
 | 
			
		||||
        if (rule is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (rule is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(rule));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (title is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(title));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            rule.Title = title;
 | 
			
		||||
            return rule;
 | 
			
		||||
            throw new ArgumentNullException(nameof(rule));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the rule style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="rule">The rule.</param>
 | 
			
		||||
        /// <param name="style">The rule style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Rule RuleStyle(this Rule rule, Style style)
 | 
			
		||||
        if (title is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (rule is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(rule));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (style is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(style));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            rule.Style = style;
 | 
			
		||||
            return rule;
 | 
			
		||||
            throw new ArgumentNullException(nameof(title));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        rule.Title = title;
 | 
			
		||||
        return rule;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the rule style.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="rule">The rule.</param>
 | 
			
		||||
    /// <param name="style">The rule style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Rule RuleStyle(this Rule rule, Style style)
 | 
			
		||||
    {
 | 
			
		||||
        if (rule is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(rule));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (style is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(style));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        rule.Style = style;
 | 
			
		||||
        return rule;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,24 +1,23 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
{
 | 
			
		||||
    internal static class StackExtensions
 | 
			
		||||
    {
 | 
			
		||||
        public static void PushRange<T>(this Stack<T> stack, IEnumerable<T> source)
 | 
			
		||||
        {
 | 
			
		||||
            if (stack is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(stack));
 | 
			
		||||
            }
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
            if (source != null)
 | 
			
		||||
internal static class StackExtensions
 | 
			
		||||
{
 | 
			
		||||
    public static void PushRange<T>(this Stack<T> stack, IEnumerable<T> source)
 | 
			
		||||
    {
 | 
			
		||||
        if (stack is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(stack));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (source != null)
 | 
			
		||||
        {
 | 
			
		||||
            foreach (var item in source)
 | 
			
		||||
            {
 | 
			
		||||
                foreach (var item in source)
 | 
			
		||||
                {
 | 
			
		||||
                    stack.Push(item);
 | 
			
		||||
                }
 | 
			
		||||
                stack.Push(item);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -2,40 +2,39 @@ using System;
 | 
			
		||||
using System.Globalization;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
internal static class StringBuilderExtensions
 | 
			
		||||
{
 | 
			
		||||
    internal static class StringBuilderExtensions
 | 
			
		||||
    public static StringBuilder AppendWithStyle(this StringBuilder builder, Style? style, int? value)
 | 
			
		||||
    {
 | 
			
		||||
        public static StringBuilder AppendWithStyle(this StringBuilder builder, Style? style, int? value)
 | 
			
		||||
        {
 | 
			
		||||
            return AppendWithStyle(builder, style, value?.ToString(CultureInfo.InvariantCulture));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static StringBuilder AppendWithStyle(this StringBuilder builder, Style? style, string? value)
 | 
			
		||||
        {
 | 
			
		||||
            value ??= string.Empty;
 | 
			
		||||
 | 
			
		||||
            if (style != null)
 | 
			
		||||
            {
 | 
			
		||||
                return builder.Append('[')
 | 
			
		||||
                .Append(style.ToMarkup())
 | 
			
		||||
                .Append(']')
 | 
			
		||||
                .Append(value.EscapeMarkup())
 | 
			
		||||
                .Append("[/]");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return builder.Append(value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static void AppendSpan(this StringBuilder builder, ReadOnlySpan<char> span)
 | 
			
		||||
        {
 | 
			
		||||
            // NetStandard 2 lacks the override for StringBuilder to add the span. We'll need to convert the span
 | 
			
		||||
            // to a string for it, but for .NET 5.0 we'll use the override.
 | 
			
		||||
#if NETSTANDARD2_0
 | 
			
		||||
            builder.Append(span.ToString());
 | 
			
		||||
#else
 | 
			
		||||
            builder.Append(span);
 | 
			
		||||
#endif
 | 
			
		||||
        }
 | 
			
		||||
        return AppendWithStyle(builder, style, value?.ToString(CultureInfo.InvariantCulture));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    public static StringBuilder AppendWithStyle(this StringBuilder builder, Style? style, string? value)
 | 
			
		||||
    {
 | 
			
		||||
        value ??= string.Empty;
 | 
			
		||||
 | 
			
		||||
        if (style != null)
 | 
			
		||||
        {
 | 
			
		||||
            return builder.Append('[')
 | 
			
		||||
            .Append(style.ToMarkup())
 | 
			
		||||
            .Append(']')
 | 
			
		||||
            .Append(value.EscapeMarkup())
 | 
			
		||||
            .Append("[/]");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return builder.Append(value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void AppendSpan(this StringBuilder builder, ReadOnlySpan<char> span)
 | 
			
		||||
    {
 | 
			
		||||
        // NetStandard 2 lacks the override for StringBuilder to add the span. We'll need to convert the span
 | 
			
		||||
        // to a string for it, but for .NET 5.0 we'll use the override.
 | 
			
		||||
#if NETSTANDARD2_0
 | 
			
		||||
        builder.Append(span.ToString());
 | 
			
		||||
#else
 | 
			
		||||
        builder.Append(span);
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -4,193 +4,192 @@ using System.Globalization;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="string"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class StringExtensions
 | 
			
		||||
{
 | 
			
		||||
    // Cache whether or not internally normalized line endings
 | 
			
		||||
    // already are normalized. No reason to do yet another replace if it is.
 | 
			
		||||
    private static readonly bool _alreadyNormalized
 | 
			
		||||
        = Environment.NewLine.Equals("\n", StringComparison.OrdinalIgnoreCase);
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="string"/>.
 | 
			
		||||
    /// Escapes text so that it won’t be interpreted as markup.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class StringExtensions
 | 
			
		||||
    /// <param name="text">The text to escape.</param>
 | 
			
		||||
    /// <returns>A string that is safe to use in markup.</returns>
 | 
			
		||||
    public static string EscapeMarkup(this string? text)
 | 
			
		||||
    {
 | 
			
		||||
        // Cache whether or not internally normalized line endings
 | 
			
		||||
        // already are normalized. No reason to do yet another replace if it is.
 | 
			
		||||
        private static readonly bool _alreadyNormalized
 | 
			
		||||
            = Environment.NewLine.Equals("\n", StringComparison.OrdinalIgnoreCase);
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Escapes text so that it won’t be interpreted as markup.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="text">The text to escape.</param>
 | 
			
		||||
        /// <returns>A string that is safe to use in markup.</returns>
 | 
			
		||||
        public static string EscapeMarkup(this string? text)
 | 
			
		||||
        if (text == null)
 | 
			
		||||
        {
 | 
			
		||||
            if (text == null)
 | 
			
		||||
            {
 | 
			
		||||
                return string.Empty;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return text
 | 
			
		||||
                .ReplaceExact("[", "[[")
 | 
			
		||||
                .ReplaceExact("]", "]]");
 | 
			
		||||
            return string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Removes markup from the specified string.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="text">The text to remove markup from.</param>
 | 
			
		||||
        /// <returns>A string that does not have any markup.</returns>
 | 
			
		||||
        public static string RemoveMarkup(this string? text)
 | 
			
		||||
        {
 | 
			
		||||
            if (string.IsNullOrWhiteSpace(text))
 | 
			
		||||
            {
 | 
			
		||||
                return string.Empty;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var result = new StringBuilder();
 | 
			
		||||
 | 
			
		||||
            var tokenizer = new MarkupTokenizer(text);
 | 
			
		||||
            while (tokenizer.MoveNext() && tokenizer.Current != null)
 | 
			
		||||
            {
 | 
			
		||||
                if (tokenizer.Current.Kind == MarkupTokenKind.Text)
 | 
			
		||||
                {
 | 
			
		||||
                    result.Append(tokenizer.Current.Value);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return result.ToString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the cell width of the specified text.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="text">The text to get the cell width of.</param>
 | 
			
		||||
        /// <returns>The cell width of the text.</returns>
 | 
			
		||||
        public static int GetCellWidth(this string text)
 | 
			
		||||
        {
 | 
			
		||||
            return Cell.GetCellLength(text);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        internal static string CapitalizeFirstLetter(this string? text, CultureInfo? culture = null)
 | 
			
		||||
        {
 | 
			
		||||
            if (text == null)
 | 
			
		||||
            {
 | 
			
		||||
                return string.Empty;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            culture ??= CultureInfo.InvariantCulture;
 | 
			
		||||
 | 
			
		||||
            if (text.Length > 0 && char.IsLower(text[0]))
 | 
			
		||||
            {
 | 
			
		||||
                text = string.Format(culture, "{0}{1}", char.ToUpper(text[0], culture), text.Substring(1));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return text;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        internal static string? RemoveNewLines(this string? text)
 | 
			
		||||
        {
 | 
			
		||||
            return text?.ReplaceExact("\r\n", string.Empty)
 | 
			
		||||
                ?.ReplaceExact("\n", string.Empty);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        internal static string NormalizeNewLines(this string? text, bool native = false)
 | 
			
		||||
        {
 | 
			
		||||
            text = text?.ReplaceExact("\r\n", "\n");
 | 
			
		||||
            text ??= string.Empty;
 | 
			
		||||
 | 
			
		||||
            if (native && !_alreadyNormalized)
 | 
			
		||||
            {
 | 
			
		||||
                text = text.ReplaceExact("\n", Environment.NewLine);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return text;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        internal static string[] SplitLines(this string text)
 | 
			
		||||
        {
 | 
			
		||||
            var result = text?.NormalizeNewLines()?.Split(new[] { '\n' }, StringSplitOptions.None);
 | 
			
		||||
            return result ?? Array.Empty<string>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        internal static string[] SplitWords(this string word, StringSplitOptions options = StringSplitOptions.None)
 | 
			
		||||
        {
 | 
			
		||||
            var result = new List<string>();
 | 
			
		||||
 | 
			
		||||
            static string Read(StringBuffer reader, Func<char, bool> criteria)
 | 
			
		||||
            {
 | 
			
		||||
                var buffer = new StringBuilder();
 | 
			
		||||
                while (!reader.Eof)
 | 
			
		||||
                {
 | 
			
		||||
                    var current = reader.Peek();
 | 
			
		||||
                    if (!criteria(current))
 | 
			
		||||
                    {
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    buffer.Append(reader.Read());
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                return buffer.ToString();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            using (var reader = new StringBuffer(word))
 | 
			
		||||
            {
 | 
			
		||||
                while (!reader.Eof)
 | 
			
		||||
                {
 | 
			
		||||
                    var current = reader.Peek();
 | 
			
		||||
                    if (char.IsWhiteSpace(current))
 | 
			
		||||
                    {
 | 
			
		||||
                        var x = Read(reader, c => char.IsWhiteSpace(c));
 | 
			
		||||
                        if (options != StringSplitOptions.RemoveEmptyEntries)
 | 
			
		||||
                        {
 | 
			
		||||
                            result.Add(x);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        result.Add(Read(reader, c => !char.IsWhiteSpace(c)));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return result.ToArray();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        internal static string Repeat(this string text, int count)
 | 
			
		||||
        {
 | 
			
		||||
            if (text is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(text));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (count <= 0)
 | 
			
		||||
            {
 | 
			
		||||
                return string.Empty;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (count == 1)
 | 
			
		||||
            {
 | 
			
		||||
                return text;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return string.Concat(Enumerable.Repeat(text, count));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        internal static string ReplaceExact(this string text, string oldValue, string? newValue)
 | 
			
		||||
        {
 | 
			
		||||
#if NETSTANDARD2_0
 | 
			
		||||
            return text.Replace(oldValue, newValue);
 | 
			
		||||
#else
 | 
			
		||||
            return text.Replace(oldValue, newValue, StringComparison.Ordinal);
 | 
			
		||||
#endif
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        internal static bool ContainsExact(this string text, string value)
 | 
			
		||||
        {
 | 
			
		||||
#if NETSTANDARD2_0
 | 
			
		||||
            return text.Contains(value);
 | 
			
		||||
#else
 | 
			
		||||
            return text.Contains(value, StringComparison.Ordinal);
 | 
			
		||||
#endif
 | 
			
		||||
        }
 | 
			
		||||
        return text
 | 
			
		||||
            .ReplaceExact("[", "[[")
 | 
			
		||||
            .ReplaceExact("]", "]]");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Removes markup from the specified string.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="text">The text to remove markup from.</param>
 | 
			
		||||
    /// <returns>A string that does not have any markup.</returns>
 | 
			
		||||
    public static string RemoveMarkup(this string? text)
 | 
			
		||||
    {
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(text))
 | 
			
		||||
        {
 | 
			
		||||
            return string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var result = new StringBuilder();
 | 
			
		||||
 | 
			
		||||
        var tokenizer = new MarkupTokenizer(text);
 | 
			
		||||
        while (tokenizer.MoveNext() && tokenizer.Current != null)
 | 
			
		||||
        {
 | 
			
		||||
            if (tokenizer.Current.Kind == MarkupTokenKind.Text)
 | 
			
		||||
            {
 | 
			
		||||
                result.Append(tokenizer.Current.Value);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return result.ToString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Gets the cell width of the specified text.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="text">The text to get the cell width of.</param>
 | 
			
		||||
    /// <returns>The cell width of the text.</returns>
 | 
			
		||||
    public static int GetCellWidth(this string text)
 | 
			
		||||
    {
 | 
			
		||||
        return Cell.GetCellLength(text);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    internal static string CapitalizeFirstLetter(this string? text, CultureInfo? culture = null)
 | 
			
		||||
    {
 | 
			
		||||
        if (text == null)
 | 
			
		||||
        {
 | 
			
		||||
            return string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        culture ??= CultureInfo.InvariantCulture;
 | 
			
		||||
 | 
			
		||||
        if (text.Length > 0 && char.IsLower(text[0]))
 | 
			
		||||
        {
 | 
			
		||||
            text = string.Format(culture, "{0}{1}", char.ToUpper(text[0], culture), text.Substring(1));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return text;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    internal static string? RemoveNewLines(this string? text)
 | 
			
		||||
    {
 | 
			
		||||
        return text?.ReplaceExact("\r\n", string.Empty)
 | 
			
		||||
            ?.ReplaceExact("\n", string.Empty);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    internal static string NormalizeNewLines(this string? text, bool native = false)
 | 
			
		||||
    {
 | 
			
		||||
        text = text?.ReplaceExact("\r\n", "\n");
 | 
			
		||||
        text ??= string.Empty;
 | 
			
		||||
 | 
			
		||||
        if (native && !_alreadyNormalized)
 | 
			
		||||
        {
 | 
			
		||||
            text = text.ReplaceExact("\n", Environment.NewLine);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return text;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    internal static string[] SplitLines(this string text)
 | 
			
		||||
    {
 | 
			
		||||
        var result = text?.NormalizeNewLines()?.Split(new[] { '\n' }, StringSplitOptions.None);
 | 
			
		||||
        return result ?? Array.Empty<string>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    internal static string[] SplitWords(this string word, StringSplitOptions options = StringSplitOptions.None)
 | 
			
		||||
    {
 | 
			
		||||
        var result = new List<string>();
 | 
			
		||||
 | 
			
		||||
        static string Read(StringBuffer reader, Func<char, bool> criteria)
 | 
			
		||||
        {
 | 
			
		||||
            var buffer = new StringBuilder();
 | 
			
		||||
            while (!reader.Eof)
 | 
			
		||||
            {
 | 
			
		||||
                var current = reader.Peek();
 | 
			
		||||
                if (!criteria(current))
 | 
			
		||||
                {
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                buffer.Append(reader.Read());
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return buffer.ToString();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        using (var reader = new StringBuffer(word))
 | 
			
		||||
        {
 | 
			
		||||
            while (!reader.Eof)
 | 
			
		||||
            {
 | 
			
		||||
                var current = reader.Peek();
 | 
			
		||||
                if (char.IsWhiteSpace(current))
 | 
			
		||||
                {
 | 
			
		||||
                    var x = Read(reader, c => char.IsWhiteSpace(c));
 | 
			
		||||
                    if (options != StringSplitOptions.RemoveEmptyEntries)
 | 
			
		||||
                    {
 | 
			
		||||
                        result.Add(x);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    result.Add(Read(reader, c => !char.IsWhiteSpace(c)));
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return result.ToArray();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    internal static string Repeat(this string text, int count)
 | 
			
		||||
    {
 | 
			
		||||
        if (text is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(text));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (count <= 0)
 | 
			
		||||
        {
 | 
			
		||||
            return string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (count == 1)
 | 
			
		||||
        {
 | 
			
		||||
            return text;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return string.Concat(Enumerable.Repeat(text, count));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    internal static string ReplaceExact(this string text, string oldValue, string? newValue)
 | 
			
		||||
    {
 | 
			
		||||
#if NETSTANDARD2_0
 | 
			
		||||
        return text.Replace(oldValue, newValue);
 | 
			
		||||
#else
 | 
			
		||||
        return text.Replace(oldValue, newValue, StringComparison.Ordinal);
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    internal static bool ContainsExact(this string text, string value)
 | 
			
		||||
    {
 | 
			
		||||
#if NETSTANDARD2_0
 | 
			
		||||
        return text.Contains(value);
 | 
			
		||||
#else
 | 
			
		||||
        return text.Contains(value, StringComparison.Ordinal);
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,108 +1,107 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="Style"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class StyleExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="Style"/>.
 | 
			
		||||
    /// Creates a new style from the specified one with
 | 
			
		||||
    /// the specified foreground color.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class StyleExtensions
 | 
			
		||||
    /// <param name="style">The style.</param>
 | 
			
		||||
    /// <param name="color">The foreground color.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Style Foreground(this Style style, Color color)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a new style from the specified one with
 | 
			
		||||
        /// the specified foreground color.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="style">The style.</param>
 | 
			
		||||
        /// <param name="color">The foreground color.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Style Foreground(this Style style, Color color)
 | 
			
		||||
        if (style is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (style is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(style));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return new Style(
 | 
			
		||||
                foreground: color,
 | 
			
		||||
                background: style.Background,
 | 
			
		||||
                decoration: style.Decoration);
 | 
			
		||||
            throw new ArgumentNullException(nameof(style));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a new style from the specified one with
 | 
			
		||||
        /// the specified background color.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="style">The style.</param>
 | 
			
		||||
        /// <param name="color">The background color.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        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);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a new style from the specified one with
 | 
			
		||||
        /// the specified text decoration.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="style">The style.</param>
 | 
			
		||||
        /// <param name="decoration">The text decoration.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        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);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Creates a new style from the specified one with
 | 
			
		||||
        /// the specified link.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="style">The style.</param>
 | 
			
		||||
        /// <param name="link">The link.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        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<Style> source)
 | 
			
		||||
        {
 | 
			
		||||
            if (style is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(style));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var current = style;
 | 
			
		||||
            foreach (var item in source)
 | 
			
		||||
            {
 | 
			
		||||
                current = current.Combine(item);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return current;
 | 
			
		||||
        }
 | 
			
		||||
        return new Style(
 | 
			
		||||
            foreground: color,
 | 
			
		||||
            background: style.Background,
 | 
			
		||||
            decoration: style.Decoration);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Creates a new style from the specified one with
 | 
			
		||||
    /// the specified background color.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="style">The style.</param>
 | 
			
		||||
    /// <param name="color">The background color.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Creates a new style from the specified one with
 | 
			
		||||
    /// the specified text decoration.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="style">The style.</param>
 | 
			
		||||
    /// <param name="decoration">The text decoration.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Creates a new style from the specified one with
 | 
			
		||||
    /// the specified link.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="style">The style.</param>
 | 
			
		||||
    /// <param name="link">The link.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    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<Style> source)
 | 
			
		||||
    {
 | 
			
		||||
        if (style is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(style));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var current = style;
 | 
			
		||||
        foreach (var item in source)
 | 
			
		||||
        {
 | 
			
		||||
            current = current.Combine(item);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return current;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,31 +1,30 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console.Rendering
 | 
			
		||||
namespace Spectre.Console.Rendering;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="TableBorder"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class TableBorderExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="TableBorder"/>.
 | 
			
		||||
    /// Gets the safe border for a border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class TableBorderExtensions
 | 
			
		||||
    /// <param name="border">The border to get the safe border for.</param>
 | 
			
		||||
    /// <param name="safe">Whether or not to return the safe border.</param>
 | 
			
		||||
    /// <returns>The safe border if one exist, otherwise the original border.</returns>
 | 
			
		||||
    public static TableBorder GetSafeBorder(this TableBorder border, bool safe)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the safe border for a border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="border">The border to get the safe border for.</param>
 | 
			
		||||
        /// <param name="safe">Whether or not to return the safe border.</param>
 | 
			
		||||
        /// <returns>The safe border if one exist, otherwise the original border.</returns>
 | 
			
		||||
        public static TableBorder GetSafeBorder(this TableBorder border, bool safe)
 | 
			
		||||
        if (border is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (border is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(border));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (safe && border.SafeBorder != null)
 | 
			
		||||
            {
 | 
			
		||||
                border = border.SafeBorder;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return border;
 | 
			
		||||
            throw new ArgumentNullException(nameof(border));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (safe && border.SafeBorder != null)
 | 
			
		||||
        {
 | 
			
		||||
            border = border.SafeBorder;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return border;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,99 +1,98 @@
 | 
			
		||||
using System;
 | 
			
		||||
using Spectre.Console.Rendering;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="TableColumn"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class TableColumnExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="TableColumn"/>.
 | 
			
		||||
    /// Sets the table column header.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class TableColumnExtensions
 | 
			
		||||
    /// <param name="column">The table column.</param>
 | 
			
		||||
    /// <param name="header">The table column header markup text.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static TableColumn Header(this TableColumn column, string header)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the table column header.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="column">The table column.</param>
 | 
			
		||||
        /// <param name="header">The table column header markup text.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static TableColumn Header(this TableColumn column, string header)
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (header is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(header));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            column.Header = new Markup(header);
 | 
			
		||||
            return column;
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the table column header.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="column">The table column.</param>
 | 
			
		||||
        /// <param name="header">The table column header.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static TableColumn Header(this TableColumn column, IRenderable header)
 | 
			
		||||
        if (header is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (header is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(header));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            column.Footer = header;
 | 
			
		||||
            return column;
 | 
			
		||||
            throw new ArgumentNullException(nameof(header));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the table column footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="column">The table column.</param>
 | 
			
		||||
        /// <param name="footer">The table column footer markup text.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static TableColumn Footer(this TableColumn column, string footer)
 | 
			
		||||
        {
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (footer is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(footer));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            column.Footer = new Markup(footer);
 | 
			
		||||
            return column;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the table column footer.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="column">The table column.</param>
 | 
			
		||||
        /// <param name="footer">The table column footer.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static TableColumn Footer(this TableColumn column, IRenderable footer)
 | 
			
		||||
        {
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (footer is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(footer));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            column.Footer = footer;
 | 
			
		||||
            return column;
 | 
			
		||||
        }
 | 
			
		||||
        column.Header = new Markup(header);
 | 
			
		||||
        return column;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the table column header.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="column">The table column.</param>
 | 
			
		||||
    /// <param name="header">The table column header.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static TableColumn Header(this TableColumn column, IRenderable header)
 | 
			
		||||
    {
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (header is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(header));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        column.Footer = header;
 | 
			
		||||
        return column;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the table column footer.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="column">The table column.</param>
 | 
			
		||||
    /// <param name="footer">The table column footer markup text.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static TableColumn Footer(this TableColumn column, string footer)
 | 
			
		||||
    {
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (footer is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(footer));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        column.Footer = new Markup(footer);
 | 
			
		||||
        return column;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the table column footer.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="column">The table column.</param>
 | 
			
		||||
    /// <param name="footer">The table column footer.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static TableColumn Footer(this TableColumn column, IRenderable footer)
 | 
			
		||||
    {
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (footer is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(footer));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        column.Footer = footer;
 | 
			
		||||
        return column;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -3,450 +3,449 @@ using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using Spectre.Console.Rendering;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="Table"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class TableExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="Table"/>.
 | 
			
		||||
    /// Adds multiple columns to the table.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class TableExtensions
 | 
			
		||||
    /// <param name="table">The table to add the column to.</param>
 | 
			
		||||
    /// <param name="columns">The columns to add.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table AddColumns(this Table table, params TableColumn[] columns)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds multiple columns to the table.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table to add the column to.</param>
 | 
			
		||||
        /// <param name="columns">The columns to add.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table AddColumns(this Table table, params TableColumn[] columns)
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (columns is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (var column in columns)
 | 
			
		||||
            {
 | 
			
		||||
                table.AddColumn(column);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return table;
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a row to the table.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
        /// <param name="columns">The row columns to add.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table AddRow(this Table table, IEnumerable<IRenderable> columns)
 | 
			
		||||
        if (columns is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (columns is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            table.Rows.Add(new TableRow(columns));
 | 
			
		||||
            return table;
 | 
			
		||||
            throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a row to the table.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
        /// <param name="columns">The row columns to add.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table AddRow(this Table table, params IRenderable[] columns)
 | 
			
		||||
        foreach (var column in columns)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return table.AddRow((IEnumerable<IRenderable>)columns);
 | 
			
		||||
            table.AddColumn(column);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds an empty row to the table.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table AddEmptyRow(this Table table)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var columns = new IRenderable[table.Columns.Count];
 | 
			
		||||
            Enumerable.Range(0, table.Columns.Count).ForEach(index => columns[index] = Text.Empty);
 | 
			
		||||
            table.AddRow(columns);
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a column to the table.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table to add the column to.</param>
 | 
			
		||||
        /// <param name="column">The column to add.</param>
 | 
			
		||||
        /// <param name="configure">Delegate that can be used to configure the added column.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table AddColumn(this Table table, string column, Action<TableColumn>? configure = null)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (column is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(column));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var tableColumn = new TableColumn(column);
 | 
			
		||||
            configure?.Invoke(tableColumn);
 | 
			
		||||
 | 
			
		||||
            table.AddColumn(tableColumn);
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds multiple columns to the table.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table to add the columns to.</param>
 | 
			
		||||
        /// <param name="columns">The columns to add.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table AddColumns(this Table table, params string[] columns)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (columns is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            foreach (var column in columns)
 | 
			
		||||
            {
 | 
			
		||||
                AddColumn(table, column);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Adds a row to the table.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
        /// <param name="columns">The row columns to add.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table AddRow(this Table table, params string[] columns)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (columns is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            table.AddRow(columns.Select(column => new Markup(column)).ToArray());
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Inserts a row in the table at the specified index.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
        /// <param name="index">The index to insert the row at.</param>
 | 
			
		||||
        /// <param name="columns">The row columns to add.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table InsertRow(this Table table, int index, IEnumerable<IRenderable> columns)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (columns is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            table.Rows.Insert(index, new TableRow(columns));
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Updates a tables cell.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table to update.</param>
 | 
			
		||||
        /// <param name="rowIndex">The index of row to update.</param>
 | 
			
		||||
        /// <param name="columnIndex">The index of column to update.</param>
 | 
			
		||||
        /// <param name="cellData">New cell data.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table UpdateCell(this Table table, int rowIndex, int columnIndex, IRenderable cellData)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (cellData is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(cellData));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            table.Rows.Update(rowIndex, columnIndex, cellData);
 | 
			
		||||
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Updates a tables cell.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table to update.</param>
 | 
			
		||||
        /// <param name="rowIndex">The index of row to update.</param>
 | 
			
		||||
        /// <param name="columnIndex">The index of column to update.</param>
 | 
			
		||||
        /// <param name="cellData">New cell data.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table UpdateCell(this Table table, int rowIndex, int columnIndex, string cellData)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (cellData is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(cellData));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            table.Rows.Update(rowIndex, columnIndex, new Markup(cellData));
 | 
			
		||||
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Inserts a row in the table at the specified index.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
        /// <param name="index">The index to insert the row at.</param>
 | 
			
		||||
        /// <param name="columns">The row columns to add.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table InsertRow(this Table table, int index, params IRenderable[] columns)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return InsertRow(table, index, (IEnumerable<IRenderable>)columns);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Inserts a row in the table at the specified index.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
        /// <param name="index">The index to insert the row at.</param>
 | 
			
		||||
        /// <param name="columns">The row columns to add.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table InsertRow(this Table table, int index, params string[] columns)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return InsertRow(table, index, columns.Select(column => new Markup(column)));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Removes a row from the table with the specified index.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
        /// <param name="index">The index to remove the row at.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table RemoveRow(this Table table, int index)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            table.Rows.RemoveAt(index);
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the table width.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table.</param>
 | 
			
		||||
        /// <param name="width">The width.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table Width(this Table table, int? width)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            table.Width = width;
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Shows table headers.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table ShowHeaders(this Table table)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            table.ShowHeaders = true;
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Hides table headers.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table HideHeaders(this Table table)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            table.ShowHeaders = false;
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Shows table footers.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table ShowFooters(this Table table)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            table.ShowFooters = true;
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Hides table footers.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table HideFooters(this Table table)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            table.ShowFooters = false;
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the table title.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table.</param>
 | 
			
		||||
        /// <param name="text">The table title markup text.</param>
 | 
			
		||||
        /// <param name="style">The table title style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table Title(this Table table, string text, Style? style = null)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (text is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(text));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return Title(table, new TableTitle(text, style));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the table title.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table.</param>
 | 
			
		||||
        /// <param name="title">The table title.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table Title(this Table table, TableTitle title)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            table.Title = title;
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the table caption.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table.</param>
 | 
			
		||||
        /// <param name="text">The caption markup text.</param>
 | 
			
		||||
        /// <param name="style">The style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table Caption(this Table table, string text, Style? style = null)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (text is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(text));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return Caption(table, new TableTitle(text, style));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the table caption.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="table">The table.</param>
 | 
			
		||||
        /// <param name="caption">The caption.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Table Caption(this Table table, TableTitle caption)
 | 
			
		||||
        {
 | 
			
		||||
            if (table is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(table));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            table.Caption = caption;
 | 
			
		||||
            return table;
 | 
			
		||||
        }
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds a row to the table.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
    /// <param name="columns">The row columns to add.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table AddRow(this Table table, IEnumerable<IRenderable> columns)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (columns is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        table.Rows.Add(new TableRow(columns));
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds a row to the table.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
    /// <param name="columns">The row columns to add.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table AddRow(this Table table, params IRenderable[] columns)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return table.AddRow((IEnumerable<IRenderable>)columns);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds an empty row to the table.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table AddEmptyRow(this Table table)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var columns = new IRenderable[table.Columns.Count];
 | 
			
		||||
        Enumerable.Range(0, table.Columns.Count).ForEach(index => columns[index] = Text.Empty);
 | 
			
		||||
        table.AddRow(columns);
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds a column to the table.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table to add the column to.</param>
 | 
			
		||||
    /// <param name="column">The column to add.</param>
 | 
			
		||||
    /// <param name="configure">Delegate that can be used to configure the added column.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table AddColumn(this Table table, string column, Action<TableColumn>? configure = null)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (column is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(column));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        var tableColumn = new TableColumn(column);
 | 
			
		||||
        configure?.Invoke(tableColumn);
 | 
			
		||||
 | 
			
		||||
        table.AddColumn(tableColumn);
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds multiple columns to the table.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table to add the columns to.</param>
 | 
			
		||||
    /// <param name="columns">The columns to add.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table AddColumns(this Table table, params string[] columns)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (columns is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach (var column in columns)
 | 
			
		||||
        {
 | 
			
		||||
            AddColumn(table, column);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Adds a row to the table.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
    /// <param name="columns">The row columns to add.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table AddRow(this Table table, params string[] columns)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (columns is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        table.AddRow(columns.Select(column => new Markup(column)).ToArray());
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Inserts a row in the table at the specified index.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
    /// <param name="index">The index to insert the row at.</param>
 | 
			
		||||
    /// <param name="columns">The row columns to add.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table InsertRow(this Table table, int index, IEnumerable<IRenderable> columns)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (columns is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(columns));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        table.Rows.Insert(index, new TableRow(columns));
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Updates a tables cell.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table to update.</param>
 | 
			
		||||
    /// <param name="rowIndex">The index of row to update.</param>
 | 
			
		||||
    /// <param name="columnIndex">The index of column to update.</param>
 | 
			
		||||
    /// <param name="cellData">New cell data.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table UpdateCell(this Table table, int rowIndex, int columnIndex, IRenderable cellData)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (cellData is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(cellData));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        table.Rows.Update(rowIndex, columnIndex, cellData);
 | 
			
		||||
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Updates a tables cell.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table to update.</param>
 | 
			
		||||
    /// <param name="rowIndex">The index of row to update.</param>
 | 
			
		||||
    /// <param name="columnIndex">The index of column to update.</param>
 | 
			
		||||
    /// <param name="cellData">New cell data.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table UpdateCell(this Table table, int rowIndex, int columnIndex, string cellData)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (cellData is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(cellData));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        table.Rows.Update(rowIndex, columnIndex, new Markup(cellData));
 | 
			
		||||
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Inserts a row in the table at the specified index.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
    /// <param name="index">The index to insert the row at.</param>
 | 
			
		||||
    /// <param name="columns">The row columns to add.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table InsertRow(this Table table, int index, params IRenderable[] columns)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return InsertRow(table, index, (IEnumerable<IRenderable>)columns);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Inserts a row in the table at the specified index.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
    /// <param name="index">The index to insert the row at.</param>
 | 
			
		||||
    /// <param name="columns">The row columns to add.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table InsertRow(this Table table, int index, params string[] columns)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return InsertRow(table, index, columns.Select(column => new Markup(column)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Removes a row from the table with the specified index.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table to add the row to.</param>
 | 
			
		||||
    /// <param name="index">The index to remove the row at.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table RemoveRow(this Table table, int index)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        table.Rows.RemoveAt(index);
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the table width.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table.</param>
 | 
			
		||||
    /// <param name="width">The width.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table Width(this Table table, int? width)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        table.Width = width;
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Shows table headers.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table ShowHeaders(this Table table)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        table.ShowHeaders = true;
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Hides table headers.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table HideHeaders(this Table table)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        table.ShowHeaders = false;
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Shows table footers.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table ShowFooters(this Table table)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        table.ShowFooters = true;
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Hides table footers.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table HideFooters(this Table table)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        table.ShowFooters = false;
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the table title.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table.</param>
 | 
			
		||||
    /// <param name="text">The table title markup text.</param>
 | 
			
		||||
    /// <param name="style">The table title style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table Title(this Table table, string text, Style? style = null)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (text is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(text));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return Title(table, new TableTitle(text, style));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the table title.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table.</param>
 | 
			
		||||
    /// <param name="title">The table title.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table Title(this Table table, TableTitle title)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        table.Title = title;
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the table caption.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table.</param>
 | 
			
		||||
    /// <param name="text">The caption markup text.</param>
 | 
			
		||||
    /// <param name="style">The style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table Caption(this Table table, string text, Style? style = null)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (text is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(text));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return Caption(table, new TableTitle(text, style));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the table caption.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="table">The table.</param>
 | 
			
		||||
    /// <param name="caption">The caption.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Table Caption(this Table table, TableTitle caption)
 | 
			
		||||
    {
 | 
			
		||||
        if (table is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(table));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        table.Caption = caption;
 | 
			
		||||
        return table;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,31 +1,30 @@
 | 
			
		||||
using System.IO;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
{
 | 
			
		||||
    internal static class TextWriterExtensions
 | 
			
		||||
    {
 | 
			
		||||
        public static bool IsStandardOut(this TextWriter writer)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                return writer == System.Console.Out;
 | 
			
		||||
            }
 | 
			
		||||
            catch
 | 
			
		||||
            {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
        public static bool IsStandardError(this TextWriter writer)
 | 
			
		||||
internal static class TextWriterExtensions
 | 
			
		||||
{
 | 
			
		||||
    public static bool IsStandardOut(this TextWriter writer)
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                return writer == System.Console.Error;
 | 
			
		||||
            }
 | 
			
		||||
            catch
 | 
			
		||||
            {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            return writer == System.Console.Out;
 | 
			
		||||
        }
 | 
			
		||||
        catch
 | 
			
		||||
        {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    public static bool IsStandardError(this TextWriter writer)
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            return writer == System.Console.Error;
 | 
			
		||||
        }
 | 
			
		||||
        catch
 | 
			
		||||
        {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,44 +1,43 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="Tree"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class TreeExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="Tree"/>.
 | 
			
		||||
    /// Sets the tree style.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class TreeExtensions
 | 
			
		||||
    /// <param name="tree">The tree.</param>
 | 
			
		||||
    /// <param name="style">The tree style.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Tree Style(this Tree tree, Style? style)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the tree style.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="tree">The tree.</param>
 | 
			
		||||
        /// <param name="style">The tree style.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Tree Style(this Tree tree, Style? style)
 | 
			
		||||
        if (tree is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (tree is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(tree));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            tree.Style = style;
 | 
			
		||||
            return tree;
 | 
			
		||||
            throw new ArgumentNullException(nameof(tree));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets the tree guide line appearance.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="tree">The tree.</param>
 | 
			
		||||
        /// <param name="guide">The tree guide lines to use.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static Tree Guide(this Tree tree, TreeGuide guide)
 | 
			
		||||
        {
 | 
			
		||||
            if (tree is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(tree));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            tree.Guide = guide;
 | 
			
		||||
            return tree;
 | 
			
		||||
        }
 | 
			
		||||
        tree.Style = style;
 | 
			
		||||
        return tree;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets the tree guide line appearance.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="tree">The tree.</param>
 | 
			
		||||
    /// <param name="guide">The tree guide lines to use.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static Tree Guide(this Tree tree, TreeGuide guide)
 | 
			
		||||
    {
 | 
			
		||||
        if (tree is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(tree));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        tree.Guide = guide;
 | 
			
		||||
        return tree;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,31 +1,30 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console.Rendering
 | 
			
		||||
namespace Spectre.Console.Rendering;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="TreeGuide"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class TreeGuideExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="TreeGuide"/>.
 | 
			
		||||
    /// Gets the safe border for a border.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class TreeGuideExtensions
 | 
			
		||||
    /// <param name="guide">The tree guide to get the safe version for.</param>
 | 
			
		||||
    /// <param name="safe">Whether or not to return the safe border.</param>
 | 
			
		||||
    /// <returns>The safe border if one exist, otherwise the original border.</returns>
 | 
			
		||||
    public static TreeGuide GetSafeTreeGuide(this TreeGuide guide, bool safe)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the safe border for a border.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="guide">The tree guide to get the safe version for.</param>
 | 
			
		||||
        /// <param name="safe">Whether or not to return the safe border.</param>
 | 
			
		||||
        /// <returns>The safe border if one exist, otherwise the original border.</returns>
 | 
			
		||||
        public static TreeGuide GetSafeTreeGuide(this TreeGuide guide, bool safe)
 | 
			
		||||
        if (guide is null)
 | 
			
		||||
        {
 | 
			
		||||
            if (guide is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(guide));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (safe && guide.SafeTreeGuide != null)
 | 
			
		||||
            {
 | 
			
		||||
                return guide.SafeTreeGuide;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return guide;
 | 
			
		||||
            throw new ArgumentNullException(nameof(guide));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (safe && guide.SafeTreeGuide != null)
 | 
			
		||||
        {
 | 
			
		||||
            return guide.SafeTreeGuide;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return guide;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,47 +1,46 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
namespace Spectre.Console;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Contains extension methods for <see cref="TreeNode"/>.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class TreeNodeExtensions
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Contains extension methods for <see cref="TreeNode"/>.
 | 
			
		||||
    /// Expands the tree.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class TreeNodeExtensions
 | 
			
		||||
    /// <param name="node">The tree node.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static TreeNode Expand(this TreeNode node)
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Expands the tree.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="node">The tree node.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static TreeNode Expand(this TreeNode node)
 | 
			
		||||
        {
 | 
			
		||||
            return Expand(node, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Collapses the tree.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="node">The tree node.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static TreeNode Collapse(this TreeNode node)
 | 
			
		||||
        {
 | 
			
		||||
            return Expand(node, false);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Sets whether or not the tree node should be expanded.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="node">The tree node.</param>
 | 
			
		||||
        /// <param name="expand">Whether or not the tree node should be expanded.</param>
 | 
			
		||||
        /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
        public static TreeNode Expand(this TreeNode node, bool expand)
 | 
			
		||||
        {
 | 
			
		||||
            if (node is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(node));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            node.Expanded = expand;
 | 
			
		||||
            return node;
 | 
			
		||||
        }
 | 
			
		||||
        return Expand(node, true);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Collapses the tree.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="node">The tree node.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static TreeNode Collapse(this TreeNode node)
 | 
			
		||||
    {
 | 
			
		||||
        return Expand(node, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Sets whether or not the tree node should be expanded.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="node">The tree node.</param>
 | 
			
		||||
    /// <param name="expand">Whether or not the tree node should be expanded.</param>
 | 
			
		||||
    /// <returns>The same instance so that multiple calls can be chained.</returns>
 | 
			
		||||
    public static TreeNode Expand(this TreeNode node, bool expand)
 | 
			
		||||
    {
 | 
			
		||||
        if (node is null)
 | 
			
		||||
        {
 | 
			
		||||
            throw new ArgumentNullException(nameof(node));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        node.Expanded = expand;
 | 
			
		||||
        return node;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user