ConsoleForge 0.3.0
Elm-architecture TUI framework for .NET 8
Loading...
Searching...
No Matches
ConsoleForge.Core Namespace Reference

Classes

class  App
 Main event loop for a ConsoleForge application. More...
class  Cmd
 Factory for creating common command values. More...
class  Component
 Static helpers for working with IComponent and IComponent<TResult> in parent model Update methods. More...
class  ComponentAttribute
 Instructs the generator to also emit the Init() method (returns null) and the explicit IComponent<TResult>.Result property implementation when the type implements IComponent<TResult>. More...
class  DispatchUpdateAttribute
 Instructs the ConsoleForge source generator to produce the Update(IMsg) dispatch method for this partial record or class. More...
class  FocusManager
 Stateless helper that traverses a widget tree depth-first and finds all IFocusable instances in declaration order. More...
interface  IComponent
 A self-contained sub-program: owns its own state, update logic, and view. More...
interface  IComponent< out TResult >
 A self-contained sub-program that can signal completion by setting Result to a non-null value. More...
interface  IHasSubscriptions
 Optional interface for models that declare long-running subscriptions. More...
interface  IModel
 The root interface for all ConsoleForge application models. More...
interface  IMsg
 Marker interface for all messages flowing through the event loop. More...
class  KeyMap
 Declarative input binding map. More...
struct  KeyPattern
 Pattern for matching keyboard events. More...
class  Sub
 Factory helpers for creating common ISub values. More...
struct  ViewDescriptor
 Immutable descriptor for a single rendered frame. More...

Enumerations

enum  MouseAction { Press , Release , Move }
 The type of mouse action represented by a MouseMsg. More...
enum  MouseButton {
  Left , Middle , Right , ScrollUp ,
  ScrollDown , None
}
 Dispatched by List when the user presses Enter on a selected item. More...

Functions

delegate Task< IMsgICmd ()
 A command: an async function that produces one message when complete.
delegate IAsyncEnumerable< IMsgISub (CancellationToken cancellationToken)
 A subscription: a long-running async function that produces messages continuously until the supplied CancellationToken is cancelled.

Variables

record QuitMsg
 Signals the program loop to exit cleanly.
record KeyMsg(ConsoleKey Key, char? Character, bool Shift=false, bool Alt=false, bool Ctrl=false) record WindowResizeMsg(int Width, int Height) record FocusChangedMsg(IWidget? Previous, IWidget? Next) record FocusIndexChangedMsg(int Index) record BatchMsg(IMsg[] Messages) record SequenceMsg(IMsg[] Messages) record RedrawMsg
 A keyboard input event.

Enumeration Type Documentation

◆ MouseAction

The type of mouse action represented by a MouseMsg.

Enumerator
Press 

Button pressed down.

Release 

Button released.

Move 

Cursor moved (button may or may not be held).

◆ MouseButton

Dispatched by List when the user presses Enter on a selected item.

Parameters
IndexZero-based index of the selected item.
ItemThe item value (string for built-in List).

Dispatched to change the active theme at runtime. Program intercepts this message and calls Program.SetTheme before forwarding to the model. The model should update any theme-tracking state in its own Update handler.

Dispatched when a command throws an unhandled exception. Models may handle this to display error state; unhandled it is silently dropped.

Parameters
ExceptionThe exception thrown by the command.
SourceOptional label identifying which command failed (for logging).

Which mouse button was involved in an event.

Enumerator
Left 

Primary (left) button.

Middle 

Middle button or scroll-wheel click.

Right 

Secondary (right) button.

ScrollUp 

Scroll wheel rotated upward (away from user).

ScrollDown 

Scroll wheel rotated downward (toward user).

None 

No button — motion-only event.

Function Documentation

◆ ICmd()

delegate Task< IMsg > ConsoleForge.Core.ICmd ( )

A command: an async function that produces one message when complete.

The framework awaits each non-null command. Use async lambdas or Task.FromResult<TResult> for synchronous results. Return null (Cmd.None) to indicate no operation.

◆ ISub()

delegate IAsyncEnumerable< IMsg > ConsoleForge.Core.ISub ( CancellationToken cancellationToken)

A subscription: a long-running async function that produces messages continuously until the supplied CancellationToken is cancelled.

Return null from the callback to suppress dispatching a message (e.g. after an interval fires with no meaningful data). The framework will not write null messages to the channel.

Variable Documentation

◆ RedrawMsg

record KeyMsg ( ConsoleKey Key, char? Character, bool Shift = false, bool Alt = false, bool Ctrl = false) record WindowResizeMsg (int Width, int Height) record FocusChangedMsg (IWidget? Previous, IWidget? Next) record FocusIndexChangedMsg (int Index) record BatchMsg (IMsg[] Messages) record SequenceMsg (IMsg[] Messages) record ConsoleForge.Core.RedrawMsg
sealed

A keyboard input event.

Terminal was resized.

Focus moved from one widget to another.

Focus moved to the widget at Index in the depth-first focusable list. Models use this to set HasFocus = true on the correct widget instance.

Internal: aggregates results from Cmd.Batch concurrent execution.

Internal: aggregates results from Cmd.Sequence serial execution.

Triggers a re-render without changing model state (e.g., theme swap).