Skip to content
ConsoleMonster
Class

AppScreens

ConsoleMonster.Interactive

Namespace
ConsoleMonster.Interactive
Assembly
ConsoleMonster
Modifiers
sealed

The screens of an app as a stack. The first screen added is the root; AppScreens.Push opens another and AppScreens.Back returns, which Escape and Backspace do when the focused input leaves them unused. Every screen is registered up front, so inputs inside screens keep their state values and take part in focus; only the current screen is mounted. Each screen remembers its focused input and brings its own key bindings to the footer, and a HeaderBar without crumbs of its own shows the path. The current key is also the state value AppScreens.StateKey: assigning it from a callback opens that screen.

Inheritance

  • object
  • AppScreens

Usage

Explore 17 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 AppScreens(params AppScreen[] screens) #

Creates a stack; the first screen is the root.

Parameters

screens ConsoleMonster.Interactive.AppScreen[] required
The screens.

Methods

public AppScreens Add(AppScreen screen) #

Registers a screen. Add every screen before the app runs.

Parameters

screen ConsoleMonster.Interactive.AppScreen required
The screen; its key must be unique.

Returns

AppScreens This instance.
public bool Back() #

Returns to the previous screen.

Returns

bool False at the root.
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 Push(string key) #

Opens a screen on top of the current one. A screen already on the path is returned to instead of stacked twice.

Parameters

key string required
The screen key.
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 string StateKey { get; set; } #

The state key holding the current screen's key (default Screen).

public IList<KeyChord> BackKeys { get; } #

Keys that return to the previous screen when the focused input does not use them (default Escape and Backspace).

public IReadOnlyList<AppScreen> Screens { get; } #

The registered screens, root first.

public IReadOnlyList<AppScreen> Path { get; } #

The open screens from the root to the current one.

public AppScreen Current { get; } #

The current screen.

public IReadOnlyList<IWidget> Children { get; } #

The child widgets in layout order.

Extension Methods

public static AppScreens AddBackKey(AppScreens appScreens, KeyChord item) #

Adds an item to AppScreens.BackKeys: Keys that return to the previous screen when the focused input does not use them (default Escape and Backspace).

Parameters

appScreens ConsoleMonster.Interactive.AppScreens required
The instance.
item ConsoleMonster.Input.KeyChord required
The item.

Returns

AppScreens The same instance.
AddBackKeys 2 overloads
public static AppScreens AddBackKeys(AppScreens appScreens, params KeyChord[] items) #

Adds items to AppScreens.BackKeys: Keys that return to the previous screen when the focused input does not use them (default Escape and Backspace).

Parameters

appScreens ConsoleMonster.Interactive.AppScreens required
The instance.
items ConsoleMonster.Input.KeyChord[] required
The items, in order.

Returns

AppScreens The same instance.
public static AppScreens AddBackKeys(AppScreens appScreens, IEnumerable<KeyChord> items) #

Adds items to AppScreens.BackKeys: Keys that return to the previous screen when the focused input does not use them (default Escape and Backspace).

Parameters

appScreens ConsoleMonster.Interactive.AppScreens required
The instance.
items System.Collections.Generic.IEnumerable<ConsoleMonster.Input.KeyChord> required
The items, in order.

Returns

AppScreens The same instance.
public static AppScreens Current(AppScreens appScreens, Action<AppScreen> configure) #

Configures AppScreens.Current in place: The current screen.

Parameters

appScreens ConsoleMonster.Interactive.AppScreens required
The instance.
configure System.Action<ConsoleMonster.Interactive.AppScreen> required
Configures the value.

Returns

AppScreens The same instance.
public static AppScreens StateKey(AppScreens appScreens, string value) #

Sets AppScreens.StateKey: The state key holding the current screen's key (default Screen).

Parameters

appScreens ConsoleMonster.Interactive.AppScreens required
The instance.
value string required
The value.

Returns

AppScreens The same instance.

Examples

// C# initializer or property    // C# fluent
appScreens.StateKey = value;     appScreens.StateKey(value);