ConsoleForge 0.0.2
See the version list below for details.
dotnet add package ConsoleForge --version 0.0.2
NuGet\Install-Package ConsoleForge -Version 0.0.2
<PackageReference Include="ConsoleForge" Version="0.0.2" />
<PackageVersion Include="ConsoleForge" Version="0.0.2" />
<PackageReference Include="ConsoleForge" />
paket add ConsoleForge --version 0.0.2
#r "nuget: ConsoleForge, 0.0.2"
#:package ConsoleForge@0.0.2
#addin nuget:?package=ConsoleForge&version=0.0.2
#tool nuget:?package=ConsoleForge&version=0.0.2
ConsoleForge
A C# 12 / .NET 8 terminal UI framework. Simple to use, expressive enough for real apps.
Architecture: Elm-loop — immutable model, pure Update, pure View. No mutable state in widgets.
Renderer: Double-buffered, cell-level diff. Only changed cells hit the terminal per frame.
Docs: popplywop.github.io/ConsoleForge
Quick Start
using ConsoleForge.Core;
using ConsoleForge.Layout;
using ConsoleForge.Styling;
using ConsoleForge.Widgets;
record HelloModel(string Message) : IModel
{
public ICmd? Init() => null;
public (IModel Model, ICmd? Cmd) Update(IMsg msg) => msg switch
{
KeyMsg { Key: ConsoleKey.Q } => (this, Cmd.Quit()),
_ => (this, null)
};
public IWidget View() =>
new BorderBox(
title: "ConsoleForge",
body: new TextBlock(Message),
style: Style.Default.BorderForeground(Colors.Green)
);
}
Program.Run(new HelloModel("Press Q to quit."));
dotnet run
Core Concepts
The Elm Loop
IModel.Init() → optional startup command
↓
input event → IModel.Update(msg) → (newModel, cmd?)
↓
IModel.View() → IWidget tree → render
Your model is an immutable record. Update returns a new copy. View is pure — no side effects.
Widgets
| Widget | Description |
|---|---|
TextBlock |
Renders text, word-wraps at region width |
Container |
Lays out children along horizontal or vertical axis |
BorderBox |
Bordered box with optional title and body widget |
List |
Scrollable list, keyboard navigable, dispatches selection messages |
TextInput |
Single-line text input with cursor, dispatches change messages |
Layout
Children declare Width and Height as SizeConstraint:
SizeConstraint.Fixed(24) // exact column/row count
SizeConstraint.Flex(1) // proportional share of remaining space
SizeConstraint.Auto // shrink to content
SizeConstraint.Min(n, inner)
SizeConstraint.Max(n, inner)
Container does two-pass layout: fixed children first, then flex children share the remainder.
Styling
Style is an immutable value type. All methods return a new Style — fluent builder pattern:
var style = Style.Default
.Foreground(Colors.Cyan)
.Bold()
.Padding(1, 2)
.Border(Borders.Rounded);
Styles inherit from parent theme when properties are unset — no redundant overrides needed.
Commands
ICmd represents async side effects returned alongside the new model:
Cmd.Quit() // exit the program
Cmd.From(async ct => someMsg) // run async work, dispatch result as message
Cmd.Batch(cmd1, cmd2) // run multiple commands
Focus
IFocusable widgets (TextInput, List) receive keyboard events when focused.
FocusManager.CycleNext / CyclePrev traverse focusable widgets in render order.
Samples
| Sample | Description |
|---|---|
ConsoleForge.TodoApp |
Todo list — browse, add, toggle, delete |
ConsoleForge.Gallery |
Widget showcase — all widgets, styles, layouts |
ConsoleForge.SysMonitor |
Live system stats via async commands |
Run a sample:
dotnet run --project samples/ConsoleForge.TodoApp
Project Structure
src/
ConsoleForge/
Core/ IModel, IMsg, ICmd, Program (runtime loop), Renderer, FocusManager
Layout/ IWidget, Container layout engine, RenderContext (double-buffer), Region
Styling/ Style, Theme, BorderSpec, Colors, ColorProfile
Terminal/ ITerminal, AnsiTerminal, Termios (Unix raw mode)
Widgets/ TextBlock, TextInput, List, BorderBox, Container
tests/
ConsoleForge.Tests/ Unit + integration tests, VirtualTerminal test double
ConsoleForge.Benchmarks/ BenchmarkDotNet render benchmarks
samples/
ConsoleForge.Gallery/
ConsoleForge.SysMonitor/
ConsoleForge.TodoApp/
Building
dotnet build
dotnet test
Requires .NET 8 SDK. No external NuGet dependencies beyond System.Reactive.
License
MIT — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- System.Reactive (>= 6.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.