using System;
using System.Collections.Generic;
using System.Linq;
using Spectre.Console.Rendering;
namespace Spectre.Console
{
///
/// Node of a tree.
///
public sealed class TreeNode : IHasTreeNodes, IRenderable
{
private readonly IRenderable _renderable;
///
public List Children { get; }
///
/// Initializes a new instance of the class.
///
/// The which this node wraps.
/// Any children that the node is declared with.
public TreeNode(IRenderable renderable, IEnumerable? children = null)
{
_renderable = renderable ?? throw new ArgumentNullException(nameof(renderable));
Children = new List(children ?? Enumerable.Empty());
}
///
public Measurement Measure(RenderContext context, int maxWidth)
{
return _renderable.Measure(context, maxWidth);
}
///
public IEnumerable Render(RenderContext context, int maxWidth)
{
return _renderable.Render(context, maxWidth);
}
}
}