Skip to content
ConsoleMonster
Class

Spinner

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Modifiers
sealed

A one-line activity indicator for work without a known total: ⠹ Resolving DNS records zone 4 of ? 3.2s. While running it animates with the frame counter (braille in Full, | / - \ in Basic and ASCII); once finished it shows the status marker in the status tone and the final duration. Live operations: label (Text), detail (Text), state (State, optional Text as the detail), start (restarts the clock and returns to running).

Inheritance

Usage

Explore 27 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 13

Accepted by parameters 14

Constructors

public Spinner(string label = "", string widgetId = "spinner") #

Creates a spinner.

Parameters

label string = "" optional
The label (markup).
widgetId string = "spinner" optional
The live name (default spinner).

Methods

public override void Apply(LiveEvent liveEvent) #

Applies an event to the widget's state.

Parameters

liveEvent ConsoleMonster.Live.LiveEvent required
The event.
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 string? GetSummaryLine() #

Returns the current status, or null to omit this target from the heartbeat.

Returns

string? The plain-text status line.
public SpinnerHandle Handle(ILiveDispatcher dispatcher) #

Returns a handle that updates this spinner through a dispatcher.

Parameters

dispatcher ConsoleMonster.Live.ILiveDispatcher required
The dispatcher.

Returns

SpinnerHandle 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 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 bool TryGetTaskbarProgress(out TaskbarState state, out double fraction) #

The widget's contribution, if any.

Parameters

state ConsoleMonster.Output.TaskbarState required
The state (Normal, Indeterminate, Error or Paused).
fraction double required
The fraction done (0 to 1), or NaN when unknown.

Returns

bool False when the widget has nothing to report.

Properties

public string Label { get; set; } #

The label (markup).

public string? Detail { get; set; } #

Muted detail shown after the label, for example the current item.

public StatusKind Status { get; set; } #

The status; anything other than Running or Pending replaces the animation with the status marker.

public bool ShowElapsed { get; set; } #

Whether the elapsed time is shown on the right (default true).

public TimeSpan? Started { get; set; } #

When the current run started on the session clock, or null for "when the session started". Set by the start operation and by the first running state event.

public TimeSpan? Finished { get; set; } #

When the spinner finished on the session clock, or null while running.

public bool IsFinished { get; } #

Whether the spinner reached a final status.

Extension Methods

public static Spinner Detail(Spinner spinner, string? value) #

Sets Spinner.Detail: Muted detail shown after the label, for example the current item.

Parameters

spinner ConsoleMonster.Widgets.Spinner required
The instance.
value string? required
The value.

Returns

Spinner The same instance.

Examples

// C# initializer or property                                     // C# fluent
new global::ConsoleMonster.Widgets.Spinner { Detail = value };    Ui.Spinner().Detail(value);
public static Spinner Finished(Spinner spinner, TimeSpan? value) #

Sets Spinner.Finished: When the spinner finished on the session clock, or null while running.

Parameters

spinner ConsoleMonster.Widgets.Spinner required
The instance.
value System.TimeSpan? required
The value.

Returns

Spinner The same instance.

Examples

// C# initializer or property                                       // C# fluent
new global::ConsoleMonster.Widgets.Spinner { Finished = value };    Ui.Spinner().Finished(value);
public static Spinner Label(Spinner spinner, string value) #

Sets Spinner.Label: The label (markup).

Parameters

spinner ConsoleMonster.Widgets.Spinner required
The instance.
value string required
The value.

Returns

Spinner The same instance.

Examples

// C# initializer or property                                    // C# fluent
new global::ConsoleMonster.Widgets.Spinner { Label = value };    Ui.Spinner().Label(value);
public static Spinner ShowElapsed(Spinner spinner, bool value = true) #

Sets Spinner.ShowElapsed: Whether the elapsed time is shown on the right (default true).

Parameters

spinner ConsoleMonster.Widgets.Spinner required
The instance.
value bool = true optional
The value; true when omitted.

Returns

Spinner The same instance.

Examples

// C# initializer or property                                          // C# fluent
new global::ConsoleMonster.Widgets.Spinner { ShowElapsed = value };    Ui.Spinner().ShowElapsed(value);
public static Spinner Started(Spinner spinner, TimeSpan? value) #

Sets Spinner.Started: When the current run started on the session clock, or null for "when the session started". Set by the start operation and by the first running state event.

Parameters

spinner ConsoleMonster.Widgets.Spinner required
The instance.
value System.TimeSpan? required
The value.

Returns

Spinner The same instance.

Examples

// C# initializer or property                                      // C# fluent
new global::ConsoleMonster.Widgets.Spinner { Started = value };    Ui.Spinner().Started(value);
public static Spinner Status(Spinner spinner, StatusKind value) #

Sets Spinner.Status: The status; anything other than Running or Pending replaces the animation with the status marker.

Parameters

spinner ConsoleMonster.Widgets.Spinner required
The instance.
value ConsoleMonster.Styling.StatusKind required
The value.

Returns

Spinner The same instance.

Examples

// C# initializer or property                                     // C# fluent
new global::ConsoleMonster.Widgets.Spinner { Status = value };    Ui.Spinner().Status(value);