Skip to content

Commit 07f2b1d

Browse files
tigBDispCopilotCopilotCopilot
authored
Release v2.0.0-rc.2 (#5030)
* Release new `main` build (#5005) * Updates the sample.gif (#5007) * Cleans up examples. * updated docs * new sample.gif * reverted * Fix remaining TextView issues (#4987) * Fixes #4986. Navigating with Viewport.Y greater than zero will cause scrolling to increase, even if the current line fits within the available height. * Fixes #4990. Navigating with Viewport.X greater than zero will cause scrolling left, even if the current column isn't at the right of the viewport * Fixes #4994 - Navigating left and right while holding down the Ctrl key does not cause edge scrolling. * Fixes #4998. TextView.UpdateContentSize isn't working correctly on insert and delete text * Fixes #4999. TextView with hidden cursor due scrolling pressing any CursorRight/Left/Down/Up keys doesn't adjust to make the cursor visible * Update Tests/UnitTestsParallelizable/Views/TextView.NavigationTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixes #4891. DoDrawComplete should ignore scrolled Viewport.Location when excluding opaque view area * Clarify comment related to deleted * Fix MoveUp() and add more unit tests * Test that proves despite does not change viewport position but does set NeedsDraw. * Fix MoveLeft method and add a test * Fix MoveWordLeft and add unit test * Fix MoveWordRight and add unit test * Simplify MoveRight code * Fix DeleteCharLeft invoke ContentChanged twice * Fix ShouldInvalidateMaxWidthCache to use full size * Remove unnecessary LINQ in _cachedMaxWidthPerLine * Move ShouldInvalidateMaxWidthCache tests * Fix ArgumentOutOfRangeException on DeleteTextLeft --------- Co-authored-by: Tig <tig@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixes UICatalog --version, adds release workflows and maintainer docs (#5009) * Fixes `AppModel.Inline` issues needed for `Output-ConsoleGridView` to work well (#5010) * Cleans up examples. * updated docs * Add LayoutAndDrawComplete event, improve shutdown/reset - Adds LayoutAndDrawComplete event to IApplication and ApplicationImpl, raised after layout/draw completes - Refactors ApplicationMainLoop to track first layout/draw with _firstLayoutAndDrawComplete - Removes UnsubscribeDriverEvents and inlines DeviceAttributesStartupQueryTimeout - Uses Lock for _sessionStackLock for better thread safety - Ensures terminal attributes are reset (ESC[0m) and cursor shown on shutdown in AnsiOutput - Adds CSI_ResetAttributes to EscSeqUtils - Skips IterationImpl_Inline_FullTimeline_TraceDump test (tracing not for test results) * Update Tests/UnitTestsParallelizable/Drivers/Output/InlineDrawTimingTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Terminal.Gui/Drivers/AnsiHandling/EscSeqUtils/EscSeqUtils.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Terminal.Gui/App/MainLoop/ApplicationMainLoop.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update LayoutAndDrawComplete event summary and remarks --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixes prepare release workflow (#5015) * Cleans up examples. * updated docs * Use RELEASE_PAT for release workflows to allow PR creation GITHUB_TOKEN is not permitted to create pull requests in this repo. Switch prepare-release and finalize-release workflows to use the RELEASE_PAT secret for checkout, PR creation, and release creation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix version numbering: auto-increment pre-release from existing tags (#5018) The workflow was manually constructing versions like '2.0.0-beta' without the incrementing number suffix. Now it scans existing git tags to find the latest matching tag (e.g., v2.0.0-beta.217) and increments to produce the next version (e.g., 2.0.0-beta.218). Also adds: - Concurrency group to prevent race conditions between runs - Remote branch conflict detection before creating release branch - Simplified GitVersion.yml label update logic Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix/prepare release (#5019) * Cleans up examples. * updated docs * Use RELEASE_PAT for release workflows to allow PR creation GITHUB_TOKEN is not permitted to create pull requests in this repo. Switch prepare-release and finalize-release workflows to use the RELEASE_PAT secret for checkout, PR creation, and release creation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix version numbering: auto-increment pre-release from existing tags The workflow was manually constructing versions like '2.0.0-beta' without the incrementing number suffix. Now it scans existing git tags to find the latest matching tag (e.g., v2.0.0-beta.217) and increments to produce the next version (e.g., 2.0.0-beta.218). Also adds: - Concurrency group to prevent race conditions between runs - Remote branch conflict detection before creating release branch - Simplified GitVersion.yml label update logic Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fixes #4843. Button: avoid create-then-destroy shadow allocation via CWP InitializingShadowStyle event (#5012) * Cleans up examples. * updated docs * Initial plan * Fixes #4885. Button: avoid create-then-destroy shadow allocation via GetDefaultShadowStyle() Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/4c164de3-c266-4539-996f-a3b941b0a367 Co-authored-by: tig <585482+tig@users.noreply.github.com> * Update Terminal.Gui/Views/ScrollBar/ScrollButton.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Terminal.Gui/ViewBase/Adornment/ArrangerButton.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Tests/UnitTestsParallelizable/Views/ButtonTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Terminal.Gui/Views/Button.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Redesign shadow initialization to use CWP event (OnInitializingShadowStyle + InitializingShadowStyle) Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/14508ce0-b4f0-4534-8270-4c61d75880c9 Co-authored-by: tig <585482+tig@users.noreply.github.com> * Darken shadow effect in ShadowView for non-opaque style Increased the dimming factor for shadow colors in ShadowView by updating GetDimmerColor parameters from 0.05/0.25 to 0.9. This results in a much darker shadow appearance when ShadowStyle is not Opaque. * Refactor docs and style in Button and ArrangerButton Reformat XML docs for readability and line wrapping. Convert OnHotKeyCommand to an expression-bodied member. Apply minor whitespace and style fixes to align with project conventions. No functional changes. * Update ShadowTests expected ANSI output for background Changed the expected ANSI color code in ShadowTests.cs from bright white (\x1b[107m) to black (\x1b[40m) for the second cell in the driver output assertion, aligning the test with the updated rendering behavior. --------- Co-authored-by: Tig <tig@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Bump Markdig from 1.1.2 to 1.1.3 (#5017) --- updated-dependencies: - dependency-name: Markdig dependency-version: 1.1.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Back-merge v2.0.0-beta.218 from main into develop (#5022) * Cleans up examples. * updated docs * Release v2.0.0-beta.218 (#5021) * Release new `main` build (#5005) * Updates the sample.gif (#5007) * Cleans up examples. * updated docs * new sample.gif * reverted * Fix remaining TextView issues (#4987) * Fixes #4986. Navigating with Viewport.Y greater than zero will cause scrolling to increase, even if the current line fits within the available height. * Fixes #4990. Navigating with Viewport.X greater than zero will cause scrolling left, even if the current column isn't at the right of the viewport * Fixes #4994 - Navigating left and right while holding down the Ctrl key does not cause edge scrolling. * Fixes #4998. TextView.UpdateContentSize isn't working correctly on insert and delete text * Fixes #4999. TextView with hidden cursor due scrolling pressing any CursorRight/Left/Down/Up keys doesn't adjust to make the cursor visible * Update Tests/UnitTestsParallelizable/Views/TextView.NavigationTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixes #4891. DoDrawComplete should ignore scrolled Viewport.Location when excluding opaque view area * Clarify comment related to deleted * Fix MoveUp() and add more unit tests * Test that proves despite does not change viewport position but does set NeedsDraw. * Fix MoveLeft method and add a test * Fix MoveWordLeft and add unit test * Fix MoveWordRight and add unit test * Simplify MoveRight code * Fix DeleteCharLeft invoke ContentChanged twice * Fix ShouldInvalidateMaxWidthCache to use full size * Remove unnecessary LINQ in _cachedMaxWidthPerLine * Move ShouldInvalidateMaxWidthCache tests * Fix ArgumentOutOfRangeException on DeleteTextLeft --------- Co-authored-by: Tig <tig@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixes UICatalog --version, adds release workflows and maintainer docs (#5009) * Fixes `AppModel.Inline` issues needed for `Output-ConsoleGridView` to work well (#5010) * Cleans up examples. * updated docs * Add LayoutAndDrawComplete event, improve shutdown/reset - Adds LayoutAndDrawComplete event to IApplication and ApplicationImpl, raised after layout/draw completes - Refactors ApplicationMainLoop to track first layout/draw with _firstLayoutAndDrawComplete - Removes UnsubscribeDriverEvents and inlines DeviceAttributesStartupQueryTimeout - Uses Lock for _sessionStackLock for better thread safety - Ensures terminal attributes are reset (ESC[0m) and cursor shown on shutdown in AnsiOutput - Adds CSI_ResetAttributes to EscSeqUtils - Skips IterationImpl_Inline_FullTimeline_TraceDump test (tracing not for test results) * Update Tests/UnitTestsParallelizable/Drivers/Output/InlineDrawTimingTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Terminal.Gui/Drivers/AnsiHandling/EscSeqUtils/EscSeqUtils.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Terminal.Gui/App/MainLoop/ApplicationMainLoop.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update LayoutAndDrawComplete event summary and remarks --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixes prepare release workflow (#5015) * Cleans up examples. * updated docs * Use RELEASE_PAT for release workflows to allow PR creation GITHUB_TOKEN is not permitted to create pull requests in this repo. Switch prepare-release and finalize-release workflows to use the RELEASE_PAT secret for checkout, PR creation, and release creation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix version numbering: auto-increment pre-release from existing tags (#5018) The workflow was manually constructing versions like '2.0.0-beta' without the incrementing number suffix. Now it scans existing git tags to find the latest matching tag (e.g., v2.0.0-beta.217) and increments to produce the next version (e.g., 2.0.0-beta.218). Also adds: - Concurrency group to prevent race conditions between runs - Remote branch conflict detection before creating release branch - Simplified GitVersion.yml label update logic Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix/prepare release (#5019) * Cleans up examples. * updated docs * Use RELEASE_PAT for release workflows to allow PR creation GITHUB_TOKEN is not permitted to create pull requests in this repo. Switch prepare-release and finalize-release workflows to use the RELEASE_PAT secret for checkout, PR creation, and release creation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix version numbering: auto-increment pre-release from existing tags The workflow was manually constructing versions like '2.0.0-beta' without the incrementing number suffix. Now it scans existing git tags to find the latest matching tag (e.g., v2.0.0-beta.217) and increments to produce the next version (e.g., 2.0.0-beta.218). Also adds: - Concurrency group to prevent race conditions between runs - Remote branch conflict detection before creating release branch - Simplified GitVersion.yml label update logic Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: BDisp <bd.bdisp@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: BDisp <bd.bdisp@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Adds `TreeView.GetSize` (#5025) * Refactor driver param, MinUI, and Terminal.Gui integration - Rename ForceDriver to Driver across all cmdlets and ApplicationData for consistency; update help text - Switch to ProjectReference for Terminal.Gui, update solution and project files for local dev - Refactor MinUI handling and help text; clarify that only title/status bar are hidden, filter shown if specified - Use FrameView.DefaultBorderStyle and modularize filter/status bar logic in OutGridViewWindow, OutTableViewWindow, and ShowObjectTreeWindow - Add FullScreen param to ShowObjectTreeCmdletCommand; set AppModel accordingly in ShowObjectView - Ensure explicit disposal of windows and apps in all entry points - Expose TreeView<T>.GetSize() for accurate sizing - Update launchSettings.json and tests for new Driver param and MinUI usage - Improve null-safety, event handling, and consistency throughout UI code * Revert "Refactor driver param, MinUI, and Terminal.Gui integration" This reverts commit 10821a1. * Refactor tree size calculation into GetSize() method Extracted content size logic to a new public GetSize() method in TreeView<T>. This method computes the logical size based on expanded branches and is now used for content size updates. Added XML documentation for GetSize(). * Ensures `CollectionNavigator` does not repond to alt or ctrl keys (#5014) * Cleans up examples. * updated docs * Update IsCompatibleKey to reject Alt/Ctrl; improve tests IsCompatibleKey now rejects keys with Alt or Ctrl modifiers, ensuring only plain character keys are accepted for search. Added tests to verify this behavior, including scenarios with AssociatedText. Refactored and reformatted tests for clarity, style compliance, and improved thread safety test code. * Fixes #4865. Add v1→v2 corrections table and expand agent-facing files for all AI tools (#5027) * Initial plan * Add v1→v2 corrections table and expand agent-facing files for all AI tools - Create ai-v2-primer.md: canonical v1→v2 reference for all agents - Expand llms.txt from 115 to ~330 lines with corrections table, snippets, gotchas - Flesh out .cursorrules from 5-line stub to full agent config - Create .windsurfrules for Windsurf AI support - Create .aider.md for Aider AI support - Update AGENTS.md with v1→v2 corrections table - Update CLAUDE.md to reference v2 primer - Update .github/copilot-instructions.md with v1→v2 corrections and updated lifecycle Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/ac004541-cd96-4c44-b6e7-ac21c60aad0b Co-authored-by: tig <585482+tig@users.noreply.github.com> * Address review feedback: clarify Pos.At docs, improve copilot-instructions readability Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/ac004541-cd96-4c44-b6e7-ac21c60aad0b Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix C# version to 14/net10.0 and clarify style rules are for library contributors only Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/e034da10-7544-4fa9-8186-53d7e5011eee Co-authored-by: tig <585482+tig@users.noreply.github.com> * Use Accepted (post-event) instead of Accepting as the v1 Clicked replacement Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/15e8840e-cec8-4098-8272-fb78a1516eb4 Co-authored-by: tig <585482+tig@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fixes #5008. Fix Markdown codeblock background attribute (#5011) * Initial plan * Fix MarkdownCodeBlock rendering codeblocks with incorrect background attribute - Remove ThemeBackground assignment on embedded code blocks in SyncCodeBlockViews() so code blocks always use the distinct Code role background instead of blending with the main content background when UseThemeBackground=true. - Pass resolved code block background to GetAttributeForSegment in MarkdownCodeBlock.OnDrawingContent() so text segments use the same background as the fill, fixing the mismatch when UseThemeBackground=false. - Add two tests verifying both scenarios. Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/fd4d1cad-1f64-4890-b1a7-74df3f9a2ab7 Co-authored-by: tig <585482+tig@users.noreply.github.com> * Fix Markdown code block background and highlighter logic Markdown code blocks now use the SyntaxHighlighter's DefaultBackground for their ThemeBackground, ensuring correct theming for both light and dark themes. The SyntaxHighlighter is passed to MarkdownCodeBlock SubViews. The "Theme BG" CheckBox in Deepdives and MarkdownTester reflects the current UseThemeBackground state. Added and updated tests to verify code block background and highlighter assignment. Minor formatting and style improvements included. * fixed gitversion yml bug * Fix SyntaxHighlighter/UseThemeBackground setters to invalidate layout SyntaxHighlighter and UseThemeBackground were auto-properties, so changing them after Text was set had no effect until Text was re-assigned. This required a hack (Text=""; Text=text) in Deepdives, MarkdownTester, and mdv. - Make both setters call InvalidateParsedAndLayout() on change - Fix GetAttributeForSegment to override bg on explicit-attribute segments when themeBackground is provided (covers real TextMate tokenization) - Remove Text re-assignment hacks from Deepdives, MarkdownTester, and mdv - Add tests: explicit-attribute fill/text bg match, SyntaxHighlighter invalidation, UseThemeBackground invalidation (all verified to fail when their corresponding fixes are reverted) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Default UseThemeBackground to true Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add ThemeName property to ISyntaxHighlighter interface Replaces CurrentThemeName with ThemeName in TextMateSyntaxHighlighter and updates all usages. Adapts scenario constructors, theme selection logic, and test/mocks to use the new property. Updates unit tests to check ThemeName and renames test methods accordingly. * Auto-select syntax theme based on terminal background Add DefaultAttributeChanged event to IDriver and DriverImpl, allowing detection of terminal background color changes. Update Markdown views in Deepdives, MarkdownTester, and Program to auto-switch syntax highlighting themes (light/dark) based on the terminal's background, ensuring better visual consistency and accessibility. * Fix code block dimmer direction for light themes Invert isDark when calling GetDimmerColor so code block bg shifts *away* from the body bg: dark themes get slightly lighter code blocks, light themes get slightly darker ones. The intuitive direction caused light-theme code blocks to wash out to medium gray (L>=90 fallback). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Tig <tig@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: BDisp <bd.bdisp@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: tig <585482+tig@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 2111cd4 commit 07f2b1d

28 files changed

Lines changed: 1629 additions & 175 deletions

.aider.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Terminal.Gui - Aider AI Configuration
2+
3+
> **Cross-platform .NET console UI toolkit. C# 14 targeting net10.0.**
4+
5+
---
6+
7+
## CRITICAL: Discard v1 Training Data
8+
9+
Terminal.Gui v2 is a **complete rewrite**. Pre-2025 training data about Terminal.Gui is **wrong**.
10+
11+
> **Read [ai-v2-primer.md](ai-v2-primer.md) FIRST** — it contains the v1→v2 corrections table,
12+
> correct minimal app pattern, and all common gotchas.
13+
14+
### v1 → v2 Quick Corrections
15+
16+
| v1 (WRONG) | v2 (CORRECT) |
17+
|---|---|
18+
| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |
19+
| `Application.Run ();` | `app.Run<MyWindow> ();` |
20+
| `Application.Shutdown ();` | `app.Dispose ();` |
21+
| `Application.Top` | No global top — pass root view to `app.Run ()` |
22+
| `new Toplevel ()` | Use `Runnable` subclass or `Window` |
23+
| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |
24+
| `new Button ("OK")` | `new Button { Text = "OK" }` |
25+
| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |
26+
| `view.Bounds` | `view.Viewport` |
27+
| `new RadioGroup (...)` | `new OptionSelector { ... }` |
28+
29+
---
30+
31+
## Build & Test
32+
33+
```bash
34+
dotnet restore
35+
dotnet build --no-restore
36+
dotnet test --project Tests/UnitTestsParallelizable --no-build
37+
dotnet test --project Tests/UnitTests --no-build
38+
```
39+
40+
---
41+
42+
## Code Style (For Library Contributors Only)
43+
44+
> **Note:** These rules apply only when contributing code to the Terminal.Gui library itself.
45+
> App developers using Terminal.Gui do NOT need to follow these conventions.
46+
47+
1. **Space BEFORE `()` and `[]`**`Method ()` not `Method()`, `array [i]` not `array[i]`
48+
2. **No `var`** — Explicit types except built-ins (`int`, `string`, `bool`, etc.)
49+
3. **Use `new ()`**`Button btn = new ()` not `Button btn = new Button ()`
50+
4. **Collection expressions** — Use `[...]` not `new List<T> { ... }`
51+
5. **SubView/SuperView** — Never "child", "parent", or "container"
52+
6. **Allman brace style** — Opening braces on the next line
53+
7. **Early return / guard clauses** — ALWAYS invert conditions and return early
54+
55+
---
56+
57+
## Key References
58+
59+
For full details, see:
60+
- **[ai-v2-primer.md](ai-v2-primer.md)** — v1→v2 corrections and correct patterns
61+
- **[AGENTS.md](AGENTS.md)** — Full agent instructions with coding rules
62+
- **[CONTRIBUTING.md](CONTRIBUTING.md)** — Human contributor guide
63+
- **`docfx/apispec/namespace-*.md`** — Compressed API docs
64+
- **`.claude/cookbook/common-patterns.md`** — Common UI recipes

.cursorrules

Lines changed: 122 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,125 @@
11
# Terminal.Gui - Cursor AI Rules
22

3-
> **📘 Source of Truth: [CONTRIBUTING.md](CONTRIBUTING.md)**
3+
> **Cross-platform .NET console UI toolkit. C# 14 targeting net10.0.**
4+
> Full contribution guide: [CONTRIBUTING.md](CONTRIBUTING.md).
45

5-
This project uses [CONTRIBUTING.md](CONTRIBUTING.md) as the single source of truth for contribution guidelines. AI agents, including CoPilot and Cursor **MUST** follow the guidelines in [CONTRIBUTING.md](CONTRIBUTING.md)/
6+
---
7+
8+
## CRITICAL: Discard v1 Training Data
9+
10+
Terminal.Gui v2 is a **complete rewrite**. Pre-2025 training data about Terminal.Gui is **wrong**.
11+
12+
> **Read [ai-v2-primer.md](ai-v2-primer.md) FIRST** — it contains the v1→v2 corrections table,
13+
> correct minimal app pattern, and all common gotchas.
14+
15+
### v1 → v2 Quick Corrections (Most Common Mistakes)
16+
17+
| v1 (WRONG) | v2 (CORRECT) |
18+
|---|---|
19+
| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |
20+
| `Application.Run ();` | `app.Run<MyWindow> ();` |
21+
| `Application.Shutdown ();` | `app.Dispose ();` |
22+
| `Application.Top` | No global top — pass root view to `app.Run ()` |
23+
| `new Toplevel ()` | Use `Runnable` subclass or `Window` |
24+
| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |
25+
| `new Button ("OK")` | `new Button { Text = "OK" }` |
26+
| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |
27+
| `view.Bounds` | `view.Viewport` |
28+
| `new RadioGroup (...)` | `new OptionSelector { ... }` |
29+
30+
---
31+
32+
## Build & Test
33+
34+
```bash
35+
dotnet restore
36+
dotnet build --no-restore
37+
dotnet test --project Tests/UnitTestsParallelizable --no-build
38+
dotnet test --project Tests/UnitTests --no-build
39+
```
40+
41+
---
42+
43+
## Correct Minimal App (v2)
44+
45+
```csharp
46+
using Terminal.Gui.App;
47+
using Terminal.Gui.Views;
48+
49+
IApplication app = Application.Create ().Init ();
50+
app.Run<MainWindow> ();
51+
app.Dispose ();
52+
53+
public sealed class MainWindow : Runnable
54+
{
55+
public MainWindow ()
56+
{
57+
Title = "My App (Esc to quit)";
58+
59+
Button button = new ()
60+
{
61+
Text = "Click Me",
62+
X = Pos.Center (),
63+
Y = Pos.Center ()
64+
};
65+
66+
button.Accepted += (_, _) =>
67+
{
68+
MessageBox.Query (App!, "Hello", "Button was clicked!", "OK");
69+
};
70+
71+
Add (button);
72+
}
73+
}
74+
```
75+
76+
---
77+
78+
## Code Style (For Library Contributors Only)
79+
80+
> **Note:** These rules apply only when contributing code to the Terminal.Gui library itself.
81+
> App developers using Terminal.Gui do NOT need to follow these conventions.
82+
83+
1. **Space BEFORE `()` and `[]`** — `Method ()` not `Method()`, `array [i]` not `array[i]`
84+
2. **Braces on NEXT line** (Allman style) — no exceptions
85+
3. **Blank lines** — before `return`/`break`/`continue`, after `if`/`for`/`while` blocks
86+
4. **No `var`** — Explicit types except built-ins (`int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`)
87+
5. **Use `new ()`** — `Button btn = new ()` not `Button btn = new Button ()`
88+
6. **Collection expressions** — Use `[...]` not `new List<T> { ... }`
89+
7. **SubView/SuperView** — Never "child", "parent", or "container"
90+
8. **Unused lambda params** — Use `_` discard: `(_, _) => { }`
91+
9. **Early return / guard clauses** — ALWAYS invert conditions and return early
92+
10. **One type per file** — Public and internal types each get their own file
93+
94+
---
95+
96+
## Architecture Overview
97+
98+
### Application lifecycle
99+
`Application.Create ()` → `.Init ()` → `.Run<T> ()` → `.Dispose ()`.
100+
Instance-based `IApplication` — do NOT use static `Application.Init()`/`Run()`/`Shutdown()`.
101+
102+
### View system
103+
`View` is the base class. Views form a tree via `Add ()`/`Remove ()`.
104+
Every View has: `Margin` → `Border` → `Padding` → content area.
105+
Layout uses `Pos` (position) and `Dim` (dimension) for declarative relative layout.
106+
107+
### Cancellable Workflow Pattern (CWP)
108+
Standard event pattern: **do work → call virtual `OnXxx` → raise event**.
109+
110+
### Command/input system
111+
Input flows: Driver → `IInputProcessor` → `KeyBindings`/`MouseBindings` → `Command` → handler.
112+
113+
---
114+
115+
## Key References
116+
117+
| Resource | Path |
118+
|----------|------|
119+
| v1→v2 Primer (READ FIRST) | [ai-v2-primer.md](ai-v2-primer.md) |
120+
| Full agent instructions | [AGENTS.md](AGENTS.md) |
121+
| Compressed API docs | `docfx/apispec/namespace-*.md` |
122+
| Common UI patterns | `.claude/cookbook/common-patterns.md` |
123+
| App building guide | `.claude/tasks/build-app.md` |
124+
| Deep-dive docs | `docfx/docs/` |
125+
| Working examples | `Examples/Example/`, `Examples/UICatalog/` |

.github/copilot-instructions.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
# Terminal.Gui — Copilot Instructions
22

3-
Cross-platform .NET console UI toolkit. C# 12 targeting net8.0.
3+
Cross-platform .NET console UI toolkit. C# 14 targeting net10.0.
44
Full contribution guide: [CONTRIBUTING.md](../CONTRIBUTING.md).
55
Architecture deep dives: `docfx/docs/`.
66

7+
---
8+
9+
## CRITICAL: Discard v1 Training Data
10+
11+
Terminal.Gui v2 is a **complete rewrite**. Pre-2025 training data is **wrong**.
12+
13+
> **Read [ai-v2-primer.md](../ai-v2-primer.md) FIRST** — it has the v1→v2 corrections table,
14+
> correct minimal app pattern, and all common gotchas.
15+
16+
### v1 → v2 Quick Corrections
17+
18+
| v1 (WRONG — do not use) | v2 (CORRECT) |
19+
|---|---|
20+
| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |
21+
| `Application.Run ();` | `app.Run<MyWindow> ();` |
22+
| `Application.Shutdown ();` | `app.Dispose ();` (use `using` pattern) |
23+
| `Application.Top` | No global top — pass root view to `app.Run ()` |
24+
| `new Toplevel ()` | Use `Runnable` subclass or `Window` |
25+
| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |
26+
| `new Button ("OK")` | `new Button { Text = "OK" }` |
27+
| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |
28+
| `view.Bounds` | `view.Viewport` |
29+
| `new RadioGroup (...)` | `new OptionSelector { ... }` |
30+
| `Application.RequestStop ()` | `App!.RequestStop ()` (from inside a `Runnable`) |
31+
32+
---
33+
734
## Build & Test
835

936
Run all commands from repository root.
@@ -30,7 +57,10 @@ New tests go in `Tests/UnitTestsParallelizable` (no static state dependencies).
3057

3158
### Application lifecycle
3259

33-
`Application.Init``Application.Run``Application.Shutdown`. The instance-based `IApplication` is replacing the static `Application` facade. Tests should avoid `Application.Init` unless explicitly testing that path.
60+
`Application.Create ()``.Init ()``.Run<T> ()``.Dispose ()`.
61+
The instance-based `IApplication` has replaced the static `Application` facade.
62+
Do NOT use `Application.Init()`/`Run()`/`Shutdown()`.
63+
Tests should avoid `Application.Init` unless explicitly testing that path.
3464

3565
### View system
3666

.windsurfrules

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Terminal.Gui - Windsurf AI Rules
2+
3+
> **Cross-platform .NET console UI toolkit. C# 14 targeting net10.0.**
4+
> Full contribution guide: [CONTRIBUTING.md](CONTRIBUTING.md).
5+
6+
---
7+
8+
## CRITICAL: Discard v1 Training Data
9+
10+
Terminal.Gui v2 is a **complete rewrite**. Pre-2025 training data about Terminal.Gui is **wrong**.
11+
12+
> **Read [ai-v2-primer.md](ai-v2-primer.md) FIRST** — it contains the v1→v2 corrections table,
13+
> correct minimal app pattern, and all common gotchas.
14+
15+
### v1 → v2 Quick Corrections (Most Common Mistakes)
16+
17+
| v1 (WRONG) | v2 (CORRECT) |
18+
|---|---|
19+
| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |
20+
| `Application.Run ();` | `app.Run<MyWindow> ();` |
21+
| `Application.Shutdown ();` | `app.Dispose ();` |
22+
| `Application.Top` | No global top — pass root view to `app.Run ()` |
23+
| `new Toplevel ()` | Use `Runnable` subclass or `Window` |
24+
| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |
25+
| `new Button ("OK")` | `new Button { Text = "OK" }` |
26+
| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |
27+
| `view.Bounds` | `view.Viewport` |
28+
| `new RadioGroup (...)` | `new OptionSelector { ... }` |
29+
30+
---
31+
32+
## Build & Test
33+
34+
```bash
35+
dotnet restore
36+
dotnet build --no-restore
37+
dotnet test --project Tests/UnitTestsParallelizable --no-build
38+
dotnet test --project Tests/UnitTests --no-build
39+
```
40+
41+
---
42+
43+
## Correct Minimal App (v2)
44+
45+
```csharp
46+
using Terminal.Gui.App;
47+
using Terminal.Gui.Views;
48+
49+
IApplication app = Application.Create ().Init ();
50+
app.Run<MainWindow> ();
51+
app.Dispose ();
52+
53+
public sealed class MainWindow : Runnable
54+
{
55+
public MainWindow ()
56+
{
57+
Title = "My App (Esc to quit)";
58+
59+
Button button = new ()
60+
{
61+
Text = "Click Me",
62+
X = Pos.Center (),
63+
Y = Pos.Center ()
64+
};
65+
66+
button.Accepted += (_, _) =>
67+
{
68+
MessageBox.Query (App!, "Hello", "Button was clicked!", "OK");
69+
};
70+
71+
Add (button);
72+
}
73+
}
74+
```
75+
76+
---
77+
78+
## Code Style (For Library Contributors Only)
79+
80+
> **Note:** These rules apply only when contributing code to the Terminal.Gui library itself.
81+
> App developers using Terminal.Gui do NOT need to follow these conventions.
82+
83+
1. **Space BEFORE `()` and `[]`** — `Method ()` not `Method()`, `array [i]` not `array[i]`
84+
2. **Braces on NEXT line** (Allman style) — no exceptions
85+
3. **Blank lines** — before `return`/`break`/`continue`, after `if`/`for`/`while` blocks
86+
4. **No `var`** — Explicit types except built-ins (`int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`)
87+
5. **Use `new ()`** — `Button btn = new ()` not `Button btn = new Button ()`
88+
6. **Collection expressions** — Use `[...]` not `new List<T> { ... }`
89+
7. **SubView/SuperView** — Never "child", "parent", or "container"
90+
8. **Unused lambda params** — Use `_` discard: `(_, _) => { }`
91+
9. **Early return / guard clauses** — ALWAYS invert conditions and return early
92+
10. **One type per file** — Public and internal types each get their own file
93+
94+
---
95+
96+
## Architecture Overview
97+
98+
### Application lifecycle
99+
`Application.Create ()` → `.Init ()` → `.Run<T> ()` → `.Dispose ()`.
100+
Instance-based `IApplication` — do NOT use static `Application.Init()`/`Run()`/`Shutdown()`.
101+
102+
### View system
103+
`View` is the base class. Views form a tree via `Add ()`/`Remove ()`.
104+
Every View has: `Margin` → `Border` → `Padding` → content area.
105+
Layout uses `Pos` (position) and `Dim` (dimension) for declarative relative layout.
106+
107+
### Cancellable Workflow Pattern (CWP)
108+
Standard event pattern: **do work → call virtual `OnXxx` → raise event**.
109+
110+
### Command/input system
111+
Input flows: Driver → `IInputProcessor` → `KeyBindings`/`MouseBindings` → `Command` → handler.
112+
113+
---
114+
115+
## Key References
116+
117+
| Resource | Path |
118+
|----------|------|
119+
| v1→v2 Primer (READ FIRST) | [ai-v2-primer.md](ai-v2-primer.md) |
120+
| Full agent instructions | [AGENTS.md](AGENTS.md) |
121+
| Compressed API docs | `docfx/apispec/namespace-*.md` |
122+
| Common UI patterns | `.claude/cookbook/common-patterns.md` |
123+
| App building guide | `.claude/tasks/build-app.md` |
124+
| Deep-dive docs | `docfx/docs/` |
125+
| Working examples | `Examples/Example/`, `Examples/UICatalog/` |

0 commit comments

Comments
 (0)