using System; using Spectre.Console.Rendering; namespace Spectre.Console { /// /// Represents a table column. /// public sealed class TableColumn : IColumn { /// /// Gets the text associated with the column. /// public IRenderable Text { get; } /// /// Gets or sets the width of the column. /// If null, the column will adapt to it's contents. /// public int? Width { get; set; } /// /// Gets or sets the padding of the column. /// Vertical padding (top and bottom) is ignored. /// public Padding Padding { get; set; } /// /// Gets or sets a value indicating whether wrapping of /// text within the column should be prevented. /// public bool NoWrap { get; set; } /// /// Gets or sets the alignment of the column. /// public Justify? Alignment { get; set; } /// /// Initializes a new instance of the class. /// /// The table column text. public TableColumn(string text) : this(new Markup(text).Overflow(Overflow.Ellipsis)) { } /// /// Initializes a new instance of the class. /// /// The instance to use as the table column. public TableColumn(IRenderable renderable) { Text = renderable ?? throw new ArgumentNullException(nameof(renderable)); Width = null; Padding = new Padding(1, 0, 1, 0); NoWrap = false; Alignment = null; } } }