$npx -y skills add managedcode/dotnet-skills --skill sharpconsoleuiUse SharpConsoleUI to build full terminal (TUI) applications in .NET — equally suited to full-screen single-window apps and multi-window desktops with overlapping draggable windows — using a compositor, a DOM layout engine, and 40+ reactive controls (data tables, tree views, form
| 1 | # SharpConsoleUI terminal application framework |
| 2 | |
| 3 | ## Trigger On |
| 4 | |
| 5 | - building an interactive terminal UI: dashboards, wizards, settings screens, admin/monitoring consoles |
| 6 | - building a full-screen single-window TUI: a `.Frameless()` (no title bar, no title buttons) + `.Maximized()` app that owns the whole terminal |
| 7 | - building a multi-window terminal desktop: overlapping windows with drag/resize/minimize/maximize, z-order, focus routing, modal windows, and mouse support (full-screen and multi-window are equally first-class here) |
| 8 | - wanting flicker-free rendering that stays clean over SSH (diff-based cell buffer, not full repaints) |
| 9 | - needing rich terminal controls: data tables, tree/list views, forms, an embedded PTY terminal, markdown, charts, or video |
| 10 | - shipping a NativeAOT-ready console application with a real UI |
| 11 | |
| 12 | Do not trigger for plain line-based CLI tools, argument parsing, or non-interactive scripts. |
| 13 | |
| 14 | ## Install |
| 15 | |
| 16 | - NuGet: |
| 17 | - `dotnet add package SharpConsoleUI` |
| 18 | - `dotnet add package SharpConsoleUI --version <version>` |
| 19 | - XML package reference: |
| 20 | - `<PackageReference Include="SharpConsoleUI" Version="x.y.z" />` |
| 21 | - Targets `net8.0`, `net9.0`, `net10.0`. |
| 22 | - Sources: |
| 23 | - [NuGet: SharpConsoleUI](https://www.nuget.org/packages/SharpConsoleUI/) |
| 24 | - [GitHub: nickprotop/ConsoleEx](https://github.com/nickprotop/ConsoleEx) |
| 25 | - [Docs site](https://nickprotop.github.io/ConsoleEx/) |
| 26 | |
| 27 | ## Workflow |
| 28 | |
| 29 | ```mermaid |
| 30 | flowchart LR |
| 31 | A["NetConsoleDriver (RenderMode.Buffer)"] --> B["ConsoleWindowSystem"] |
| 32 | B --> C["WindowBuilder -> Window"] |
| 33 | C --> D["window.AddControl(Controls.*)"] |
| 34 | D --> E["DOM layout: Measure -> Arrange -> Paint"] |
| 35 | E --> F["windowSystem.AddWindow(window)"] |
| 36 | F --> G["windowSystem.Run() (blocks until Shutdown)"] |
| 37 | G --> H["compositor merges per-window buffers -> terminal"] |
| 38 | ``` |
| 39 | |
| 40 | 1. Create a `NetConsoleDriver` and a `ConsoleWindowSystem` that owns all windows. |
| 41 | 2. Build one or more windows with `WindowBuilder` (title, size, position, borders, padding). |
| 42 | 3. Add controls to each window with `window.AddControl(...)`, usually via the `Controls` static factory. |
| 43 | 4. Wire interactivity through control events (e.g. `Button.OnClick`); call `windowSystem.Shutdown()` to exit. |
| 44 | 5. `windowSystem.AddWindow(window)` then `windowSystem.Run()` starts the render/input loop (blocks until shutdown). |
| 45 | 6. For layout, dialogs, portals/overlays, forms, and the full control set, load the reference files below. |
| 46 | |
| 47 | ### Minimal app (read + show + interact) |
| 48 | |
| 49 | ```csharp |
| 50 | using SharpConsoleUI; |
| 51 | using SharpConsoleUI.Builders; |
| 52 | using SharpConsoleUI.Controls; |
| 53 | using SharpConsoleUI.Drivers; |
| 54 | |
| 55 | var driver = new NetConsoleDriver(RenderMode.Buffer); |
| 56 | var windowSystem = new ConsoleWindowSystem(driver); |
| 57 | |
| 58 | var window = new WindowBuilder(windowSystem) |
| 59 | .WithTitle("Hello World") |
| 60 | .WithSize(50, 12) |
| 61 | .Centered() |
| 62 | .Build(); |
| 63 | |
| 64 | window.AddControl(Controls.Markup() |
| 65 | .AddLine("[bold cyan]Hello, SharpConsoleUI![/]") |
| 66 | .Build()); |
| 67 | |
| 68 | window.AddControl(Controls.Button("Quit") |
| 69 | .OnClick((sender, e, win) => windowSystem.Shutdown()) |
| 70 | .Build()); |
| 71 | |
| 72 | windowSystem.AddWindow(window); |
| 73 | windowSystem.Run(); |
| 74 | ``` |
| 75 | |
| 76 | ### Layout + data example |
| 77 | |
| 78 | Use a `GridControl` when you need columns/rows with fixed, size-to-content, or |
| 79 | proportional (`Star`) tracks, and put content controls (tables, lists, markdown) |
| 80 | into the cells: |
| 81 | |
| 82 | ```csharp |
| 83 | var grid = Controls.Grid() |
| 84 | .Columns(GridLength.Cells(20), GridLength.Star(1)) // fixed sidebar + fill |
| 85 | .Rows(GridLength.Auto(), GridLength.Star(1)) // toolbar + body |
| 86 | .RowGap(1) |
| 87 | .Place(Controls.Markup("[bold]Dashboard[/]").Build(), 0, 0, colSpan: 2) |
| 88 | .Place(sidebarList, 1, 0) |
| 89 | .Place(dataTable, 1, 1) |
| 90 | .Build(); |
| 91 | |
| 92 | window.AddControl(grid); |
| 93 | ``` |
| 94 | |
| 95 | See `references/recipes.md` for full grid/table/form/dialog examples and |
| 96 | `references/controls.md` for the control chosen per region. |
| 97 | |
| 98 | ## Best practices |
| 99 | |
| 100 | - Describe the UI declara |