Table of Contents

Class ConsoleWindowSystem

Namespace
SharpConsoleUI
Assembly
SharpConsoleUI.dll

The main window system that manages console windows, input processing, and rendering. Provides window management, focus handling, theming, and event processing for console applications.

public class ConsoleWindowSystem
Inheritance
ConsoleWindowSystem
Inherited Members

Constructors

ConsoleWindowSystem(IConsoleDriver, PluginConfiguration?, ConsoleWindowSystemOptions?)

Initializes a new instance of the ConsoleWindowSystem class with the default theme.

public ConsoleWindowSystem(IConsoleDriver driver, PluginConfiguration? pluginConfiguration = null, ConsoleWindowSystemOptions? options = null)

Parameters

driver IConsoleDriver

Pre-configured console driver.

pluginConfiguration PluginConfiguration

Optional plugin configuration for auto-loading plugins.

options ConsoleWindowSystemOptions

Optional configuration options for system behavior.

ConsoleWindowSystem(IConsoleDriver, ITheme, PluginConfiguration?, ConsoleWindowSystemOptions?)

Initializes a new instance of the ConsoleWindowSystem class with a specific theme instance.

public ConsoleWindowSystem(IConsoleDriver driver, ITheme theme, PluginConfiguration? pluginConfiguration = null, ConsoleWindowSystemOptions? options = null)

Parameters

driver IConsoleDriver

Pre-configured console driver.

theme ITheme

The theme instance to use.

pluginConfiguration PluginConfiguration

Optional plugin configuration for auto-loading plugins.

options ConsoleWindowSystemOptions

Optional configuration options for system behavior.

ConsoleWindowSystem(IConsoleDriver, string, PluginConfiguration?, ConsoleWindowSystemOptions?)

Initializes a new instance of the ConsoleWindowSystem class with a theme specified by name.

public ConsoleWindowSystem(IConsoleDriver driver, string themeName, PluginConfiguration? pluginConfiguration = null, ConsoleWindowSystemOptions? options = null)

Parameters

driver IConsoleDriver

Pre-configured console driver.

themeName string

The name of the theme to use.

pluginConfiguration PluginConfiguration

Optional plugin configuration for auto-loading plugins.

options ConsoleWindowSystemOptions

Optional configuration options for system behavior.

Fields

Input

Gets the input coordinator for managing keyboard and mouse input across windows.

public InputCoordinator Input

Field Value

InputCoordinator

Performance

Gets the performance tracker for monitoring frame rates and render times.

public PerformanceTracker Performance

Field Value

PerformanceTracker

Properties

ActiveWindow

Gets the currently active window, or null if no window is active.

public Window? ActiveWindow { get; }

Property Value

Window

ConsoleDriver

Gets or sets the console driver used for low-level console operations.

public IConsoleDriver ConsoleDriver { get; set; }

Property Value

IConsoleDriver

CursorStateService

Gets the cursor state service for managing cursor visibility and position.

public CursorStateService CursorStateService { get; }

Property Value

CursorStateService

DesktopBottomRight

Gets the bottom-right coordinate of the usable desktop area (excluding status bars).

public Point DesktopBottomRight { get; }

Property Value

Point

DesktopDimensions

Gets the dimensions of the usable desktop area (excluding status bars).

public Size DesktopDimensions { get; }

Property Value

Size

DesktopUpperLeft

Gets the upper-left coordinate of the usable desktop area (excluding status bars).

public Point DesktopUpperLeft { get; }

Property Value

Point

FocusStateService

Gets the focus state service for managing control focus within windows.

public FocusStateService FocusStateService { get; }

Property Value

FocusStateService

InputStateService

Gets the input state service for managing input queue and idle state.

public InputStateService InputStateService { get; }

Property Value

InputStateService

IsRunning

Gets a value indicating whether the window system is currently running.

public bool IsRunning { get; }

Property Value

bool

LogService

Gets the library-managed logging service. Subscribe to LogAdded event or call GetRecentLogs() to access internal logs.

public ILogService LogService { get; }

Property Value

ILogService

ModalStateService

Gets the modal state service for managing modal window behavior.

public ModalStateService ModalStateService { get; }

Property Value

ModalStateService

NotificationStateService

