KeyValueList
ConsoleMonster.Widgets
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
- LiveWidget
- KeyValueList
Usage
Explore 29 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.
Returned or exposed by 15
- Method Ui.KeyValue
- Extension method KeyValueList.Columns
- Extension method KeyValueList.Gap
- Extension method KeyValueList.KeyRole
- Extension method KeyValueList.MaxKeyFraction
- Extension method KeyValueList.NumberColumn
- Extension method KeyValueList.Presentation
- Method KeyValueList.Add
- Method KeyValueList.Value
- Method KeyValueListFluent.Columns
- Method KeyValueListFluent.Gap
- Method KeyValueListFluent.KeyRole
- Method KeyValueListFluent.MaxKeyFraction
- Method KeyValueListFluent.NumberColumn
- Method KeyValueListFluent.Presentation
Accepted by parameters 14
- Method ContentBuilder.KeyValue
- Method ContentBuilder.KeyValue
- Extension method KeyValueList.Columns
- Extension method KeyValueList.Gap
- Extension method KeyValueList.KeyRole
- Extension method KeyValueList.MaxKeyFraction
- Extension method KeyValueList.NumberColumn
- Extension method KeyValueList.Presentation
- Method KeyValueListFluent.Columns
- Method KeyValueListFluent.Gap
- Method KeyValueListFluent.KeyRole
- Method KeyValueListFluent.MaxKeyFraction
- Method KeyValueListFluent.NumberColumn
- Method KeyValueListFluent.Presentation
Constructors
public KeyValueList(string widgetId = "keyvalue") #Creates a key/value list.
Parameters
- widgetId string = "keyvalue"
- The live name (default keyvalue).
Methods
public KeyValueList Add(string key, string value, StatusKind? status = null) #Adds or replaces a pair.
Parameters
- key string
- The key (plain text).
- value string
- The value (markup).
- status ConsoleMonster.Styling.StatusKind? = null
- An optional status shown as a marker before the value.
public KeyValueList Add(KeyValueItem item) #Adds or replaces a pair made beforehand, keeping its presenter (a key already in the list is replaced in place).
Parameters
- item ConsoleMonster.Widgets.KeyValueItem
- The pair.
public KeyValueList Add(string key, double value) #Adds a pair with a number formatted with thousands separators.
Parameters
- key string
- The key.
- value double
- The number.
public override void Apply(LiveEvent liveEvent) #Applies an event to the widget's state.
Parameters
- liveEvent ConsoleMonster.Live.LiveEvent
- The event.
public KeyValueHandle Handle(ILiveDispatcher dispatcher) #Returns a handle that updates this list through a dispatcher (a live session).
Parameters
- dispatcher ConsoleMonster.Live.ILiveDispatcher
- The dispatcher.
public override Size Measure(Constraints constraints, RenderContext context) #Returns the size the widget wants within the constraints.
Parameters
- constraints ConsoleMonster.Layout.Constraints
- The space offered.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
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
- The target region.
- context ConsoleMonster.Canvas.RenderContext
- Profile, theme and glyphs.
public KeyValueList Value(string key, object? value, ICellPresenter? presenter = null, IReadOnlyList<RoleRule>? rules = null) #Adds or replaces a pair whose value is formatted by a presenter (sizes, durations, dates, statuses...).
Parameters
- key string
- The key (plain text).
- value object?
- The raw value.
- presenter ConsoleMonster.Presenters.ICellPresenter? = null
- The presenter, or null for automatic.
- rules System.Collections.Generic.IReadOnlyList<ConsoleMonster.Presenters.RoleRule>? = null
- Tone rules, or null.
Inherited Methods
public virtual string? Describe(LiveEvent liveEvent) #Parameters
- liveEvent LiveEvent
Returns
string?Properties
public int Gap { get; set; } #Cells between the key column and the values (default 2).
public int Columns { get; set; } #Preferred number of pairs per row; narrow layouts reduce the count automatically.
public double MaxKeyFraction { get; set; } #Preferred key fraction when the natural label and value widths cannot both fit (default 0.4).
public ColumnFormat NumberColumn { get; set; } #Layout of the leading number of each value (234 / 332, 8.4 rules/s, ~12s): when every value starts with a number, the numbers share a column, right-aligned by default, so they line up under each other. A list that mixes in text (a host name, an OS) keeps every value left-aligned as written, so "3 days" under a name is not pushed right. Set the alignment to HorizontalAlignment.Left to always print values as written.
public PresentationOptions Presentation { get; set; } #Culture, clock and time zone for values added with KeyValueList.Value.
Inherited Properties
Extension Methods
public static KeyValueList Columns(KeyValueList keyValueList, int value) #Sets KeyValueList.Columns: Preferred number of pairs per row; narrow layouts reduce the count automatically.
Parameters
- keyValueList ConsoleMonster.Widgets.KeyValueList
- The instance.
- value int
- The value.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.KeyValueList { Columns = value }; Ui.KeyValue().Columns(value);public static KeyValueList Gap(KeyValueList keyValueList, int value) #Sets KeyValueList.Gap: Cells between the key column and the values (default 2).
Parameters
- keyValueList ConsoleMonster.Widgets.KeyValueList
- The instance.
- value int
- The value.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.KeyValueList { Gap = value }; Ui.KeyValue().Gap(value);public static KeyValueList KeyRole(KeyValueList keyValueList, ThemeToken value) #Sets KeyValueList.KeyRole: Theme colour for keys.
Parameters
- keyValueList ConsoleMonster.Widgets.KeyValueList
- The instance.
- value ConsoleMonster.Styling.ThemeToken
- The value.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.KeyValueList { KeyRole = value }; Ui.KeyValue().KeyRole(value);public static KeyValueList MaxKeyFraction(KeyValueList keyValueList, double value) #Sets KeyValueList.MaxKeyFraction: Preferred key fraction when the natural label and value widths cannot both fit (default 0.4).
Parameters
- keyValueList ConsoleMonster.Widgets.KeyValueList
- The instance.
- value double
- The value.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.KeyValueList { MaxKeyFraction = value }; Ui.KeyValue().MaxKeyFraction(value);public static KeyValueList NumberColumn(KeyValueList keyValueList, ColumnFormat value) #Sets KeyValueList.NumberColumn: Layout of the leading number of each value (234 / 332, 8.4 rules/s, ~12s): when every value starts with a number, the numbers share a column, right-aligned by default, so they line up under each other. A list that mixes in text (a host name, an OS) keeps every value left-aligned as written, so "3 days" under a name is not pushed right. Set the alignment to HorizontalAlignment.Left to always print values as written.
Parameters
- keyValueList ConsoleMonster.Widgets.KeyValueList
- The instance.
- value ConsoleMonster.Layout.ColumnFormat
- The value.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.KeyValueList { NumberColumn = value }; Ui.KeyValue().NumberColumn(value);public static KeyValueList NumberColumn(KeyValueList keyValueList, Action<ColumnFormat> configure) #Configures KeyValueList.NumberColumn in place: Layout of the leading number of each value (234 / 332, 8.4 rules/s, ~12s): when every value starts with a number, the numbers share a column, right-aligned by default, so they line up under each other. A list that mixes in text (a host name, an OS) keeps every value left-aligned as written, so "3 days" under a name is not pushed right. Set the alignment to HorizontalAlignment.Left to always print values as written.
Parameters
- keyValueList ConsoleMonster.Widgets.KeyValueList
- The instance.
- configure System.Action<ConsoleMonster.Layout.ColumnFormat>
- Configures the value.
public static KeyValueList Presentation(KeyValueList keyValueList, PresentationOptions value) #Sets KeyValueList.Presentation: Culture, clock and time zone for values added with KeyValueList.Value.
Parameters
- keyValueList ConsoleMonster.Widgets.KeyValueList
- The instance.
- value ConsoleMonster.Presenters.PresentationOptions
- The value.
Examples
// C# initializer or property // C# fluent
new global::ConsoleMonster.Widgets.KeyValueList { Presentation = value }; Ui.KeyValue().Presentation(value);public static KeyValueList Presentation(KeyValueList keyValueList, Action<PresentationOptions> configure) #Configures KeyValueList.Presentation in place (creating it when not set): Culture, clock and time zone for values added with KeyValueList.Value.
Parameters
- keyValueList ConsoleMonster.Widgets.KeyValueList
- The instance.
- configure System.Action<ConsoleMonster.Presenters.PresentationOptions>
- Configures the value.