Console improvements, info providers

This commit is contained in:
2023-08-09 23:24:30 +02:00
parent 7dcca6363b
commit af140ff6b4
21 changed files with 406 additions and 69 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using Microsoft.Extensions.Logging;
using TerminalUI.Extensions;
using TerminalUI.Models;
using TerminalUI.ViewExtensions;
@@ -7,6 +8,8 @@ namespace TerminalUI.Controls;
public class Grid<T> : ChildContainerView<T>
{
private ILogger<Grid<T>>? Logger => ApplicationContext?.LoggerFactory?.CreateLogger<Grid<T>>();
private delegate void WithSizes(Span<int> widths, Span<int> heights);
private delegate TResult WithSizes<TResult>(Span<int> widths, Span<int> heights);
@@ -91,6 +94,18 @@ public class Grid<T> : ChildContainerView<T>
var x = positionExtension?.Column ?? 0;
var y = positionExtension?.Row ?? 0;
if (x > columnWidths.Length)
{
Logger?.LogWarning("Child {Child} is out of bounds, x: {X}, y: {Y}", child, x, y);
x = 0;
}
if (y > rowHeights.Length)
{
Logger?.LogWarning("Child {Child} is out of bounds, x: {X}, y: {Y}", child, x, y);
y = 0;
}
var width = columnWidths[x];
var height = rowHeights[y];