mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-12-30 12:25:48 +08:00
Add row and column accessors for tables and grids
This commit is contained in:
committed by
Patrik Svensson
parent
3e5e22d6c2
commit
e7f497050c
@@ -36,6 +36,22 @@ namespace Spectre.Console
|
||||
return table;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a row to the table.
|
||||
/// </summary>
|
||||
/// <param name="table">The table to add the row to.</param>
|
||||
/// <param name="columns">The row columns to add.</param>
|
||||
/// <returns>The same instance so that multiple calls can be chained.</returns>
|
||||
public static Table AddRow(this Table table, params IRenderable[] columns)
|
||||
{
|
||||
if (table is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(table));
|
||||
}
|
||||
|
||||
return table.AddRow(columns);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an empty row to the table.
|
||||
/// </summary>
|
||||
@@ -48,8 +64,8 @@ namespace Spectre.Console
|
||||
throw new ArgumentNullException(nameof(table));
|
||||
}
|
||||
|
||||
var columns = new IRenderable[table.ColumnCount];
|
||||
Enumerable.Range(0, table.ColumnCount).ForEach(index => columns[index] = Text.Empty);
|
||||
var columns = new IRenderable[table.Columns.Count];
|
||||
Enumerable.Range(0, table.Columns.Count).ForEach(index => columns[index] = Text.Empty);
|
||||
table.AddRow(columns);
|
||||
return table;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user