Console upgrades, PossibleCommands VM
This commit is contained in:
18
src/Library/TerminalUI/Models/Margin.cs
Normal file
18
src/Library/TerminalUI/Models/Margin.cs
Normal 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))
|
||||
};
|
||||
}
|
||||
}
|
||||
18
src/Library/TerminalUI/Models/RenderContext.cs
Normal file
18
src/Library/TerminalUI/Models/RenderContext.cs
Normal 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!);
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace TerminalUI.Models;
|
||||
|
||||
public record struct Size(int Width, int Height);
|
||||
public readonly record struct Size(int Width, int Height);
|
||||
Reference in New Issue
Block a user