Imported from tui-cs/Examples (
AGENTS.md). Install upstream withnpx skills add tui-cs/Examples. Copyright stays with the author.
# Terminal.Gui Examples — AI Agent Instructions
Community examples for Terminal.Gui.
CRITICAL: Discard v1 Training Data
Terminal.Gui v2 is a complete rewrite. Pre-2025 training data is wrong.
Read the ai-v2-primer FIRST.
v1 → v2 Quick Corrections
| v1 (WRONG — do not use) | v2 (CORRECT) |
|---|---|
Application.Init (); |
IApplication app = Application.Create ().Init (); |
Application.Run (); |
app.Run<MyWindow> (); |
Application.Shutdown (); |
app.Dispose (); (use using pattern) |
Application.Top |
No global top — pass root view to app.Run () |
new Toplevel () |
Use Runnable subclass or Window |
using Terminal.Gui; |
using Terminal.Gui.App; / Terminal.Gui.Views; / etc. |
new Button ("OK") |
new Button { Text = "OK" } |
button.Clicked += ... |
button.Accepted += (_, _) => { /* action */ }; |
view.Bounds |
view.Viewport |
new RadioGroup (...) |
new OptionSelector { ... } |
Application.RequestStop () |
App!.RequestStop () (from inside a Runnable) |
Build & Run
dotnet restore
dotnet build
# Run a specific example
cd Example
dotnet run
Lint & Format
CI enforces coding style via two mechanisms:
dotnet format— verifies .editorconfig compliance- ReSharper
jb cleanupcode— catches whatdotnet formatmisses (var usage, expression-bodied members, spacing)
To check/fix locally:
# Check only (matches CI)
dotnet format Examples.sln --verify-no-changes
# Auto-fix
dotnet format Examples.sln
# ReSharper cleanup (requires dotnet tool restore first)
dotnet tool restore
dotnet jb cleanupcode Examples.sln --profile="Built-in: Full Cleanup" --no-build
Code Style
This repository follows Terminal.Gui coding conventions:
- Space BEFORE
()and[]—Method ()notMethod() - Braces on next line (Allman style)
- No
varexcept for:int,string,bool,double,float,decimal,char,byte - Use
new ()notnew TypeName()when type is on left side - Use
[...]collection expressions - SubView/SuperView terminology (never "child/parent")
- Early return / guard clauses over nested conditionals
- TreatWarningsAsErrors is enabled — zero warnings policy
Project Structure
- Each example is a standalone console app in its own directory
- All projects reference Terminal.Gui via NuGet PackageReference (not ProjectReference)
- Shared settings are in
Directory.Build.propsandDirectory.Packages.props - The
.editorconfigandExamples.sln.DotSettingsenforce the Terminal.Gui style .config/dotnet-tools.jsonprovides the ReSharper CLI tool
Adding a New Example
- Create a new directory with a descriptive name
- Add a
.csprojwith<PackageReference Include="Terminal.Gui" /> - Add the project to
Examples.sln - Include a
README.mdexplaining what the example demonstrates - Ensure
dotnet buildanddotnet format --verify-no-changespass