mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-30 06:42:51 +08:00

Fixes some tree rendering problems where lines were not properly drawn at some levels during some circumstances. * Change the API back to only allow one root. * Now uses a stack based approach to rendering instead of recursion. * Removes the need for measuring the whole tree in advance. Leave this up to each child to render.
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using System;
|
|
|
|
namespace Spectre.Console
|
|
{
|
|
/// <summary>
|
|
/// Contains extension methods for <see cref="Tree"/>.
|
|
/// </summary>
|
|
public static class TreeExtensions
|
|
{
|
|
/// <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)
|
|
{
|
|
throw new ArgumentNullException(nameof(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;
|
|
}
|
|
}
|
|
}
|