mirror of
https://github.com/dnwSilver/tld.git
synced 2025-04-04 04:16:19 +00:00
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using TUI.Engine.Attributes.Resizings;
|
|
using TUI.Engine.Components;
|
|
using TUI.Engine.Nodes;
|
|
|
|
namespace TUI.Engine.Containers;
|
|
|
|
internal static class ContainerExtensions
|
|
{
|
|
private static readonly Func<INode, bool> AbsoluteNodes = node => node is IComponent { IsRelative: false };
|
|
|
|
private static readonly Func<INode, bool> FixedNodes = node => node.ResizingVertical == Resizing.Fixed;
|
|
|
|
internal static IEnumerable<INode> GetAbsoluteNodes(this IContainer container, int? takeNodeNumber = null)
|
|
{
|
|
if (takeNodeNumber is not null)
|
|
{
|
|
return container
|
|
.GetNodes()
|
|
.Take(takeNodeNumber.Value + 1)
|
|
.Where(AbsoluteNodes);
|
|
}
|
|
|
|
return container
|
|
.GetNodes()
|
|
.Where(AbsoluteNodes);
|
|
}
|
|
|
|
internal static IEnumerable<INode> GetFixedNodes(this IContainer container, int? takeNodeNumber = null)
|
|
{
|
|
if (takeNodeNumber is not null)
|
|
{
|
|
return container
|
|
.GetNodes()
|
|
.Take(takeNodeNumber.Value + 1)
|
|
.Where(FixedNodes);
|
|
}
|
|
|
|
return container
|
|
.GetNodes()
|
|
.Where(FixedNodes);
|
|
}
|
|
} |