mirror of
https://github.com/spectreconsole/spectre.console.git
synced 2026-01-02 01:03:32 +01:00
59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using System;
|
|
|
|
namespace Spectre.Console
|
|
{
|
|
/// <summary>
|
|
/// Represents a table title such as a heading or footnote.
|
|
/// </summary>
|
|
public sealed class TableTitle
|
|
{
|
|
/// <summary>
|
|
/// Gets the title text.
|
|
/// </summary>
|
|
public string Text { get; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the title style.
|
|
/// </summary>
|
|
public Style? Style { get; set; }
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="TableTitle"/> class.
|
|
/// </summary>
|
|
/// <param name="text">The title text.</param>
|
|
/// <param name="style">The title style.</param>
|
|
public TableTitle(string text, Style? style = null)
|
|
{
|
|
Text = text ?? throw new ArgumentNullException(nameof(text));
|
|
Style = style;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the title style.
|
|
/// </summary>
|
|
/// <param name="style">The title style.</param>
|
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
|
public TableTitle SetStyle(Style? style)
|
|
{
|
|
Style = style ?? Style.Plain;
|
|
return this;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the title style.
|
|
/// </summary>
|
|
/// <param name="style">The title style.</param>
|
|
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
|
public TableTitle SetStyle(string style)
|
|
{
|
|
if (style is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(style));
|
|
}
|
|
|
|
Style = Style.Parse(style);
|
|
return this;
|
|
}
|
|
}
|
|
}
|