mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-09-18 02:15:34 +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
@@ -59,7 +59,7 @@ namespace Spectre.Console
|
||||
/// <param name="value">The value to write.</param>
|
||||
public static void MarkupLine(this IAnsiConsole console, string value)
|
||||
{
|
||||
Markup(console, value + Environment.NewLine);
|
||||
Markup(console, value + "\n");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,7 +71,7 @@ namespace Spectre.Console
|
||||
/// <param name="args">An array of objects to write.</param>
|
||||
public static void MarkupLine(this IAnsiConsole console, IFormatProvider provider, string format, params object[] args)
|
||||
{
|
||||
Markup(console, provider, format + Environment.NewLine, args);
|
||||
Markup(console, provider, format + "\n", args);
|
||||
}
|
||||
}
|
||||
}
|
@@ -73,7 +73,7 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(console));
|
||||
}
|
||||
|
||||
console.Write(new Text(Environment.NewLine, Style.Plain));
|
||||
console.Write(new Text("\n", Style.Plain));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -104,7 +104,7 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
console.Write(text + Environment.NewLine, style);
|
||||
console.Write(text + "\n", style);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -11,11 +11,6 @@ namespace Spectre.Console
|
||||
/// </summary>
|
||||
public static class StringExtensions
|
||||
{
|
||||
// Cache whether or not internally normalized line endings
|
||||
// already are normalized. No reason to do yet another replace if it is.
|
||||
private static readonly bool _alreadyNormalized
|
||||
= Environment.NewLine.Equals("\n", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// Escapes text so that it won’t be interpreted as markup.
|
||||
/// </summary>
|
||||
@@ -91,12 +86,6 @@ namespace Spectre.Console
|
||||
{
|
||||
text = text?.ReplaceExact("\r\n", "\n");
|
||||
text ??= string.Empty;
|
||||
|
||||
if (native && !_alreadyNormalized)
|
||||
{
|
||||
text = text.ReplaceExact("\n", Environment.NewLine);
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user