Skip to content
ConsoleMonster

API Reference

Class

KeyValueList

Namespace ConsoleMonster.Widgets
Assembly ConsoleMonster
Implements
Modifiers sealed

Aligned key/value pairs: muted keys in a column sized to the longest key, values (markup) wrapping in the rest. Live operation set (Key, Text, optional State) adds or replaces a pair.

Inheritance

Usage

Explore 19 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 8

Constructors

public KeyValueList(String name = "keyvalue") #

Creates a key/value list.

Parameters

name System.String = "keyvalue" optionalposition: 0
The live name (default keyvalue).

Methods

Add 2 overloads
public KeyValueList Add(String key, String value, StatusKind? status = null) #
Returns: KeyValueList

Adds or replaces a pair.

Parameters

key System.String requiredposition: 0
The key (plain text).
value System.String requiredposition: 1
The value (markup).
status ConsoleMonster.Styling.StatusKind? = null optionalposition: 2
An optional status shown as a marker before the value.

Returns

This instance.

public KeyValueList Add(String key, Double value) #
Returns: KeyValueList

Adds a pair with a number formatted with thousands separators.

Parameters

key System.String requiredposition: 0
The key.
value System.Double requiredposition: 1
The number.

Returns

This instance.

public KeyValueList AddValue(String key, Object? value, ICellPresenter? presenter = null, IReadOnlyList<ToneRule>? rules = null) #
Returns: KeyValueList

Adds or replaces a pair whose value is formatted by a presenter (sizes, durations, dates, statuses...).

Parameters

key System.String requiredposition: 0
The key (plain text).
value System.Object? requiredposition: 1
The raw value.
presenter ConsoleMonster.Presenters.ICellPresenter? = null optionalposition: 2
The presenter, or null for automatic.
rules System.Collections.Generic.IReadOnlyList<ConsoleMonster.Presenters.ToneRule>? = null optionalposition: 3
Tone rules, or null.

Returns

This instance.

public override Void Apply(LiveEvent liveEvent) #
Returns: Void

Applies an event to the widget's state.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent requiredposition: 0
The event.
public KeyValueHandle Handle(ILiveDispatcher dispatcher) #
Returns: KeyValueHandle

Returns a handle that updates this list through a dispatcher (a live session).

Parameters

dispatcher ConsoleMonster.Live.ILiveDispatcher requiredposition: 0
The dispatcher.

Returns

The handle.

public override Size Measure(Constraints constraints, RenderContext context) #
Returns: Size

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints requiredposition: 0
The space offered.
context ConsoleMonster.Canvas.RenderContext requiredposition: 1
Profile, theme and glyphs.

Returns

The desired size, never larger than the constraints.

public override Void Render(Region region, RenderContext context) #
Returns: Void

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

Parameters

region ConsoleMonster.Canvas.Region requiredposition: 0
The target region.
context ConsoleMonster.Canvas.RenderContext requiredposition: 1
Profile, theme and glyphs.

Properties

public IReadOnlyList<KeyValueItem> Items { get; } #

The pairs in order.

public Int32 Gap { get; set; } #

Cells between the key column and the values (default 2).

public Double MaxKeyFraction { get; set; } #

The widest the key column may be, as a fraction of the width (default 0.4).

public ColumnFormat NumberColumn { get; set; } #

Layout of the leading number of each value (234 / 332, 8.4 rules/s, ~12s): values that start with a number share a number column, right-aligned by default, so the numbers line up under each other. Set the alignment to HorizontalAlignment.Left to print values as written.

public PresentationOptions Presentation { get; set; } #

Culture, clock and time zone for values added with KeyValueList.AddValue.

Extension Methods

public static KeyValueList WithGap(KeyValueList keyValueList, Int32 value) #
Returns: KeyValueList

Sets KeyValueList.Gap: Cells between the key column and the values (default 2).

Parameters

keyValueList ConsoleMonster.Widgets.KeyValueList requiredposition: 0
The instance.
value System.Int32 requiredposition: 1
The value.

Returns

The same instance.

public static KeyValueList WithMaxKeyFraction(KeyValueList keyValueList, Double value) #
Returns: KeyValueList

Sets KeyValueList.MaxKeyFraction: The widest the key column may be, as a fraction of the width (default 0.4).

Parameters

keyValueList ConsoleMonster.Widgets.KeyValueList requiredposition: 0
The instance.
value System.Double requiredposition: 1
The value.

Returns

The same instance.

WithNumberColumn 2 overloads
public static KeyValueList WithNumberColumn(KeyValueList keyValueList, ColumnFormat value) #
Returns: KeyValueList

Sets KeyValueList.NumberColumn: Layout of the leading number of each value (234 / 332, 8.4 rules/s, ~12s): values that start with a number share a number column, right-aligned by default, so the numbers line up under each other. Set the alignment to HorizontalAlignment.Left to print values as written.

Parameters

keyValueList ConsoleMonster.Widgets.KeyValueList requiredposition: 0
The instance.
value ConsoleMonster.Layout.ColumnFormat requiredposition: 1
The value.

Returns

The same instance.

public static KeyValueList WithNumberColumn(KeyValueList keyValueList, Action<ColumnFormat> configure) #
Returns: KeyValueList

Configures KeyValueList.NumberColumn in place: Layout of the leading number of each value (234 / 332, 8.4 rules/s, ~12s): values that start with a number share a number column, right-aligned by default, so the numbers line up under each other. Set the alignment to HorizontalAlignment.Left to print values as written.

Parameters

keyValueList ConsoleMonster.Widgets.KeyValueList requiredposition: 0
The instance.
configure System.Action<ConsoleMonster.Layout.ColumnFormat> requiredposition: 1
Configures the value.

Returns

The same instance.

WithPresentation 2 overloads
public static KeyValueList WithPresentation(KeyValueList keyValueList, PresentationOptions value) #
Returns: KeyValueList

Sets KeyValueList.Presentation: Culture, clock and time zone for values added with KeyValueList.AddValue.

Parameters

keyValueList ConsoleMonster.Widgets.KeyValueList requiredposition: 0
The instance.
value ConsoleMonster.Presenters.PresentationOptions requiredposition: 1
The value.

Returns

The same instance.

public static KeyValueList WithPresentation(KeyValueList keyValueList, Action<PresentationOptions> configure) #
Returns: KeyValueList

Configures KeyValueList.Presentation in place (creating it when not set): Culture, clock and time zone for values added with KeyValueList.AddValue.

Parameters

keyValueList ConsoleMonster.Widgets.KeyValueList requiredposition: 0
The instance.
configure System.Action<ConsoleMonster.Presenters.PresentationOptions> requiredposition: 1
Configures the value.

Returns

The same instance.