mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Fix progress rendering bug
This commit is contained in:

committed by
Patrik Svensson

parent
ae32785f21
commit
3c504155bc
@ -8,6 +8,12 @@ namespace Spectre.Console
|
||||
/// </summary>
|
||||
public sealed class RemainingTimeColumn : ProgressColumn
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected internal override int? ColumnWidth => 7;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected internal override bool NoWrap => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style of the remaining time text.
|
||||
/// </summary>
|
||||
|
@ -14,6 +14,12 @@ namespace Spectre.Console
|
||||
private readonly string _ansiSequence = "⣷⣯⣟⡿⢿⣻⣽⣾";
|
||||
private readonly string _asciiSequence = "-\\|/-\\|/";
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected internal override int? ColumnWidth => 1;
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected internal override bool NoWrap => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the style of the spinner.
|
||||
/// </summary>
|
||||
|
@ -8,11 +8,14 @@ namespace Spectre.Console
|
||||
/// </summary>
|
||||
public sealed class TaskDescriptionColumn : ProgressColumn
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected internal override bool NoWrap => true;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime)
|
||||
{
|
||||
var text = task.Description?.RemoveNewLines()?.Trim();
|
||||
return new Markup(text ?? string.Empty).RightAligned();
|
||||
return new Markup(text ?? string.Empty).Overflow(Overflow.Ellipsis).RightAligned();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,11 @@ namespace Spectre.Console
|
||||
/// </summary>
|
||||
public abstract class ProgressColumn
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether or not content should not wrap.
|
||||
/// </summary>
|
||||
protected internal virtual bool NoWrap { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the requested column width for the column.
|
||||
/// </summary>
|
||||
|
@ -65,11 +65,17 @@ namespace Spectre.Console.Internal
|
||||
for (var columnIndex = 0; columnIndex < _columns.Count; columnIndex++)
|
||||
{
|
||||
var column = new GridColumn().PadRight(1);
|
||||
|
||||
if (_columns[columnIndex].ColumnWidth != null)
|
||||
{
|
||||
column.Width = _columns[columnIndex].ColumnWidth;
|
||||
}
|
||||
|
||||
if (_columns[columnIndex].NoWrap)
|
||||
{
|
||||
column.NoWrap();
|
||||
}
|
||||
|
||||
// Last column?
|
||||
if (columnIndex == _columns.Count - 1)
|
||||
{
|
||||
|
@ -58,6 +58,11 @@ namespace Spectre.Console
|
||||
var width = childWidth + paddingWidth;
|
||||
var result = new List<Segment>();
|
||||
|
||||
if (width > maxWidth)
|
||||
{
|
||||
width = maxWidth;
|
||||
}
|
||||
|
||||
// Top padding
|
||||
for (var i = 0; i < Padding.GetTopSafe(); i++)
|
||||
{
|
||||
|
Reference in New Issue
Block a user