namespace Spectre.Console.Rendering;
///
/// Represents a collection of segments.
///
public sealed class SegmentLine : List
{
///
/// Gets the width of the line.
///
public int Length => this.Sum(line => line.Text.Length);
///
/// Initializes a new instance of the class.
///
public SegmentLine()
{
}
///
/// Initializes a new instance of the class.
///
/// The segments.
public SegmentLine(IEnumerable segments)
: base(segments)
{
}
///
/// Gets the number of cells the segment line occupies.
///
/// The cell width of the segment line.
public int CellCount()
{
return Segment.CellCount(this);
}
///
/// Preprends a segment to the line.
///
/// The segment to prepend.
public void Prepend(Segment segment)
{
if (segment is null)
{
throw new System.ArgumentNullException(nameof(segment));
}
Insert(0, segment);
}
}