Don't limit tables and grids to markup text

Closes #13
This commit is contained in:
Patrik Svensson
2020-08-24 23:24:23 +02:00
committed by Patrik Svensson
parent effdecb1d4
commit 8a01b93aca
41 changed files with 472 additions and 193 deletions

View File

@@ -0,0 +1,43 @@
using System.Collections.Generic;
using Spectre.Console.Internal;
using Spectre.Console.Rendering;
namespace Spectre.Console
{
/// <summary>
/// A renderable piece of markup text.
/// </summary>
public sealed class Markup : Renderable, IAlignable
{
private readonly Text _text;
/// <inheritdoc/>
public Justify? Alignment
{
get => _text.Alignment;
set => _text.Alignment = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="Markup"/> class.
/// </summary>
/// <param name="text">The markup text.</param>
/// <param name="style">The style of the text.</param>
public Markup(string text, Style? style = null)
{
_text = MarkupParser.Parse(text, style);
}
/// <inheritdoc/>
protected override Measurement Measure(RenderContext context, int maxWidth)
{
return ((IRenderable)_text).Measure(context, maxWidth);
}
/// <inheritdoc/>
protected override IEnumerable<Segment> Render(RenderContext context, int maxWidth)
{
return ((IRenderable)_text).Render(context, maxWidth);
}
}
}