Skip to content

Commit f8223b7

Browse files
authored
Merge branch 'gui-cs:v2_develop' into v2_develop
2 parents d2c8693 + cb381bd commit f8223b7

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

copilot-instructions.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Terminal.Gui - GitHub Copilot Instructions
2+
3+
This file provides instructions for GitHub Copilot when working with the Terminal.Gui project.
4+
5+
## Project Overview
6+
7+
**Terminal.Gui** is a cross-platform UI toolkit for creating console-based graphical user interfaces in .NET. It provides a comprehensive framework for building interactive console applications with support for keyboard and mouse input, customizable views, and a robust event system. The toolkit works across Windows, macOS, and Linux, leveraging platform-specific console capabilities where available.
8+
9+
**Key characteristics:**
10+
- Cross-platform terminal/console UI framework for .NET
11+
- Supports Windows, macOS, and Linux
12+
- Rich GUI controls (buttons, dialogs, menus, text boxes, etc.)
13+
- Keyboard-first design with full mouse support
14+
- Follows Microsoft .NET Framework Design Guidelines, with some tweaks.
15+
- v2 is currently in Alpha with stable core API (v1 is in maintenance mode)
16+
17+
## Documentation
18+
19+
- Full documentation: [gui-cs.github.io/Terminal.Gui](https://gui-cs.github.io/Terminal.Gui)
20+
- API Reference: [API Documentation](https://gui-cs.github.io/Terminal.Gui/api/Terminal.Gui.App.html)
21+
- Getting Started: [Getting Started Guide](https://gui-cs.github.io/Terminal.Gui/docs/getting-started)
22+
23+
## Repository Structure
24+
25+
- `/Terminal.Gui/` - Core library source code
26+
- `App/` - Core application logic, `Application.cs` (static class managing `RunState` and `MainLoop`)
27+
- `Configuration/` - `ConfigurationManager` for application settings
28+
- `Drivers/` - Console driver implementations (`IConsoleDriver.cs`, `NetDriver`, `UnixDriver`, `WindowsDriver`)
29+
- `Drawing/` - Rendering graphical elements in the console
30+
- `Input/` - Keyboard and mouse input handling
31+
- `View/` - Core `View` class hierarchy
32+
- `Views/` - Specific sub-classes of `View` (Toplevel, Window, Dialog, etc.)
33+
- `/Examples/` - Sample applications and demos
34+
- `/Examples/UICatalog/` - Comprehensive demo app for manual testing
35+
- `/Tests/` - Unit and integration tests
36+
- `/docfx/` - Documentation source files (Deep Dive Articles and API docs)
37+
- `/Scripts/` - Build and utility scripts
38+
39+
## Branching Model
40+
41+
**Terminal.Gui uses GitFlow:**
42+
- `v2_develop` - Default branch for v2 development (active development)
43+
- `v2_release` - Stable release branches matching NuGet packages
44+
45+
## Code Style and Standards
46+
47+
### Code Style Tenets
48+
49+
1. **Six-Year-Old Reading Level** - Prioritize readability over terseness. Use clear variable names and comments.
50+
2. **Consistency, Consistency, Consistency** - Follow established patterns ruthlessly.
51+
3. **Don't be Weird** - Follow Microsoft and .NET community conventions.
52+
4. **Set and Forget** - Use ReSharper/Rider for automated formatting.
53+
5. **Documentation is the Spec** - API documentation is the source of truth.
54+
55+
### Coding Conventions
56+
57+
- Based on [Microsoft C# Coding Conventions](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions)
58+
- Project settings defined and enforced via `./Terminal.sln.DotSettings` and `./.editorconfig`
59+
- Use `var` only for the most basic dotnet types - prefer explicit types for clarity
60+
- Use target-typed new
61+
62+
## API Design Guidelines
63+
64+
### Public API Tenets
65+
66+
1. **Stand on the shoulders of giants** - Follow [Microsoft .NET Framework Design Guidelines](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/)
67+
2. **Don't Break Existing Stuff** - Avoid breaking changes; find compatible ways to add features
68+
3. **Fail-fast** - Prefer early failure to expose bugs sooner
69+
4. **Standards Reduce Complexity** - Use standard .NET idioms, tweaked to match Terminal.Gui.
70+
71+
### API Documentation Requirements
72+
73+
**All public APIs must have XML documentation:**
74+
- Clear, concise, and complete `<summary>` tags
75+
- Use `<see cref=""/>` liberally for cross-references
76+
- Add `<remarks>` for context and detailed explanations
77+
- Document complex topics in `docfx/articles/*.md` files
78+
- Use proper English and correct grammar
79+
- Provide sample code via `<example>` in cases where a sample is needed (not for very obvious things)
80+
81+
### Events
82+
83+
- Follow the [Events Deep Dive](https://gui-cs.github.io/Terminal.Gui/docs/events.html) documentation
84+
- Use the Cancellable Work Pattern for user-initiated actions
85+
- Use the CWPHelpers if possible
86+
- Name event handlers consistently (e.g., `On[EventName]`), following dotnet guidelines.
87+
88+
## User Experience Tenets
89+
90+
1. **Honor What's Come Before** - Follow established Mac/Windows GUI idioms (e.g., `Ctrl-C` for copy)
91+
2. **Consistency Matters** - Common UI patterns should be consistent (e.g., `Ctrl-Q` quits modals)
92+
3. **Honor the OS, but Work Everywhere** - Take advantage of platform capabilities while maintaining cross-platform support
93+
4. **Keyboard first, Mouse also** - Optimize for keyboard, but ensure everything also works with mouse
94+
95+
## Testing
96+
97+
### Unit Test Requirements
98+
99+
- **Never decrease code coverage** - Aim for 70%+ coverage on new code
100+
- Write unit tests for all new functionality
101+
- Follow existing test patterns in `/Tests/`
102+
- Many existing unit tests are obtuse and not really unit tests. Anytime new tests are added or updated, strive to refactor the tests into more granular tests where each test covers the smallest area possible.
103+
- Many existing unit tests in the `./Tests/UnitTests` project incorrectly require `Application.Init` and use `[AutoInitShutdown]`. Anytime new tests are added or updated, strive to remove these dependencies and make the tests parallelizable. This means not taking any dependency on static objects like `Application` and `ConfigurationManager`.
104+
105+
## Pull Request Checklist
106+
107+
Before submitting a PR, ensure:
108+
- [ ] PR title: "Fixes #issue. Terse description."
109+
- [ ] Code follows style guidelines (`.editorconfig`)
110+
- [ ] Code follows design guidelines (`CONTRIBUTING.md`)
111+
- [ ] Ran `dotnet test` and all tests pass
112+
- [ ] Added/updated XML API documentation (`///` comments)
113+
- [ ] No new warnings generated
114+
- [ ] Checked for grammar/spelling errors
115+
- [ ] Conducted basic QA testing
116+
- [ ] Added/updated UICatalog scenario if applicable
117+
118+
## Building and Running
119+
120+
### Build the Solution
121+
```powershell
122+
dotnet build
123+
```
124+
125+
### Run Tests
126+
```powershell
127+
dotnet test
128+
```
129+
130+
## Key Concepts
131+
132+
`./docfx/docs` contains a set of architectural and key-concept deep-dives.
133+
134+
## Additional Guidelines
135+
1. Maintain existing code structure and organization unless explicitly told
136+
2. View sub-classes must not use private APIs
137+
3. Suggest changes to the `./docfx/docs/` folder when appropriate

0 commit comments

Comments
 (0)