mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00
Expose extension method that gets the cell width of text
This commit is contained in:
parent
48d49d6e18
commit
8cfe06e77a
@ -59,7 +59,12 @@ namespace Spectre.Console
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
internal static int CellLength(this string text)
|
||||
/// <summary>
|
||||
/// Gets the cell width of the specified text.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to get the cell width of.</param>
|
||||
/// <returns>The cell width of the text.</returns>
|
||||
public static int GetCellWidth(this string text)
|
||||
{
|
||||
return Cell.GetCellLength(text);
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ namespace Spectre.Console.Rendering
|
||||
var builder = new StringBuilder();
|
||||
foreach (var character in segment.Text)
|
||||
{
|
||||
var accumulatedCellWidth = builder.ToString().CellLength();
|
||||
var accumulatedCellWidth = builder.ToString().GetCellWidth();
|
||||
if (accumulatedCellWidth >= maxWidth)
|
||||
{
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user