* Phase 5: Add IsFixed and RequiresTargetLayout categorization properties Co-authored-by: tig <585482+tig@users.noreply.github.com> * Further simplify DimAuto.Calculate using IsFixed property Co-authored-by: tig <585482+tig@users.noreply.github.com> * Refactor for-loops to foreach and clarify DimFill logic Refactored multiple for-loops iterating over view lists to use foreach loops for improved readability and reduced boilerplate. Removed unused variables such as viewsNeedingLayout and index counters. Clarified DimFill handling by continuing early if the DimFill is not valid or lacks a To property, reducing nesting and improving intent. Made minor formatting and code style improvements for consistency. * Refactor subview filtering and sizing logic Refactored repeated LINQ queries for subview filtering into reusable helper methods (`GetViewsThatMatch`, `GetViewsThatHavePos<TPos>`, `GetViewsThatHaveDim<TDim>`), reducing duplication and improving readability. Moved max content size calculations for various subview types into new helper methods (`GetMaxSizePos<TPos>`, `GetMaxSizeDim<TDim>`). Updated main logic to use these helpers. Adornment thickness calculation now uses a switch expression. These changes improve modularity and maintainability. * Refactor subview categorization for layout calculation Refactored layout calculation to use a single-pass CategorizeSubViews method, grouping subviews by relevant Pos/Dim types into a new CategorizedViews struct. This replaces multiple helper methods and reduces redundant iterations. Updated main logic to use these categorized lists, and unified size calculation helpers to further reduce code duplication. Improves performance and maintainability by consolidating subview processing and removing obsolete methods. * Revert perf POC commits and add missing overrides to Combine types Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add helper methods and simplify DimAuto.Calculate with foreach loops Co-authored-by: tig <585482+tig@users.noreply.github.com> * Refactor layout calculation in DimAuto.cs Removed commented-out code and unnecessary list declarations to clean up the layout calculation logic. * removed old plan file * Code cleanup * Add performance analysis and improvement plan for DimAuto.Calculate Co-authored-by: tig <585482+tig@users.noreply.github.com> * Add DimAuto benchmarks and benchmark documentation Co-authored-by: tig <585482+tig@users.noreply.github.com> * Implement Phase 1 & 2 performance optimizations for DimAuto.Calculate Co-authored-by: tig <585482+tig@users.noreply.github.com> * Code cleanup * Delete plans/dimauto-perf-plan.md --------- 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: Tig <tig@users.noreply.github.com>
This folder generates the API docs for Terminal.Gui.
The API documentation is generated via a GitHub Action (.github/workflows/api-docs.yml) using DocFX.
To Generate the Docs Locally
- Install DocFX: https://dotnet.github.io/docfx/tutorial/docfx_getting_started.html
- Run
./docfx/scripts/build.ps1 - Browse to http://localhost:8080 and verify everything looks good.
- Hit Ctrl-C to stop the script.
To Update views.md
- Switch to the
./docfxfolder - Run
./scripts/generate-views-doc.ps1 - Commit the changes to
docs/views.md
API Documentation Overview
The API documentation for Terminal.Gui is a critical resource for developers, providing detailed information on classes, methods, properties, and events within the library. This documentation is hosted at gui-cs.github.io/Terminal.Gui and includes both auto-generated API references and conceptual guides. For a broader overview of the Terminal.Gui project, including project structure and contribution guidelines, refer to the main Terminal.Gui README.
Scripts for Documentation Generation
The scripts folder contains PowerShell scripts to assist in generating and updating documentation:
-
Build.ps1: Main build script that generates the documentation site locally. Running this script with DocFX installed will:- Generate the AI agent source index (see below)
- Build the documentation site at
http://localhost:8080
-
Generate-SourceIndex.ps1: Generates Vercel-style file path indices for AI agent retrieval-led reasoning. This script:- Scans
./Terminal.Gui/for.cssource files, grouped by directory - Scans
./docfx/docs/for.mddocumentation files - Outputs to
.tg-docs/INDEX.md - Injects the source index into
AGENTS.mdbetween markers
- Scans
-
generate-views-doc.ps1: Updates theviews.mdfile in thedocsdirectory. This script automates the process of documenting the various view classes in Terminal.Gui. -
OutputView/: Directory for storing intermediate files related to the documentation generation process.
These scripts streamline the process of maintaining up-to-date documentation, ensuring that contributors can easily generate and verify documentation changes locally before committing them.
AI Agent Source Index
The Generate-SourceIndex.ps1 script creates a file path index using the Vercel-style format for AI agent "retrieval-led reasoning". This approach is inspired by Vercel's work on optimizing LLM context for large codebases.
Background
This implementation is based on Vercel's blog post: How we compressed our JS SDK documentation by 80%
The key insight is that instead of embedding full descriptions in the context (which can become stale), we point AI agents to actual source files. The agents then read the files they need using "retrieval-led reasoning" rather than relying on "pre-training-led reasoning" from potentially outdated embedded content.
Format
[Index Name]|root: ./path/to/root
|IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning. Read files when needed.
|directory:{file1.cs,file2.cs,...}
|subdirectory:{file3.cs,file4.cs,...}
Files Generated
| File | Description |
|---|---|
.tg-docs/INDEX.md |
Complete auto-generated index with both source and docs indices |
AGENTS.md |
Source index injected between <!-- BEGIN AUTO-GENERATED-SOURCE-INDEX --> and <!-- END AUTO-GENERATED-SOURCE-INDEX --> markers |
Benefits
- Always in sync - Index is regenerated on every build
- No manual maintenance - File paths are discovered automatically
- Retrieval-led - AI reads actual files, not stale summaries
- ~80% smaller - File paths only, no embedded content