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:
Patrik Svensson
2022-11-15 10:12:17 +01:00
committed by GitHub
parent 9ce3b99cd6
commit c3ec6a7363
137 changed files with 2651 additions and 387 deletions

View File

@ -81,7 +81,7 @@ public sealed class PanelTests
// When
console.Write(new Panel("Hello World")
{
Header = new PanelHeader("Greeting").LeftAligned(),
Header = new PanelHeader("Greeting").LeftJustified(),
Expand = true,
});
@ -117,7 +117,7 @@ public sealed class PanelTests
// When
console.Write(new Panel("Hello World")
{
Header = new PanelHeader("Greeting").RightAligned(),
Header = new PanelHeader("Greeting").RightJustified(),
Expand = true,
});
@ -204,6 +204,76 @@ public sealed class PanelTests
return Verifier.Verify(console.Output);
}
[Fact]
[Expectation("Render_Width")]
public Task Should_Render_To_Specified_Width()
{
// Given
var console = new TestConsole();
// When
console.Write(new Panel(new Text("Hello World"))
{
Width = 25,
});
// Then
return Verifier.Verify(console.Output);
}
[Fact]
[Expectation("Render_Width_MaxWidth")]
public Task Should_Use_Max_Width_If_Specified_Width_Is_Too_Large()
{
// Given
var console = new TestConsole();
console.Profile.Width = 20;
// When
console.Write(new Panel(new Text("Hello World"))
{
Width = 25,
});
// Then
return Verifier.Verify(console.Output);
}
[Fact]
[Expectation("Render_Height")]
public Task Should_Render_To_Specified_Height()
{
// Given
var console = new TestConsole();
// When
console.Write(new Panel(new Text("Hello World\nHello Hello Hello"))
{
Height = 25,
});
// Then
return Verifier.Verify(console.Output);
}
[Fact]
[Expectation("Render_Width_Height")]
public Task Should_Render_To_Specified_Width_And_Height()
{
// Given
var console = new TestConsole();
// When
console.Write(new Panel("Hello World\nHello Hello Hello")
{
Width = 50,
Height = 25,
});
// Then
return Verifier.Verify(console.Output);
}
[Fact]
[Expectation("Render_Child_RightAligned")]
public Task Should_Justify_Child_To_Right_Correctly()
@ -213,7 +283,7 @@ public sealed class PanelTests
// When
console.Write(
new Panel(new Text("Hello World").RightAligned())
new Panel(new Text("Hello World").RightJustified())
{
Expand = true,
});