mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-06 04:28:15 +08:00
Add Layout widget (#1041)
* Add width to panels * Add height to panels * Replace RenderContext with RenderOptions * Remove exclusivity from alternative buffer * Add Layout widget * Add Align widget
This commit is contained in:
@ -27,11 +27,17 @@ public sealed class TestCapabilities : IReadOnlyCapabilities
|
||||
public bool Unicode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="RenderContext"/> with the same capabilities as this instace.
|
||||
/// Creates a <see cref="RenderOptions"/> with the same capabilities as this instace.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="RenderContext"/> with the same capabilities as this instace.</returns>
|
||||
public RenderContext CreateRenderContext()
|
||||
/// <param name="console">The console.</param>
|
||||
/// <returns>A <see cref="RenderOptions"/> with the same capabilities as this instace.</returns>
|
||||
public RenderOptions CreateRenderContext(IAnsiConsole console)
|
||||
{
|
||||
return new RenderContext(this);
|
||||
if (console is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(console));
|
||||
}
|
||||
|
||||
return RenderOptions.Create(console, this);
|
||||
}
|
||||
}
|
@ -52,6 +52,31 @@ public static class TestConsoleExtensions
|
||||
return console;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the console height.
|
||||
/// </summary>
|
||||
/// <param name="console">The console.</param>
|
||||
/// <param name="width">The console height.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static TestConsole Height(this TestConsole console, int width)
|
||||
{
|
||||
console.Profile.Height = width;
|
||||
return console;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the console size.
|
||||
/// </summary>
|
||||
/// <param name="console">The console.</param>
|
||||
/// <param name="size">The console size.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static TestConsole Size(this TestConsole console, Size size)
|
||||
{
|
||||
console.Profile.Width = size.Width;
|
||||
console.Profile.Height = size.Height;
|
||||
return console;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Turns on emitting of VT/ANSI sequences.
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user