mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 21:38:16 +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:
@ -3,7 +3,7 @@ namespace Spectre.Console;
|
||||
/// <summary>
|
||||
/// Represents text rendered with a FIGlet font.
|
||||
/// </summary>
|
||||
public sealed class FigletText : Renderable, IAlignable
|
||||
public sealed class FigletText : Renderable, IHasJustification
|
||||
{
|
||||
private readonly FigletFont _font;
|
||||
private readonly string _text;
|
||||
@ -14,7 +14,7 @@ public sealed class FigletText : Renderable, IAlignable
|
||||
public Color? Color { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Justify? Alignment { get; set; }
|
||||
public Justify? Justification { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FigletText"/> class.
|
||||
@ -37,10 +37,10 @@ public sealed class FigletText : Renderable, IAlignable
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override IEnumerable<Segment> Render(RenderContext context, int maxWidth)
|
||||
protected override IEnumerable<Segment> Render(RenderOptions options, int maxWidth)
|
||||
{
|
||||
var style = new Style(Color ?? Console.Color.Default);
|
||||
var alignment = Alignment ?? Justify.Left;
|
||||
var alignment = Justification ?? Console.Justify.Left;
|
||||
|
||||
foreach (var row in GetRows(maxWidth))
|
||||
{
|
||||
@ -49,7 +49,7 @@ public sealed class FigletText : Renderable, IAlignable
|
||||
var line = new Segment(string.Concat(row.Select(x => x.Lines[index])), style);
|
||||
|
||||
var lineWidth = line.CellCount();
|
||||
if (alignment == Justify.Left)
|
||||
if (alignment == Console.Justify.Left)
|
||||
{
|
||||
yield return line;
|
||||
|
||||
@ -58,7 +58,7 @@ public sealed class FigletText : Renderable, IAlignable
|
||||
yield return Segment.Padding(maxWidth - lineWidth);
|
||||
}
|
||||
}
|
||||
else if (alignment == Justify.Center)
|
||||
else if (alignment == Console.Justify.Center)
|
||||
{
|
||||
var left = (maxWidth - lineWidth) / 2;
|
||||
var right = left + ((maxWidth - lineWidth) % 2);
|
||||
@ -67,7 +67,7 @@ public sealed class FigletText : Renderable, IAlignable
|
||||
yield return line;
|
||||
yield return Segment.Padding(right);
|
||||
}
|
||||
else if (alignment == Justify.Right)
|
||||
else if (alignment == Console.Justify.Right)
|
||||
{
|
||||
if (lineWidth < maxWidth)
|
||||
{
|
||||
|
Reference in New Issue
Block a user