Add progress task list support

This commit is contained in:
Patrik Svensson
2020-11-27 08:12:29 +01:00
committed by Patrik Svensson
parent c61e386440
commit ae32785f21
71 changed files with 2350 additions and 106 deletions

View File

@@ -72,7 +72,7 @@ namespace Spectre.Console.Rendering
private Segment(string text, Style style, bool lineBreak, bool control)
{
Text = text?.NormalizeLineEndings() ?? throw new ArgumentNullException(nameof(text));
Text = text?.NormalizeNewLines() ?? throw new ArgumentNullException(nameof(text));
Style = style ?? throw new ArgumentNullException(nameof(style));
IsLineBreak = lineBreak;
IsWhiteSpace = string.IsNullOrWhiteSpace(text);
@@ -102,6 +102,11 @@ namespace Spectre.Console.Rendering
throw new ArgumentNullException(nameof(context));
}
if (IsControlCode)
{
return 0;
}
return Text.CellLength(context);
}
@@ -477,16 +482,22 @@ namespace Spectre.Console.Rendering
continue;
}
// Both control codes?
if (segment.IsControlCode && previous.IsControlCode)
{
previous = Control(previous.Text + segment.Text);
continue;
}
// Same style?
if (previous.Style.Equals(segment.Style) && !previous.IsLineBreak)
if (previous.Style.Equals(segment.Style) && !previous.IsLineBreak && !previous.IsControlCode)
{
previous = new Segment(previous.Text + segment.Text, previous.Style);
continue;
}
else
{
result.Add(previous);
previous = segment;
}
result.Add(previous);
previous = segment;
}
if (previous != null)