Skip to content
ConsoleMonster
Class

Splitter

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Implements
IContainer IWidget IAppInputContainer
Modifiers
sealed

Two panes with a divider between them. Dragging the divider resizes the panes, and so do Ctrl+Shift+←/→ (Ctrl+Shift+↑/↓ when Splitter.Vertical) when the focused input leaves those keys free. Text editing takes precedence. Inside an app with screens, a splitter with a Splitter.Key remembers its ratio for the screen it is on, also when its layout is rebuilt.

Inheritance

  • object
  • Splitter

Usage

Explore 23 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 11

Accepted by parameters 12

Constructors

Splitter 2 overloads
public Splitter() #

Creates a splitter with empty panes.

public Splitter(IWidget first, IWidget second) #

Creates a splitter.

Parameters

first ConsoleMonster.Layout.IWidget required
The left pane, or the top pane when Splitter.Vertical.
second ConsoleMonster.Layout.IWidget required
The right pane, or the bottom pane when Splitter.Vertical.

Methods

public 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 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.

Properties

public IWidget First { get; set; } #

The left pane, or the top pane when Splitter.Vertical.

public IWidget Second { get; set; } #

The right pane, or the bottom pane when Splitter.Vertical.

public bool Vertical { get; set; } #

Stacks the panes top and bottom with a horizontal divider instead of side by side.

public double Ratio { get; set; } #

The first pane's share of the space, between 0.05 and 0.95 (default 0.5).

public string? Key { get; set; } #

The name the ratio is remembered under on each app screen; null keeps it with this instance only.

public IReadOnlyList<IWidget> Children { get; } #

The child widgets in layout order.

Extension Methods

First 2 overloads
public static Splitter First(Splitter splitter, Action<ContentBuilder> content) #

Builds the left (or top) pane.

Parameters

splitter ConsoleMonster.Widgets.Splitter required
The splitter.
content System.Action<ConsoleMonster.Layout.ContentBuilder> required
The pane's content.

Returns

Splitter The splitter.
public static Splitter First(Splitter splitter, IWidget value) #

Sets Splitter.First: The left pane, or the top pane when Splitter.Vertical.

Parameters

splitter ConsoleMonster.Widgets.Splitter required
The instance.
value ConsoleMonster.Layout.IWidget required
The value.

Returns

Splitter The same instance.

Examples

// C# initializer or property                                     // C# fluent
new global::ConsoleMonster.Widgets.Splitter { First = value };    Ui.Splitter().First(value);
public static Splitter Key(Splitter splitter, string? value) #

Sets Splitter.Key: The name the ratio is remembered under on each app screen; null keeps it with this instance only.

Parameters

splitter ConsoleMonster.Widgets.Splitter required
The instance.
value string? required
The value.

Returns

Splitter The same instance.

Examples

// C# initializer or property                                   // C# fluent
new global::ConsoleMonster.Widgets.Splitter { Key = value };    Ui.Splitter().Key(value);
public static Splitter Ratio(Splitter splitter, double value) #

Sets Splitter.Ratio: The first pane's share of the space, between 0.05 and 0.95 (default 0.5).

Parameters

splitter ConsoleMonster.Widgets.Splitter required
The instance.
value double required
The value.

Returns

Splitter The same instance.

Examples

// C# initializer or property                                     // C# fluent
new global::ConsoleMonster.Widgets.Splitter { Ratio = value };    Ui.Splitter().Ratio(value);
Second 2 overloads
public static Splitter Second(Splitter splitter, Action<ContentBuilder> content) #

Builds the right (or bottom) pane.

Parameters

splitter ConsoleMonster.Widgets.Splitter required
The splitter.
content System.Action<ConsoleMonster.Layout.ContentBuilder> required
The pane's content.

Returns

Splitter The splitter.
public static Splitter Second(Splitter splitter, IWidget value) #

Sets Splitter.Second: The right pane, or the bottom pane when Splitter.Vertical.

Parameters

splitter ConsoleMonster.Widgets.Splitter required
The instance.
value ConsoleMonster.Layout.IWidget required
The value.

Returns

Splitter The same instance.

Examples

// C# initializer or property                                      // C# fluent
new global::ConsoleMonster.Widgets.Splitter { Second = value };    Ui.Splitter().Second(value);
Vertical 2 overloads
public static Splitter Vertical(Splitter splitter, bool value) #

Sets Splitter.Vertical: Stacks the panes top and bottom with a horizontal divider instead of side by side.

Parameters

splitter ConsoleMonster.Widgets.Splitter required
The instance.
value bool required
The value.

Returns

Splitter The same instance.

Examples

// C# initializer or property                                        // C# fluent
new global::ConsoleMonster.Widgets.Splitter { Vertical = value };    Ui.Splitter().Vertical(value);
public static Splitter Vertical(Splitter splitter) #

Sets Splitter.Vertical to true.

Parameters

splitter ConsoleMonster.Widgets.Splitter required
The instance to configure.

Returns

Splitter The same instance.