Add Length and Lines properties to Paragraph

* Adds Length and Lines to `Paragraph`, `Markup` and `Text`.
* Do not use Environment.NewLine
This commit is contained in:
Patrik Svensson
2021-04-29 17:59:49 +02:00
committed by Patrik Svensson
parent e48ae9600a
commit d1d94cdebe
12 changed files with 113 additions and 19 deletions

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Spectre.Console.Rendering;
namespace Spectre.Console
@@ -25,6 +26,16 @@ namespace Spectre.Console
/// </summary>
public Overflow? Overflow { get; set; }
/// <summary>
/// Gets the character count of the paragraph.
/// </summary>
public int Length => _lines.Sum(line => line.Length) + Math.Max(0, Lines - 1);
/// <summary>
/// Gets the number of lines in the paragraph.
/// </summary>
public int Lines => _lines.Count;
/// <summary>
/// Initializes a new instance of the <see cref="Paragraph"/> class.
/// </summary>