mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-12-30 04:15:49 +08:00
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:
committed by
Patrik Svensson
parent
e48ae9600a
commit
d1d94cdebe
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user