Gets the notification state service for managing notifications and toasts.

public NotificationStateService NotificationStateService { get; }

Property Value

NotificationStateService

Options

Gets or sets the current console window system options.

public ConsoleWindowSystemOptions Options { get; set; }

Property Value

ConsoleWindowSystemOptions

PluginStateService

Gets the plugin state service for managing plugins and their contributions.

public PluginStateService PluginStateService { get; }

Property Value

PluginStateService

Positioning

Gets the window positioning manager for handling window movement and resizing.

public WindowPositioningManager Positioning { get; }

Property Value

WindowPositioningManager

Render

Gets the render coordinator for managing window rendering and invalidation.

public RenderCoordinator Render { get; }

Property Value

RenderCoordinator

Renderer

Gets the renderer for drawing operations.

public Renderer Renderer { get; }

Property Value

Renderer

RenderingDiagnostics

Gets the rendering diagnostics system for testing and debugging. Only available when EnableDiagnostics is true in options.

public RenderingDiagnostics? RenderingDiagnostics { get; }

Property Value

RenderingDiagnostics

StatusBarStateService

Gets the status bar state service for managing status bars and Start menu.

public StatusBarStateService StatusBarStateService { get; }

Property Value

StatusBarStateService

Theme

Gets the theme used for styling windows and controls. Use ThemeStateService.CurrentTheme or ThemeStateService.SetTheme() for theme management.

public ITheme Theme { get; }

Property Value

ITheme

ThemeStateService

Gets the theme state service for managing theme application.

public ThemeStateService ThemeStateService { get; }

Property Value

ThemeStateService

VisibleRegions

Gets the visible regions manager for calculating window visibility.

public VisibleRegions VisibleRegions { get; }

Property Value

VisibleRegions

WindowStateService

Gets the window state service for managing window lifecycle and state.

public WindowStateService WindowStateService { get; }

Property Value

WindowStateService

Windows

Gets a read-only dictionary of all windows in the system, keyed by their GUID.

public IReadOnlyDictionary<string, Window> Windows { get; }

Property Value

IReadOnlyDictionary<string, Window>

Methods

AddWindow(Window, bool)

Adds a window to the window system.

public Window AddWindow(Window window, bool activateWindow = true)

Parameters

window Window

The window to add.

activateWindow bool

Whether to activate the window after adding. Defaults to true.

Returns

Window

The added window.

CloseModalWindow(Window?)

Closes a modal window and optionally activates its parent window.

public void CloseModalWindow(Window? modalWindow)

Parameters

modalWindow Window

The modal window to close. If null or not a modal window, the method returns without action.

CloseWindow(Window?, bool, bool)

Closes a window and removes it from the window system.

public bool CloseWindow(Window? window, bool activateParent = true, bool force = false)

Parameters

window Window

The window to close. If null or not in the system, returns false.

activateParent bool

Whether to activate the parent window after closing. Defaults to true.

force bool

If true, forces the window to close even if IsClosable is false or OnClosing cancels.

Returns

bool

True if the window was closed successfully; false otherwise.

CycleActiveWindow()

Cycles to the next active window (Ctrl+T handler).

public void CycleActiveWindow()

GetWindowAtPoint(Point)

Finds the topmost window at the specified point.

public Window? GetWindowAtPoint(Point point)

Parameters

point Point

The point in absolute screen coordinates.

Returns

Window

The topmost window at the point, or null if none found.

ProcessOnce()

Processes one iteration of the main loop (input, display, cursor). This is useful for modal dialogs that need to block while still processing UI events.

public void ProcessOnce()

RequestExit(int)

Requests the window system to exit with the specified exit code.

public void RequestExit(int exitCode)

Parameters

exitCode int

Run()

Starts the main event loop of the window system. Blocks until Shutdown(int) is called.

public int Run()

Returns

int

The exit code set by Shutdown(int) or 1 if an unhandled exception occurred.

SetActiveWindow(Window)

Sets the specified window as the active window, handling modal window logic and focus.

public void SetActiveWindow(Window window)

Parameters

window Window

The window to activate. If null, the method returns without action.

Shutdown(int)

Gracefully shuts down the console window system with the specified exit code

public void Shutdown(int exitCode = 0)

Parameters

exitCode int

The exit code to return