mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-02-10 04:03:41 +01:00
b43390a07089d2ed7d61fbfbc48975841368273f
DimAuto for less coupling and improves performance (#4678)
* 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>
Fixes #4332 - Refactor test infrastructure to use modern ApplicationImpl.Coordinator instead of legacy MainLoop (#4335)
#4329—Major Terminal.Gui v2 Architecture Modernization: Application Decoupling, Terminology Improvements, and Nullable Migration (#4338)
Terminal.Gui v2
Cross-platform UI toolkit for building sophisticated terminal UI (TUI) applications on Windows, macOS, and Linux/Unix.
Important:
- v1 is in maintenance mode - only critical bug fixes accepted
- v2 Alpha is recommended for new projects - API is stable with comprehensive features
- Breaking changes possible before Beta, but core architecture is solid
Quick Start
Install the Terminal.Gui.Templates, create a new TUI app, and run it:
dotnet new install Terminal.Gui.Templates@2.0.0-alpha.*
dotnet new tui-simple -n myproj
cd myproj
dotnet run
Run the comprehensive UI Catalog demo to explore all controls:
dotnet run --project Examples/UICatalog/UICatalog.csproj
Simple Example
using Terminal.Gui.App;
using Terminal.Gui.ViewBase;
using Terminal.Gui.Views;
using IApplication app = Application.Create ();
app.Init ();
using Window window = new () { Title = "Hello World (Esc to quit)" };
Label label = new ()
{
Text = "Hello, Terminal.Gui v2!",
X = Pos.Center (),
Y = Pos.Center ()
};
window.Add (label);
app.Run (window);
See the Examples directory for more.
Build Powerful Terminal Applications
Terminal.Gui enables building sophisticated console applications with modern UIs:
- Rich Forms and Dialogs - Text fields, buttons, checkboxes, radio buttons, and data validation
- Interactive Data Views - Tables, lists, and trees with sorting, filtering, and in-place editing
- Visualizations - Charts, graphs, progress indicators, and color pickers with TrueColor support
- Text Editors - Full-featured text editing with clipboard, undo/redo, and Unicode support
- File Management - File and directory browsers with search and filtering
- Wizards and Multi-Step Processes - Guided workflows with navigation and validation
- System Monitoring Tools - Real-time dashboards with scrollable, resizable views
- Configuration UIs - Settings editors with persistent themes and user preferences
- Cross-Platform CLI Tools - Consistent experience on Windows, macOS, and Linux
- Server Management Interfaces - SSH-compatible UIs for remote administration
See the Views Overview for available controls and What's New in v2 for architectural improvements.
Documentation
Comprehensive documentation is at gui-cs.github.io/Terminal.Gui.
Getting Started
- Getting Started Guide - First Terminal.Gui application
- API Reference - Complete API documentation
- What's New in v2 - New features and improvements
Migration & Deep Dives
- Migrating from v1 to v2 - Complete migration guide
- Application Architecture - Instance-based model and IRunnable pattern
- Layout System - Positioning, sizing, and adornments
- Keyboard Handling - Key bindings and commands
- View Documentation - View hierarchy and lifecycle
- Configuration - Themes and persistent settings
See the documentation index for all topics.
Installing
v2 Alpha (Recommended)
dotnet add package Terminal.Gui --version "2.0.0-alpha.*"
v2 Develop (Latest)
dotnet add package Terminal.Gui --version "2.0.0-develop.*"
Or use the Terminal.Gui.Templates:
dotnet new install Terminal.Gui.Templates@2.0.0-alpha.*
v1 Legacy
dotnet add package Terminal.Gui --version "1.*"
Contributing
Contributions welcome! See CONTRIBUTING.md.
History
See gui-cs for project history and origins.
Languages
C#
99.1%
PowerShell
0.9%

