mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-12-29 20:05:48 +08:00
Add progress task list support
This commit is contained in:
committed by
Patrik Svensson
parent
c61e386440
commit
ae32785f21
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user