Add status support

This commit is contained in:
Patrik Svensson
2020-12-08 00:43:24 +01:00
committed by Patrik Svensson
parent cbed41e637
commit 501db5d287
36 changed files with 1290 additions and 476 deletions

View File

@@ -599,6 +599,7 @@ namespace Spectre.Console.Rendering
return stack.ToList();
}
// TODO: Move this to Table
internal static List<List<SegmentLine>> MakeSameHeight(int cellHeight, List<List<SegmentLine>> cells)
{
if (cells is null)
@@ -619,5 +620,49 @@ namespace Spectre.Console.Rendering
return cells;
}
internal static (int Width, int Height) GetShape(RenderContext context, List<SegmentLine> lines)
{
if (context is null)
{
throw new ArgumentNullException(nameof(context));
}
if (lines is null)
{
throw new ArgumentNullException(nameof(lines));
}
var height = lines.Count;
var width = lines.Max(l => CellCount(context, l));
return (width, height);
}
internal static List<SegmentLine> SetShape(RenderContext context, List<SegmentLine> lines, (int Width, int Height) shape)
{
foreach (var line in lines)
{
var length = CellCount(context, line);
var missing = shape.Width - length;
if (missing > 0)
{
line.Add(new Segment(new string(' ', missing)));
}
}
if (lines.Count < shape.Height)
{
var missing = shape.Height - lines.Count;
for (int i = 0; i < missing; i++)
{
var line = new SegmentLine();
line.Add(new Segment(new string(' ', shape.Width)));
lines.Add(line);
}
}
return lines;
}
}
}