Console upgrades, PossibleCommands VM

This commit is contained in:
2023-08-10 22:54:52 +02:00
parent 96d4eb926d
commit e989a65e81
48 changed files with 983 additions and 400 deletions

View File

@@ -0,0 +1,18 @@
namespace TerminalUI.Models;
public record Margin(int Left, int Top, int Right, int Bottom)
{
public static implicit operator Margin(int value) => new(value, value, value, value);
public static implicit operator Margin((int Left, int Top, int Right, int Bottom) value) => new(value.Left, value.Top, value.Right, value.Bottom);
public static implicit operator Margin(string s)
{
var parts = s.Split(' ');
return parts.Length switch
{
1 => new Margin(int.Parse(parts[0])),
2 => new Margin(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[0]), int.Parse(parts[1])),
4 => new Margin(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])),
_ => throw new ArgumentException("Invalid margin format", nameof(s))
};
}
}

View File

@@ -0,0 +1,18 @@
using TerminalUI.ConsoleDrivers;
namespace TerminalUI.Models;
public readonly ref struct RenderContext
{
private static int _renderId = 0;
public readonly int RenderId;
public readonly IConsoleDriver ConsoleDriver;
public RenderContext(IConsoleDriver consoleDriver)
{
ConsoleDriver = consoleDriver;
RenderId = _renderId++;
}
public static RenderContext Empty => new(null!);
}

View File

@@ -1,3 +1,3 @@
namespace TerminalUI.Models;
public record struct Size(int Width, int Height);
public readonly record struct Size(int Width, int Height);