mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Add support for indeterminate progress
This commit also changes the behavior of ProgressContext.IsFinished. Only tasks that have been started will be taken into consideration, and not indeterminate tasks. Closes #329 Closes #331
This commit is contained in:

committed by
Phil Scott

parent
6121203fee
commit
6f16081f42
@ -9,6 +9,11 @@ namespace Spectre.Console.Rendering
|
||||
{
|
||||
private readonly IReadOnlyCapabilities _capabilities;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current color system.
|
||||
/// </summary>
|
||||
public ColorSystem ColorSystem { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether or not unicode is supported.
|
||||
/// </summary>
|
||||
@ -28,17 +33,19 @@ namespace Spectre.Console.Rendering
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RenderContext"/> class.
|
||||
/// </summary>
|
||||
/// <param name="colorSystem">The color system.</param>
|
||||
/// <param name="capabilities">The capabilities.</param>
|
||||
/// <param name="justification">The justification.</param>
|
||||
public RenderContext(IReadOnlyCapabilities capabilities, Justify? justification = null)
|
||||
: this(capabilities, justification, false)
|
||||
public RenderContext(ColorSystem colorSystem, IReadOnlyCapabilities capabilities, Justify? justification = null)
|
||||
: this(colorSystem, capabilities, justification, false)
|
||||
{
|
||||
}
|
||||
|
||||
private RenderContext(IReadOnlyCapabilities capabilities, Justify? justification = null, bool singleLine = false)
|
||||
private RenderContext(ColorSystem colorSystem, IReadOnlyCapabilities capabilities, Justify? justification = null, bool singleLine = false)
|
||||
{
|
||||
_capabilities = capabilities ?? throw new ArgumentNullException(nameof(capabilities));
|
||||
|
||||
ColorSystem = colorSystem;
|
||||
Justification = justification;
|
||||
SingleLine = singleLine;
|
||||
}
|
||||
@ -50,7 +57,7 @@ namespace Spectre.Console.Rendering
|
||||
/// <returns>A new <see cref="RenderContext"/> instance.</returns>
|
||||
public RenderContext WithJustification(Justify? justification)
|
||||
{
|
||||
return new RenderContext(_capabilities, justification, SingleLine);
|
||||
return new RenderContext(ColorSystem, _capabilities, justification, SingleLine);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -65,7 +72,7 @@ namespace Spectre.Console.Rendering
|
||||
/// <returns>A new <see cref="RenderContext"/> instance.</returns>
|
||||
internal RenderContext WithSingleLine()
|
||||
{
|
||||
return new RenderContext(_capabilities, Justification, true);
|
||||
return new RenderContext(ColorSystem, _capabilities, Justification, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user