mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Streamline tree API a bit
This commit is contained in:

committed by
Patrik Svensson

parent
b136d0299b
commit
4bfb24bfcb
@ -1,20 +0,0 @@
|
||||
namespace Spectre.Console.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the characters used to render a tree.
|
||||
/// </summary>
|
||||
public interface ITreeRendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the set of characters used to render the corresponding <see cref="TreePart"/>.
|
||||
/// </summary>
|
||||
/// <param name="part">The part of the tree to get rendering string for.</param>
|
||||
/// <returns>Rendering string for the tree part.</returns>
|
||||
string GetPart(TreePart part);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the length of all tree part strings.
|
||||
/// </summary>
|
||||
int PartSize { get; }
|
||||
}
|
||||
}
|
@ -5,10 +5,13 @@ namespace Spectre.Console.Rendering
|
||||
/// <summary>
|
||||
/// An ASCII rendering of a tree.
|
||||
/// </summary>
|
||||
public sealed class AsciiTreeRendering : ITreeRendering
|
||||
public sealed class AsciiTreeAppearance : TreeAppearance
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public string GetPart(TreePart part)
|
||||
public override int PartSize => 4;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string GetPart(TreePart part)
|
||||
{
|
||||
return part switch
|
||||
{
|
||||
@ -18,8 +21,5 @@ namespace Spectre.Console.Rendering
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(part), part, "Unknown tree part."),
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int PartSize => 4;
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
namespace Spectre.Console.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Selection of different renderings which can be used by <see cref="Tree"/>.
|
||||
/// </summary>
|
||||
public static class TreeRendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets ASCII rendering of a tree.
|
||||
/// </summary>
|
||||
public static ITreeRendering Ascii { get; } = new AsciiTreeRendering();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user