Skip to content
ConsoleMonster
Class

LiveTable

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Modifiers
sealed

A table whose rows change while a live session runs: rows have stable keys and are added, updated, removed or cleared through a LiveTableHandle (thread-safe, through the update queue). The LiveTable.Table defines the columns, presenters and options; its column widths only grow (Table.StableWidths), so rows never jitter while values change. Optionally only the most recent LiveTable.MaxRows rows are kept, and rows can be kept sorted by a column. Live operations (Key = row key): add and update (Payload = the values; both insert or replace), remove, clear. A recording replays the tab-separated text form of the values.

Inheritance

Usage

Explore 25 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 12

Constructors

public LiveTable(Table table, string widgetId = "table") #

Creates a live table.

Parameters

table ConsoleMonster.Widgets.Table required
The table that defines the columns and options (its own rows are replaced).
widgetId string = "table" optional
The live name (default table).

Methods

public LiveTable Add(object inputObject, string? keyProperty = null, ShapeOptions? shape = null) #

Adds or replaces one ordinary object row, preserving typed cell values.

Parameters

inputObject object required
The record or dictionary.
keyProperty string? = null optional
An explicit key field, otherwise KeyProperty or the first column.
shape ConsoleMonster.Values.ShapeOptions? = null optional
Host member adapters; null uses ordinary C# data adapters.

Returns

LiveTable This table.
public override void Apply(LiveEvent liveEvent) #

Applies an event to the widget's state.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent required
The event.
public void Clear() #

Removes every row directly (column widths stay).

public override string? Describe(LiveEvent liveEvent) #

Returns a line describing the event for line-based outputs (Stream/Plain), or null when the event is not worth a line (for example a single counter increment). Called after ILiveTarget.Apply.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent required
The event that was applied.

Returns

string? A plain line or null.
public LiveTableHandle Handle(ILiveDispatcher dispatcher) #

A handle that changes rows through a dispatcher (a live session).

Parameters

dispatcher ConsoleMonster.Live.ILiveDispatcher required
The dispatcher.

Returns

LiveTableHandle The handle.
public override Size Measure(Constraints constraints, RenderContext context) #

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints required
The space offered.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.

Returns

Size The desired size, never larger than the constraints.
public bool Remove(string key) #

Removes a row directly (not thread-safe; use a handle while a session runs).

Parameters

key string required
The row key.

Returns

bool Whether the row existed.
public override void Render(Region region, RenderContext context) #

Renders into a region. The region may be smaller or larger than the measured size.

Parameters

region ConsoleMonster.Canvas.Region required
The target region.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.
public void Set(string key, params object?[] values) #

Adds or replaces a row directly (not thread-safe; use a handle while a session runs).

Parameters

key string required
The row key.
values object?[] required
The values, one per column.
public static string TextOf(object?[] values) #

The text form of row values that recordings keep (tab-separated plain text).

Parameters

values object?[] required
The values.

Returns

string The text.

Properties

public Table Table { get; } #

The table that defines the columns, presenters and options.

public int MaxRows { get; set; } #

Keeps only the most recently added rows (0, the default, keeps them all): a bounded "recent N" window.

public int? SortColumn { get; set; } #

The column index to keep rows sorted by, or null (default) for insertion order.

public bool SortDescending { get; set; } #

Whether LiveTable.SortColumn sorts from the largest value down.

public string Filter { get; set; } #

Only show rows whose cell values contain each literal word before formatting, ignoring case. Empty restores the full table.

public IReadOnlyList<string> VisibleKeys { get; } #

Currently matching row keys, in display order. Hidden rows remain available for updates.

public IReadOnlyList<string> Keys { get; } #

The row keys in display order.

public string? KeyProperty { get; set; } #

The input field used as the row key; null uses the first column's key or header.

Extension Methods

public static LiveTable Filter(LiveTable liveTable, string value) #

Sets LiveTable.Filter: Only show rows whose cell values contain each literal word before formatting, ignoring case. Empty restores the full table.

Parameters

liveTable ConsoleMonster.Widgets.LiveTable required
The instance.
value string required
The value.

Returns

LiveTable The same instance.

Examples

// C# initializer or property    // C# fluent
liveTable.Filter = value;        liveTable.Filter(value);
public static LiveTable KeyProperty(LiveTable liveTable, string? value) #

Sets LiveTable.KeyProperty: The input field used as the row key; null uses the first column's key or header.

Parameters

liveTable ConsoleMonster.Widgets.LiveTable required
The instance.
value string? required
The value.

Returns

LiveTable The same instance.

Examples

// C# initializer or property     // C# fluent
liveTable.KeyProperty = value;    liveTable.KeyProperty(value);
public static LiveTable MaxRows(LiveTable liveTable, int value) #

Sets LiveTable.MaxRows: Keeps only the most recently added rows (0, the default, keeps them all): a bounded "recent N" window.

Parameters

liveTable ConsoleMonster.Widgets.LiveTable required
The instance.
value int required
The value.

Returns

LiveTable The same instance.

Examples

// C# initializer or property    // C# fluent
liveTable.MaxRows = value;       liveTable.MaxRows(value);
public static LiveTable SortColumn(LiveTable liveTable, int? value) #

Sets LiveTable.SortColumn: The column index to keep rows sorted by, or null (default) for insertion order.

Parameters

liveTable ConsoleMonster.Widgets.LiveTable required
The instance.
value int? required
The value.

Returns

LiveTable The same instance.

Examples

// C# initializer or property    // C# fluent
liveTable.SortColumn = value;    liveTable.SortColumn(value);
public static LiveTable SortDescending(LiveTable liveTable, bool value = true) #

Sets LiveTable.SortDescending: Whether LiveTable.SortColumn sorts from the largest value down.

Parameters

liveTable ConsoleMonster.Widgets.LiveTable required
The instance.
value bool = true optional
The value; true when omitted.

Returns

LiveTable The same instance.

Examples

// C# initializer or property        // C# fluent
liveTable.SortDescending = value;    liveTable.SortDescending(value);
public static LiveTable Table(LiveTable liveTable, Action<Table> configure) #

Configures LiveTable.Table in place: The table that defines the columns, presenters and options.

Parameters

liveTable ConsoleMonster.Widgets.LiveTable required
The instance.
configure System.Action<ConsoleMonster.Widgets.Table> required
Configures the value.

Returns

LiveTable The same instance.