mirror of
https://github.com/spectreconsole/spectre.console.git
synced 2025-12-31 02:08:08 +01: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.
32 lines
939 B
C#
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;
|
|
}
|
|
}
|
|
}
|