Files
spectre.console/src/Spectre.Console/Extensions/TreeGuideExtensions.cs
Patrik Svensson 8261b25e5c Fix tree rendering
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.
2021-01-10 15:55:11 +01:00

32 lines
939 B
C#

using System;
namespace Spectre.Console.Rendering
{
/// <summary>
/// Contains extension methods for <see cref="TreeGuide"/>.
/// </summary>
public static class TreeGuideExtensions
{
/// <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)
{
throw new ArgumentNullException(nameof(guide));
}
if (safe && guide.SafeTreeGuide != null)
{
return guide.SafeTreeGuide;
}
return guide;
}
}
}