TextBox, PropertyChangeHandler
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
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))
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,10 @@
|
||||
namespace TerminalUI.Models;
|
||||
using System.Diagnostics;
|
||||
|
||||
public record struct Position(int X, int Y);
|
||||
namespace TerminalUI.Models;
|
||||
|
||||
[DebuggerDisplay("X = {X}, Y = {Y}")]
|
||||
public readonly record struct Position(int X, int Y)
|
||||
{
|
||||
public static Position operator +(Position left, Position right) => new(left.X + right.X, left.Y + right.Y);
|
||||
public static Position operator -(Position left, Position right) => new(left.X - right.X, left.Y - right.Y);
|
||||
}
|
||||
@@ -1,18 +1,32 @@
|
||||
using TerminalUI.ConsoleDrivers;
|
||||
using System.Diagnostics;
|
||||
using TerminalUI.Color;
|
||||
using TerminalUI.ConsoleDrivers;
|
||||
|
||||
namespace TerminalUI.Models;
|
||||
|
||||
[DebuggerDisplay("RenderId = {RenderId}, ForceRerender = {ForceRerender}, Driver = {ConsoleDriver.GetType().Name}")]
|
||||
public readonly ref struct RenderContext
|
||||
{
|
||||
private static int _renderId = 0;
|
||||
private static int _renderId;
|
||||
public readonly int RenderId;
|
||||
public readonly IConsoleDriver ConsoleDriver;
|
||||
public readonly bool ForceRerender;
|
||||
public readonly IColor? Foreground;
|
||||
public readonly IColor? Background;
|
||||
|
||||
public RenderContext(IConsoleDriver consoleDriver)
|
||||
public RenderContext(
|
||||
IConsoleDriver consoleDriver,
|
||||
bool forceRerender,
|
||||
IColor? foreground,
|
||||
IColor? background)
|
||||
{
|
||||
ConsoleDriver = consoleDriver;
|
||||
RenderId = _renderId++;
|
||||
|
||||
ConsoleDriver = consoleDriver;
|
||||
ForceRerender = forceRerender;
|
||||
Foreground = foreground;
|
||||
Background = background;
|
||||
}
|
||||
|
||||
public static RenderContext Empty => new(null!);
|
||||
public static RenderContext Empty => new(null!, false, null, null);
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
namespace TerminalUI.Models;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace TerminalUI.Models;
|
||||
|
||||
[DebuggerDisplay("Width = {Width}, Height = {Height}")]
|
||||
public readonly record struct Size(int Width, int Height);
|
||||
21
src/Library/TerminalUI/Models/Thickness.cs
Normal file
21
src/Library/TerminalUI/Models/Thickness.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace TerminalUI.Models;
|
||||
|
||||
[DebuggerDisplay("Left = {Left}, Top = {Top}, Right = {Right}, Bottom = {Bottom}")]
|
||||
public record Thickness(int Left, int Top, int Right, int Bottom)
|
||||
{
|
||||
public static implicit operator Thickness(int value) => new(value, value, value, value);
|
||||
public static implicit operator Thickness((int Left, int Top, int Right, int Bottom) value) => new(value.Left, value.Top, value.Right, value.Bottom);
|
||||
public static implicit operator Thickness(string s)
|
||||
{
|
||||
var parts = s.Split(' ');
|
||||
return parts.Length switch
|
||||
{
|
||||
1 => new Thickness(int.Parse(parts[0])),
|
||||
2 => new Thickness(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[0]), int.Parse(parts[1])),
|
||||
4 => new Thickness(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])),
|
||||
_ => throw new ArgumentException("Invalid margin format", nameof(s))
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user