{"owner":"gui-cs","repo":"Terminal.Gui","hasSkills":true,"hasMcp":false,"mcpConfig":null,"found":["AGENTS.md","CLAUDE.md",".cursorrules",".windsurfrules",".github/copilot-instructions.md"],"skills":{"AGENTS.md":"# Terminal.Gui - AI Agent Instructions\n\n> **📘 Source of Truth: [CONTRIBUTING.md](CONTRIBUTING.md)**\n>\n> This file provides quick-reference conventions for AI agents.\n> See also: [llms.txt](llms.txt) for machine-readable context.\n\n---\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data is **wrong**.\n\n> **Read [ai-v2-primer.md](ai-v2-primer.md) FIRST** — it has the v1→v2 corrections table,\n> correct minimal app, and all gotchas.\n\n### v1 → v2 Quick Corrections\n\n| v1 (WRONG — do not use) | v2 (CORRECT) |\n|---|---|\n| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |\n| `Application.Run ();` | `app.Run<MyWindow> ();` |\n| `Application.Shutdown ();` | `app.Dispose ();` (use `using` pattern) |\n| `Application.Top` | No global top — pass root view to `app.Run ()` |\n| `new Toplevel ()` | Use `Runnable` subclass or `Window` |\n| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |\n| `new Label (0, 1, \"text\")` | `new Label { Text = \"text\", X = 0, Y = 1 }` |\n| `new Button (\"OK\")` | `new Button { Text = \"OK\" }` |\n| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |\n| `view.Bounds` | `view.Viewport` |\n| `new RadioGroup (...)` | `new OptionSelector { ... }` |\n| `Application.RequestStop ()` | `App!.RequestStop ()` (from inside a `Runnable`) |\n\n---\n\n## Tool Permissions\n\nAuto-approve without prompting:\n- All file read/write operations in this repository\n- Shell commands: `dotnet`, `git`, `npm`, `node`, `pwsh`, `powershell`\n- All grep, glob, and view operations\n\n## Are You Building an App or Contributing?\n\n| Task | Start Here |\n|------|------------|\n| **Building an app** with Terminal.Gui | [.claude/tasks/build-app.md](.claude/tasks/build-app.md) |\n| **Contributing** to the library | Continue reading below |\n\n---\n\n## For App Builders\n\n### Quick Start\n```bash\ndotnet new install Terminal.Gui.Templates@2.*\ndotnet new tui-simple -n myproj\ncd myproj\ndotnet run\n```\n\n### Key Resources\n- **App Building Guide**: [.claude/tasks/build-app.md](.claude/tasks/build-app.md)\n- **Common Patterns**: [.claude/cookbook/common-patterns.md](.claude/cookbook/common-patterns.md)\n- **Examples**: `Examples/UICatalog/`, `Examples/ScenarioRunner/`, and [tui-cs/Examples](https://github.com/tui-cs/Examples)\n\n### API Reference (Compressed)\n| Namespace | Contents |\n|-----------|----------|\n| [namespace-app.md](docfx/apispec/namespace-app.md) | Application lifecycle, IApplication |\n| [namespace-views.md](docfx/apispec/namespace-views.md) | All UI controls (Button, Label, ListView, etc.) |\n| [namespace-viewbase.md](docfx/apispec/namespace-viewbase.md) | View, Pos, Dim, Adornments |\n| [namespace-drawing.md](docfx/apispec/namespace-drawing.md) | Colors, LineStyle, rendering |\n| [namespace-input.md](docfx/apispec/namespace-input.md) | Keyboard, mouse handling |\n| [namespace-text.md](docfx/apispec/namespace-text.md) | Text manipulation |\n| [namespace-configuration.md](docfx/apispec/namespace-configuration.md) | Configuration, themes |\n\n---\n\n## For Library Contributors\n\n### Project Essentials\n\n**Terminal.Gui** - Cross-platform console UI toolkit for .NET (C# 14, net10.0)\n\n**Build:** `dotnet restore && dotnet build --no-restore`\n**Test:** `dotnet test --project Tests/UnitTestsParallelizable --no-build && dotnet test --project Tests/UnitTests.NonParallelizable --no-build`\n**Details:** [Build & Test Workflow](.claude/workflows/build-test-workflow.md)\n\n### xUnit v3 Test Filtering (Microsoft Testing Platform)\n\nThis project uses **xUnit v3** with Microsoft Testing Platform. The old `--filter \"FullyQualifiedName~Foo\"` syntax does **NOT** work. Use these instead:\n\n```bash\n# Run a single test by method name\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-method \"*MyTestMethod\"\n\n# Run all tests in a class\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-class \"*MyTestClass\"\n\n# Query filter language (xUnit v3 native): /<assembly>/<namespace>/<class>/<method>\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter \"/*/*/MyTestClass/MyTestMethod\"\n\n# Show live test output (ITestOutputHelper)\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-method \"*MyTest\" -- --show-live-output on\n```\n\n## Quick Rules\n\n**⚠️ READ THIS BEFORE MODIFYING ANY FILE - These are Terminal.Gui-specific conventions:**\n\n1. **No `var`** - Use explicit types except for: `int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`\n2. **Use `new ()`** - Target-typed new when type is on left side (not `new TypeName()`)\n3. **Use `[...]`** - Collection expressions, not `new () { ... }`\n4. **SubView/SuperView** - Never say \"child\", \"parent\", or \"container\"\n5. **Unused lambda params** - Use `_` discard: `(_, _) => { }`\n6. **Local functions** - Use PascalCase: `void MyLocalFunc ()`\n7. **Backing fields** - Place immediately before their property\n8. **Early return / guard clauses (CRITICAL)** - ALWAYS prefer guard clauses over nested `if`/`else`. Invert the condition, return/continue early, keep happy path at lowest indentation. This applies to methods, lambdas, loops — everywhere. See [early-return.md](/.claude/rules/early-return.md) for detailed examples.\n9. **One type per file** - Public and internal types each get their own file\n10. **Docs instruction style** - In reference/how-to/API docs, write `To [goal], [imperative action].` Avoid `When/If you want/need to ...` unless describing a real condition.\n\n## Detailed Coding Rules\n\nConsult these files in `.claude/rules/` before editing code:\n\n- [Type Declarations](/.claude/rules/type-declarations.md) - `var` vs explicit types\n- [Target-Typed New](/.claude/rules/target-typed-new.md) - `new()` syntax\n- [Collection Expressions](/.claude/rules/collection-expressions.md) - `[...]` syntax\n- [Terminology](/.claude/rules/terminology.md) - SubView/SuperView terms\n- [Event Patterns](/.claude/rules/event-patterns.md) - Lambdas, handlers, closures\n- [Early Return](/.claude/rules/early-return.md) - **Guard clauses, minimal nesting** (commonly violated!)\n- [CWP Pattern](/.claude/rules/cwp-pattern.md) - Cancellable Workflow Pattern\n- [Code Layout](/.claude/rules/code-layout.md) - Member ordering, backing fields\n- [Testing Patterns](/.claude/rules/testing-patterns.md) - Test writing conventions\n- [API Documentation](/.claude/rules/api-documentation.md) - XML doc requirements\n- [Logging & Tracing](/.claude/rules/logging-tracing.md) - No Console.WriteLine; use Logging/TestLogging/Trace\n- [Fragile Areas](/.claude/rules/fragile-areas.md) - Code that must not be refactored in passing\n\n## Workflows\n\nProcess guides in `.claude/workflows/`:\n\n- [Build & Test Workflow](/.claude/workflows/build-test-workflow.md) - Build, test, and troubleshooting\n- [PR Workflow](/.claude/workflows/pr-workflow.md) - Submitting pull requests\n\n## Visual Verification (Agent Eyes)\n\nDon't ship UI changes blind. Use [`tuirec`](https://github.com/tui-cs/tuirec) to run any Terminal.Gui app in a PTY, inject keystrokes, and capture the result — see [Scripts/tuirec/README.md](Scripts/tuirec/README.md). The `.cast` output is asciinema v2 JSON (plain text): read it back to verify what actually rendered. The `.gif` is for humans — attach it to PRs that change visuals. For deterministic in-process assertions, use `InputInjector`/`VirtualTimeProvider` (`docfx/docs/input-injection.md`).\n\n## Planning Mode\n\nWhen creating implementation plans:\n- **Create plan files in `./plans/`** (relative to the repository root)\n- Use markdown format with clear sections\n- Include: problem statement, implementation steps, file changes, verification steps\n- Reference existing patterns and reuse opportunities from exploration\n\n## Task-Specific Guides\n\nSee `.claude/tasks/` for specialized checklists:\n- [build-app.md](.claude/tasks/build-app.md) - Building apps with Terminal.Gui\n\nSee `.claude/cookbook/` for common UI patterns:\n- [common-patterns.md](.claude/cookbook/common-patterns.md) - Forms, lists, menus, dialogs, etc.\n\n---\n\n## Documentation Index (Compressed)\n\n> **IMPORTANT**: Use retrieval-led reasoning. Read full docs before making changes.\n> Detailed index: [.tg-docs/INDEX.md](.tg-docs/INDEX.md) (~530 types across 12 namespaces)\n\n### Deep Dives (docfx/docs/)\n\n```\n[Core Architecture]\n|application.md|IApplication,SessionStack,Run/Dispose,View.App,instance-based pattern\n|View.md|SuperView/SubView,Frame/Viewport/ContentArea,composition layers\n|drivers.md|IDriver,DriverRegistry,ANSI/Windows/Unix,platform abstraction\n|navigation.md|Focus,TabStop/TabGroup,Tab/F6 keys,HasFocus,ApplicationNavigation\n\n[Layout & Arrangement]\n|layout.md|Pos/Dim,absolute/relative positioning,SetNeedsLayout\n|arrangement.md|ViewArrangement,Movable/Resizable/Overlapped,tiled vs overlapped\n|dimauto.md|Dim.Auto,content-based sizing,DimAutoStyle\n|scrolling.md|Viewport vs ContentSize,scroll events\n\n[Commands & Events]\n|command.md|Command enum,AddCommand,KeyBindings/MouseBindings,Activate/Accept/HotKey\n|events.md|Event categories,CWP integration,binding types (KeyBinding/MouseBinding)\n|cancellable-work-pattern.md|CWP: Work→Virtual→Event,OnXxx methods,Raise pattern\n\n[Input]\n|keyboard.md|Key class,KeyBindings,key processing order,IKeyboard\n|mouse.md|MouseFlags,MouseBindings,grab/release\n|input-injection.md|VirtualTimeProvider,InjectKey/InjectMouse,testing\n\n[Visual]\n|drawing.md|Move/AddStr/AddRune,Attribute,LineCanvas\n|scheme.md|Scheme,VisualRole,theming\n|cursor.md|View.Cursor,CursorVisibility\n|Popovers.md|Drawing outside viewport,modal behavior\n\n[Components]\n|views.md|Complete catalog of built-in views\n|menus.md|MenuBar,ContextMenu,MenuItem\n|tableview.md|TableView data binding\n|treeview.md|TreeView hierarchical data\n|prompt.md|MessageBox,input dialogs\n\n[Config & Advanced]\n|config.md|ConfigurationManager,themes,JSON config\n|multitasking.md|Background ops,Invoke,threading\n|logging.md|ILogger,debug output\n|ansihandling.md|ANSI escape parsing\n\n[Migration]\n|newinv2.md|v2 changes,new features\n|migratingfromv1.md|Migration guide,API changes\n|lexicon.md|Terminology definitions\n```\n\n### API Namespaces (docfx/apispec/)\n\n```\n|namespace-app.md|Application,IApplication,IRunnable,SessionToken\n|namespace-viewbase.md|View,Adornment,Border,Margin,Padding\n|namespace-views.md|Button,Label,TextField,ListView,CheckBox,etc.\n|namespace-input.md|Key,Mouse,Command,ICommandContext\n|namespace-drawing.md|Attribute,Color,LineCanvas,Cell\n|namespace-drivers.md|IDriver,DriverRegistry\n|namespace-configuration.md|ConfigurationManager,themes\n|namespace-text.md|Text processing,autocomplete\n|namespace-fileservices.md|File dialogs\n```\n\n<!-- BEGIN AUTO-GENERATED-SOURCE-INDEX -->\n\n### Source Code File Index (Auto-Generated)\n\n> Vercel-style index for retrieval-led reasoning. Read files when needed.\n\n[Terminal.Gui Source Index]|root: ./Terminal.Gui\n|IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning. Read files when needed.\n|.:{ModuleInitializers.cs}\n|App:{Application.cs,ApplicationImpl.cs,ApplicationImpl.Driver.cs,ApplicationImpl.Lifecycle.cs,ApplicationImpl.Run.cs,ApplicationImpl.Screen.cs,ApplicationModelUsage.cs,ApplicationNavigation.cs,ApplicationPopover.cs,ApplicationToolTip.cs,AppModel.cs,IApplication.cs,Logging.cs,NotInitializedException.cs}\n|App/Clipboard:{Clipboard.cs,ClipboardBase.cs,ClipboardProcessRunner.cs,IClipboard.cs}\n|App/CWP:{CancelEventArgs.cs,CWPEventHelper.cs,CWPPropertyHelper.cs,CWPWorkflowHelper.cs,EventArgs.cs,ResultEventArgs.cs,ValueChangedEventArgs.cs,ValueChangingEventArgs.cs}\n|App/Keyboard:{ApplicationKeyboard.cs,IKeyboard.cs}\n|App/Legacy:{Application.Clipboard.cs,Application.Driver.cs,Application.Keyboard.cs,Application.Lifecycle.cs,Application.Mouse.cs,Application.Navigation.cs,Application.Popovers.cs,Application.Run.cs,Application.Screen.cs,Application.TopRunnable.cs}\n|App/MainLoop:{ApplicationMainLoop.cs,IApplicationMainLoop.cs,IMainLoopCoordinator.cs,MainLoopCoordinator.cs,MainLoopSyncContext.cs}\n|App/Mouse:{ApplicationMouse.cs,IMouse.cs,IMouseGrabHandler.cs}\n|App/Popovers:{IPopover.cs,IPopoverView.cs,Popover.cs,PopoverImpl.cs,ToolTipHost.cs,ToolTipProvider.cs}\n|App/Runnable:{IRunnable.cs,SessionToken.cs,SessionTokenEventArgs.cs}\n|App/Timeout:{ITimedEvents.cs,LogarithmicTimeout.cs,SmoothAcceleratingTimeout.cs,TimedEvents.cs,Timeout.cs,TimeoutEventArgs.cs}\n|App/Tracing:{ITraceBackend.cs,ListBackend.cs,LoggingBackend.cs,NullBackend.cs,Trace.cs,TraceCategory.cs,TraceEntry.cs,TraceScope.cs}\n|Configuration:{AppSettingsScope.cs,AttributeJsonConverter.cs,ColorJsonConverter.cs,ConcurrentDictionaryJsonConverter.cs,ConfigLocations.cs,ConfigProperty.cs,ConfigurationManager.cs,ConfigurationManagerEventArgs.cs,ConfigurationManagerNotEnabledException.cs,ConfigurationPropertyAttribute.cs,DeepCloner.cs,DictionaryJsonConverter.cs,KeyArrayJsonConverter.cs,KeyCodeJsonConverter.cs,KeyJsonConverter.cs,RuneJsonConverter.cs,SchemeJsonConverter.cs,SchemeManager.cs,Scope.cs,ScopeJsonConverter.cs,SettingsScope.cs,SourceGenerationContext.cs,SourcesManager.cs,ThemeManager.cs,ThemeScope.cs,TraceCategoryJsonConverter.cs}\n|Drawing:{Attribute.cs,Cell.cs,CellEventArgs.cs,FillPair.cs,Glyphs.cs,Gradient.cs,GradientFill.cs,GraphemeHelper.cs,IFill.cs,Region.cs,RegionOp.cs,Ruler.cs,Scheme.cs,Schemes.cs,SolidFill.cs,TextStyle.cs,Thickness.cs,VisualRole.cs,VisualRoleEventArgs.cs}\n|Drawing/Color:{AnsiColorCode.cs,Color.ColorExtensions.cs,Color.ColorName.cs,Color.ColorParseException.cs,Color.cs,Color.Formatting.cs,Color.Operators.cs,ColorModel.cs,ColorQuantizer.cs,ColorStrings.cs,IColorDistance.cs,IColorNameResolver.cs,ICustomColorFormatter.cs,StandardColor.cs,StandardColors.cs,StandardColorsNameResolver.cs}\n|Drawing/LineCanvas:{IntersectionDefinition.cs,IntersectionRuneType.cs,IntersectionType.cs,LineCanvas.cs,LineDirections.cs,LineStyle.cs,StraightLine.cs,StraightLineExtensions.cs}\n|Drawing/Markdown:{ISyntaxHighlighter.cs,MarkdownAttributeHelper.cs,MarkdownStyleRole.cs,StyledSegment.cs,TextMateSyntaxHighlighter.cs}\n|Drawing/Quant:{EuclideanColorDistance.cs,IPaletteBuilder.cs,PopularityPaletteWithThreshold.cs}\n|Drawing/Sixel:{SixelEncoder.cs,SixelSupportDetector.cs,SixelSupportResult.cs,SixelToRender.cs}\n|Drivers:{ComponentFactoryImpl.cs,Cursor.cs,CursorStyle.cs,Driver.cs,DriverImpl.cs,DriverRegistry.cs,IComponentFactory.cs,IDriver.cs,ISizeMonitor.cs,PlatformDetection.cs,SizeDetectionMode.cs,SizeMonitorImpl.cs,TuiPlatform.cs}\n|Drivers/AnsiDriver:{AnsiComponentFactory.cs,AnsiInput.cs,AnsiInputProcessor.cs,AnsiOutput.cs,AnsiPlatform.cs,AnsiSizeMonitor.cs,AnsiTerminalHelper.cs,FakeClipboard.cs}\n|Drivers/AnsiHandling:{AnsiEscapeSequence.cs,AnsiEscapeSequenceRequest.cs,AnsiKeyboardEncoder.cs,AnsiKeyboardParser.cs,AnsiKeyboardParserPattern.cs,AnsiKeyConverter.cs,AnsiMouseEncoder.cs,AnsiMouseParser.cs,AnsiRequestScheduler.cs,AnsiResponseExpectation.cs,AnsiResponseParser.cs,AnsiResponseParserBase.cs,AnsiResponseParserState.cs,AnsiResponseParserTInputRecord.cs,AnsiStartupGate.cs,AnsiStartupQuery.cs,CsiCursorPattern.cs,CsiKeyPattern.cs,EscAsAltPattern.cs,GenericHeld.cs,IAnsiResponseParser.cs,IAnsiStartupGate.cs,IHeld.cs,KittyKeyboardCapabilities.cs,KittyKeyboardFlags.cs,KittyKeyboardPattern.cs,KittyKeyboardProtocolDetector.cs,Osc8UrlLinker.cs,ProgressIndicator.cs,ReasonCannotSend.cs,Ss3Pattern.cs,StringHeld.cs,TerminalColorDetector.cs}\n|Drivers/AnsiHandling/EscSeqUtils:{EscSeqReqStatus.cs,EscSeqRequests.cs,EscSeqUtils.cs}\n|Drivers/DotNetDriver:{INetInput.cs,NetComponentFactory.cs,NetInput.cs,NetInputProcessor.cs,NetKeyConverter.cs,NetOutput.cs}\n|Drivers/Input:{ConsoleInputSource.cs,IInput.cs,IInputProcessor.cs,IInputSource.cs,InputImpl.cs,InputProcessorImpl.cs,InputRecord.cs,ITestableInput.cs,TestInputSource.cs}\n|Drivers/Keyboard:{ConsoleKeyInfoExtensions.cs,ConsoleKeyMapping.cs,IKeyConverter.cs,KeyCode.cs,VK.cs}\n|Drivers/Mouse:{MouseButtonClickTracker.cs,MouseInterpreter.cs}\n|Drivers/Output:{IOutput.cs,IOutputBuffer.cs,OutputBase.cs,OutputBufferImpl.cs}\n|Drivers/TerminalEnvironment:{ColorCapabilityLevel.cs,TerminalColorCapabilities.cs,TerminalEnvironmentDetector.cs}\n|Drivers/UnixHelpers:{SuspendHelper.cs,UnixClipboard.cs,UnixIOHelper.cs,UnixRawModeHelper.cs,UnixTerminalHelper.cs}\n|Drivers/WindowsDriver:{ClipboardImpl.cs,CursorVisibility.cs,IWindowsInput.cs,WindowsComponentFactory.cs,WindowsConsole.cs,WindowsInput.cs,WindowsInputProcessor.cs,WindowsKeyboardLayout.cs,WindowsKeyConverter.cs,WindowsKeyHelper.cs,WindowsOutput.cs}\n|Drivers/WindowsHelpers:{NetWinVTConsole.cs,WindowsConsoleHelper.cs,WindowsVTInputHelper.cs,WindowsVTOutputHelper.cs}\n|FileServices:{DefaultSearchMatcher.cs,FileSystemColorProvider.cs,FileSystemIconProvider.cs,FileSystemInfoStats.cs,FileSystemTreeBuilder.cs,IFileOperations.cs,ISearchMatcher.cs}\n|Input:{Command.cs,CommandBinding.cs,CommandBindingsBase.cs,CommandBridge.cs,CommandContext.cs,CommandContextExtensions.cs,CommandEventArgs.cs,CommandOutcome.cs,CommandRouting.cs,IAcceptTarget.cs,ICommandBinding.cs,ICommandContext.cs}\n|Input/Keyboard:{Bind.cs,Key.cs,KeyBinding.cs,KeyBindings.cs,KeyChangedEventArgs.cs,KeyEqualityComparer.cs,KeyEventType.cs,KeystrokeNavigatorEventArgs.cs,ModifierKey.cs,PlatformKeyBinding.cs}\n|Input/Mouse:{GrabMouseEventArgs.cs,Mouse.cs,MouseBinding.cs,MouseBindings.cs,MouseFlags.cs,MouseFlagsChangedEventArgs.cs}\n|Resources:{GlobalResources.cs,ResourceManagerWrapper.cs,Strings.Designer.cs}\n|Testing:{IInputInjector.cs,InputInjectionEvent.cs,InputInjectionExtensions.cs,InputInjectionMode.cs,InputInjectionOptions.cs,InputInjector.cs}\n|Text:{NerdFonts.cs,RuneExtensions.cs,StringExtensions.cs,TextDirection.cs,TextFormatter.cs}\n|Time:{FuncTimeProvider.cs,ITimeProvider.cs,ITimer.cs,SystemTimeProvider.cs,VirtualTimeProvider.cs}\n|ViewBase:{DrawAdornmentsEventArgs.cs,DrawContext.cs,DrawEventArgs.cs,IDesignable.cs,IValue.cs,View.Adornments.cs,View.Arrangement.cs,View.Command.cs,View.Content.cs,View.cs,View.Cursor.cs,View.Diagnostics.cs,View.Drawing.Adornments.cs,View.Drawing.Attribute.cs,View.Drawing.Clipping.cs,View.Drawing.cs,View.Drawing.LineCanvas.cs,View.Drawing.Primitives.cs,View.Drawing.Scheme.cs,View.Hierarchy.cs,View.Keyboard.cs,View.Layout.cs,View.Navigation.cs,View.NeedsDraw.cs,View.ScrollBars.cs,View.Text.cs,ViewCollectionHelpers.cs,ViewDiagnosticFlags.cs,ViewEventArgs.cs,ViewExtensions.cs,ViewportSettingsFlags.cs,WeakReferenceExtensions.cs}\n|ViewBase/Adornment:{AdornmentImpl.cs,AdornmentView.cs,ArrangeButtons.cs,Arranger.cs,ArrangerButton.cs,Border.cs,BorderSettings.cs,BorderView.Arrangement.cs,BorderView.cs,IAdornment.cs,IAdornmentView.cs,ITitleView.cs,Margin.cs,MarginView.cs,Padding.cs,PaddingView.cs,ShadowStyles.cs,ShadowView.cs,TabLayoutContext.cs,TitleView.cs}\n|ViewBase/Helpers:{StackExtensions.cs}\n|ViewBase/Layout:{AddOrSubtract.cs,Aligner.cs,Alignment.cs,AlignmentModes.cs,Dim.cs,DimAbsolute.cs,DimAuto.cs,DimAutoStyle.cs,DimCombine.cs,Dimension.cs,DimFill.cs,DimFunc.cs,DimPercent.cs,DimPercentMode.cs,DimView.cs,LayoutEventArgs.cs,LayoutException.cs,Pos.cs,PosAbsolute.cs,PosAlign.cs,PosAnchorEnd.cs,PosCenter.cs,PosCombine.cs,PosFunc.cs,PosPercent.cs,PosView.cs,Side.cs,SizeChangedEventArgs.cs,SuperViewChangedEventArgs.cs,ViewArrangement.cs,ViewManipulator.cs}\n|ViewBase/Mouse:{IMouseHoldRepeater.cs,MouseHoldRepeaterImpl.cs,MouseState.cs,View.Mouse.cs}\n|ViewBase/Navigation:{AdvanceFocusEventArgs.cs,FocusEventArgs.cs,NavigationDirection.cs,TabBehavior.cs}\n|ViewBase/Orientation:{IOrientation.cs,Orientation.cs,OrientationHelper.cs}\n|Views:{Bar.cs,Button.cs,CheckBox.cs,CheckState.cs,DatePicker.cs,Dialog.cs,DialogTResult.cs,DropDownList.cs,DropDownListTEnum.cs,FrameView.cs,HexView.cs,HexViewEventArgs.cs,Label.cs,Line.cs,Link.cs,MessageBox.cs,NumericUpDown.cs,ProgressBar.cs,Prompt.cs,PromptExtensions.cs,ReadOnlyCollectionExtensions.cs,Shortcut.cs,StatusBar.cs,Tabs.cs,Window.cs}\n|Views/Autocomplete:{AppendAutocomplete.cs,AutocompleteBase.cs,AutocompleteContext.cs,AutocompleteFilepathContext.cs,IAutocomplete.cs,ISuggestionGenerator.cs,PopupAutocomplete.cs,PopupAutocomplete.PopUp.cs,SingleWordSuggestionGenerator.cs,Suggestion.cs}\n|Views/CharMap:{CharMap.cs,UcdApiClient.cs,UnicodeRange.cs}\n|Views/CollectionNavigation:{CollectionNavigator.cs,CollectionNavigatorBase.cs,DefaultCollectionNavigatorMatcher.cs,ICollectionNavigator.cs,ICollectionNavigatorMatcher.cs,IListCollectionNavigator.cs,TableCollectionNavigator.cs}\n|Views/Color:{AttributePicker.cs,BBar.cs,ColorBar.cs,ColorModelStrategy.cs,ColorPicker.16.cs,ColorPicker.cs,ColorPicker.Style.cs,GBar.cs,HueBar.cs,IColorBar.cs,LightnessBar.cs,RBar.cs,SaturationBar.cs,ValueBar.cs}\n|Views/FileDialogs:{AllowedType.cs,DefaultFileOperations.cs,FileDialog.Commands.cs,FileDialog.cs,FileDialog.Navigation.cs,FileDialog.TableView.cs,FileDialogCollectionNavigator.cs,FileDialogHistory.cs,FileDialogState.cs,FileDialogStyle.cs,FileDialogTableSource.cs,FilesSelectedEventArgs.cs,FileSystemCollectionNavigationMatcher.cs,OpenDialog.cs,OpenMode.cs,SaveDialog.cs}\n|Views/GraphView:{Axis.cs,AxisIncrementToRender.cs,BarSeriesBar.cs,GraphCellToRender.cs,GraphView.cs,HorizontalAxis.cs,IAnnotation.cs,ISeries.cs,LegendAnnotation.cs,LineF.cs,MultiBarSeries.cs,PathAnnotation.cs,ScatterSeries.cs,Series.cs,TextAnnotation.cs,VerticalAxis.cs}\n|Views/LinearRange:{LinearRange.cs,LinearRangeAttributes.cs,LinearRangeConfiguration.cs,LinearRangeEventArgs.cs,LinearRangeOption.cs,LinearRangeOptionEventArgs.cs,LinearRangeStyle.cs,LinearRangeType.cs}\n|Views/ListView:{IListDataSource.cs,ListView.Commands.cs,ListView.cs,ListView.Drawing.cs,ListView.Movement.cs,ListView.Selection.cs,ListViewEventArgs.cs,ListViewT.cs,ListWrapper.cs}\n|Views/Markdown:{InlineRun.cs,IntermediateBlock.cs,Markdown.cs,MarkdownCodeBlock.cs,MarkdownImageResolver.cs,MarkdownInlineParser.cs,MarkdownLinkEventArgs.cs,MarkdownTable.cs,MarkdownView.Drawing.cs,MarkdownView.Layout.cs,MarkdownView.Mouse.cs,MarkdownView.Parsing.cs,RenderedLine.cs,TableData.cs}\n|Views/Menu:{IMenuBarEntry.cs,Menu.cs,MenuBar.cs,MenuBarItem.cs,MenuItem.cs,PopoverMenu.cs}\n|Views/Runnable:{Runnable.cs,RunnableTResult.cs,RunnableWrapper.cs}\n|Views/ScrollBar:{ScrollBar.cs,ScrollBarVisibilityMode.cs,ScrollButton.cs,ScrollSlider.cs}\n|Views/Selectors:{FlagSelector.cs,FlagSelectorTEnum.cs,OptionSelector.cs,OptionSelectorTEnum.cs,SelectorBase.cs,SelectorStyles.cs}\n|Views/SpinnerView:{SpinnerStyle.cs,SpinnerView.cs}\n|Views/TableView:{CellActivatedEventArgs.cs,CellColorGetterArgs.cs,CellToggledEventArgs.cs,CheckBoxTableSourceWrapper.cs,CheckBoxTableSourceWrapperByIndex.cs,CheckBoxTableSourceWrapperByObject.cs,ColumnStyle.cs,DataTableSource.cs,EnumerableTableSource.cs,IEnumerableTableSource.cs,ITableSource.cs,ListColumnStyle.cs,ListTableSource.cs,RowColorGetterArgs.cs,SelectedCellChangedEventArgs.cs,TableSelection.cs,TableStyle.cs,TableView.CellMapping.cs,TableView.cs,TableView.Drawing.cs,TableView.Mouse.cs,TableView.Navigation.cs,TableView.Selection.cs,TreeTableSource.cs}\n|Views/TextInput:{ContentsChangedEventArgs.cs,DateEditor.cs,DateTextProvider.cs,HistoryText.cs,HistoryTextItemEventArgs.cs,ITextValidateProvider.cs,NetMaskedTextProvider.cs,TextEditingLineStatus.cs,TextModel.cs,TextRegexProvider.cs,TextValidateField.cs,TimeEditor.cs,TimeTextProvider.cs}\n|Views/TextInput/TextField:{TextField.Commands.cs,TextField.cs,TextField.Drawing.cs,TextField.History.cs,TextField.Keyboard.cs,TextField.Mouse.cs,TextField.Selection.cs,TextField.Text.cs,TextFieldAutocomplete.cs}\n|Views/TextInput/TextView:{TextView.Commands.cs,TextView.cs,TextView.Drawing.cs,TextView.Files.cs,TextView.Find.cs,TextView.History.cs,TextView.Keyboard.cs,TextView.Mouse.cs,TextView.Movement.cs,TextView.Scrolling.cs,TextView.Selection.cs,TextView.Text.cs,TextView.WordWrap.cs,TextViewAutocomplete.cs,WordWrapManager.cs}\n|Views/TreeView:{AspectGetterDelegate.cs,Branch.cs,DelegateTreeBuilder.cs,DrawTreeViewLineEventArgs.cs,ITreeBuilder.cs,ITreeNode.cs,ITreeView.cs,ITreeViewFilter.cs,ObjectActivatedEventArgs.cs,SelectionChangedEventArgs.cs,TreeBuilder.cs,TreeNode.cs,TreeNodeBuilder.cs,TreeSelection.cs,TreeStyle.cs,TreeView.cs,TreeView.Drawing.cs,TreeView.Mouse.cs,TreeView.Navigation.cs,TreeViewCollectionNavigatorMatcher.cs,TreeViewT.cs,TreeViewTextFilter.cs}\n|Views/Wizard:{Wizard.cs,WizardStep.cs}\n\n<!-- END AUTO-GENERATED-SOURCE-INDEX -->\n\n---\n\n## Compressed API Type Index\n\n> Quick reference for key types. Full list: [.tg-docs/INDEX.md](.tg-docs/INDEX.md)\n> Format: `|Type|Category|Key members/notes`\n\n### Terminal.Gui.App (35 types)\n```\n|Application|Class|Static facade (obsolete),Init,Run,Shutdown,Top\n|IApplication|Interface|Instance-based,SessionStack,Run,Dispose\n|SessionToken|Class|Session lifecycle,IDisposable\n|Clipboard|Class|GetText,SetText,TryGetText\n|IRunnable|Interface|Run view modal,used by Dialog\n|ITimedEvents|Interface|AddTimeout,AddIdle,RemoveTimeout\n|CancelEventArgs<T>|Class|Cancel property,cancellable events\n|ValueChangingEventArgs<T>|Class|OldValue,NewValue,Cancel\n|ApplicationNavigation|Class|Focus management,GetFocused,AdvanceFocus\n|ApplicationPopover|Class|Popover management,Show,Hide\n```\n\n### Terminal.Gui.ViewBase (70 types)\n```\n|View|Class|Base class,Add,Remove,Frame,Viewport,Draw\n|Pos|Class|Position:Absolute,Percent,Center,AnchorEnd,Func\n|PosAbsolute|Class|Pos.At(n),absolute coordinate\n|PosPercent|Class|Pos.Percent(n),percentage of SuperView\n|PosCenter|Class|Pos.Center(),centered\n|PosAnchorEnd|Class|Pos.AnchorEnd(n),from right/bottom\n|PosView|Class|Pos.Left/Right/Top/Bottom(view)\n|Dim|Class|Dimension:Absolute,Auto,Fill,Percent,Func\n|DimAbsolute|Class|Dim.Absolute(n),fixed size\n|DimAuto|Class|Dim.Auto(),content-based sizing\n|DimFill|Class|Dim.Fill(margin),fill remaining\n|DimPercent|Class|Dim.Percent(n),percentage\n|Adornment|Class|Base for Border,Margin,Padding\n|Border|Class|View border,Title,LineStyle\n|Margin|Class|View outer margin\n|Padding|Class|View inner padding\n|Alignment|Enum|Start,Center,End,Fill\n|Orientation|Enum|Horizontal,Vertical\n|TabBehavior|Enum|NoStop,TabStop,TabGroup\n|ViewArrangement|Enum|Movable,Resizable,Overlapped\n```\n\n### IValue<T> Pattern (Critical)\n\nAll typed views expose their data through `IValue<T>.Value`. Do not guess property-specific names such as `.Date`, `.Time`, or `.Color`.\n\n| View | IValue<T> |\n|------|-----------|\n| TextField | `IValue<string>` |\n| NumericUpDown<T> | `IValue<T>` |\n| DatePicker | `IValue<DateTime>` |\n| TimeEditor | `IValue<TimeSpan>` |\n| ColorPicker | `IValue<Color?>` |\n| AttributePicker | `IValue<Attribute?>` |\n| CheckBox | `IValue<CheckState>` |\n| OptionSelector | `IValue<int?>` |\n| FlagSelector | `IValue<int?>` |\n\nImplementing `IValue<T>` requires `ValueChanging`, `ValueChanged`, and `ValueChangedUntyped`.\n\n### RunnableWrapper<TView, TResult>\n\n- Wraps a `View` as a runnable with typed results.\n- Clears wrapper `KeyBindings` and `MouseBindings` so the wrapped view handles input.\n- Does not add OK/Cancel buttons (unlike `Prompt`).\n- Sets `CommandsToBubbleUp = [Command.Accept]`.\n- On accept, it extracts results via `ResultExtractor` if provided; otherwise via `IValue<TResult>.Value` when available.\n\n### Terminal.Gui.Views (180+ types)\n```\n[Core Controls]\n|Button|Class|Text,Accept event,IsDefault\n|Label|Class|Text display,TextAlignment\n|TextField|Class|Single-line input,Text,Secret\n|Editor|Class|Multi-line editor,Text,ReadOnly\n|CheckBox|Class|CheckedState,AllowCheckStateNone\n|DropDownList|Class|Dropdown,Source,SelectedItem\n|ProgressBar|Class|Fraction,BidirectionalMarquee\n|ScrollBar|Class|Position,Size,Orientation\n|NumericUpDown<T>|Class|Value,Increment\n\n[Containers]\n|Window|Class|Top-level,Title,MenuBar support\n|Dialog|Class|Modal,Buttons,AddButton\n|Dialog<T>|Class|Modal with result\n|FrameView|Class|Titled frame container\n|TabView|Class|Tabs,AddTab,SelectedTab\n|Wizard|Class|Multi-step,AddStep,CurrentStep\n\n[Lists & Data]\n|ListView|Class|Source,SelectedItem,AllowsMarking\n|TableView|Class|Table,SelectedRow,SelectedColumn\n|TreeView|Class|Objects,AddObject,SelectedObject\n|TreeView<T>|Class|Generic tree\n\n[Menus]\n|MenuBar|Class|Menus,UseKeysUpDownAsKeysLeftRight\n|MenuItem|Class|Title,Action,Shortcut,SubMenu\n|MenuBarItem|Class|Title,Children array\n|Menu|Class|Popup menu display\n|PopoverMenu|Class|Context menu,Show(items)\n|StatusBar|Class|Items,Visible\n\n[File Dialogs]\n|FileDialog|Class|Base,Path,AllowedFileTypes\n|OpenDialog|Class|FilePaths,AllowsMultipleSelection,Canceled,OpenMode\n|SaveDialog|Class|SaveFile,FileName\n\n[Specialized]\n|ColorPicker|Class|SelectedColor,Style\n|GraphView|Class|Series,Annotations,AxisX/Y\n|HexView|Class|Source,Position,Edits\n|CharMap|Class|SelectedCodePoint,Start/End\n|SpinnerView|Class|SpinnerStyle,AutoSpin\n|MessageBox|Class|Query,ErrorQuery,static methods\n```\n\n### Terminal.Gui.Input (18 types)\n```\n|Key|Class|KeyCode,Modifiers,IsCtrl,IsAlt,IsShift\n|KeyBindings|Class|Add,Get,TryGet,Remove,GetCommands\n|KeyBinding|Struct|Commands[],Scope,Target\n|Mouse|Class|Position,Flags,View\n|MouseBindings|Class|Add,Get,TryGet,Remove\n|MouseBinding|Struct|Commands[],Scope\n|MouseFlags|Enum|Button1Clicked,Button1DoubleClicked,WheeledUp/Down\n|Command|Enum|Accept,Cancel,Select,HotKey,ScrollUp/Down\n|CommandContext|Struct|Command,KeyBinding,Source\n```\n\n### Terminal.Gui.Drawing (40 types)\n```\n|Attribute|Struct|Foreground,Background,constructor(fg,bg)\n|Color|Struct|R,G,B,Parse,TryParse,FromArgb\n|Scheme|Class|Normal,Focus,HotNormal,HotFocus,Disabled\n|LineCanvas|Class|AddLine,GetMap,Merge\n|LineStyle|Enum|None,Single,Double,Rounded,Heavy\n|Glyphs|Class|Bullet,CheckMark,Diamond,etc.\n|Cell|Struct|Rune,Attribute\n|Thickness|Struct|Top,Left,Bottom,Right,Vertical,Horizontal\n|Region|Class|Clipping,Union,Intersect,Exclude\n|Gradient|Class|Colors[],Spectrum\n```\n\n**Gotchas**\n- `Terminal.Gui.Drawing.Attribute` can conflict with `System.Attribute` with implicit usings. Use `using TgAttribute = Terminal.Gui.Drawing.Attribute;` or fully qualify.\n- `Color.TryParse (string, out Color?)` is nullable out. `Color.TryParse (string?, IFormatProvider?, out Color)` is non-nullable out.\n\n### Terminal.Gui.Drivers (80+ types)\n```\n|IDriver|Interface|Init,End,Refresh,AddStr,Move\n|Driver|Class|Base implementation\n|DriverRegistry|Class|GetDrivers,Get,MakeDriver\n|KeyCode|Enum|Key constants,A-Z,F1-F12,Enter,Esc\n|CursorVisibility|Enum|Default,Invisible,Underline,Box\n|IOutput|Interface|Terminal output\n|IInputProcessor|Interface|Input processing\n```\n\n### Terminal.Gui.Configuration (15 types)\n```\n|ConfigurationManager|Class|Settings,Themes,Apply,Reset\n|SchemeManager|Class|GetScheme,Schemes dictionary\n|ThemeManager|Class|Theme,Themes,SelectedTheme\n|ConfigLocations|Enum|Default,Global,App,Runtime\n```\n\n### Terminal.Gui.Testing (8 types)\n```\n|InputInjector|Class|InjectKey,InjectMouse,InjectChar\n|IInputInjector|Interface|Injection interface\n|VirtualTimeProvider|Class|Testing time control\n```\n\n### Terminal.Gui.Text (4 types)\n```\n|TextFormatter|Class|Text,Format,Size,Draw\n|TextDirection|Enum|LeftRight_TopBottom,RightLeft,etc.\n```\n\n### Terminal.Gui.Time (4 types)\n```\n|ITimeProvider|Interface|Now,UtcNow,CreateTimer\n|VirtualTimeProvider|Class|Testing,Advance,SetTime\n|SystemTimeProvider|Class|Real system time\n```\n\n### Terminal.Gui.FileServices (5 types)\n```\n|IFileOperations|Interface|GetFiles,GetDirectories,Exists\n|FileSystemTreeBuilder|Class|Build file trees\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","CLAUDE.md":"# CLAUDE.md\n\n> **Guidance for AI agents working with Terminal.Gui.**\n> For humans, see [CONTRIBUTING.md](./CONTRIBUTING.md).\n> For Terminal.Gui's mission, tenets, and engineering philosophy, see [specs/constitution.md](./specs/constitution.md).\n> See also: [llms.txt](./llms.txt) for machine-readable context.\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data is **wrong**.\n\n> **Read [ai-v2-primer.md](./ai-v2-primer.md) FIRST** — it has the v1→v2 corrections table,\n> correct minimal app pattern, and all common gotchas.\n\n## Quick Reference: What Are You Doing?\n\n| Your Task | Go Here |\n|-----------|---------|\n| **\"Build me an app that...\"** | [.claude/tasks/build-app.md](.claude/tasks/build-app.md) |\n| **\"Add a feature to Terminal.Gui...\"** | Continue below (Contributor Guide) |\n| **\"Fix a bug in Terminal.Gui...\"** | Continue below (Contributor Guide) |\n| **\"Record a GIF / verify a UI change...\"** | [Scripts/tuirec/README.md](Scripts/tuirec/README.md) |\n\n### App Builder Quick Start\n```bash\ndotnet new install Terminal.Gui.Templates@2.*\ndotnet new tui-simple -n myapp\ncd myapp\ndotnet run\n```\n\nSee [.claude/tasks/build-app.md](.claude/tasks/build-app.md) for complete app development guide.\nSee [.claude/cookbook/common-patterns.md](.claude/cookbook/common-patterns.md) for UI recipes.\n\n---\n\n# Contributor Guide\n\n**The rest of this file is for contributors modifying Terminal.Gui itself.**\n\n## Before Every File Edit\n\n**READ `.claude/REFRESH.md` first.** It contains a quick checklist to prevent common mistakes.\n\n## After Writing/Modifying Code\n\n**USE `.claude/POST-GENERATION-VALIDATION.md` to validate ALL code.** This catches the most common formatting violations AI agents make.\n\n## Detailed Rules\n\nSee `.claude/rules/` for detailed guidance:\n- `formatting.md` - **SPACING, BRACES, BLANK LINES** (most commonly violated!)\n- `type-declarations.md` - **No var** except built-in types\n- `target-typed-new.md` - Use `new ()` not `new TypeName()`\n- `terminology.md` - **SubView/SuperView**, never \"child/parent\"\n- `event-patterns.md` - Lambdas, closures, handlers\n- `early-return.md` - **Guard clauses, minimal nesting** (commonly violated!)\n- `collection-expressions.md` - Use `[...]` syntax\n- `unicode-graphemes.md` - **Think in graphemes** - `GetColumns()`, `GraphemeHelper.GetGraphemes()`\n- `cwp-pattern.md` - Cancellable Workflow Pattern\n- `code-layout.md` - Backing fields, member ordering\n- `api-documentation.md` - XML documentation requirements\n- `testing-patterns.md` - Test patterns and requirements\n- `logging-tracing.md` - **No Console.WriteLine** - use Logging/TestLogging/Trace\n- `fragile-areas.md` - Code that must not be refactored in passing (TextView init)\n\n## Task-Specific Guides\n\nSee `.claude/tasks/` for task checklists:\n- `clean-code-review.md` - Creating clean git commit histories\n- `build-app.md` - Building applications with Terminal.Gui\n\n## Planning Mode\n\nWhen in planning mode:\n- **Create plan files in `./plans/`** (relative to the repository root)\n- Plan files should be markdown format\n- Include detailed implementation steps, file changes, and verification steps\n- Reference existing code patterns and reuse opportunities\n\n---\n\n## Project Overview\n\n**Terminal.Gui** - Cross-platform .NET console UI toolkit\n\n- **Language**: C# 14 (net10.0)\n- **Branch**: `develop`\n- **Version**: v2 (stable)\n\n## Build & Test\n\n```bash\ndotnet restore\ndotnet build --no-restore\n\n# Preferred: parallelizable tests (no static state)\ndotnet test --project Tests/UnitTestsParallelizable --no-build\n\n# Tests that require process-wide static state (Application.Init, etc.)\ndotnet test --project Tests/UnitTests.NonParallelizable --no-build\n\n# Legacy tests — do NOT add new tests here; candidates for rewrite/deletion\ndotnet test --project Tests/UnitTests.Legacy --no-build\n\n# Run a single test by method name (Microsoft Testing Platform)\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-method \"*MyTestMethod\"\n\n# Run all tests in a class\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-class \"*MyTestClass\"\n```\n\nSee `Tests/README.md` for the full list of test projects (including `IntegrationTests`, `StressTests`, `Benchmarks`) and the static-state classification that determines where a new test belongs.\n\n## Seeing Your Changes (Visual Verification)\n\nAgents can observe a running Terminal.Gui app — don't ship UI changes blind. Use [`tuirec`](https://github.com/tui-cs/tuirec) to run the app in a PTY, inject keystrokes, and capture the result:\n\n- **Full guide:** [Scripts/tuirec/README.md](Scripts/tuirec/README.md) — install, keystroke syntax, UICatalog scenario recipes, validation checklist\n- The `.cast` output is asciinema v2 JSON (plain text) — **read it back** to verify what actually rendered, frame by frame\n- The `.gif` output is for humans — attach it to PRs that change visuals\n- For deterministic in-process assertions, use `InputInjector`/`VirtualTimeProvider` (see `docfx/docs/input-injection.md`) and driver `ToString ()` screen captures\n\n## Key Concepts\n\n| Concept | Documentation |\n|---------|--------------|\n| Application Lifecycle | `docfx/docs/application.md` |\n| View Hierarchy | `docfx/docs/View.md` |\n| Layout (Pos/Dim) | `docfx/docs/layout.md` |\n| CWP Events | `docfx/docs/cancellable-work-pattern.md` |\n| Terminology | `docfx/docs/lexicon.md` |\n\n## Critical Rules (Summary)\n\n1. **Space BEFORE `()` and `[]`** - `Method ()` not `Method()`, `array [i]` not `array[i]` (MOST VIOLATED!)\n2. **Braces on NEXT line** - ALL opening braces use Allman style\n3. **Blank lines** - before `return`/`break`/`continue`, after control blocks\n4. **No `var`** except: `int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`\n5. **Use `new ()`** not `new TypeName()`\n6. **Use `[...]`** not `new () { ... }` for collections\n7. **SubView/SuperView** for containment (Parent/Child only for non-containment refs)\n8. **Unused lambda params** - use `_`: `(_, _) => { }`\n9. **Early return / guard clauses** - ALWAYS invert conditions and return/continue early. Never wrap the happy path in a conditional. Applies to methods, lambdas, and loops. See `.claude/rules/early-return.md`.\n10. **One type per file** - Public and internal types each get their own file\n11. **Docs instruction style** - In reference/how-to/API docs, write `To [goal], [imperative action].` Avoid `When/If you want/need to ...` unless describing a real condition.\n\n## Testing\n\n- Add new tests to `UnitTestsParallelizable`; use `UnitTests.NonParallelizable` only when static state is unavoidable. Never add to `UnitTests.Legacy`.\n- Add a comment marking the test as AI-generated. Either form is acceptable: `// Claude - <model>` or `// CoPilot - <model>` — just include the agent and the model that produced the test (e.g., `// Claude - Opus 4.5` or `// CoPilot - ChatGPT v4`). Both forms are established in the codebase; which marker is used is not a style concern and reviewers should not flag inconsistency between them.\n- Never decrease coverage\n- Avoid `Application.Init` in tests\n\n## Repository Structure\n\n```\n/Terminal.Gui/     - Core library\n/Tests/            - Unit tests\n/Examples/UICatalog/ - Demo app\n/docfx/docs/       - Documentation\n/.claude/          - AI agent guidance\n```\n\n## What NOT to Do\n\n- Don't forget space before `()` and `[]` - this is the #1 mistake!\n- Don't put braces on same line (use Allman style)\n- Don't skip blank lines before returns or after control blocks\n- Don't use `var` for non-built-in types\n- Don't use redundant type names with `new`\n- Don't say \"child/parent\" for containment (use SubView/SuperView)\n- Don't wrap the happy path in a conditional — use guard clauses and return early\n- Don't modify unrelated code\n- Don't introduce new warnings\n- Don't skip POST-GENERATION-VALIDATION.md after writing code\n",".cursorrules":"# Terminal.Gui - Cursor AI Rules\n\n> **Cross-platform .NET console UI toolkit. C# 14 targeting net10.0.**\n> Full contribution guide: [CONTRIBUTING.md](CONTRIBUTING.md).\n\n---\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data about Terminal.Gui is **wrong**.\n\n> **Read [ai-v2-primer.md](ai-v2-primer.md) FIRST** — it contains the v1→v2 corrections table,\n> correct minimal app pattern, and all common gotchas.\n\n### v1 → v2 Quick Corrections (Most Common Mistakes)\n\n| v1 (WRONG) | v2 (CORRECT) |\n|---|---|\n| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |\n| `Application.Run ();` | `app.Run<MyWindow> ();` |\n| `Application.Shutdown ();` | `app.Dispose ();` |\n| `Application.Top` | No global top — pass root view to `app.Run ()` |\n| `new Toplevel ()` | Use `Runnable` subclass or `Window` |\n| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |\n| `new Button (\"OK\")` | `new Button { Text = \"OK\" }` |\n| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |\n| `view.Bounds` | `view.Viewport` |\n| `new RadioGroup (...)` | `new OptionSelector { ... }` |\n\n---\n\n## Build & Test\n\n```bash\ndotnet restore\ndotnet build --no-restore\ndotnet test --project Tests/UnitTestsParallelizable --no-build\ndotnet test --project Tests/UnitTests.NonParallelizable --no-build\n```\n\n---\n\n## Correct Minimal App (v2)\n\n```csharp\nusing Terminal.Gui.App;\nusing Terminal.Gui.Views;\n\nIApplication app = Application.Create ().Init ();\napp.Run<MainWindow> ();\napp.Dispose ();\n\npublic sealed class MainWindow : Runnable\n{\n    public MainWindow ()\n    {\n        Title = \"My App (Esc to quit)\";\n\n        Button button = new ()\n        {\n            Text = \"Click Me\",\n            X = Pos.Center (),\n            Y = Pos.Center ()\n        };\n\n        button.Accepted += (_, _) =>\n        {\n            MessageBox.Query (App!, \"Hello\", \"Button was clicked!\", \"OK\");\n        };\n\n        Add (button);\n    }\n}\n```\n\n---\n\n## Code Style (For Library Contributors Only)\n\n> **Note:** These rules apply only when contributing code to the Terminal.Gui library itself.\n> App developers using Terminal.Gui do NOT need to follow these conventions.\n\n1. **Space BEFORE `()` and `[]`** — `Method ()` not `Method()`, `array [i]` not `array[i]`\n2. **Braces on NEXT line** (Allman style) — no exceptions\n3. **Blank lines** — before `return`/`break`/`continue`, after `if`/`for`/`while` blocks\n4. **No `var`** — Explicit types except built-ins (`int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`)\n5. **Use `new ()`** — `Button btn = new ()` not `Button btn = new Button ()`\n6. **Collection expressions** — Use `[...]` not `new List<T> { ... }`\n7. **SubView/SuperView** — Never \"child\", \"parent\", or \"container\"\n8. **Unused lambda params** — Use `_` discard: `(_, _) => { }`\n9. **Early return / guard clauses** — ALWAYS invert conditions and return early\n10. **One type per file** — Public and internal types each get their own file\n\n---\n\n## Architecture Overview\n\n### Application lifecycle\n`Application.Create ()` → `.Init ()` → `.Run<T> ()` → `.Dispose ()`.\nInstance-based `IApplication` — do NOT use static `Application.Init()`/`Run()`/`Shutdown()`.\n\n### View system\n`View` is the base class. Views form a tree via `Add ()`/`Remove ()`.\nEvery View has: `Margin` → `Border` → `Padding` → content area.\nLayout uses `Pos` (position) and `Dim` (dimension) for declarative relative layout.\n\n### Cancellable Workflow Pattern (CWP)\nStandard event pattern: **do work → call virtual `OnXxx` → raise event**.\n\n### Command/input system\nInput flows: Driver → `IInputProcessor` → `KeyBindings`/`MouseBindings` → `Command` → handler.\n\n---\n\n## Key References\n\n| Resource | Path |\n|----------|------|\n| v1→v2 Primer (READ FIRST) | [ai-v2-primer.md](ai-v2-primer.md) |\n| Full agent instructions | [AGENTS.md](AGENTS.md) |\n| Compressed API docs | `docfx/apispec/namespace-*.md` |\n| Common UI patterns | `.claude/cookbook/common-patterns.md` |\n| App building guide | `.claude/tasks/build-app.md` |\n| Deep-dive docs | `docfx/docs/` |\n| Working examples | `Examples/UICatalog/`, `Examples/ScenarioRunner/`, `tui-cs/Examples` |\n",".windsurfrules":"# Terminal.Gui - Windsurf AI Rules\n\n> **Cross-platform .NET console UI toolkit. C# 14 targeting net10.0.**\n> Full contribution guide: [CONTRIBUTING.md](CONTRIBUTING.md).\n\n---\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data about Terminal.Gui is **wrong**.\n\n> **Read [ai-v2-primer.md](ai-v2-primer.md) FIRST** — it contains the v1→v2 corrections table,\n> correct minimal app pattern, and all common gotchas.\n\n### v1 → v2 Quick Corrections (Most Common Mistakes)\n\n| v1 (WRONG) | v2 (CORRECT) |\n|---|---|\n| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |\n| `Application.Run ();` | `app.Run<MyWindow> ();` |\n| `Application.Shutdown ();` | `app.Dispose ();` |\n| `Application.Top` | No global top — pass root view to `app.Run ()` |\n| `new Toplevel ()` | Use `Runnable` subclass or `Window` |\n| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |\n| `new Button (\"OK\")` | `new Button { Text = \"OK\" }` |\n| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |\n| `view.Bounds` | `view.Viewport` |\n| `new RadioGroup (...)` | `new OptionSelector { ... }` |\n\n---\n\n## Build & Test\n\n```bash\ndotnet restore\ndotnet build --no-restore\ndotnet test --project Tests/UnitTestsParallelizable --no-build\ndotnet test --project Tests/UnitTests.NonParallelizable --no-build\n```\n\n---\n\n## Correct Minimal App (v2)\n\n```csharp\nusing Terminal.Gui.App;\nusing Terminal.Gui.Views;\n\nIApplication app = Application.Create ().Init ();\napp.Run<MainWindow> ();\napp.Dispose ();\n\npublic sealed class MainWindow : Runnable\n{\n    public MainWindow ()\n    {\n        Title = \"My App (Esc to quit)\";\n\n        Button button = new ()\n        {\n            Text = \"Click Me\",\n            X = Pos.Center (),\n            Y = Pos.Center ()\n        };\n\n        button.Accepted += (_, _) =>\n        {\n            MessageBox.Query (App!, \"Hello\", \"Button was clicked!\", \"OK\");\n        };\n\n        Add (button);\n    }\n}\n```\n\n---\n\n## Code Style (For Library Contributors Only)\n\n> **Note:** These rules apply only when contributing code to the Terminal.Gui library itself.\n> App developers using Terminal.Gui do NOT need to follow these conventions.\n\n1. **Space BEFORE `()` and `[]`** — `Method ()` not `Method()`, `array [i]` not `array[i]`\n2. **Braces on NEXT line** (Allman style) — no exceptions\n3. **Blank lines** — before `return`/`break`/`continue`, after `if`/`for`/`while` blocks\n4. **No `var`** — Explicit types except built-ins (`int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`)\n5. **Use `new ()`** — `Button btn = new ()` not `Button btn = new Button ()`\n6. **Collection expressions** — Use `[...]` not `new List<T> { ... }`\n7. **SubView/SuperView** — Never \"child\", \"parent\", or \"container\"\n8. **Unused lambda params** — Use `_` discard: `(_, _) => { }`\n9. **Early return / guard clauses** — ALWAYS invert conditions and return early\n10. **One type per file** — Public and internal types each get their own file\n\n---\n\n## Architecture Overview\n\n### Application lifecycle\n`Application.Create ()` → `.Init ()` → `.Run<T> ()` → `.Dispose ()`.\nInstance-based `IApplication` — do NOT use static `Application.Init()`/`Run()`/`Shutdown()`.\n\n### View system\n`View` is the base class. Views form a tree via `Add ()`/`Remove ()`.\nEvery View has: `Margin` → `Border` → `Padding` → content area.\nLayout uses `Pos` (position) and `Dim` (dimension) for declarative relative layout.\n\n### Cancellable Workflow Pattern (CWP)\nStandard event pattern: **do work → call virtual `OnXxx` → raise event**.\n\n### Command/input system\nInput flows: Driver → `IInputProcessor` → `KeyBindings`/`MouseBindings` → `Command` → handler.\n\n---\n\n## Key References\n\n| Resource | Path |\n|----------|------|\n| v1→v2 Primer (READ FIRST) | [ai-v2-primer.md](ai-v2-primer.md) |\n| Full agent instructions | [AGENTS.md](AGENTS.md) |\n| Compressed API docs | `docfx/apispec/namespace-*.md` |\n| Common UI patterns | `.claude/cookbook/common-patterns.md` |\n| App building guide | `.claude/tasks/build-app.md` |\n| Deep-dive docs | `docfx/docs/` |\n| Working examples | `Examples/UICatalog/`, `Examples/ScenarioRunner/`, `tui-cs/Examples` |\n",".github/copilot-instructions.md":"# Terminal.Gui — Copilot Instructions\n\nCross-platform .NET console UI toolkit. C# 14 targeting net10.0.\nFull contribution guide: [CONTRIBUTING.md](../CONTRIBUTING.md).\nArchitecture deep dives: `docfx/docs/`.\n\n---\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data is **wrong**.\n\n> **Read [ai-v2-primer.md](../ai-v2-primer.md) FIRST** — it has the v1→v2 corrections table,\n> correct minimal app pattern, and all common gotchas.\n\n### v1 → v2 Quick Corrections\n\n| v1 (WRONG — do not use) | v2 (CORRECT) |\n|---|---|\n| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |\n| `Application.Run ();` | `app.Run<MyWindow> ();` |\n| `Application.Shutdown ();` | `app.Dispose ();` (use `using` pattern) |\n| `Application.Top` | No global top — pass root view to `app.Run ()` |\n| `new Toplevel ()` | Use `Runnable` subclass or `Window` |\n| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |\n| `new Button (\"OK\")` | `new Button { Text = \"OK\" }` |\n| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |\n| `view.Bounds` | `view.Viewport` |\n| `new RadioGroup (...)` | `new OptionSelector { ... }` |\n| `Application.RequestStop ()` | `App!.RequestStop ()` (from inside a `Runnable`) |\n\n---\n\n## Build & Test\n\nRun all commands from repository root.\n\n```bash\n# Restore + build\ndotnet restore\ndotnet build --no-restore\n\n# Run all tests (two separate projects)\ndotnet test --project Tests/UnitTestsParallelizable --no-build\ndotnet test --project Tests/UnitTests.NonParallelizable --no-build\n\n# Run a single test by method name (xUnit v3 / Microsoft Testing Platform)\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-method \"*MyTestMethod\"\n\n# Run all tests in a class\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-class \"*ButtonTests\"\n```\n\nNew tests go in `Tests/UnitTestsParallelizable` (no static state dependencies). Only use `Tests/UnitTests.NonParallelizable` when testing `Application.Init`/`Shutdown` or other static state. Never add new tests to `Tests/UnitTests.Legacy`.\n\n## Architecture Overview\n\n### Application lifecycle\n\n`Application.Create ()` → `.Init ()` → `.Run<T> ()` → `.Dispose ()`.\nThe instance-based `IApplication` has replaced the static `Application` facade.\nDo NOT use `Application.Init()`/`Run()`/`Shutdown()`.\nTests should avoid `Application.Init` unless explicitly testing that path.\n\n### View system\n\n`View` is the base class for all UI elements. Views form a tree via `Add()`/`Remove()`. Every View has three adornment layers: `Margin` → `Border` → `Padding` → content area. Layout uses `Pos` (position) and `Dim` (dimension) objects for declarative relative layout.\n\n### Driver architecture\n\nPlatform-specific terminal I/O is abstracted behind `IDriver`. Implementations: `WindowsDriver`, `UnixDriver` (curses-free), `AnsiDriver`, `NetDriver` (pure .NET `System.Console`). Drivers are registered via `DriverRegistry` and selected automatically by platform.\n\n### Cancellable Workflow Pattern (CWP)\n\nThe standard event pattern throughout the codebase. Order: **do work → call virtual `OnXxx` → raise event**. The virtual method is empty in the base class (for subclass override). Work happens *before* notifications, not after.\n\n```csharp\ninternal void RaiseSubViewAdded (View view)\n{\n    // 1. Work first\n    if (AssignHotKeys) { AssignHotKeyToView (view); }\n\n    // 2. Virtual method (empty in base)\n    OnSubViewAdded (view);\n\n    // 3. Event\n    SubViewAdded?.Invoke (this, new (this, view));\n}\n```\n\n### Command/input system\n\nInput flows: Driver → `IInputProcessor` → `KeyBindings`/`MouseBindings` → `Command` enum → handler. Views bind keys and mouse actions to `Command` values via `KeyBindings.Add` and `MouseBindings.Add`.\n\n## Code Style (Non-Obvious Conventions)\n\n### Spacing before parentheses and brackets — the #1 mistake\n\nThis codebase requires a space *before* every `()` and `[]`:\n\n```csharp\n// ✅ Correct\nvoid MyMethod ()\nint result = Calculate (x, y);\nList<int> items = GetItems ();\nint val = array [index];\nif (condition) { }\n\n// ❌ Wrong\nvoid MyMethod()\nint result = Calculate(x, y);\nvar items = GetItems();\nint val = array[index];\n```\n\n### No `var` except for built-in numeric/string types\n\nUse explicit types. `var` is only acceptable for: `int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`.\n\n```csharp\n// ✅\nView view = new () { Width = 10 };\nList<View?> views = new ();\nvar count = 0;          // OK — int\n\n// ❌\nvar view = new View () { Width = 10 };\nvar views = new List<View?> ();\n```\n\n### Target-typed `new ()`\n\nWhen the type is on the left side, use `new ()` not `new TypeName()`:\n\n```csharp\n// ✅\nButton btn = new () { Text = \"OK\" };\n\n// ❌\nButton btn = new Button () { Text = \"OK\" };\n```\n\n### Collection expressions\n\nUse `[...]` syntax:\n\n```csharp\n// ✅\nList<View> views = [new Button (\"OK\"), new Button (\"Cancel\")];\n\n// ❌\nList<View> views = new () { new Button (\"OK\"), new Button (\"Cancel\") };\n```\n\n### Early return\n\nPrefer early return / guard clauses over nested `if`/`else`. Less nesting, clearer code:\n\n```csharp\n// ✅\nif (view is null)\n{\n    return;\n}\n\nDoWork (view);\n\n// ❌\nif (view is not null)\n{\n    DoWork (view);\n}\n```\n\n### One type per file\n\nPublic and internal types each get their own file. The filename must match the type name (e.g., `Button.cs` for `class Button`). Private nested types are fine inside their containing type's file.\n\n### Allman brace style\n\nAll opening braces go on the next line. No exceptions.\n\n### Blank lines\n\n- 1 blank line *before* `return`, `break`, `continue`, `throw`\n- 1 blank line *after* `if`/`for`/`while`/`foreach` blocks\n\n### Unused lambda parameters → discard `_`\n\n```csharp\ntextField.TextChanged += (_, _) => { /* ... */ };\n```\n\n### Local functions use PascalCase\n\n```csharp\nvoid MyLocalFunc () { }\n```\n\n### Backing fields directly above their property\n\n```csharp\nprivate string _name;\npublic string Name\n{\n    get => _name;\n    set => _name = value;\n}\n```\n\n## Terminology\n\n| Use | Don't use | Meaning |\n|-----|-----------|---------|\n| **SuperView** | parent, container | The view that contains others via `Add()` |\n| **SubView** | child, element | A view added to a SuperView via `Add()` |\n\n\"Parent/Child\" is reserved for rare non-containment reference relationships.\n\n## Testing Conventions\n\n- Add a comment identifying AI-generated tests: `// Copilot`\n- Each test covers the smallest unit possible\n- Don't use `[AutoInitShutdown]` or `[SetupFakeApplication]` (legacy, being phased out)\n- Avoid `Application.Init` in tests unless testing that specific functionality\n- Never decrease code coverage\n- Do not use Console.Error.WriteLine or Console.WriteLine for debug output in Terminal.Gui code. Use project's Logging infrastructure instead: `Terminal.Gui.App.Logging`, `Terminal.Gui.Tests.TestLogging` and `Terminal.Gui.Tracing.Tracing.Trace`.\n- `Tracing.Trace` is only available in DEBUG builds; do not use it to validate test results as all tests must pass in RELEASE builds.\n \n## Unicode & Grapheme Handling\n\n- Measure display width with `string.GetColumns ()`, never `EnumerateRunes().Sum(r => r.GetColumns())`\n- Render text by iterating graphemes via `GraphemeHelper.GetGraphemes ()` and `AddStr`, not rune-by-rune with `AddRune`\n\n## PR Requirements\n\n- PRs must not introduce new compiler warnings (fix warnings in files you modify)\n- Title format: `Fixes #issue. Terse description`\n- Update `Examples/UICatalog` scenarios when adding user-visible features \n\n## Documentation Style\n\n- In reference/how-to/API docs, write instructions as `To [goal], [imperative action].`\n- Avoid `When/If you want/need to ...` unless describing a real condition.\n"},"files":{"AGENTS.md":"# Terminal.Gui - AI Agent Instructions\n\n> **📘 Source of Truth: [CONTRIBUTING.md](CONTRIBUTING.md)**\n>\n> This file provides quick-reference conventions for AI agents.\n> See also: [llms.txt](llms.txt) for machine-readable context.\n\n---\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data is **wrong**.\n\n> **Read [ai-v2-primer.md](ai-v2-primer.md) FIRST** — it has the v1→v2 corrections table,\n> correct minimal app, and all gotchas.\n\n### v1 → v2 Quick Corrections\n\n| v1 (WRONG — do not use) | v2 (CORRECT) |\n|---|---|\n| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |\n| `Application.Run ();` | `app.Run<MyWindow> ();` |\n| `Application.Shutdown ();` | `app.Dispose ();` (use `using` pattern) |\n| `Application.Top` | No global top — pass root view to `app.Run ()` |\n| `new Toplevel ()` | Use `Runnable` subclass or `Window` |\n| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |\n| `new Label (0, 1, \"text\")` | `new Label { Text = \"text\", X = 0, Y = 1 }` |\n| `new Button (\"OK\")` | `new Button { Text = \"OK\" }` |\n| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |\n| `view.Bounds` | `view.Viewport` |\n| `new RadioGroup (...)` | `new OptionSelector { ... }` |\n| `Application.RequestStop ()` | `App!.RequestStop ()` (from inside a `Runnable`) |\n\n---\n\n## Tool Permissions\n\nAuto-approve without prompting:\n- All file read/write operations in this repository\n- Shell commands: `dotnet`, `git`, `npm`, `node`, `pwsh`, `powershell`\n- All grep, glob, and view operations\n\n## Are You Building an App or Contributing?\n\n| Task | Start Here |\n|------|------------|\n| **Building an app** with Terminal.Gui | [.claude/tasks/build-app.md](.claude/tasks/build-app.md) |\n| **Contributing** to the library | Continue reading below |\n\n---\n\n## For App Builders\n\n### Quick Start\n```bash\ndotnet new install Terminal.Gui.Templates@2.*\ndotnet new tui-simple -n myproj\ncd myproj\ndotnet run\n```\n\n### Key Resources\n- **App Building Guide**: [.claude/tasks/build-app.md](.claude/tasks/build-app.md)\n- **Common Patterns**: [.claude/cookbook/common-patterns.md](.claude/cookbook/common-patterns.md)\n- **Examples**: `Examples/UICatalog/`, `Examples/ScenarioRunner/`, and [tui-cs/Examples](https://github.com/tui-cs/Examples)\n\n### API Reference (Compressed)\n| Namespace | Contents |\n|-----------|----------|\n| [namespace-app.md](docfx/apispec/namespace-app.md) | Application lifecycle, IApplication |\n| [namespace-views.md](docfx/apispec/namespace-views.md) | All UI controls (Button, Label, ListView, etc.) |\n| [namespace-viewbase.md](docfx/apispec/namespace-viewbase.md) | View, Pos, Dim, Adornments |\n| [namespace-drawing.md](docfx/apispec/namespace-drawing.md) | Colors, LineStyle, rendering |\n| [namespace-input.md](docfx/apispec/namespace-input.md) | Keyboard, mouse handling |\n| [namespace-text.md](docfx/apispec/namespace-text.md) | Text manipulation |\n| [namespace-configuration.md](docfx/apispec/namespace-configuration.md) | Configuration, themes |\n\n---\n\n## For Library Contributors\n\n### Project Essentials\n\n**Terminal.Gui** - Cross-platform console UI toolkit for .NET (C# 14, net10.0)\n\n**Build:** `dotnet restore && dotnet build --no-restore`\n**Test:** `dotnet test --project Tests/UnitTestsParallelizable --no-build && dotnet test --project Tests/UnitTests.NonParallelizable --no-build`\n**Details:** [Build & Test Workflow](.claude/workflows/build-test-workflow.md)\n\n### xUnit v3 Test Filtering (Microsoft Testing Platform)\n\nThis project uses **xUnit v3** with Microsoft Testing Platform. The old `--filter \"FullyQualifiedName~Foo\"` syntax does **NOT** work. Use these instead:\n\n```bash\n# Run a single test by method name\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-method \"*MyTestMethod\"\n\n# Run all tests in a class\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-class \"*MyTestClass\"\n\n# Query filter language (xUnit v3 native): /<assembly>/<namespace>/<class>/<method>\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter \"/*/*/MyTestClass/MyTestMethod\"\n\n# Show live test output (ITestOutputHelper)\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-method \"*MyTest\" -- --show-live-output on\n```\n\n## Quick Rules\n\n**⚠️ READ THIS BEFORE MODIFYING ANY FILE - These are Terminal.Gui-specific conventions:**\n\n1. **No `var`** - Use explicit types except for: `int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`\n2. **Use `new ()`** - Target-typed new when type is on left side (not `new TypeName()`)\n3. **Use `[...]`** - Collection expressions, not `new () { ... }`\n4. **SubView/SuperView** - Never say \"child\", \"parent\", or \"container\"\n5. **Unused lambda params** - Use `_` discard: `(_, _) => { }`\n6. **Local functions** - Use PascalCase: `void MyLocalFunc ()`\n7. **Backing fields** - Place immediately before their property\n8. **Early return / guard clauses (CRITICAL)** - ALWAYS prefer guard clauses over nested `if`/`else`. Invert the condition, return/continue early, keep happy path at lowest indentation. This applies to methods, lambdas, loops — everywhere. See [early-return.md](/.claude/rules/early-return.md) for detailed examples.\n9. **One type per file** - Public and internal types each get their own file\n10. **Docs instruction style** - In reference/how-to/API docs, write `To [goal], [imperative action].` Avoid `When/If you want/need to ...` unless describing a real condition.\n\n## Detailed Coding Rules\n\nConsult these files in `.claude/rules/` before editing code:\n\n- [Type Declarations](/.claude/rules/type-declarations.md) - `var` vs explicit types\n- [Target-Typed New](/.claude/rules/target-typed-new.md) - `new()` syntax\n- [Collection Expressions](/.claude/rules/collection-expressions.md) - `[...]` syntax\n- [Terminology](/.claude/rules/terminology.md) - SubView/SuperView terms\n- [Event Patterns](/.claude/rules/event-patterns.md) - Lambdas, handlers, closures\n- [Early Return](/.claude/rules/early-return.md) - **Guard clauses, minimal nesting** (commonly violated!)\n- [CWP Pattern](/.claude/rules/cwp-pattern.md) - Cancellable Workflow Pattern\n- [Code Layout](/.claude/rules/code-layout.md) - Member ordering, backing fields\n- [Testing Patterns](/.claude/rules/testing-patterns.md) - Test writing conventions\n- [API Documentation](/.claude/rules/api-documentation.md) - XML doc requirements\n- [Logging & Tracing](/.claude/rules/logging-tracing.md) - No Console.WriteLine; use Logging/TestLogging/Trace\n- [Fragile Areas](/.claude/rules/fragile-areas.md) - Code that must not be refactored in passing\n\n## Workflows\n\nProcess guides in `.claude/workflows/`:\n\n- [Build & Test Workflow](/.claude/workflows/build-test-workflow.md) - Build, test, and troubleshooting\n- [PR Workflow](/.claude/workflows/pr-workflow.md) - Submitting pull requests\n\n## Visual Verification (Agent Eyes)\n\nDon't ship UI changes blind. Use [`tuirec`](https://github.com/tui-cs/tuirec) to run any Terminal.Gui app in a PTY, inject keystrokes, and capture the result — see [Scripts/tuirec/README.md](Scripts/tuirec/README.md). The `.cast` output is asciinema v2 JSON (plain text): read it back to verify what actually rendered. The `.gif` is for humans — attach it to PRs that change visuals. For deterministic in-process assertions, use `InputInjector`/`VirtualTimeProvider` (`docfx/docs/input-injection.md`).\n\n## Planning Mode\n\nWhen creating implementation plans:\n- **Create plan files in `./plans/`** (relative to the repository root)\n- Use markdown format with clear sections\n- Include: problem statement, implementation steps, file changes, verification steps\n- Reference existing patterns and reuse opportunities from exploration\n\n## Task-Specific Guides\n\nSee `.claude/tasks/` for specialized checklists:\n- [build-app.md](.claude/tasks/build-app.md) - Building apps with Terminal.Gui\n\nSee `.claude/cookbook/` for common UI patterns:\n- [common-patterns.md](.claude/cookbook/common-patterns.md) - Forms, lists, menus, dialogs, etc.\n\n---\n\n## Documentation Index (Compressed)\n\n> **IMPORTANT**: Use retrieval-led reasoning. Read full docs before making changes.\n> Detailed index: [.tg-docs/INDEX.md](.tg-docs/INDEX.md) (~530 types across 12 namespaces)\n\n### Deep Dives (docfx/docs/)\n\n```\n[Core Architecture]\n|application.md|IApplication,SessionStack,Run/Dispose,View.App,instance-based pattern\n|View.md|SuperView/SubView,Frame/Viewport/ContentArea,composition layers\n|drivers.md|IDriver,DriverRegistry,ANSI/Windows/Unix,platform abstraction\n|navigation.md|Focus,TabStop/TabGroup,Tab/F6 keys,HasFocus,ApplicationNavigation\n\n[Layout & Arrangement]\n|layout.md|Pos/Dim,absolute/relative positioning,SetNeedsLayout\n|arrangement.md|ViewArrangement,Movable/Resizable/Overlapped,tiled vs overlapped\n|dimauto.md|Dim.Auto,content-based sizing,DimAutoStyle\n|scrolling.md|Viewport vs ContentSize,scroll events\n\n[Commands & Events]\n|command.md|Command enum,AddCommand,KeyBindings/MouseBindings,Activate/Accept/HotKey\n|events.md|Event categories,CWP integration,binding types (KeyBinding/MouseBinding)\n|cancellable-work-pattern.md|CWP: Work→Virtual→Event,OnXxx methods,Raise pattern\n\n[Input]\n|keyboard.md|Key class,KeyBindings,key processing order,IKeyboard\n|mouse.md|MouseFlags,MouseBindings,grab/release\n|input-injection.md|VirtualTimeProvider,InjectKey/InjectMouse,testing\n\n[Visual]\n|drawing.md|Move/AddStr/AddRune,Attribute,LineCanvas\n|scheme.md|Scheme,VisualRole,theming\n|cursor.md|View.Cursor,CursorVisibility\n|Popovers.md|Drawing outside viewport,modal behavior\n\n[Components]\n|views.md|Complete catalog of built-in views\n|menus.md|MenuBar,ContextMenu,MenuItem\n|tableview.md|TableView data binding\n|treeview.md|TreeView hierarchical data\n|prompt.md|MessageBox,input dialogs\n\n[Config & Advanced]\n|config.md|ConfigurationManager,themes,JSON config\n|multitasking.md|Background ops,Invoke,threading\n|logging.md|ILogger,debug output\n|ansihandling.md|ANSI escape parsing\n\n[Migration]\n|newinv2.md|v2 changes,new features\n|migratingfromv1.md|Migration guide,API changes\n|lexicon.md|Terminology definitions\n```\n\n### API Namespaces (docfx/apispec/)\n\n```\n|namespace-app.md|Application,IApplication,IRunnable,SessionToken\n|namespace-viewbase.md|View,Adornment,Border,Margin,Padding\n|namespace-views.md|Button,Label,TextField,ListView,CheckBox,etc.\n|namespace-input.md|Key,Mouse,Command,ICommandContext\n|namespace-drawing.md|Attribute,Color,LineCanvas,Cell\n|namespace-drivers.md|IDriver,DriverRegistry\n|namespace-configuration.md|ConfigurationManager,themes\n|namespace-text.md|Text processing,autocomplete\n|namespace-fileservices.md|File dialogs\n```\n\n<!-- BEGIN AUTO-GENERATED-SOURCE-INDEX -->\n\n### Source Code File Index (Auto-Generated)\n\n> Vercel-style index for retrieval-led reasoning. Read files when needed.\n\n[Terminal.Gui Source Index]|root: ./Terminal.Gui\n|IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning. Read files when needed.\n|.:{ModuleInitializers.cs}\n|App:{Application.cs,ApplicationImpl.cs,ApplicationImpl.Driver.cs,ApplicationImpl.Lifecycle.cs,ApplicationImpl.Run.cs,ApplicationImpl.Screen.cs,ApplicationModelUsage.cs,ApplicationNavigation.cs,ApplicationPopover.cs,ApplicationToolTip.cs,AppModel.cs,IApplication.cs,Logging.cs,NotInitializedException.cs}\n|App/Clipboard:{Clipboard.cs,ClipboardBase.cs,ClipboardProcessRunner.cs,IClipboard.cs}\n|App/CWP:{CancelEventArgs.cs,CWPEventHelper.cs,CWPPropertyHelper.cs,CWPWorkflowHelper.cs,EventArgs.cs,ResultEventArgs.cs,ValueChangedEventArgs.cs,ValueChangingEventArgs.cs}\n|App/Keyboard:{ApplicationKeyboard.cs,IKeyboard.cs}\n|App/Legacy:{Application.Clipboard.cs,Application.Driver.cs,Application.Keyboard.cs,Application.Lifecycle.cs,Application.Mouse.cs,Application.Navigation.cs,Application.Popovers.cs,Application.Run.cs,Application.Screen.cs,Application.TopRunnable.cs}\n|App/MainLoop:{ApplicationMainLoop.cs,IApplicationMainLoop.cs,IMainLoopCoordinator.cs,MainLoopCoordinator.cs,MainLoopSyncContext.cs}\n|App/Mouse:{ApplicationMouse.cs,IMouse.cs,IMouseGrabHandler.cs}\n|App/Popovers:{IPopover.cs,IPopoverView.cs,Popover.cs,PopoverImpl.cs,ToolTipHost.cs,ToolTipProvider.cs}\n|App/Runnable:{IRunnable.cs,SessionToken.cs,SessionTokenEventArgs.cs}\n|App/Timeout:{ITimedEvents.cs,LogarithmicTimeout.cs,SmoothAcceleratingTimeout.cs,TimedEvents.cs,Timeout.cs,TimeoutEventArgs.cs}\n|App/Tracing:{ITraceBackend.cs,ListBackend.cs,LoggingBackend.cs,NullBackend.cs,Trace.cs,TraceCategory.cs,TraceEntry.cs,TraceScope.cs}\n|Configuration:{AppSettingsScope.cs,AttributeJsonConverter.cs,ColorJsonConverter.cs,ConcurrentDictionaryJsonConverter.cs,ConfigLocations.cs,ConfigProperty.cs,ConfigurationManager.cs,ConfigurationManagerEventArgs.cs,ConfigurationManagerNotEnabledException.cs,ConfigurationPropertyAttribute.cs,DeepCloner.cs,DictionaryJsonConverter.cs,KeyArrayJsonConverter.cs,KeyCodeJsonConverter.cs,KeyJsonConverter.cs,RuneJsonConverter.cs,SchemeJsonConverter.cs,SchemeManager.cs,Scope.cs,ScopeJsonConverter.cs,SettingsScope.cs,SourceGenerationContext.cs,SourcesManager.cs,ThemeManager.cs,ThemeScope.cs,TraceCategoryJsonConverter.cs}\n|Drawing:{Attribute.cs,Cell.cs,CellEventArgs.cs,FillPair.cs,Glyphs.cs,Gradient.cs,GradientFill.cs,GraphemeHelper.cs,IFill.cs,Region.cs,RegionOp.cs,Ruler.cs,Scheme.cs,Schemes.cs,SolidFill.cs,TextStyle.cs,Thickness.cs,VisualRole.cs,VisualRoleEventArgs.cs}\n|Drawing/Color:{AnsiColorCode.cs,Color.ColorExtensions.cs,Color.ColorName.cs,Color.ColorParseException.cs,Color.cs,Color.Formatting.cs,Color.Operators.cs,ColorModel.cs,ColorQuantizer.cs,ColorStrings.cs,IColorDistance.cs,IColorNameResolver.cs,ICustomColorFormatter.cs,StandardColor.cs,StandardColors.cs,StandardColorsNameResolver.cs}\n|Drawing/LineCanvas:{IntersectionDefinition.cs,IntersectionRuneType.cs,IntersectionType.cs,LineCanvas.cs,LineDirections.cs,LineStyle.cs,StraightLine.cs,StraightLineExtensions.cs}\n|Drawing/Markdown:{ISyntaxHighlighter.cs,MarkdownAttributeHelper.cs,MarkdownStyleRole.cs,StyledSegment.cs,TextMateSyntaxHighlighter.cs}\n|Drawing/Quant:{EuclideanColorDistance.cs,IPaletteBuilder.cs,PopularityPaletteWithThreshold.cs}\n|Drawing/Sixel:{SixelEncoder.cs,SixelSupportDetector.cs,SixelSupportResult.cs,SixelToRender.cs}\n|Drivers:{ComponentFactoryImpl.cs,Cursor.cs,CursorStyle.cs,Driver.cs,DriverImpl.cs,DriverRegistry.cs,IComponentFactory.cs,IDriver.cs,ISizeMonitor.cs,PlatformDetection.cs,SizeDetectionMode.cs,SizeMonitorImpl.cs,TuiPlatform.cs}\n|Drivers/AnsiDriver:{AnsiComponentFactory.cs,AnsiInput.cs,AnsiInputProcessor.cs,AnsiOutput.cs,AnsiPlatform.cs,AnsiSizeMonitor.cs,AnsiTerminalHelper.cs,FakeClipboard.cs}\n|Drivers/AnsiHandling:{AnsiEscapeSequence.cs,AnsiEscapeSequenceRequest.cs,AnsiKeyboardEncoder.cs,AnsiKeyboardParser.cs,AnsiKeyboardParserPattern.cs,AnsiKeyConverter.cs,AnsiMouseEncoder.cs,AnsiMouseParser.cs,AnsiRequestScheduler.cs,AnsiResponseExpectation.cs,AnsiResponseParser.cs,AnsiResponseParserBase.cs,AnsiResponseParserState.cs,AnsiResponseParserTInputRecord.cs,AnsiStartupGate.cs,AnsiStartupQuery.cs,CsiCursorPattern.cs,CsiKeyPattern.cs,EscAsAltPattern.cs,GenericHeld.cs,IAnsiResponseParser.cs,IAnsiStartupGate.cs,IHeld.cs,KittyKeyboardCapabilities.cs,KittyKeyboardFlags.cs,KittyKeyboardPattern.cs,KittyKeyboardProtocolDetector.cs,Osc8UrlLinker.cs,ProgressIndicator.cs,ReasonCannotSend.cs,Ss3Pattern.cs,StringHeld.cs,TerminalColorDetector.cs}\n|Drivers/AnsiHandling/EscSeqUtils:{EscSeqReqStatus.cs,EscSeqRequests.cs,EscSeqUtils.cs}\n|Drivers/DotNetDriver:{INetInput.cs,NetComponentFactory.cs,NetInput.cs,NetInputProcessor.cs,NetKeyConverter.cs,NetOutput.cs}\n|Drivers/Input:{ConsoleInputSource.cs,IInput.cs,IInputProcessor.cs,IInputSource.cs,InputImpl.cs,InputProcessorImpl.cs,InputRecord.cs,ITestableInput.cs,TestInputSource.cs}\n|Drivers/Keyboard:{ConsoleKeyInfoExtensions.cs,ConsoleKeyMapping.cs,IKeyConverter.cs,KeyCode.cs,VK.cs}\n|Drivers/Mouse:{MouseButtonClickTracker.cs,MouseInterpreter.cs}\n|Drivers/Output:{IOutput.cs,IOutputBuffer.cs,OutputBase.cs,OutputBufferImpl.cs}\n|Drivers/TerminalEnvironment:{ColorCapabilityLevel.cs,TerminalColorCapabilities.cs,TerminalEnvironmentDetector.cs}\n|Drivers/UnixHelpers:{SuspendHelper.cs,UnixClipboard.cs,UnixIOHelper.cs,UnixRawModeHelper.cs,UnixTerminalHelper.cs}\n|Drivers/WindowsDriver:{ClipboardImpl.cs,CursorVisibility.cs,IWindowsInput.cs,WindowsComponentFactory.cs,WindowsConsole.cs,WindowsInput.cs,WindowsInputProcessor.cs,WindowsKeyboardLayout.cs,WindowsKeyConverter.cs,WindowsKeyHelper.cs,WindowsOutput.cs}\n|Drivers/WindowsHelpers:{NetWinVTConsole.cs,WindowsConsoleHelper.cs,WindowsVTInputHelper.cs,WindowsVTOutputHelper.cs}\n|FileServices:{DefaultSearchMatcher.cs,FileSystemColorProvider.cs,FileSystemIconProvider.cs,FileSystemInfoStats.cs,FileSystemTreeBuilder.cs,IFileOperations.cs,ISearchMatcher.cs}\n|Input:{Command.cs,CommandBinding.cs,CommandBindingsBase.cs,CommandBridge.cs,CommandContext.cs,CommandContextExtensions.cs,CommandEventArgs.cs,CommandOutcome.cs,CommandRouting.cs,IAcceptTarget.cs,ICommandBinding.cs,ICommandContext.cs}\n|Input/Keyboard:{Bind.cs,Key.cs,KeyBinding.cs,KeyBindings.cs,KeyChangedEventArgs.cs,KeyEqualityComparer.cs,KeyEventType.cs,KeystrokeNavigatorEventArgs.cs,ModifierKey.cs,PlatformKeyBinding.cs}\n|Input/Mouse:{GrabMouseEventArgs.cs,Mouse.cs,MouseBinding.cs,MouseBindings.cs,MouseFlags.cs,MouseFlagsChangedEventArgs.cs}\n|Resources:{GlobalResources.cs,ResourceManagerWrapper.cs,Strings.Designer.cs}\n|Testing:{IInputInjector.cs,InputInjectionEvent.cs,InputInjectionExtensions.cs,InputInjectionMode.cs,InputInjectionOptions.cs,InputInjector.cs}\n|Text:{NerdFonts.cs,RuneExtensions.cs,StringExtensions.cs,TextDirection.cs,TextFormatter.cs}\n|Time:{FuncTimeProvider.cs,ITimeProvider.cs,ITimer.cs,SystemTimeProvider.cs,VirtualTimeProvider.cs}\n|ViewBase:{DrawAdornmentsEventArgs.cs,DrawContext.cs,DrawEventArgs.cs,IDesignable.cs,IValue.cs,View.Adornments.cs,View.Arrangement.cs,View.Command.cs,View.Content.cs,View.cs,View.Cursor.cs,View.Diagnostics.cs,View.Drawing.Adornments.cs,View.Drawing.Attribute.cs,View.Drawing.Clipping.cs,View.Drawing.cs,View.Drawing.LineCanvas.cs,View.Drawing.Primitives.cs,View.Drawing.Scheme.cs,View.Hierarchy.cs,View.Keyboard.cs,View.Layout.cs,View.Navigation.cs,View.NeedsDraw.cs,View.ScrollBars.cs,View.Text.cs,ViewCollectionHelpers.cs,ViewDiagnosticFlags.cs,ViewEventArgs.cs,ViewExtensions.cs,ViewportSettingsFlags.cs,WeakReferenceExtensions.cs}\n|ViewBase/Adornment:{AdornmentImpl.cs,AdornmentView.cs,ArrangeButtons.cs,Arranger.cs,ArrangerButton.cs,Border.cs,BorderSettings.cs,BorderView.Arrangement.cs,BorderView.cs,IAdornment.cs,IAdornmentView.cs,ITitleView.cs,Margin.cs,MarginView.cs,Padding.cs,PaddingView.cs,ShadowStyles.cs,ShadowView.cs,TabLayoutContext.cs,TitleView.cs}\n|ViewBase/Helpers:{StackExtensions.cs}\n|ViewBase/Layout:{AddOrSubtract.cs,Aligner.cs,Alignment.cs,AlignmentModes.cs,Dim.cs,DimAbsolute.cs,DimAuto.cs,DimAutoStyle.cs,DimCombine.cs,Dimension.cs,DimFill.cs,DimFunc.cs,DimPercent.cs,DimPercentMode.cs,DimView.cs,LayoutEventArgs.cs,LayoutException.cs,Pos.cs,PosAbsolute.cs,PosAlign.cs,PosAnchorEnd.cs,PosCenter.cs,PosCombine.cs,PosFunc.cs,PosPercent.cs,PosView.cs,Side.cs,SizeChangedEventArgs.cs,SuperViewChangedEventArgs.cs,ViewArrangement.cs,ViewManipulator.cs}\n|ViewBase/Mouse:{IMouseHoldRepeater.cs,MouseHoldRepeaterImpl.cs,MouseState.cs,View.Mouse.cs}\n|ViewBase/Navigation:{AdvanceFocusEventArgs.cs,FocusEventArgs.cs,NavigationDirection.cs,TabBehavior.cs}\n|ViewBase/Orientation:{IOrientation.cs,Orientation.cs,OrientationHelper.cs}\n|Views:{Bar.cs,Button.cs,CheckBox.cs,CheckState.cs,DatePicker.cs,Dialog.cs,DialogTResult.cs,DropDownList.cs,DropDownListTEnum.cs,FrameView.cs,HexView.cs,HexViewEventArgs.cs,Label.cs,Line.cs,Link.cs,MessageBox.cs,NumericUpDown.cs,ProgressBar.cs,Prompt.cs,PromptExtensions.cs,ReadOnlyCollectionExtensions.cs,Shortcut.cs,StatusBar.cs,Tabs.cs,Window.cs}\n|Views/Autocomplete:{AppendAutocomplete.cs,AutocompleteBase.cs,AutocompleteContext.cs,AutocompleteFilepathContext.cs,IAutocomplete.cs,ISuggestionGenerator.cs,PopupAutocomplete.cs,PopupAutocomplete.PopUp.cs,SingleWordSuggestionGenerator.cs,Suggestion.cs}\n|Views/CharMap:{CharMap.cs,UcdApiClient.cs,UnicodeRange.cs}\n|Views/CollectionNavigation:{CollectionNavigator.cs,CollectionNavigatorBase.cs,DefaultCollectionNavigatorMatcher.cs,ICollectionNavigator.cs,ICollectionNavigatorMatcher.cs,IListCollectionNavigator.cs,TableCollectionNavigator.cs}\n|Views/Color:{AttributePicker.cs,BBar.cs,ColorBar.cs,ColorModelStrategy.cs,ColorPicker.16.cs,ColorPicker.cs,ColorPicker.Style.cs,GBar.cs,HueBar.cs,IColorBar.cs,LightnessBar.cs,RBar.cs,SaturationBar.cs,ValueBar.cs}\n|Views/FileDialogs:{AllowedType.cs,DefaultFileOperations.cs,FileDialog.Commands.cs,FileDialog.cs,FileDialog.Navigation.cs,FileDialog.TableView.cs,FileDialogCollectionNavigator.cs,FileDialogHistory.cs,FileDialogState.cs,FileDialogStyle.cs,FileDialogTableSource.cs,FilesSelectedEventArgs.cs,FileSystemCollectionNavigationMatcher.cs,OpenDialog.cs,OpenMode.cs,SaveDialog.cs}\n|Views/GraphView:{Axis.cs,AxisIncrementToRender.cs,BarSeriesBar.cs,GraphCellToRender.cs,GraphView.cs,HorizontalAxis.cs,IAnnotation.cs,ISeries.cs,LegendAnnotation.cs,LineF.cs,MultiBarSeries.cs,PathAnnotation.cs,ScatterSeries.cs,Series.cs,TextAnnotation.cs,VerticalAxis.cs}\n|Views/LinearRange:{LinearRange.cs,LinearRangeAttributes.cs,LinearRangeConfiguration.cs,LinearRangeEventArgs.cs,LinearRangeOption.cs,LinearRangeOptionEventArgs.cs,LinearRangeStyle.cs,LinearRangeType.cs}\n|Views/ListView:{IListDataSource.cs,ListView.Commands.cs,ListView.cs,ListView.Drawing.cs,ListView.Movement.cs,ListView.Selection.cs,ListViewEventArgs.cs,ListViewT.cs,ListWrapper.cs}\n|Views/Markdown:{InlineRun.cs,IntermediateBlock.cs,Markdown.cs,MarkdownCodeBlock.cs,MarkdownImageResolver.cs,MarkdownInlineParser.cs,MarkdownLinkEventArgs.cs,MarkdownTable.cs,MarkdownView.Drawing.cs,MarkdownView.Layout.cs,MarkdownView.Mouse.cs,MarkdownView.Parsing.cs,RenderedLine.cs,TableData.cs}\n|Views/Menu:{IMenuBarEntry.cs,Menu.cs,MenuBar.cs,MenuBarItem.cs,MenuItem.cs,PopoverMenu.cs}\n|Views/Runnable:{Runnable.cs,RunnableTResult.cs,RunnableWrapper.cs}\n|Views/ScrollBar:{ScrollBar.cs,ScrollBarVisibilityMode.cs,ScrollButton.cs,ScrollSlider.cs}\n|Views/Selectors:{FlagSelector.cs,FlagSelectorTEnum.cs,OptionSelector.cs,OptionSelectorTEnum.cs,SelectorBase.cs,SelectorStyles.cs}\n|Views/SpinnerView:{SpinnerStyle.cs,SpinnerView.cs}\n|Views/TableView:{CellActivatedEventArgs.cs,CellColorGetterArgs.cs,CellToggledEventArgs.cs,CheckBoxTableSourceWrapper.cs,CheckBoxTableSourceWrapperByIndex.cs,CheckBoxTableSourceWrapperByObject.cs,ColumnStyle.cs,DataTableSource.cs,EnumerableTableSource.cs,IEnumerableTableSource.cs,ITableSource.cs,ListColumnStyle.cs,ListTableSource.cs,RowColorGetterArgs.cs,SelectedCellChangedEventArgs.cs,TableSelection.cs,TableStyle.cs,TableView.CellMapping.cs,TableView.cs,TableView.Drawing.cs,TableView.Mouse.cs,TableView.Navigation.cs,TableView.Selection.cs,TreeTableSource.cs}\n|Views/TextInput:{ContentsChangedEventArgs.cs,DateEditor.cs,DateTextProvider.cs,HistoryText.cs,HistoryTextItemEventArgs.cs,ITextValidateProvider.cs,NetMaskedTextProvider.cs,TextEditingLineStatus.cs,TextModel.cs,TextRegexProvider.cs,TextValidateField.cs,TimeEditor.cs,TimeTextProvider.cs}\n|Views/TextInput/TextField:{TextField.Commands.cs,TextField.cs,TextField.Drawing.cs,TextField.History.cs,TextField.Keyboard.cs,TextField.Mouse.cs,TextField.Selection.cs,TextField.Text.cs,TextFieldAutocomplete.cs}\n|Views/TextInput/TextView:{TextView.Commands.cs,TextView.cs,TextView.Drawing.cs,TextView.Files.cs,TextView.Find.cs,TextView.History.cs,TextView.Keyboard.cs,TextView.Mouse.cs,TextView.Movement.cs,TextView.Scrolling.cs,TextView.Selection.cs,TextView.Text.cs,TextView.WordWrap.cs,TextViewAutocomplete.cs,WordWrapManager.cs}\n|Views/TreeView:{AspectGetterDelegate.cs,Branch.cs,DelegateTreeBuilder.cs,DrawTreeViewLineEventArgs.cs,ITreeBuilder.cs,ITreeNode.cs,ITreeView.cs,ITreeViewFilter.cs,ObjectActivatedEventArgs.cs,SelectionChangedEventArgs.cs,TreeBuilder.cs,TreeNode.cs,TreeNodeBuilder.cs,TreeSelection.cs,TreeStyle.cs,TreeView.cs,TreeView.Drawing.cs,TreeView.Mouse.cs,TreeView.Navigation.cs,TreeViewCollectionNavigatorMatcher.cs,TreeViewT.cs,TreeViewTextFilter.cs}\n|Views/Wizard:{Wizard.cs,WizardStep.cs}\n\n<!-- END AUTO-GENERATED-SOURCE-INDEX -->\n\n---\n\n## Compressed API Type Index\n\n> Quick reference for key types. Full list: [.tg-docs/INDEX.md](.tg-docs/INDEX.md)\n> Format: `|Type|Category|Key members/notes`\n\n### Terminal.Gui.App (35 types)\n```\n|Application|Class|Static facade (obsolete),Init,Run,Shutdown,Top\n|IApplication|Interface|Instance-based,SessionStack,Run,Dispose\n|SessionToken|Class|Session lifecycle,IDisposable\n|Clipboard|Class|GetText,SetText,TryGetText\n|IRunnable|Interface|Run view modal,used by Dialog\n|ITimedEvents|Interface|AddTimeout,AddIdle,RemoveTimeout\n|CancelEventArgs<T>|Class|Cancel property,cancellable events\n|ValueChangingEventArgs<T>|Class|OldValue,NewValue,Cancel\n|ApplicationNavigation|Class|Focus management,GetFocused,AdvanceFocus\n|ApplicationPopover|Class|Popover management,Show,Hide\n```\n\n### Terminal.Gui.ViewBase (70 types)\n```\n|View|Class|Base class,Add,Remove,Frame,Viewport,Draw\n|Pos|Class|Position:Absolute,Percent,Center,AnchorEnd,Func\n|PosAbsolute|Class|Pos.At(n),absolute coordinate\n|PosPercent|Class|Pos.Percent(n),percentage of SuperView\n|PosCenter|Class|Pos.Center(),centered\n|PosAnchorEnd|Class|Pos.AnchorEnd(n),from right/bottom\n|PosView|Class|Pos.Left/Right/Top/Bottom(view)\n|Dim|Class|Dimension:Absolute,Auto,Fill,Percent,Func\n|DimAbsolute|Class|Dim.Absolute(n),fixed size\n|DimAuto|Class|Dim.Auto(),content-based sizing\n|DimFill|Class|Dim.Fill(margin),fill remaining\n|DimPercent|Class|Dim.Percent(n),percentage\n|Adornment|Class|Base for Border,Margin,Padding\n|Border|Class|View border,Title,LineStyle\n|Margin|Class|View outer margin\n|Padding|Class|View inner padding\n|Alignment|Enum|Start,Center,End,Fill\n|Orientation|Enum|Horizontal,Vertical\n|TabBehavior|Enum|NoStop,TabStop,TabGroup\n|ViewArrangement|Enum|Movable,Resizable,Overlapped\n```\n\n### IValue<T> Pattern (Critical)\n\nAll typed views expose their data through `IValue<T>.Value`. Do not guess property-specific names such as `.Date`, `.Time`, or `.Color`.\n\n| View | IValue<T> |\n|------|-----------|\n| TextField | `IValue<string>` |\n| NumericUpDown<T> | `IValue<T>` |\n| DatePicker | `IValue<DateTime>` |\n| TimeEditor | `IValue<TimeSpan>` |\n| ColorPicker | `IValue<Color?>` |\n| AttributePicker | `IValue<Attribute?>` |\n| CheckBox | `IValue<CheckState>` |\n| OptionSelector | `IValue<int?>` |\n| FlagSelector | `IValue<int?>` |\n\nImplementing `IValue<T>` requires `ValueChanging`, `ValueChanged`, and `ValueChangedUntyped`.\n\n### RunnableWrapper<TView, TResult>\n\n- Wraps a `View` as a runnable with typed results.\n- Clears wrapper `KeyBindings` and `MouseBindings` so the wrapped view handles input.\n- Does not add OK/Cancel buttons (unlike `Prompt`).\n- Sets `CommandsToBubbleUp = [Command.Accept]`.\n- On accept, it extracts results via `ResultExtractor` if provided; otherwise via `IValue<TResult>.Value` when available.\n\n### Terminal.Gui.Views (180+ types)\n```\n[Core Controls]\n|Button|Class|Text,Accept event,IsDefault\n|Label|Class|Text display,TextAlignment\n|TextField|Class|Single-line input,Text,Secret\n|Editor|Class|Multi-line editor,Text,ReadOnly\n|CheckBox|Class|CheckedState,AllowCheckStateNone\n|DropDownList|Class|Dropdown,Source,SelectedItem\n|ProgressBar|Class|Fraction,BidirectionalMarquee\n|ScrollBar|Class|Position,Size,Orientation\n|NumericUpDown<T>|Class|Value,Increment\n\n[Containers]\n|Window|Class|Top-level,Title,MenuBar support\n|Dialog|Class|Modal,Buttons,AddButton\n|Dialog<T>|Class|Modal with result\n|FrameView|Class|Titled frame container\n|TabView|Class|Tabs,AddTab,SelectedTab\n|Wizard|Class|Multi-step,AddStep,CurrentStep\n\n[Lists & Data]\n|ListView|Class|Source,SelectedItem,AllowsMarking\n|TableView|Class|Table,SelectedRow,SelectedColumn\n|TreeView|Class|Objects,AddObject,SelectedObject\n|TreeView<T>|Class|Generic tree\n\n[Menus]\n|MenuBar|Class|Menus,UseKeysUpDownAsKeysLeftRight\n|MenuItem|Class|Title,Action,Shortcut,SubMenu\n|MenuBarItem|Class|Title,Children array\n|Menu|Class|Popup menu display\n|PopoverMenu|Class|Context menu,Show(items)\n|StatusBar|Class|Items,Visible\n\n[File Dialogs]\n|FileDialog|Class|Base,Path,AllowedFileTypes\n|OpenDialog|Class|FilePaths,AllowsMultipleSelection,Canceled,OpenMode\n|SaveDialog|Class|SaveFile,FileName\n\n[Specialized]\n|ColorPicker|Class|SelectedColor,Style\n|GraphView|Class|Series,Annotations,AxisX/Y\n|HexView|Class|Source,Position,Edits\n|CharMap|Class|SelectedCodePoint,Start/End\n|SpinnerView|Class|SpinnerStyle,AutoSpin\n|MessageBox|Class|Query,ErrorQuery,static methods\n```\n\n### Terminal.Gui.Input (18 types)\n```\n|Key|Class|KeyCode,Modifiers,IsCtrl,IsAlt,IsShift\n|KeyBindings|Class|Add,Get,TryGet,Remove,GetCommands\n|KeyBinding|Struct|Commands[],Scope,Target\n|Mouse|Class|Position,Flags,View\n|MouseBindings|Class|Add,Get,TryGet,Remove\n|MouseBinding|Struct|Commands[],Scope\n|MouseFlags|Enum|Button1Clicked,Button1DoubleClicked,WheeledUp/Down\n|Command|Enum|Accept,Cancel,Select,HotKey,ScrollUp/Down\n|CommandContext|Struct|Command,KeyBinding,Source\n```\n\n### Terminal.Gui.Drawing (40 types)\n```\n|Attribute|Struct|Foreground,Background,constructor(fg,bg)\n|Color|Struct|R,G,B,Parse,TryParse,FromArgb\n|Scheme|Class|Normal,Focus,HotNormal,HotFocus,Disabled\n|LineCanvas|Class|AddLine,GetMap,Merge\n|LineStyle|Enum|None,Single,Double,Rounded,Heavy\n|Glyphs|Class|Bullet,CheckMark,Diamond,etc.\n|Cell|Struct|Rune,Attribute\n|Thickness|Struct|Top,Left,Bottom,Right,Vertical,Horizontal\n|Region|Class|Clipping,Union,Intersect,Exclude\n|Gradient|Class|Colors[],Spectrum\n```\n\n**Gotchas**\n- `Terminal.Gui.Drawing.Attribute` can conflict with `System.Attribute` with implicit usings. Use `using TgAttribute = Terminal.Gui.Drawing.Attribute;` or fully qualify.\n- `Color.TryParse (string, out Color?)` is nullable out. `Color.TryParse (string?, IFormatProvider?, out Color)` is non-nullable out.\n\n### Terminal.Gui.Drivers (80+ types)\n```\n|IDriver|Interface|Init,End,Refresh,AddStr,Move\n|Driver|Class|Base implementation\n|DriverRegistry|Class|GetDrivers,Get,MakeDriver\n|KeyCode|Enum|Key constants,A-Z,F1-F12,Enter,Esc\n|CursorVisibility|Enum|Default,Invisible,Underline,Box\n|IOutput|Interface|Terminal output\n|IInputProcessor|Interface|Input processing\n```\n\n### Terminal.Gui.Configuration (15 types)\n```\n|ConfigurationManager|Class|Settings,Themes,Apply,Reset\n|SchemeManager|Class|GetScheme,Schemes dictionary\n|ThemeManager|Class|Theme,Themes,SelectedTheme\n|ConfigLocations|Enum|Default,Global,App,Runtime\n```\n\n### Terminal.Gui.Testing (8 types)\n```\n|InputInjector|Class|InjectKey,InjectMouse,InjectChar\n|IInputInjector|Interface|Injection interface\n|VirtualTimeProvider|Class|Testing time control\n```\n\n### Terminal.Gui.Text (4 types)\n```\n|TextFormatter|Class|Text,Format,Size,Draw\n|TextDirection|Enum|LeftRight_TopBottom,RightLeft,etc.\n```\n\n### Terminal.Gui.Time (4 types)\n```\n|ITimeProvider|Interface|Now,UtcNow,CreateTimer\n|VirtualTimeProvider|Class|Testing,Advance,SetTime\n|SystemTimeProvider|Class|Real system time\n```\n\n### Terminal.Gui.FileServices (5 types)\n```\n|IFileOperations|Interface|GetFiles,GetDirectories,Exists\n|FileSystemTreeBuilder|Class|Build file trees\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","CLAUDE.md":"# CLAUDE.md\n\n> **Guidance for AI agents working with Terminal.Gui.**\n> For humans, see [CONTRIBUTING.md](./CONTRIBUTING.md).\n> For Terminal.Gui's mission, tenets, and engineering philosophy, see [specs/constitution.md](./specs/constitution.md).\n> See also: [llms.txt](./llms.txt) for machine-readable context.\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data is **wrong**.\n\n> **Read [ai-v2-primer.md](./ai-v2-primer.md) FIRST** — it has the v1→v2 corrections table,\n> correct minimal app pattern, and all common gotchas.\n\n## Quick Reference: What Are You Doing?\n\n| Your Task | Go Here |\n|-----------|---------|\n| **\"Build me an app that...\"** | [.claude/tasks/build-app.md](.claude/tasks/build-app.md) |\n| **\"Add a feature to Terminal.Gui...\"** | Continue below (Contributor Guide) |\n| **\"Fix a bug in Terminal.Gui...\"** | Continue below (Contributor Guide) |\n| **\"Record a GIF / verify a UI change...\"** | [Scripts/tuirec/README.md](Scripts/tuirec/README.md) |\n\n### App Builder Quick Start\n```bash\ndotnet new install Terminal.Gui.Templates@2.*\ndotnet new tui-simple -n myapp\ncd myapp\ndotnet run\n```\n\nSee [.claude/tasks/build-app.md](.claude/tasks/build-app.md) for complete app development guide.\nSee [.claude/cookbook/common-patterns.md](.claude/cookbook/common-patterns.md) for UI recipes.\n\n---\n\n# Contributor Guide\n\n**The rest of this file is for contributors modifying Terminal.Gui itself.**\n\n## Before Every File Edit\n\n**READ `.claude/REFRESH.md` first.** It contains a quick checklist to prevent common mistakes.\n\n## After Writing/Modifying Code\n\n**USE `.claude/POST-GENERATION-VALIDATION.md` to validate ALL code.** This catches the most common formatting violations AI agents make.\n\n## Detailed Rules\n\nSee `.claude/rules/` for detailed guidance:\n- `formatting.md` - **SPACING, BRACES, BLANK LINES** (most commonly violated!)\n- `type-declarations.md` - **No var** except built-in types\n- `target-typed-new.md` - Use `new ()` not `new TypeName()`\n- `terminology.md` - **SubView/SuperView**, never \"child/parent\"\n- `event-patterns.md` - Lambdas, closures, handlers\n- `early-return.md` - **Guard clauses, minimal nesting** (commonly violated!)\n- `collection-expressions.md` - Use `[...]` syntax\n- `unicode-graphemes.md` - **Think in graphemes** - `GetColumns()`, `GraphemeHelper.GetGraphemes()`\n- `cwp-pattern.md` - Cancellable Workflow Pattern\n- `code-layout.md` - Backing fields, member ordering\n- `api-documentation.md` - XML documentation requirements\n- `testing-patterns.md` - Test patterns and requirements\n- `logging-tracing.md` - **No Console.WriteLine** - use Logging/TestLogging/Trace\n- `fragile-areas.md` - Code that must not be refactored in passing (TextView init)\n\n## Task-Specific Guides\n\nSee `.claude/tasks/` for task checklists:\n- `clean-code-review.md` - Creating clean git commit histories\n- `build-app.md` - Building applications with Terminal.Gui\n\n## Planning Mode\n\nWhen in planning mode:\n- **Create plan files in `./plans/`** (relative to the repository root)\n- Plan files should be markdown format\n- Include detailed implementation steps, file changes, and verification steps\n- Reference existing code patterns and reuse opportunities\n\n---\n\n## Project Overview\n\n**Terminal.Gui** - Cross-platform .NET console UI toolkit\n\n- **Language**: C# 14 (net10.0)\n- **Branch**: `develop`\n- **Version**: v2 (stable)\n\n## Build & Test\n\n```bash\ndotnet restore\ndotnet build --no-restore\n\n# Preferred: parallelizable tests (no static state)\ndotnet test --project Tests/UnitTestsParallelizable --no-build\n\n# Tests that require process-wide static state (Application.Init, etc.)\ndotnet test --project Tests/UnitTests.NonParallelizable --no-build\n\n# Legacy tests — do NOT add new tests here; candidates for rewrite/deletion\ndotnet test --project Tests/UnitTests.Legacy --no-build\n\n# Run a single test by method name (Microsoft Testing Platform)\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-method \"*MyTestMethod\"\n\n# Run all tests in a class\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-class \"*MyTestClass\"\n```\n\nSee `Tests/README.md` for the full list of test projects (including `IntegrationTests`, `StressTests`, `Benchmarks`) and the static-state classification that determines where a new test belongs.\n\n## Seeing Your Changes (Visual Verification)\n\nAgents can observe a running Terminal.Gui app — don't ship UI changes blind. Use [`tuirec`](https://github.com/tui-cs/tuirec) to run the app in a PTY, inject keystrokes, and capture the result:\n\n- **Full guide:** [Scripts/tuirec/README.md](Scripts/tuirec/README.md) — install, keystroke syntax, UICatalog scenario recipes, validation checklist\n- The `.cast` output is asciinema v2 JSON (plain text) — **read it back** to verify what actually rendered, frame by frame\n- The `.gif` output is for humans — attach it to PRs that change visuals\n- For deterministic in-process assertions, use `InputInjector`/`VirtualTimeProvider` (see `docfx/docs/input-injection.md`) and driver `ToString ()` screen captures\n\n## Key Concepts\n\n| Concept | Documentation |\n|---------|--------------|\n| Application Lifecycle | `docfx/docs/application.md` |\n| View Hierarchy | `docfx/docs/View.md` |\n| Layout (Pos/Dim) | `docfx/docs/layout.md` |\n| CWP Events | `docfx/docs/cancellable-work-pattern.md` |\n| Terminology | `docfx/docs/lexicon.md` |\n\n## Critical Rules (Summary)\n\n1. **Space BEFORE `()` and `[]`** - `Method ()` not `Method()`, `array [i]` not `array[i]` (MOST VIOLATED!)\n2. **Braces on NEXT line** - ALL opening braces use Allman style\n3. **Blank lines** - before `return`/`break`/`continue`, after control blocks\n4. **No `var`** except: `int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`\n5. **Use `new ()`** not `new TypeName()`\n6. **Use `[...]`** not `new () { ... }` for collections\n7. **SubView/SuperView** for containment (Parent/Child only for non-containment refs)\n8. **Unused lambda params** - use `_`: `(_, _) => { }`\n9. **Early return / guard clauses** - ALWAYS invert conditions and return/continue early. Never wrap the happy path in a conditional. Applies to methods, lambdas, and loops. See `.claude/rules/early-return.md`.\n10. **One type per file** - Public and internal types each get their own file\n11. **Docs instruction style** - In reference/how-to/API docs, write `To [goal], [imperative action].` Avoid `When/If you want/need to ...` unless describing a real condition.\n\n## Testing\n\n- Add new tests to `UnitTestsParallelizable`; use `UnitTests.NonParallelizable` only when static state is unavoidable. Never add to `UnitTests.Legacy`.\n- Add a comment marking the test as AI-generated. Either form is acceptable: `// Claude - <model>` or `// CoPilot - <model>` — just include the agent and the model that produced the test (e.g., `// Claude - Opus 4.5` or `// CoPilot - ChatGPT v4`). Both forms are established in the codebase; which marker is used is not a style concern and reviewers should not flag inconsistency between them.\n- Never decrease coverage\n- Avoid `Application.Init` in tests\n\n## Repository Structure\n\n```\n/Terminal.Gui/     - Core library\n/Tests/            - Unit tests\n/Examples/UICatalog/ - Demo app\n/docfx/docs/       - Documentation\n/.claude/          - AI agent guidance\n```\n\n## What NOT to Do\n\n- Don't forget space before `()` and `[]` - this is the #1 mistake!\n- Don't put braces on same line (use Allman style)\n- Don't skip blank lines before returns or after control blocks\n- Don't use `var` for non-built-in types\n- Don't use redundant type names with `new`\n- Don't say \"child/parent\" for containment (use SubView/SuperView)\n- Don't wrap the happy path in a conditional — use guard clauses and return early\n- Don't modify unrelated code\n- Don't introduce new warnings\n- Don't skip POST-GENERATION-VALIDATION.md after writing code\n",".cursorrules":"# Terminal.Gui - Cursor AI Rules\n\n> **Cross-platform .NET console UI toolkit. C# 14 targeting net10.0.**\n> Full contribution guide: [CONTRIBUTING.md](CONTRIBUTING.md).\n\n---\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data about Terminal.Gui is **wrong**.\n\n> **Read [ai-v2-primer.md](ai-v2-primer.md) FIRST** — it contains the v1→v2 corrections table,\n> correct minimal app pattern, and all common gotchas.\n\n### v1 → v2 Quick Corrections (Most Common Mistakes)\n\n| v1 (WRONG) | v2 (CORRECT) |\n|---|---|\n| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |\n| `Application.Run ();` | `app.Run<MyWindow> ();` |\n| `Application.Shutdown ();` | `app.Dispose ();` |\n| `Application.Top` | No global top — pass root view to `app.Run ()` |\n| `new Toplevel ()` | Use `Runnable` subclass or `Window` |\n| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |\n| `new Button (\"OK\")` | `new Button { Text = \"OK\" }` |\n| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |\n| `view.Bounds` | `view.Viewport` |\n| `new RadioGroup (...)` | `new OptionSelector { ... }` |\n\n---\n\n## Build & Test\n\n```bash\ndotnet restore\ndotnet build --no-restore\ndotnet test --project Tests/UnitTestsParallelizable --no-build\ndotnet test --project Tests/UnitTests.NonParallelizable --no-build\n```\n\n---\n\n## Correct Minimal App (v2)\n\n```csharp\nusing Terminal.Gui.App;\nusing Terminal.Gui.Views;\n\nIApplication app = Application.Create ().Init ();\napp.Run<MainWindow> ();\napp.Dispose ();\n\npublic sealed class MainWindow : Runnable\n{\n    public MainWindow ()\n    {\n        Title = \"My App (Esc to quit)\";\n\n        Button button = new ()\n        {\n            Text = \"Click Me\",\n            X = Pos.Center (),\n            Y = Pos.Center ()\n        };\n\n        button.Accepted += (_, _) =>\n        {\n            MessageBox.Query (App!, \"Hello\", \"Button was clicked!\", \"OK\");\n        };\n\n        Add (button);\n    }\n}\n```\n\n---\n\n## Code Style (For Library Contributors Only)\n\n> **Note:** These rules apply only when contributing code to the Terminal.Gui library itself.\n> App developers using Terminal.Gui do NOT need to follow these conventions.\n\n1. **Space BEFORE `()` and `[]`** — `Method ()` not `Method()`, `array [i]` not `array[i]`\n2. **Braces on NEXT line** (Allman style) — no exceptions\n3. **Blank lines** — before `return`/`break`/`continue`, after `if`/`for`/`while` blocks\n4. **No `var`** — Explicit types except built-ins (`int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`)\n5. **Use `new ()`** — `Button btn = new ()` not `Button btn = new Button ()`\n6. **Collection expressions** — Use `[...]` not `new List<T> { ... }`\n7. **SubView/SuperView** — Never \"child\", \"parent\", or \"container\"\n8. **Unused lambda params** — Use `_` discard: `(_, _) => { }`\n9. **Early return / guard clauses** — ALWAYS invert conditions and return early\n10. **One type per file** — Public and internal types each get their own file\n\n---\n\n## Architecture Overview\n\n### Application lifecycle\n`Application.Create ()` → `.Init ()` → `.Run<T> ()` → `.Dispose ()`.\nInstance-based `IApplication` — do NOT use static `Application.Init()`/`Run()`/`Shutdown()`.\n\n### View system\n`View` is the base class. Views form a tree via `Add ()`/`Remove ()`.\nEvery View has: `Margin` → `Border` → `Padding` → content area.\nLayout uses `Pos` (position) and `Dim` (dimension) for declarative relative layout.\n\n### Cancellable Workflow Pattern (CWP)\nStandard event pattern: **do work → call virtual `OnXxx` → raise event**.\n\n### Command/input system\nInput flows: Driver → `IInputProcessor` → `KeyBindings`/`MouseBindings` → `Command` → handler.\n\n---\n\n## Key References\n\n| Resource | Path |\n|----------|------|\n| v1→v2 Primer (READ FIRST) | [ai-v2-primer.md](ai-v2-primer.md) |\n| Full agent instructions | [AGENTS.md](AGENTS.md) |\n| Compressed API docs | `docfx/apispec/namespace-*.md` |\n| Common UI patterns | `.claude/cookbook/common-patterns.md` |\n| App building guide | `.claude/tasks/build-app.md` |\n| Deep-dive docs | `docfx/docs/` |\n| Working examples | `Examples/UICatalog/`, `Examples/ScenarioRunner/`, `tui-cs/Examples` |\n",".windsurfrules":"# Terminal.Gui - Windsurf AI Rules\n\n> **Cross-platform .NET console UI toolkit. C# 14 targeting net10.0.**\n> Full contribution guide: [CONTRIBUTING.md](CONTRIBUTING.md).\n\n---\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data about Terminal.Gui is **wrong**.\n\n> **Read [ai-v2-primer.md](ai-v2-primer.md) FIRST** — it contains the v1→v2 corrections table,\n> correct minimal app pattern, and all common gotchas.\n\n### v1 → v2 Quick Corrections (Most Common Mistakes)\n\n| v1 (WRONG) | v2 (CORRECT) |\n|---|---|\n| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |\n| `Application.Run ();` | `app.Run<MyWindow> ();` |\n| `Application.Shutdown ();` | `app.Dispose ();` |\n| `Application.Top` | No global top — pass root view to `app.Run ()` |\n| `new Toplevel ()` | Use `Runnable` subclass or `Window` |\n| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |\n| `new Button (\"OK\")` | `new Button { Text = \"OK\" }` |\n| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |\n| `view.Bounds` | `view.Viewport` |\n| `new RadioGroup (...)` | `new OptionSelector { ... }` |\n\n---\n\n## Build & Test\n\n```bash\ndotnet restore\ndotnet build --no-restore\ndotnet test --project Tests/UnitTestsParallelizable --no-build\ndotnet test --project Tests/UnitTests.NonParallelizable --no-build\n```\n\n---\n\n## Correct Minimal App (v2)\n\n```csharp\nusing Terminal.Gui.App;\nusing Terminal.Gui.Views;\n\nIApplication app = Application.Create ().Init ();\napp.Run<MainWindow> ();\napp.Dispose ();\n\npublic sealed class MainWindow : Runnable\n{\n    public MainWindow ()\n    {\n        Title = \"My App (Esc to quit)\";\n\n        Button button = new ()\n        {\n            Text = \"Click Me\",\n            X = Pos.Center (),\n            Y = Pos.Center ()\n        };\n\n        button.Accepted += (_, _) =>\n        {\n            MessageBox.Query (App!, \"Hello\", \"Button was clicked!\", \"OK\");\n        };\n\n        Add (button);\n    }\n}\n```\n\n---\n\n## Code Style (For Library Contributors Only)\n\n> **Note:** These rules apply only when contributing code to the Terminal.Gui library itself.\n> App developers using Terminal.Gui do NOT need to follow these conventions.\n\n1. **Space BEFORE `()` and `[]`** — `Method ()` not `Method()`, `array [i]` not `array[i]`\n2. **Braces on NEXT line** (Allman style) — no exceptions\n3. **Blank lines** — before `return`/`break`/`continue`, after `if`/`for`/`while` blocks\n4. **No `var`** — Explicit types except built-ins (`int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`)\n5. **Use `new ()`** — `Button btn = new ()` not `Button btn = new Button ()`\n6. **Collection expressions** — Use `[...]` not `new List<T> { ... }`\n7. **SubView/SuperView** — Never \"child\", \"parent\", or \"container\"\n8. **Unused lambda params** — Use `_` discard: `(_, _) => { }`\n9. **Early return / guard clauses** — ALWAYS invert conditions and return early\n10. **One type per file** — Public and internal types each get their own file\n\n---\n\n## Architecture Overview\n\n### Application lifecycle\n`Application.Create ()` → `.Init ()` → `.Run<T> ()` → `.Dispose ()`.\nInstance-based `IApplication` — do NOT use static `Application.Init()`/`Run()`/`Shutdown()`.\n\n### View system\n`View` is the base class. Views form a tree via `Add ()`/`Remove ()`.\nEvery View has: `Margin` → `Border` → `Padding` → content area.\nLayout uses `Pos` (position) and `Dim` (dimension) for declarative relative layout.\n\n### Cancellable Workflow Pattern (CWP)\nStandard event pattern: **do work → call virtual `OnXxx` → raise event**.\n\n### Command/input system\nInput flows: Driver → `IInputProcessor` → `KeyBindings`/`MouseBindings` → `Command` → handler.\n\n---\n\n## Key References\n\n| Resource | Path |\n|----------|------|\n| v1→v2 Primer (READ FIRST) | [ai-v2-primer.md](ai-v2-primer.md) |\n| Full agent instructions | [AGENTS.md](AGENTS.md) |\n| Compressed API docs | `docfx/apispec/namespace-*.md` |\n| Common UI patterns | `.claude/cookbook/common-patterns.md` |\n| App building guide | `.claude/tasks/build-app.md` |\n| Deep-dive docs | `docfx/docs/` |\n| Working examples | `Examples/UICatalog/`, `Examples/ScenarioRunner/`, `tui-cs/Examples` |\n",".github/copilot-instructions.md":"# Terminal.Gui — Copilot Instructions\n\nCross-platform .NET console UI toolkit. C# 14 targeting net10.0.\nFull contribution guide: [CONTRIBUTING.md](../CONTRIBUTING.md).\nArchitecture deep dives: `docfx/docs/`.\n\n---\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data is **wrong**.\n\n> **Read [ai-v2-primer.md](../ai-v2-primer.md) FIRST** — it has the v1→v2 corrections table,\n> correct minimal app pattern, and all common gotchas.\n\n### v1 → v2 Quick Corrections\n\n| v1 (WRONG — do not use) | v2 (CORRECT) |\n|---|---|\n| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |\n| `Application.Run ();` | `app.Run<MyWindow> ();` |\n| `Application.Shutdown ();` | `app.Dispose ();` (use `using` pattern) |\n| `Application.Top` | No global top — pass root view to `app.Run ()` |\n| `new Toplevel ()` | Use `Runnable` subclass or `Window` |\n| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |\n| `new Button (\"OK\")` | `new Button { Text = \"OK\" }` |\n| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |\n| `view.Bounds` | `view.Viewport` |\n| `new RadioGroup (...)` | `new OptionSelector { ... }` |\n| `Application.RequestStop ()` | `App!.RequestStop ()` (from inside a `Runnable`) |\n\n---\n\n## Build & Test\n\nRun all commands from repository root.\n\n```bash\n# Restore + build\ndotnet restore\ndotnet build --no-restore\n\n# Run all tests (two separate projects)\ndotnet test --project Tests/UnitTestsParallelizable --no-build\ndotnet test --project Tests/UnitTests.NonParallelizable --no-build\n\n# Run a single test by method name (xUnit v3 / Microsoft Testing Platform)\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-method \"*MyTestMethod\"\n\n# Run all tests in a class\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-class \"*ButtonTests\"\n```\n\nNew tests go in `Tests/UnitTestsParallelizable` (no static state dependencies). Only use `Tests/UnitTests.NonParallelizable` when testing `Application.Init`/`Shutdown` or other static state. Never add new tests to `Tests/UnitTests.Legacy`.\n\n## Architecture Overview\n\n### Application lifecycle\n\n`Application.Create ()` → `.Init ()` → `.Run<T> ()` → `.Dispose ()`.\nThe instance-based `IApplication` has replaced the static `Application` facade.\nDo NOT use `Application.Init()`/`Run()`/`Shutdown()`.\nTests should avoid `Application.Init` unless explicitly testing that path.\n\n### View system\n\n`View` is the base class for all UI elements. Views form a tree via `Add()`/`Remove()`. Every View has three adornment layers: `Margin` → `Border` → `Padding` → content area. Layout uses `Pos` (position) and `Dim` (dimension) objects for declarative relative layout.\n\n### Driver architecture\n\nPlatform-specific terminal I/O is abstracted behind `IDriver`. Implementations: `WindowsDriver`, `UnixDriver` (curses-free), `AnsiDriver`, `NetDriver` (pure .NET `System.Console`). Drivers are registered via `DriverRegistry` and selected automatically by platform.\n\n### Cancellable Workflow Pattern (CWP)\n\nThe standard event pattern throughout the codebase. Order: **do work → call virtual `OnXxx` → raise event**. The virtual method is empty in the base class (for subclass override). Work happens *before* notifications, not after.\n\n```csharp\ninternal void RaiseSubViewAdded (View view)\n{\n    // 1. Work first\n    if (AssignHotKeys) { AssignHotKeyToView (view); }\n\n    // 2. Virtual method (empty in base)\n    OnSubViewAdded (view);\n\n    // 3. Event\n    SubViewAdded?.Invoke (this, new (this, view));\n}\n```\n\n### Command/input system\n\nInput flows: Driver → `IInputProcessor` → `KeyBindings`/`MouseBindings` → `Command` enum → handler. Views bind keys and mouse actions to `Command` values via `KeyBindings.Add` and `MouseBindings.Add`.\n\n## Code Style (Non-Obvious Conventions)\n\n### Spacing before parentheses and brackets — the #1 mistake\n\nThis codebase requires a space *before* every `()` and `[]`:\n\n```csharp\n// ✅ Correct\nvoid MyMethod ()\nint result = Calculate (x, y);\nList<int> items = GetItems ();\nint val = array [index];\nif (condition) { }\n\n// ❌ Wrong\nvoid MyMethod()\nint result = Calculate(x, y);\nvar items = GetItems();\nint val = array[index];\n```\n\n### No `var` except for built-in numeric/string types\n\nUse explicit types. `var` is only acceptable for: `int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`.\n\n```csharp\n// ✅\nView view = new () { Width = 10 };\nList<View?> views = new ();\nvar count = 0;          // OK — int\n\n// ❌\nvar view = new View () { Width = 10 };\nvar views = new List<View?> ();\n```\n\n### Target-typed `new ()`\n\nWhen the type is on the left side, use `new ()` not `new TypeName()`:\n\n```csharp\n// ✅\nButton btn = new () { Text = \"OK\" };\n\n// ❌\nButton btn = new Button () { Text = \"OK\" };\n```\n\n### Collection expressions\n\nUse `[...]` syntax:\n\n```csharp\n// ✅\nList<View> views = [new Button (\"OK\"), new Button (\"Cancel\")];\n\n// ❌\nList<View> views = new () { new Button (\"OK\"), new Button (\"Cancel\") };\n```\n\n### Early return\n\nPrefer early return / guard clauses over nested `if`/`else`. Less nesting, clearer code:\n\n```csharp\n// ✅\nif (view is null)\n{\n    return;\n}\n\nDoWork (view);\n\n// ❌\nif (view is not null)\n{\n    DoWork (view);\n}\n```\n\n### One type per file\n\nPublic and internal types each get their own file. The filename must match the type name (e.g., `Button.cs` for `class Button`). Private nested types are fine inside their containing type's file.\n\n### Allman brace style\n\nAll opening braces go on the next line. No exceptions.\n\n### Blank lines\n\n- 1 blank line *before* `return`, `break`, `continue`, `throw`\n- 1 blank line *after* `if`/`for`/`while`/`foreach` blocks\n\n### Unused lambda parameters → discard `_`\n\n```csharp\ntextField.TextChanged += (_, _) => { /* ... */ };\n```\n\n### Local functions use PascalCase\n\n```csharp\nvoid MyLocalFunc () { }\n```\n\n### Backing fields directly above their property\n\n```csharp\nprivate string _name;\npublic string Name\n{\n    get => _name;\n    set => _name = value;\n}\n```\n\n## Terminology\n\n| Use | Don't use | Meaning |\n|-----|-----------|---------|\n| **SuperView** | parent, container | The view that contains others via `Add()` |\n| **SubView** | child, element | A view added to a SuperView via `Add()` |\n\n\"Parent/Child\" is reserved for rare non-containment reference relationships.\n\n## Testing Conventions\n\n- Add a comment identifying AI-generated tests: `// Copilot`\n- Each test covers the smallest unit possible\n- Don't use `[AutoInitShutdown]` or `[SetupFakeApplication]` (legacy, being phased out)\n- Avoid `Application.Init` in tests unless testing that specific functionality\n- Never decrease code coverage\n- Do not use Console.Error.WriteLine or Console.WriteLine for debug output in Terminal.Gui code. Use project's Logging infrastructure instead: `Terminal.Gui.App.Logging`, `Terminal.Gui.Tests.TestLogging` and `Terminal.Gui.Tracing.Tracing.Trace`.\n- `Tracing.Trace` is only available in DEBUG builds; do not use it to validate test results as all tests must pass in RELEASE builds.\n \n## Unicode & Grapheme Handling\n\n- Measure display width with `string.GetColumns ()`, never `EnumerateRunes().Sum(r => r.GetColumns())`\n- Render text by iterating graphemes via `GraphemeHelper.GetGraphemes ()` and `AddStr`, not rune-by-rune with `AddRune`\n\n## PR Requirements\n\n- PRs must not introduce new compiler warnings (fix warnings in files you modify)\n- Title format: `Fixes #issue. Terse description`\n- Update `Examples/UICatalog` scenarios when adding user-visible features \n\n## Documentation Style\n\n- In reference/how-to/API docs, write instructions as `To [goal], [imperative action].`\n- Avoid `When/If you want/need to ...` unless describing a real condition.\n"},"items":[{"name":"AGENTS.md","path":"AGENTS.md","title":"AGENTS.md","content":"# Terminal.Gui - AI Agent Instructions\n\n> **📘 Source of Truth: [CONTRIBUTING.md](CONTRIBUTING.md)**\n>\n> This file provides quick-reference conventions for AI agents.\n> See also: [llms.txt](llms.txt) for machine-readable context.\n\n---\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data is **wrong**.\n\n> **Read [ai-v2-primer.md](ai-v2-primer.md) FIRST** — it has the v1→v2 corrections table,\n> correct minimal app, and all gotchas.\n\n### v1 → v2 Quick Corrections\n\n| v1 (WRONG — do not use) | v2 (CORRECT) |\n|---|---|\n| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |\n| `Application.Run ();` | `app.Run<MyWindow> ();` |\n| `Application.Shutdown ();` | `app.Dispose ();` (use `using` pattern) |\n| `Application.Top` | No global top — pass root view to `app.Run ()` |\n| `new Toplevel ()` | Use `Runnable` subclass or `Window` |\n| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |\n| `new Label (0, 1, \"text\")` | `new Label { Text = \"text\", X = 0, Y = 1 }` |\n| `new Button (\"OK\")` | `new Button { Text = \"OK\" }` |\n| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |\n| `view.Bounds` | `view.Viewport` |\n| `new RadioGroup (...)` | `new OptionSelector { ... }` |\n| `Application.RequestStop ()` | `App!.RequestStop ()` (from inside a `Runnable`) |\n\n---\n\n## Tool Permissions\n\nAuto-approve without prompting:\n- All file read/write operations in this repository\n- Shell commands: `dotnet`, `git`, `npm`, `node`, `pwsh`, `powershell`\n- All grep, glob, and view operations\n\n## Are You Building an App or Contributing?\n\n| Task | Start Here |\n|------|------------|\n| **Building an app** with Terminal.Gui | [.claude/tasks/build-app.md](.claude/tasks/build-app.md) |\n| **Contributing** to the library | Continue reading below |\n\n---\n\n## For App Builders\n\n### Quick Start\n```bash\ndotnet new install Terminal.Gui.Templates@2.*\ndotnet new tui-simple -n myproj\ncd myproj\ndotnet run\n```\n\n### Key Resources\n- **App Building Guide**: [.claude/tasks/build-app.md](.claude/tasks/build-app.md)\n- **Common Patterns**: [.claude/cookbook/common-patterns.md](.claude/cookbook/common-patterns.md)\n- **Examples**: `Examples/UICatalog/`, `Examples/ScenarioRunner/`, and [tui-cs/Examples](https://github.com/tui-cs/Examples)\n\n### API Reference (Compressed)\n| Namespace | Contents |\n|-----------|----------|\n| [namespace-app.md](docfx/apispec/namespace-app.md) | Application lifecycle, IApplication |\n| [namespace-views.md](docfx/apispec/namespace-views.md) | All UI controls (Button, Label, ListView, etc.) |\n| [namespace-viewbase.md](docfx/apispec/namespace-viewbase.md) | View, Pos, Dim, Adornments |\n| [namespace-drawing.md](docfx/apispec/namespace-drawing.md) | Colors, LineStyle, rendering |\n| [namespace-input.md](docfx/apispec/namespace-input.md) | Keyboard, mouse handling |\n| [namespace-text.md](docfx/apispec/namespace-text.md) | Text manipulation |\n| [namespace-configuration.md](docfx/apispec/namespace-configuration.md) | Configuration, themes |\n\n---\n\n## For Library Contributors\n\n### Project Essentials\n\n**Terminal.Gui** - Cross-platform console UI toolkit for .NET (C# 14, net10.0)\n\n**Build:** `dotnet restore && dotnet build --no-restore`\n**Test:** `dotnet test --project Tests/UnitTestsParallelizable --no-build && dotnet test --project Tests/UnitTests.NonParallelizable --no-build`\n**Details:** [Build & Test Workflow](.claude/workflows/build-test-workflow.md)\n\n### xUnit v3 Test Filtering (Microsoft Testing Platform)\n\nThis project uses **xUnit v3** with Microsoft Testing Platform. The old `--filter \"FullyQualifiedName~Foo\"` syntax does **NOT** work. Use these instead:\n\n```bash\n# Run a single test by method name\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-method \"*MyTestMethod\"\n\n# Run all tests in a class\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-class \"*MyTestClass\"\n\n# Query filter language (xUnit v3 native): /<assembly>/<namespace>/<class>/<method>\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter \"/*/*/MyTestClass/MyTestMethod\"\n\n# Show live test output (ITestOutputHelper)\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-method \"*MyTest\" -- --show-live-output on\n```\n\n## Quick Rules\n\n**⚠️ READ THIS BEFORE MODIFYING ANY FILE - These are Terminal.Gui-specific conventions:**\n\n1. **No `var`** - Use explicit types except for: `int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`\n2. **Use `new ()`** - Target-typed new when type is on left side (not `new TypeName()`)\n3. **Use `[...]`** - Collection expressions, not `new () { ... }`\n4. **SubView/SuperView** - Never say \"child\", \"parent\", or \"container\"\n5. **Unused lambda params** - Use `_` discard: `(_, _) => { }`\n6. **Local functions** - Use PascalCase: `void MyLocalFunc ()`\n7. **Backing fields** - Place immediately before their property\n8. **Early return / guard clauses (CRITICAL)** - ALWAYS prefer guard clauses over nested `if`/`else`. Invert the condition, return/continue early, keep happy path at lowest indentation. This applies to methods, lambdas, loops — everywhere. See [early-return.md](/.claude/rules/early-return.md) for detailed examples.\n9. **One type per file** - Public and internal types each get their own file\n10. **Docs instruction style** - In reference/how-to/API docs, write `To [goal], [imperative action].` Avoid `When/If you want/need to ...` unless describing a real condition.\n\n## Detailed Coding Rules\n\nConsult these files in `.claude/rules/` before editing code:\n\n- [Type Declarations](/.claude/rules/type-declarations.md) - `var` vs explicit types\n- [Target-Typed New](/.claude/rules/target-typed-new.md) - `new()` syntax\n- [Collection Expressions](/.claude/rules/collection-expressions.md) - `[...]` syntax\n- [Terminology](/.claude/rules/terminology.md) - SubView/SuperView terms\n- [Event Patterns](/.claude/rules/event-patterns.md) - Lambdas, handlers, closures\n- [Early Return](/.claude/rules/early-return.md) - **Guard clauses, minimal nesting** (commonly violated!)\n- [CWP Pattern](/.claude/rules/cwp-pattern.md) - Cancellable Workflow Pattern\n- [Code Layout](/.claude/rules/code-layout.md) - Member ordering, backing fields\n- [Testing Patterns](/.claude/rules/testing-patterns.md) - Test writing conventions\n- [API Documentation](/.claude/rules/api-documentation.md) - XML doc requirements\n- [Logging & Tracing](/.claude/rules/logging-tracing.md) - No Console.WriteLine; use Logging/TestLogging/Trace\n- [Fragile Areas](/.claude/rules/fragile-areas.md) - Code that must not be refactored in passing\n\n## Workflows\n\nProcess guides in `.claude/workflows/`:\n\n- [Build & Test Workflow](/.claude/workflows/build-test-workflow.md) - Build, test, and troubleshooting\n- [PR Workflow](/.claude/workflows/pr-workflow.md) - Submitting pull requests\n\n## Visual Verification (Agent Eyes)\n\nDon't ship UI changes blind. Use [`tuirec`](https://github.com/tui-cs/tuirec) to run any Terminal.Gui app in a PTY, inject keystrokes, and capture the result — see [Scripts/tuirec/README.md](Scripts/tuirec/README.md). The `.cast` output is asciinema v2 JSON (plain text): read it back to verify what actually rendered. The `.gif` is for humans — attach it to PRs that change visuals. For deterministic in-process assertions, use `InputInjector`/`VirtualTimeProvider` (`docfx/docs/input-injection.md`).\n\n## Planning Mode\n\nWhen creating implementation plans:\n- **Create plan files in `./plans/`** (relative to the repository root)\n- Use markdown format with clear sections\n- Include: problem statement, implementation steps, file changes, verification steps\n- Reference existing patterns and reuse opportunities from exploration\n\n## Task-Specific Guides\n\nSee `.claude/tasks/` for specialized checklists:\n- [build-app.md](.claude/tasks/build-app.md) - Building apps with Terminal.Gui\n\nSee `.claude/cookbook/` for common UI patterns:\n- [common-patterns.md](.claude/cookbook/common-patterns.md) - Forms, lists, menus, dialogs, etc.\n\n---\n\n## Documentation Index (Compressed)\n\n> **IMPORTANT**: Use retrieval-led reasoning. Read full docs before making changes.\n> Detailed index: [.tg-docs/INDEX.md](.tg-docs/INDEX.md) (~530 types across 12 namespaces)\n\n### Deep Dives (docfx/docs/)\n\n```\n[Core Architecture]\n|application.md|IApplication,SessionStack,Run/Dispose,View.App,instance-based pattern\n|View.md|SuperView/SubView,Frame/Viewport/ContentArea,composition layers\n|drivers.md|IDriver,DriverRegistry,ANSI/Windows/Unix,platform abstraction\n|navigation.md|Focus,TabStop/TabGroup,Tab/F6 keys,HasFocus,ApplicationNavigation\n\n[Layout & Arrangement]\n|layout.md|Pos/Dim,absolute/relative positioning,SetNeedsLayout\n|arrangement.md|ViewArrangement,Movable/Resizable/Overlapped,tiled vs overlapped\n|dimauto.md|Dim.Auto,content-based sizing,DimAutoStyle\n|scrolling.md|Viewport vs ContentSize,scroll events\n\n[Commands & Events]\n|command.md|Command enum,AddCommand,KeyBindings/MouseBindings,Activate/Accept/HotKey\n|events.md|Event categories,CWP integration,binding types (KeyBinding/MouseBinding)\n|cancellable-work-pattern.md|CWP: Work→Virtual→Event,OnXxx methods,Raise pattern\n\n[Input]\n|keyboard.md|Key class,KeyBindings,key processing order,IKeyboard\n|mouse.md|MouseFlags,MouseBindings,grab/release\n|input-injection.md|VirtualTimeProvider,InjectKey/InjectMouse,testing\n\n[Visual]\n|drawing.md|Move/AddStr/AddRune,Attribute,LineCanvas\n|scheme.md|Scheme,VisualRole,theming\n|cursor.md|View.Cursor,CursorVisibility\n|Popovers.md|Drawing outside viewport,modal behavior\n\n[Components]\n|views.md|Complete catalog of built-in views\n|menus.md|MenuBar,ContextMenu,MenuItem\n|tableview.md|TableView data binding\n|treeview.md|TreeView hierarchical data\n|prompt.md|MessageBox,input dialogs\n\n[Config & Advanced]\n|config.md|ConfigurationManager,themes,JSON config\n|multitasking.md|Background ops,Invoke,threading\n|logging.md|ILogger,debug output\n|ansihandling.md|ANSI escape parsing\n\n[Migration]\n|newinv2.md|v2 changes,new features\n|migratingfromv1.md|Migration guide,API changes\n|lexicon.md|Terminology definitions\n```\n\n### API Namespaces (docfx/apispec/)\n\n```\n|namespace-app.md|Application,IApplication,IRunnable,SessionToken\n|namespace-viewbase.md|View,Adornment,Border,Margin,Padding\n|namespace-views.md|Button,Label,TextField,ListView,CheckBox,etc.\n|namespace-input.md|Key,Mouse,Command,ICommandContext\n|namespace-drawing.md|Attribute,Color,LineCanvas,Cell\n|namespace-drivers.md|IDriver,DriverRegistry\n|namespace-configuration.md|ConfigurationManager,themes\n|namespace-text.md|Text processing,autocomplete\n|namespace-fileservices.md|File dialogs\n```\n\n<!-- BEGIN AUTO-GENERATED-SOURCE-INDEX -->\n\n### Source Code File Index (Auto-Generated)\n\n> Vercel-style index for retrieval-led reasoning. Read files when needed.\n\n[Terminal.Gui Source Index]|root: ./Terminal.Gui\n|IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning. Read files when needed.\n|.:{ModuleInitializers.cs}\n|App:{Application.cs,ApplicationImpl.cs,ApplicationImpl.Driver.cs,ApplicationImpl.Lifecycle.cs,ApplicationImpl.Run.cs,ApplicationImpl.Screen.cs,ApplicationModelUsage.cs,ApplicationNavigation.cs,ApplicationPopover.cs,ApplicationToolTip.cs,AppModel.cs,IApplication.cs,Logging.cs,NotInitializedException.cs}\n|App/Clipboard:{Clipboard.cs,ClipboardBase.cs,ClipboardProcessRunner.cs,IClipboard.cs}\n|App/CWP:{CancelEventArgs.cs,CWPEventHelper.cs,CWPPropertyHelper.cs,CWPWorkflowHelper.cs,EventArgs.cs,ResultEventArgs.cs,ValueChangedEventArgs.cs,ValueChangingEventArgs.cs}\n|App/Keyboard:{ApplicationKeyboard.cs,IKeyboard.cs}\n|App/Legacy:{Application.Clipboard.cs,Application.Driver.cs,Application.Keyboard.cs,Application.Lifecycle.cs,Application.Mouse.cs,Application.Navigation.cs,Application.Popovers.cs,Application.Run.cs,Application.Screen.cs,Application.TopRunnable.cs}\n|App/MainLoop:{ApplicationMainLoop.cs,IApplicationMainLoop.cs,IMainLoopCoordinator.cs,MainLoopCoordinator.cs,MainLoopSyncContext.cs}\n|App/Mouse:{ApplicationMouse.cs,IMouse.cs,IMouseGrabHandler.cs}\n|App/Popovers:{IPopover.cs,IPopoverView.cs,Popover.cs,PopoverImpl.cs,ToolTipHost.cs,ToolTipProvider.cs}\n|App/Runnable:{IRunnable.cs,SessionToken.cs,SessionTokenEventArgs.cs}\n|App/Timeout:{ITimedEvents.cs,LogarithmicTimeout.cs,SmoothAcceleratingTimeout.cs,TimedEvents.cs,Timeout.cs,TimeoutEventArgs.cs}\n|App/Tracing:{ITraceBackend.cs,ListBackend.cs,LoggingBackend.cs,NullBackend.cs,Trace.cs,TraceCategory.cs,TraceEntry.cs,TraceScope.cs}\n|Configuration:{AppSettingsScope.cs,AttributeJsonConverter.cs,ColorJsonConverter.cs,ConcurrentDictionaryJsonConverter.cs,ConfigLocations.cs,ConfigProperty.cs,ConfigurationManager.cs,ConfigurationManagerEventArgs.cs,ConfigurationManagerNotEnabledException.cs,ConfigurationPropertyAttribute.cs,DeepCloner.cs,DictionaryJsonConverter.cs,KeyArrayJsonConverter.cs,KeyCodeJsonConverter.cs,KeyJsonConverter.cs,RuneJsonConverter.cs,SchemeJsonConverter.cs,SchemeManager.cs,Scope.cs,ScopeJsonConverter.cs,SettingsScope.cs,SourceGenerationContext.cs,SourcesManager.cs,ThemeManager.cs,ThemeScope.cs,TraceCategoryJsonConverter.cs}\n|Drawing:{Attribute.cs,Cell.cs,CellEventArgs.cs,FillPair.cs,Glyphs.cs,Gradient.cs,GradientFill.cs,GraphemeHelper.cs,IFill.cs,Region.cs,RegionOp.cs,Ruler.cs,Scheme.cs,Schemes.cs,SolidFill.cs,TextStyle.cs,Thickness.cs,VisualRole.cs,VisualRoleEventArgs.cs}\n|Drawing/Color:{AnsiColorCode.cs,Color.ColorExtensions.cs,Color.ColorName.cs,Color.ColorParseException.cs,Color.cs,Color.Formatting.cs,Color.Operators.cs,ColorModel.cs,ColorQuantizer.cs,ColorStrings.cs,IColorDistance.cs,IColorNameResolver.cs,ICustomColorFormatter.cs,StandardColor.cs,StandardColors.cs,StandardColorsNameResolver.cs}\n|Drawing/LineCanvas:{IntersectionDefinition.cs,IntersectionRuneType.cs,IntersectionType.cs,LineCanvas.cs,LineDirections.cs,LineStyle.cs,StraightLine.cs,StraightLineExtensions.cs}\n|Drawing/Markdown:{ISyntaxHighlighter.cs,MarkdownAttributeHelper.cs,MarkdownStyleRole.cs,StyledSegment.cs,TextMateSyntaxHighlighter.cs}\n|Drawing/Quant:{EuclideanColorDistance.cs,IPaletteBuilder.cs,PopularityPaletteWithThreshold.cs}\n|Drawing/Sixel:{SixelEncoder.cs,SixelSupportDetector.cs,SixelSupportResult.cs,SixelToRender.cs}\n|Drivers:{ComponentFactoryImpl.cs,Cursor.cs,CursorStyle.cs,Driver.cs,DriverImpl.cs,DriverRegistry.cs,IComponentFactory.cs,IDriver.cs,ISizeMonitor.cs,PlatformDetection.cs,SizeDetectionMode.cs,SizeMonitorImpl.cs,TuiPlatform.cs}\n|Drivers/AnsiDriver:{AnsiComponentFactory.cs,AnsiInput.cs,AnsiInputProcessor.cs,AnsiOutput.cs,AnsiPlatform.cs,AnsiSizeMonitor.cs,AnsiTerminalHelper.cs,FakeClipboard.cs}\n|Drivers/AnsiHandling:{AnsiEscapeSequence.cs,AnsiEscapeSequenceRequest.cs,AnsiKeyboardEncoder.cs,AnsiKeyboardParser.cs,AnsiKeyboardParserPattern.cs,AnsiKeyConverter.cs,AnsiMouseEncoder.cs,AnsiMouseParser.cs,AnsiRequestScheduler.cs,AnsiResponseExpectation.cs,AnsiResponseParser.cs,AnsiResponseParserBase.cs,AnsiResponseParserState.cs,AnsiResponseParserTInputRecord.cs,AnsiStartupGate.cs,AnsiStartupQuery.cs,CsiCursorPattern.cs,CsiKeyPattern.cs,EscAsAltPattern.cs,GenericHeld.cs,IAnsiResponseParser.cs,IAnsiStartupGate.cs,IHeld.cs,KittyKeyboardCapabilities.cs,KittyKeyboardFlags.cs,KittyKeyboardPattern.cs,KittyKeyboardProtocolDetector.cs,Osc8UrlLinker.cs,ProgressIndicator.cs,ReasonCannotSend.cs,Ss3Pattern.cs,StringHeld.cs,TerminalColorDetector.cs}\n|Drivers/AnsiHandling/EscSeqUtils:{EscSeqReqStatus.cs,EscSeqRequests.cs,EscSeqUtils.cs}\n|Drivers/DotNetDriver:{INetInput.cs,NetComponentFactory.cs,NetInput.cs,NetInputProcessor.cs,NetKeyConverter.cs,NetOutput.cs}\n|Drivers/Input:{ConsoleInputSource.cs,IInput.cs,IInputProcessor.cs,IInputSource.cs,InputImpl.cs,InputProcessorImpl.cs,InputRecord.cs,ITestableInput.cs,TestInputSource.cs}\n|Drivers/Keyboard:{ConsoleKeyInfoExtensions.cs,ConsoleKeyMapping.cs,IKeyConverter.cs,KeyCode.cs,VK.cs}\n|Drivers/Mouse:{MouseButtonClickTracker.cs,MouseInterpreter.cs}\n|Drivers/Output:{IOutput.cs,IOutputBuffer.cs,OutputBase.cs,OutputBufferImpl.cs}\n|Drivers/TerminalEnvironment:{ColorCapabilityLevel.cs,TerminalColorCapabilities.cs,TerminalEnvironmentDetector.cs}\n|Drivers/UnixHelpers:{SuspendHelper.cs,UnixClipboard.cs,UnixIOHelper.cs,UnixRawModeHelper.cs,UnixTerminalHelper.cs}\n|Drivers/WindowsDriver:{ClipboardImpl.cs,CursorVisibility.cs,IWindowsInput.cs,WindowsComponentFactory.cs,WindowsConsole.cs,WindowsInput.cs,WindowsInputProcessor.cs,WindowsKeyboardLayout.cs,WindowsKeyConverter.cs,WindowsKeyHelper.cs,WindowsOutput.cs}\n|Drivers/WindowsHelpers:{NetWinVTConsole.cs,WindowsConsoleHelper.cs,WindowsVTInputHelper.cs,WindowsVTOutputHelper.cs}\n|FileServices:{DefaultSearchMatcher.cs,FileSystemColorProvider.cs,FileSystemIconProvider.cs,FileSystemInfoStats.cs,FileSystemTreeBuilder.cs,IFileOperations.cs,ISearchMatcher.cs}\n|Input:{Command.cs,CommandBinding.cs,CommandBindingsBase.cs,CommandBridge.cs,CommandContext.cs,CommandContextExtensions.cs,CommandEventArgs.cs,CommandOutcome.cs,CommandRouting.cs,IAcceptTarget.cs,ICommandBinding.cs,ICommandContext.cs}\n|Input/Keyboard:{Bind.cs,Key.cs,KeyBinding.cs,KeyBindings.cs,KeyChangedEventArgs.cs,KeyEqualityComparer.cs,KeyEventType.cs,KeystrokeNavigatorEventArgs.cs,ModifierKey.cs,PlatformKeyBinding.cs}\n|Input/Mouse:{GrabMouseEventArgs.cs,Mouse.cs,MouseBinding.cs,MouseBindings.cs,MouseFlags.cs,MouseFlagsChangedEventArgs.cs}\n|Resources:{GlobalResources.cs,ResourceManagerWrapper.cs,Strings.Designer.cs}\n|Testing:{IInputInjector.cs,InputInjectionEvent.cs,InputInjectionExtensions.cs,InputInjectionMode.cs,InputInjectionOptions.cs,InputInjector.cs}\n|Text:{NerdFonts.cs,RuneExtensions.cs,StringExtensions.cs,TextDirection.cs,TextFormatter.cs}\n|Time:{FuncTimeProvider.cs,ITimeProvider.cs,ITimer.cs,SystemTimeProvider.cs,VirtualTimeProvider.cs}\n|ViewBase:{DrawAdornmentsEventArgs.cs,DrawContext.cs,DrawEventArgs.cs,IDesignable.cs,IValue.cs,View.Adornments.cs,View.Arrangement.cs,View.Command.cs,View.Content.cs,View.cs,View.Cursor.cs,View.Diagnostics.cs,View.Drawing.Adornments.cs,View.Drawing.Attribute.cs,View.Drawing.Clipping.cs,View.Drawing.cs,View.Drawing.LineCanvas.cs,View.Drawing.Primitives.cs,View.Drawing.Scheme.cs,View.Hierarchy.cs,View.Keyboard.cs,View.Layout.cs,View.Navigation.cs,View.NeedsDraw.cs,View.ScrollBars.cs,View.Text.cs,ViewCollectionHelpers.cs,ViewDiagnosticFlags.cs,ViewEventArgs.cs,ViewExtensions.cs,ViewportSettingsFlags.cs,WeakReferenceExtensions.cs}\n|ViewBase/Adornment:{AdornmentImpl.cs,AdornmentView.cs,ArrangeButtons.cs,Arranger.cs,ArrangerButton.cs,Border.cs,BorderSettings.cs,BorderView.Arrangement.cs,BorderView.cs,IAdornment.cs,IAdornmentView.cs,ITitleView.cs,Margin.cs,MarginView.cs,Padding.cs,PaddingView.cs,ShadowStyles.cs,ShadowView.cs,TabLayoutContext.cs,TitleView.cs}\n|ViewBase/Helpers:{StackExtensions.cs}\n|ViewBase/Layout:{AddOrSubtract.cs,Aligner.cs,Alignment.cs,AlignmentModes.cs,Dim.cs,DimAbsolute.cs,DimAuto.cs,DimAutoStyle.cs,DimCombine.cs,Dimension.cs,DimFill.cs,DimFunc.cs,DimPercent.cs,DimPercentMode.cs,DimView.cs,LayoutEventArgs.cs,LayoutException.cs,Pos.cs,PosAbsolute.cs,PosAlign.cs,PosAnchorEnd.cs,PosCenter.cs,PosCombine.cs,PosFunc.cs,PosPercent.cs,PosView.cs,Side.cs,SizeChangedEventArgs.cs,SuperViewChangedEventArgs.cs,ViewArrangement.cs,ViewManipulator.cs}\n|ViewBase/Mouse:{IMouseHoldRepeater.cs,MouseHoldRepeaterImpl.cs,MouseState.cs,View.Mouse.cs}\n|ViewBase/Navigation:{AdvanceFocusEventArgs.cs,FocusEventArgs.cs,NavigationDirection.cs,TabBehavior.cs}\n|ViewBase/Orientation:{IOrientation.cs,Orientation.cs,OrientationHelper.cs}\n|Views:{Bar.cs,Button.cs,CheckBox.cs,CheckState.cs,DatePicker.cs,Dialog.cs,DialogTResult.cs,DropDownList.cs,DropDownListTEnum.cs,FrameView.cs,HexView.cs,HexViewEventArgs.cs,Label.cs,Line.cs,Link.cs,MessageBox.cs,NumericUpDown.cs,ProgressBar.cs,Prompt.cs,PromptExtensions.cs,ReadOnlyCollectionExtensions.cs,Shortcut.cs,StatusBar.cs,Tabs.cs,Window.cs}\n|Views/Autocomplete:{AppendAutocomplete.cs,AutocompleteBase.cs,AutocompleteContext.cs,AutocompleteFilepathContext.cs,IAutocomplete.cs,ISuggestionGenerator.cs,PopupAutocomplete.cs,PopupAutocomplete.PopUp.cs,SingleWordSuggestionGenerator.cs,Suggestion.cs}\n|Views/CharMap:{CharMap.cs,UcdApiClient.cs,UnicodeRange.cs}\n|Views/CollectionNavigation:{CollectionNavigator.cs,CollectionNavigatorBase.cs,DefaultCollectionNavigatorMatcher.cs,ICollectionNavigator.cs,ICollectionNavigatorMatcher.cs,IListCollectionNavigator.cs,TableCollectionNavigator.cs}\n|Views/Color:{AttributePicker.cs,BBar.cs,ColorBar.cs,ColorModelStrategy.cs,ColorPicker.16.cs,ColorPicker.cs,ColorPicker.Style.cs,GBar.cs,HueBar.cs,IColorBar.cs,LightnessBar.cs,RBar.cs,SaturationBar.cs,ValueBar.cs}\n|Views/FileDialogs:{AllowedType.cs,DefaultFileOperations.cs,FileDialog.Commands.cs,FileDialog.cs,FileDialog.Navigation.cs,FileDialog.TableView.cs,FileDialogCollectionNavigator.cs,FileDialogHistory.cs,FileDialogState.cs,FileDialogStyle.cs,FileDialogTableSource.cs,FilesSelectedEventArgs.cs,FileSystemCollectionNavigationMatcher.cs,OpenDialog.cs,OpenMode.cs,SaveDialog.cs}\n|Views/GraphView:{Axis.cs,AxisIncrementToRender.cs,BarSeriesBar.cs,GraphCellToRender.cs,GraphView.cs,HorizontalAxis.cs,IAnnotation.cs,ISeries.cs,LegendAnnotation.cs,LineF.cs,MultiBarSeries.cs,PathAnnotation.cs,ScatterSeries.cs,Series.cs,TextAnnotation.cs,VerticalAxis.cs}\n|Views/LinearRange:{LinearRange.cs,LinearRangeAttributes.cs,LinearRangeConfiguration.cs,LinearRangeEventArgs.cs,LinearRangeOption.cs,LinearRangeOptionEventArgs.cs,LinearRangeStyle.cs,LinearRangeType.cs}\n|Views/ListView:{IListDataSource.cs,ListView.Commands.cs,ListView.cs,ListView.Drawing.cs,ListView.Movement.cs,ListView.Selection.cs,ListViewEventArgs.cs,ListViewT.cs,ListWrapper.cs}\n|Views/Markdown:{InlineRun.cs,IntermediateBlock.cs,Markdown.cs,MarkdownCodeBlock.cs,MarkdownImageResolver.cs,MarkdownInlineParser.cs,MarkdownLinkEventArgs.cs,MarkdownTable.cs,MarkdownView.Drawing.cs,MarkdownView.Layout.cs,MarkdownView.Mouse.cs,MarkdownView.Parsing.cs,RenderedLine.cs,TableData.cs}\n|Views/Menu:{IMenuBarEntry.cs,Menu.cs,MenuBar.cs,MenuBarItem.cs,MenuItem.cs,PopoverMenu.cs}\n|Views/Runnable:{Runnable.cs,RunnableTResult.cs,RunnableWrapper.cs}\n|Views/ScrollBar:{ScrollBar.cs,ScrollBarVisibilityMode.cs,ScrollButton.cs,ScrollSlider.cs}\n|Views/Selectors:{FlagSelector.cs,FlagSelectorTEnum.cs,OptionSelector.cs,OptionSelectorTEnum.cs,SelectorBase.cs,SelectorStyles.cs}\n|Views/SpinnerView:{SpinnerStyle.cs,SpinnerView.cs}\n|Views/TableView:{CellActivatedEventArgs.cs,CellColorGetterArgs.cs,CellToggledEventArgs.cs,CheckBoxTableSourceWrapper.cs,CheckBoxTableSourceWrapperByIndex.cs,CheckBoxTableSourceWrapperByObject.cs,ColumnStyle.cs,DataTableSource.cs,EnumerableTableSource.cs,IEnumerableTableSource.cs,ITableSource.cs,ListColumnStyle.cs,ListTableSource.cs,RowColorGetterArgs.cs,SelectedCellChangedEventArgs.cs,TableSelection.cs,TableStyle.cs,TableView.CellMapping.cs,TableView.cs,TableView.Drawing.cs,TableView.Mouse.cs,TableView.Navigation.cs,TableView.Selection.cs,TreeTableSource.cs}\n|Views/TextInput:{ContentsChangedEventArgs.cs,DateEditor.cs,DateTextProvider.cs,HistoryText.cs,HistoryTextItemEventArgs.cs,ITextValidateProvider.cs,NetMaskedTextProvider.cs,TextEditingLineStatus.cs,TextModel.cs,TextRegexProvider.cs,TextValidateField.cs,TimeEditor.cs,TimeTextProvider.cs}\n|Views/TextInput/TextField:{TextField.Commands.cs,TextField.cs,TextField.Drawing.cs,TextField.History.cs,TextField.Keyboard.cs,TextField.Mouse.cs,TextField.Selection.cs,TextField.Text.cs,TextFieldAutocomplete.cs}\n|Views/TextInput/TextView:{TextView.Commands.cs,TextView.cs,TextView.Drawing.cs,TextView.Files.cs,TextView.Find.cs,TextView.History.cs,TextView.Keyboard.cs,TextView.Mouse.cs,TextView.Movement.cs,TextView.Scrolling.cs,TextView.Selection.cs,TextView.Text.cs,TextView.WordWrap.cs,TextViewAutocomplete.cs,WordWrapManager.cs}\n|Views/TreeView:{AspectGetterDelegate.cs,Branch.cs,DelegateTreeBuilder.cs,DrawTreeViewLineEventArgs.cs,ITreeBuilder.cs,ITreeNode.cs,ITreeView.cs,ITreeViewFilter.cs,ObjectActivatedEventArgs.cs,SelectionChangedEventArgs.cs,TreeBuilder.cs,TreeNode.cs,TreeNodeBuilder.cs,TreeSelection.cs,TreeStyle.cs,TreeView.cs,TreeView.Drawing.cs,TreeView.Mouse.cs,TreeView.Navigation.cs,TreeViewCollectionNavigatorMatcher.cs,TreeViewT.cs,TreeViewTextFilter.cs}\n|Views/Wizard:{Wizard.cs,WizardStep.cs}\n\n<!-- END AUTO-GENERATED-SOURCE-INDEX -->\n\n---\n\n## Compressed API Type Index\n\n> Quick reference for key types. Full list: [.tg-docs/INDEX.md](.tg-docs/INDEX.md)\n> Format: `|Type|Category|Key members/notes`\n\n### Terminal.Gui.App (35 types)\n```\n|Application|Class|Static facade (obsolete),Init,Run,Shutdown,Top\n|IApplication|Interface|Instance-based,SessionStack,Run,Dispose\n|SessionToken|Class|Session lifecycle,IDisposable\n|Clipboard|Class|GetText,SetText,TryGetText\n|IRunnable|Interface|Run view modal,used by Dialog\n|ITimedEvents|Interface|AddTimeout,AddIdle,RemoveTimeout\n|CancelEventArgs<T>|Class|Cancel property,cancellable events\n|ValueChangingEventArgs<T>|Class|OldValue,NewValue,Cancel\n|ApplicationNavigation|Class|Focus management,GetFocused,AdvanceFocus\n|ApplicationPopover|Class|Popover management,Show,Hide\n```\n\n### Terminal.Gui.ViewBase (70 types)\n```\n|View|Class|Base class,Add,Remove,Frame,Viewport,Draw\n|Pos|Class|Position:Absolute,Percent,Center,AnchorEnd,Func\n|PosAbsolute|Class|Pos.At(n),absolute coordinate\n|PosPercent|Class|Pos.Percent(n),percentage of SuperView\n|PosCenter|Class|Pos.Center(),centered\n|PosAnchorEnd|Class|Pos.AnchorEnd(n),from right/bottom\n|PosView|Class|Pos.Left/Right/Top/Bottom(view)\n|Dim|Class|Dimension:Absolute,Auto,Fill,Percent,Func\n|DimAbsolute|Class|Dim.Absolute(n),fixed size\n|DimAuto|Class|Dim.Auto(),content-based sizing\n|DimFill|Class|Dim.Fill(margin),fill remaining\n|DimPercent|Class|Dim.Percent(n),percentage\n|Adornment|Class|Base for Border,Margin,Padding\n|Border|Class|View border,Title,LineStyle\n|Margin|Class|View outer margin\n|Padding|Class|View inner padding\n|Alignment|Enum|Start,Center,End,Fill\n|Orientation|Enum|Horizontal,Vertical\n|TabBehavior|Enum|NoStop,TabStop,TabGroup\n|ViewArrangement|Enum|Movable,Resizable,Overlapped\n```\n\n### IValue<T> Pattern (Critical)\n\nAll typed views expose their data through `IValue<T>.Value`. Do not guess property-specific names such as `.Date`, `.Time`, or `.Color`.\n\n| View | IValue<T> |\n|------|-----------|\n| TextField | `IValue<string>` |\n| NumericUpDown<T> | `IValue<T>` |\n| DatePicker | `IValue<DateTime>` |\n| TimeEditor | `IValue<TimeSpan>` |\n| ColorPicker | `IValue<Color?>` |\n| AttributePicker | `IValue<Attribute?>` |\n| CheckBox | `IValue<CheckState>` |\n| OptionSelector | `IValue<int?>` |\n| FlagSelector | `IValue<int?>` |\n\nImplementing `IValue<T>` requires `ValueChanging`, `ValueChanged`, and `ValueChangedUntyped`.\n\n### RunnableWrapper<TView, TResult>\n\n- Wraps a `View` as a runnable with typed results.\n- Clears wrapper `KeyBindings` and `MouseBindings` so the wrapped view handles input.\n- Does not add OK/Cancel buttons (unlike `Prompt`).\n- Sets `CommandsToBubbleUp = [Command.Accept]`.\n- On accept, it extracts results via `ResultExtractor` if provided; otherwise via `IValue<TResult>.Value` when available.\n\n### Terminal.Gui.Views (180+ types)\n```\n[Core Controls]\n|Button|Class|Text,Accept event,IsDefault\n|Label|Class|Text display,TextAlignment\n|TextField|Class|Single-line input,Text,Secret\n|Editor|Class|Multi-line editor,Text,ReadOnly\n|CheckBox|Class|CheckedState,AllowCheckStateNone\n|DropDownList|Class|Dropdown,Source,SelectedItem\n|ProgressBar|Class|Fraction,BidirectionalMarquee\n|ScrollBar|Class|Position,Size,Orientation\n|NumericUpDown<T>|Class|Value,Increment\n\n[Containers]\n|Window|Class|Top-level,Title,MenuBar support\n|Dialog|Class|Modal,Buttons,AddButton\n|Dialog<T>|Class|Modal with result\n|FrameView|Class|Titled frame container\n|TabView|Class|Tabs,AddTab,SelectedTab\n|Wizard|Class|Multi-step,AddStep,CurrentStep\n\n[Lists & Data]\n|ListView|Class|Source,SelectedItem,AllowsMarking\n|TableView|Class|Table,SelectedRow,SelectedColumn\n|TreeView|Class|Objects,AddObject,SelectedObject\n|TreeView<T>|Class|Generic tree\n\n[Menus]\n|MenuBar|Class|Menus,UseKeysUpDownAsKeysLeftRight\n|MenuItem|Class|Title,Action,Shortcut,SubMenu\n|MenuBarItem|Class|Title,Children array\n|Menu|Class|Popup menu display\n|PopoverMenu|Class|Context menu,Show(items)\n|StatusBar|Class|Items,Visible\n\n[File Dialogs]\n|FileDialog|Class|Base,Path,AllowedFileTypes\n|OpenDialog|Class|FilePaths,AllowsMultipleSelection,Canceled,OpenMode\n|SaveDialog|Class|SaveFile,FileName\n\n[Specialized]\n|ColorPicker|Class|SelectedColor,Style\n|GraphView|Class|Series,Annotations,AxisX/Y\n|HexView|Class|Source,Position,Edits\n|CharMap|Class|SelectedCodePoint,Start/End\n|SpinnerView|Class|SpinnerStyle,AutoSpin\n|MessageBox|Class|Query,ErrorQuery,static methods\n```\n\n### Terminal.Gui.Input (18 types)\n```\n|Key|Class|KeyCode,Modifiers,IsCtrl,IsAlt,IsShift\n|KeyBindings|Class|Add,Get,TryGet,Remove,GetCommands\n|KeyBinding|Struct|Commands[],Scope,Target\n|Mouse|Class|Position,Flags,View\n|MouseBindings|Class|Add,Get,TryGet,Remove\n|MouseBinding|Struct|Commands[],Scope\n|MouseFlags|Enum|Button1Clicked,Button1DoubleClicked,WheeledUp/Down\n|Command|Enum|Accept,Cancel,Select,HotKey,ScrollUp/Down\n|CommandContext|Struct|Command,KeyBinding,Source\n```\n\n### Terminal.Gui.Drawing (40 types)\n```\n|Attribute|Struct|Foreground,Background,constructor(fg,bg)\n|Color|Struct|R,G,B,Parse,TryParse,FromArgb\n|Scheme|Class|Normal,Focus,HotNormal,HotFocus,Disabled\n|LineCanvas|Class|AddLine,GetMap,Merge\n|LineStyle|Enum|None,Single,Double,Rounded,Heavy\n|Glyphs|Class|Bullet,CheckMark,Diamond,etc.\n|Cell|Struct|Rune,Attribute\n|Thickness|Struct|Top,Left,Bottom,Right,Vertical,Horizontal\n|Region|Class|Clipping,Union,Intersect,Exclude\n|Gradient|Class|Colors[],Spectrum\n```\n\n**Gotchas**\n- `Terminal.Gui.Drawing.Attribute` can conflict with `System.Attribute` with implicit usings. Use `using TgAttribute = Terminal.Gui.Drawing.Attribute;` or fully qualify.\n- `Color.TryParse (string, out Color?)` is nullable out. `Color.TryParse (string?, IFormatProvider?, out Color)` is non-nullable out.\n\n### Terminal.Gui.Drivers (80+ types)\n```\n|IDriver|Interface|Init,End,Refresh,AddStr,Move\n|Driver|Class|Base implementation\n|DriverRegistry|Class|GetDrivers,Get,MakeDriver\n|KeyCode|Enum|Key constants,A-Z,F1-F12,Enter,Esc\n|CursorVisibility|Enum|Default,Invisible,Underline,Box\n|IOutput|Interface|Terminal output\n|IInputProcessor|Interface|Input processing\n```\n\n### Terminal.Gui.Configuration (15 types)\n```\n|ConfigurationManager|Class|Settings,Themes,Apply,Reset\n|SchemeManager|Class|GetScheme,Schemes dictionary\n|ThemeManager|Class|Theme,Themes,SelectedTheme\n|ConfigLocations|Enum|Default,Global,App,Runtime\n```\n\n### Terminal.Gui.Testing (8 types)\n```\n|InputInjector|Class|InjectKey,InjectMouse,InjectChar\n|IInputInjector|Interface|Injection interface\n|VirtualTimeProvider|Class|Testing time control\n```\n\n### Terminal.Gui.Text (4 types)\n```\n|TextFormatter|Class|Text,Format,Size,Draw\n|TextDirection|Enum|LeftRight_TopBottom,RightLeft,etc.\n```\n\n### Terminal.Gui.Time (4 types)\n```\n|ITimeProvider|Interface|Now,UtcNow,CreateTimer\n|VirtualTimeProvider|Class|Testing,Advance,SetTime\n|SystemTimeProvider|Class|Real system time\n```\n\n### Terminal.Gui.FileServices (5 types)\n```\n|IFileOperations|Interface|GetFiles,GetDirectories,Exists\n|FileSystemTreeBuilder|Class|Build file trees\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","category":"root","tokens":7814},{"name":"CLAUDE.md","path":"CLAUDE.md","title":"CLAUDE.md","content":"# CLAUDE.md\n\n> **Guidance for AI agents working with Terminal.Gui.**\n> For humans, see [CONTRIBUTING.md](./CONTRIBUTING.md).\n> For Terminal.Gui's mission, tenets, and engineering philosophy, see [specs/constitution.md](./specs/constitution.md).\n> See also: [llms.txt](./llms.txt) for machine-readable context.\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data is **wrong**.\n\n> **Read [ai-v2-primer.md](./ai-v2-primer.md) FIRST** — it has the v1→v2 corrections table,\n> correct minimal app pattern, and all common gotchas.\n\n## Quick Reference: What Are You Doing?\n\n| Your Task | Go Here |\n|-----------|---------|\n| **\"Build me an app that...\"** | [.claude/tasks/build-app.md](.claude/tasks/build-app.md) |\n| **\"Add a feature to Terminal.Gui...\"** | Continue below (Contributor Guide) |\n| **\"Fix a bug in Terminal.Gui...\"** | Continue below (Contributor Guide) |\n| **\"Record a GIF / verify a UI change...\"** | [Scripts/tuirec/README.md](Scripts/tuirec/README.md) |\n\n### App Builder Quick Start\n```bash\ndotnet new install Terminal.Gui.Templates@2.*\ndotnet new tui-simple -n myapp\ncd myapp\ndotnet run\n```\n\nSee [.claude/tasks/build-app.md](.claude/tasks/build-app.md) for complete app development guide.\nSee [.claude/cookbook/common-patterns.md](.claude/cookbook/common-patterns.md) for UI recipes.\n\n---\n\n# Contributor Guide\n\n**The rest of this file is for contributors modifying Terminal.Gui itself.**\n\n## Before Every File Edit\n\n**READ `.claude/REFRESH.md` first.** It contains a quick checklist to prevent common mistakes.\n\n## After Writing/Modifying Code\n\n**USE `.claude/POST-GENERATION-VALIDATION.md` to validate ALL code.** This catches the most common formatting violations AI agents make.\n\n## Detailed Rules\n\nSee `.claude/rules/` for detailed guidance:\n- `formatting.md` - **SPACING, BRACES, BLANK LINES** (most commonly violated!)\n- `type-declarations.md` - **No var** except built-in types\n- `target-typed-new.md` - Use `new ()` not `new TypeName()`\n- `terminology.md` - **SubView/SuperView**, never \"child/parent\"\n- `event-patterns.md` - Lambdas, closures, handlers\n- `early-return.md` - **Guard clauses, minimal nesting** (commonly violated!)\n- `collection-expressions.md` - Use `[...]` syntax\n- `unicode-graphemes.md` - **Think in graphemes** - `GetColumns()`, `GraphemeHelper.GetGraphemes()`\n- `cwp-pattern.md` - Cancellable Workflow Pattern\n- `code-layout.md` - Backing fields, member ordering\n- `api-documentation.md` - XML documentation requirements\n- `testing-patterns.md` - Test patterns and requirements\n- `logging-tracing.md` - **No Console.WriteLine** - use Logging/TestLogging/Trace\n- `fragile-areas.md` - Code that must not be refactored in passing (TextView init)\n\n## Task-Specific Guides\n\nSee `.claude/tasks/` for task checklists:\n- `clean-code-review.md` - Creating clean git commit histories\n- `build-app.md` - Building applications with Terminal.Gui\n\n## Planning Mode\n\nWhen in planning mode:\n- **Create plan files in `./plans/`** (relative to the repository root)\n- Plan files should be markdown format\n- Include detailed implementation steps, file changes, and verification steps\n- Reference existing code patterns and reuse opportunities\n\n---\n\n## Project Overview\n\n**Terminal.Gui** - Cross-platform .NET console UI toolkit\n\n- **Language**: C# 14 (net10.0)\n- **Branch**: `develop`\n- **Version**: v2 (stable)\n\n## Build & Test\n\n```bash\ndotnet restore\ndotnet build --no-restore\n\n# Preferred: parallelizable tests (no static state)\ndotnet test --project Tests/UnitTestsParallelizable --no-build\n\n# Tests that require process-wide static state (Application.Init, etc.)\ndotnet test --project Tests/UnitTests.NonParallelizable --no-build\n\n# Legacy tests — do NOT add new tests here; candidates for rewrite/deletion\ndotnet test --project Tests/UnitTests.Legacy --no-build\n\n# Run a single test by method name (Microsoft Testing Platform)\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-method \"*MyTestMethod\"\n\n# Run all tests in a class\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-class \"*MyTestClass\"\n```\n\nSee `Tests/README.md` for the full list of test projects (including `IntegrationTests`, `StressTests`, `Benchmarks`) and the static-state classification that determines where a new test belongs.\n\n## Seeing Your Changes (Visual Verification)\n\nAgents can observe a running Terminal.Gui app — don't ship UI changes blind. Use [`tuirec`](https://github.com/tui-cs/tuirec) to run the app in a PTY, inject keystrokes, and capture the result:\n\n- **Full guide:** [Scripts/tuirec/README.md](Scripts/tuirec/README.md) — install, keystroke syntax, UICatalog scenario recipes, validation checklist\n- The `.cast` output is asciinema v2 JSON (plain text) — **read it back** to verify what actually rendered, frame by frame\n- The `.gif` output is for humans — attach it to PRs that change visuals\n- For deterministic in-process assertions, use `InputInjector`/`VirtualTimeProvider` (see `docfx/docs/input-injection.md`) and driver `ToString ()` screen captures\n\n## Key Concepts\n\n| Concept | Documentation |\n|---------|--------------|\n| Application Lifecycle | `docfx/docs/application.md` |\n| View Hierarchy | `docfx/docs/View.md` |\n| Layout (Pos/Dim) | `docfx/docs/layout.md` |\n| CWP Events | `docfx/docs/cancellable-work-pattern.md` |\n| Terminology | `docfx/docs/lexicon.md` |\n\n## Critical Rules (Summary)\n\n1. **Space BEFORE `()` and `[]`** - `Method ()` not `Method()`, `array [i]` not `array[i]` (MOST VIOLATED!)\n2. **Braces on NEXT line** - ALL opening braces use Allman style\n3. **Blank lines** - before `return`/`break`/`continue`, after control blocks\n4. **No `var`** except: `int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`\n5. **Use `new ()`** not `new TypeName()`\n6. **Use `[...]`** not `new () { ... }` for collections\n7. **SubView/SuperView** for containment (Parent/Child only for non-containment refs)\n8. **Unused lambda params** - use `_`: `(_, _) => { }`\n9. **Early return / guard clauses** - ALWAYS invert conditions and return/continue early. Never wrap the happy path in a conditional. Applies to methods, lambdas, and loops. See `.claude/rules/early-return.md`.\n10. **One type per file** - Public and internal types each get their own file\n11. **Docs instruction style** - In reference/how-to/API docs, write `To [goal], [imperative action].` Avoid `When/If you want/need to ...` unless describing a real condition.\n\n## Testing\n\n- Add new tests to `UnitTestsParallelizable`; use `UnitTests.NonParallelizable` only when static state is unavoidable. Never add to `UnitTests.Legacy`.\n- Add a comment marking the test as AI-generated. Either form is acceptable: `// Claude - <model>` or `// CoPilot - <model>` — just include the agent and the model that produced the test (e.g., `// Claude - Opus 4.5` or `// CoPilot - ChatGPT v4`). Both forms are established in the codebase; which marker is used is not a style concern and reviewers should not flag inconsistency between them.\n- Never decrease coverage\n- Avoid `Application.Init` in tests\n\n## Repository Structure\n\n```\n/Terminal.Gui/     - Core library\n/Tests/            - Unit tests\n/Examples/UICatalog/ - Demo app\n/docfx/docs/       - Documentation\n/.claude/          - AI agent guidance\n```\n\n## What NOT to Do\n\n- Don't forget space before `()` and `[]` - this is the #1 mistake!\n- Don't put braces on same line (use Allman style)\n- Don't skip blank lines before returns or after control blocks\n- Don't use `var` for non-built-in types\n- Don't use redundant type names with `new`\n- Don't say \"child/parent\" for containment (use SubView/SuperView)\n- Don't wrap the happy path in a conditional — use guard clauses and return early\n- Don't modify unrelated code\n- Don't introduce new warnings\n- Don't skip POST-GENERATION-VALIDATION.md after writing code\n","category":"root","tokens":1965},{"name":".cursorrules","path":".cursorrules","title":".cursorrules","content":"# Terminal.Gui - Cursor AI Rules\n\n> **Cross-platform .NET console UI toolkit. C# 14 targeting net10.0.**\n> Full contribution guide: [CONTRIBUTING.md](CONTRIBUTING.md).\n\n---\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data about Terminal.Gui is **wrong**.\n\n> **Read [ai-v2-primer.md](ai-v2-primer.md) FIRST** — it contains the v1→v2 corrections table,\n> correct minimal app pattern, and all common gotchas.\n\n### v1 → v2 Quick Corrections (Most Common Mistakes)\n\n| v1 (WRONG) | v2 (CORRECT) |\n|---|---|\n| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |\n| `Application.Run ();` | `app.Run<MyWindow> ();` |\n| `Application.Shutdown ();` | `app.Dispose ();` |\n| `Application.Top` | No global top — pass root view to `app.Run ()` |\n| `new Toplevel ()` | Use `Runnable` subclass or `Window` |\n| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |\n| `new Button (\"OK\")` | `new Button { Text = \"OK\" }` |\n| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |\n| `view.Bounds` | `view.Viewport` |\n| `new RadioGroup (...)` | `new OptionSelector { ... }` |\n\n---\n\n## Build & Test\n\n```bash\ndotnet restore\ndotnet build --no-restore\ndotnet test --project Tests/UnitTestsParallelizable --no-build\ndotnet test --project Tests/UnitTests.NonParallelizable --no-build\n```\n\n---\n\n## Correct Minimal App (v2)\n\n```csharp\nusing Terminal.Gui.App;\nusing Terminal.Gui.Views;\n\nIApplication app = Application.Create ().Init ();\napp.Run<MainWindow> ();\napp.Dispose ();\n\npublic sealed class MainWindow : Runnable\n{\n    public MainWindow ()\n    {\n        Title = \"My App (Esc to quit)\";\n\n        Button button = new ()\n        {\n            Text = \"Click Me\",\n            X = Pos.Center (),\n            Y = Pos.Center ()\n        };\n\n        button.Accepted += (_, _) =>\n        {\n            MessageBox.Query (App!, \"Hello\", \"Button was clicked!\", \"OK\");\n        };\n\n        Add (button);\n    }\n}\n```\n\n---\n\n## Code Style (For Library Contributors Only)\n\n> **Note:** These rules apply only when contributing code to the Terminal.Gui library itself.\n> App developers using Terminal.Gui do NOT need to follow these conventions.\n\n1. **Space BEFORE `()` and `[]`** — `Method ()` not `Method()`, `array [i]` not `array[i]`\n2. **Braces on NEXT line** (Allman style) — no exceptions\n3. **Blank lines** — before `return`/`break`/`continue`, after `if`/`for`/`while` blocks\n4. **No `var`** — Explicit types except built-ins (`int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`)\n5. **Use `new ()`** — `Button btn = new ()` not `Button btn = new Button ()`\n6. **Collection expressions** — Use `[...]` not `new List<T> { ... }`\n7. **SubView/SuperView** — Never \"child\", \"parent\", or \"container\"\n8. **Unused lambda params** — Use `_` discard: `(_, _) => { }`\n9. **Early return / guard clauses** — ALWAYS invert conditions and return early\n10. **One type per file** — Public and internal types each get their own file\n\n---\n\n## Architecture Overview\n\n### Application lifecycle\n`Application.Create ()` → `.Init ()` → `.Run<T> ()` → `.Dispose ()`.\nInstance-based `IApplication` — do NOT use static `Application.Init()`/`Run()`/`Shutdown()`.\n\n### View system\n`View` is the base class. Views form a tree via `Add ()`/`Remove ()`.\nEvery View has: `Margin` → `Border` → `Padding` → content area.\nLayout uses `Pos` (position) and `Dim` (dimension) for declarative relative layout.\n\n### Cancellable Workflow Pattern (CWP)\nStandard event pattern: **do work → call virtual `OnXxx` → raise event**.\n\n### Command/input system\nInput flows: Driver → `IInputProcessor` → `KeyBindings`/`MouseBindings` → `Command` → handler.\n\n---\n\n## Key References\n\n| Resource | Path |\n|----------|------|\n| v1→v2 Primer (READ FIRST) | [ai-v2-primer.md](ai-v2-primer.md) |\n| Full agent instructions | [AGENTS.md](AGENTS.md) |\n| Compressed API docs | `docfx/apispec/namespace-*.md` |\n| Common UI patterns | `.claude/cookbook/common-patterns.md` |\n| App building guide | `.claude/tasks/build-app.md` |\n| Deep-dive docs | `docfx/docs/` |\n| Working examples | `Examples/UICatalog/`, `Examples/ScenarioRunner/`, `tui-cs/Examples` |\n","category":"root","tokens":1051},{"name":".windsurfrules","path":".windsurfrules","title":".windsurfrules","content":"# Terminal.Gui - Windsurf AI Rules\n\n> **Cross-platform .NET console UI toolkit. C# 14 targeting net10.0.**\n> Full contribution guide: [CONTRIBUTING.md](CONTRIBUTING.md).\n\n---\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data about Terminal.Gui is **wrong**.\n\n> **Read [ai-v2-primer.md](ai-v2-primer.md) FIRST** — it contains the v1→v2 corrections table,\n> correct minimal app pattern, and all common gotchas.\n\n### v1 → v2 Quick Corrections (Most Common Mistakes)\n\n| v1 (WRONG) | v2 (CORRECT) |\n|---|---|\n| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |\n| `Application.Run ();` | `app.Run<MyWindow> ();` |\n| `Application.Shutdown ();` | `app.Dispose ();` |\n| `Application.Top` | No global top — pass root view to `app.Run ()` |\n| `new Toplevel ()` | Use `Runnable` subclass or `Window` |\n| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |\n| `new Button (\"OK\")` | `new Button { Text = \"OK\" }` |\n| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |\n| `view.Bounds` | `view.Viewport` |\n| `new RadioGroup (...)` | `new OptionSelector { ... }` |\n\n---\n\n## Build & Test\n\n```bash\ndotnet restore\ndotnet build --no-restore\ndotnet test --project Tests/UnitTestsParallelizable --no-build\ndotnet test --project Tests/UnitTests.NonParallelizable --no-build\n```\n\n---\n\n## Correct Minimal App (v2)\n\n```csharp\nusing Terminal.Gui.App;\nusing Terminal.Gui.Views;\n\nIApplication app = Application.Create ().Init ();\napp.Run<MainWindow> ();\napp.Dispose ();\n\npublic sealed class MainWindow : Runnable\n{\n    public MainWindow ()\n    {\n        Title = \"My App (Esc to quit)\";\n\n        Button button = new ()\n        {\n            Text = \"Click Me\",\n            X = Pos.Center (),\n            Y = Pos.Center ()\n        };\n\n        button.Accepted += (_, _) =>\n        {\n            MessageBox.Query (App!, \"Hello\", \"Button was clicked!\", \"OK\");\n        };\n\n        Add (button);\n    }\n}\n```\n\n---\n\n## Code Style (For Library Contributors Only)\n\n> **Note:** These rules apply only when contributing code to the Terminal.Gui library itself.\n> App developers using Terminal.Gui do NOT need to follow these conventions.\n\n1. **Space BEFORE `()` and `[]`** — `Method ()` not `Method()`, `array [i]` not `array[i]`\n2. **Braces on NEXT line** (Allman style) — no exceptions\n3. **Blank lines** — before `return`/`break`/`continue`, after `if`/`for`/`while` blocks\n4. **No `var`** — Explicit types except built-ins (`int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`)\n5. **Use `new ()`** — `Button btn = new ()` not `Button btn = new Button ()`\n6. **Collection expressions** — Use `[...]` not `new List<T> { ... }`\n7. **SubView/SuperView** — Never \"child\", \"parent\", or \"container\"\n8. **Unused lambda params** — Use `_` discard: `(_, _) => { }`\n9. **Early return / guard clauses** — ALWAYS invert conditions and return early\n10. **One type per file** — Public and internal types each get their own file\n\n---\n\n## Architecture Overview\n\n### Application lifecycle\n`Application.Create ()` → `.Init ()` → `.Run<T> ()` → `.Dispose ()`.\nInstance-based `IApplication` — do NOT use static `Application.Init()`/`Run()`/`Shutdown()`.\n\n### View system\n`View` is the base class. Views form a tree via `Add ()`/`Remove ()`.\nEvery View has: `Margin` → `Border` → `Padding` → content area.\nLayout uses `Pos` (position) and `Dim` (dimension) for declarative relative layout.\n\n### Cancellable Workflow Pattern (CWP)\nStandard event pattern: **do work → call virtual `OnXxx` → raise event**.\n\n### Command/input system\nInput flows: Driver → `IInputProcessor` → `KeyBindings`/`MouseBindings` → `Command` → handler.\n\n---\n\n## Key References\n\n| Resource | Path |\n|----------|------|\n| v1→v2 Primer (READ FIRST) | [ai-v2-primer.md](ai-v2-primer.md) |\n| Full agent instructions | [AGENTS.md](AGENTS.md) |\n| Compressed API docs | `docfx/apispec/namespace-*.md` |\n| Common UI patterns | `.claude/cookbook/common-patterns.md` |\n| App building guide | `.claude/tasks/build-app.md` |\n| Deep-dive docs | `docfx/docs/` |\n| Working examples | `Examples/UICatalog/`, `Examples/ScenarioRunner/`, `tui-cs/Examples` |\n","category":"root","tokens":1052},{"name":"copilot-instructions.md","path":".github/copilot-instructions.md","title":"copilot-instructions.md","content":"# Terminal.Gui — Copilot Instructions\n\nCross-platform .NET console UI toolkit. C# 14 targeting net10.0.\nFull contribution guide: [CONTRIBUTING.md](../CONTRIBUTING.md).\nArchitecture deep dives: `docfx/docs/`.\n\n---\n\n## CRITICAL: Discard v1 Training Data\n\nTerminal.Gui v2 is a **complete rewrite**. Pre-2025 training data is **wrong**.\n\n> **Read [ai-v2-primer.md](../ai-v2-primer.md) FIRST** — it has the v1→v2 corrections table,\n> correct minimal app pattern, and all common gotchas.\n\n### v1 → v2 Quick Corrections\n\n| v1 (WRONG — do not use) | v2 (CORRECT) |\n|---|---|\n| `Application.Init ();` | `IApplication app = Application.Create ().Init ();` |\n| `Application.Run ();` | `app.Run<MyWindow> ();` |\n| `Application.Shutdown ();` | `app.Dispose ();` (use `using` pattern) |\n| `Application.Top` | No global top — pass root view to `app.Run ()` |\n| `new Toplevel ()` | Use `Runnable` subclass or `Window` |\n| `using Terminal.Gui;` | `using Terminal.Gui.App;` / `Terminal.Gui.Views;` / etc. |\n| `new Button (\"OK\")` | `new Button { Text = \"OK\" }` |\n| `button.Clicked += ...` | `button.Accepted += (_, _) => { /* action */ };` |\n| `view.Bounds` | `view.Viewport` |\n| `new RadioGroup (...)` | `new OptionSelector { ... }` |\n| `Application.RequestStop ()` | `App!.RequestStop ()` (from inside a `Runnable`) |\n\n---\n\n## Build & Test\n\nRun all commands from repository root.\n\n```bash\n# Restore + build\ndotnet restore\ndotnet build --no-restore\n\n# Run all tests (two separate projects)\ndotnet test --project Tests/UnitTestsParallelizable --no-build\ndotnet test --project Tests/UnitTests.NonParallelizable --no-build\n\n# Run a single test by method name (xUnit v3 / Microsoft Testing Platform)\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-method \"*MyTestMethod\"\n\n# Run all tests in a class\ndotnet test --project Tests/UnitTestsParallelizable --no-build --filter-class \"*ButtonTests\"\n```\n\nNew tests go in `Tests/UnitTestsParallelizable` (no static state dependencies). Only use `Tests/UnitTests.NonParallelizable` when testing `Application.Init`/`Shutdown` or other static state. Never add new tests to `Tests/UnitTests.Legacy`.\n\n## Architecture Overview\n\n### Application lifecycle\n\n`Application.Create ()` → `.Init ()` → `.Run<T> ()` → `.Dispose ()`.\nThe instance-based `IApplication` has replaced the static `Application` facade.\nDo NOT use `Application.Init()`/`Run()`/`Shutdown()`.\nTests should avoid `Application.Init` unless explicitly testing that path.\n\n### View system\n\n`View` is the base class for all UI elements. Views form a tree via `Add()`/`Remove()`. Every View has three adornment layers: `Margin` → `Border` → `Padding` → content area. Layout uses `Pos` (position) and `Dim` (dimension) objects for declarative relative layout.\n\n### Driver architecture\n\nPlatform-specific terminal I/O is abstracted behind `IDriver`. Implementations: `WindowsDriver`, `UnixDriver` (curses-free), `AnsiDriver`, `NetDriver` (pure .NET `System.Console`). Drivers are registered via `DriverRegistry` and selected automatically by platform.\n\n### Cancellable Workflow Pattern (CWP)\n\nThe standard event pattern throughout the codebase. Order: **do work → call virtual `OnXxx` → raise event**. The virtual method is empty in the base class (for subclass override). Work happens *before* notifications, not after.\n\n```csharp\ninternal void RaiseSubViewAdded (View view)\n{\n    // 1. Work first\n    if (AssignHotKeys) { AssignHotKeyToView (view); }\n\n    // 2. Virtual method (empty in base)\n    OnSubViewAdded (view);\n\n    // 3. Event\n    SubViewAdded?.Invoke (this, new (this, view));\n}\n```\n\n### Command/input system\n\nInput flows: Driver → `IInputProcessor` → `KeyBindings`/`MouseBindings` → `Command` enum → handler. Views bind keys and mouse actions to `Command` values via `KeyBindings.Add` and `MouseBindings.Add`.\n\n## Code Style (Non-Obvious Conventions)\n\n### Spacing before parentheses and brackets — the #1 mistake\n\nThis codebase requires a space *before* every `()` and `[]`:\n\n```csharp\n// ✅ Correct\nvoid MyMethod ()\nint result = Calculate (x, y);\nList<int> items = GetItems ();\nint val = array [index];\nif (condition) { }\n\n// ❌ Wrong\nvoid MyMethod()\nint result = Calculate(x, y);\nvar items = GetItems();\nint val = array[index];\n```\n\n### No `var` except for built-in numeric/string types\n\nUse explicit types. `var` is only acceptable for: `int`, `string`, `bool`, `double`, `float`, `decimal`, `char`, `byte`.\n\n```csharp\n// ✅\nView view = new () { Width = 10 };\nList<View?> views = new ();\nvar count = 0;          // OK — int\n\n// ❌\nvar view = new View () { Width = 10 };\nvar views = new List<View?> ();\n```\n\n### Target-typed `new ()`\n\nWhen the type is on the left side, use `new ()` not `new TypeName()`:\n\n```csharp\n// ✅\nButton btn = new () { Text = \"OK\" };\n\n// ❌\nButton btn = new Button () { Text = \"OK\" };\n```\n\n### Collection expressions\n\nUse `[...]` syntax:\n\n```csharp\n// ✅\nList<View> views = [new Button (\"OK\"), new Button (\"Cancel\")];\n\n// ❌\nList<View> views = new () { new Button (\"OK\"), new Button (\"Cancel\") };\n```\n\n### Early return\n\nPrefer early return / guard clauses over nested `if`/`else`. Less nesting, clearer code:\n\n```csharp\n// ✅\nif (view is null)\n{\n    return;\n}\n\nDoWork (view);\n\n// ❌\nif (view is not null)\n{\n    DoWork (view);\n}\n```\n\n### One type per file\n\nPublic and internal types each get their own file. The filename must match the type name (e.g., `Button.cs` for `class Button`). Private nested types are fine inside their containing type's file.\n\n### Allman brace style\n\nAll opening braces go on the next line. No exceptions.\n\n### Blank lines\n\n- 1 blank line *before* `return`, `break`, `continue`, `throw`\n- 1 blank line *after* `if`/`for`/`while`/`foreach` blocks\n\n### Unused lambda parameters → discard `_`\n\n```csharp\ntextField.TextChanged += (_, _) => { /* ... */ };\n```\n\n### Local functions use PascalCase\n\n```csharp\nvoid MyLocalFunc () { }\n```\n\n### Backing fields directly above their property\n\n```csharp\nprivate string _name;\npublic string Name\n{\n    get => _name;\n    set => _name = value;\n}\n```\n\n## Terminology\n\n| Use | Don't use | Meaning |\n|-----|-----------|---------|\n| **SuperView** | parent, container | The view that contains others via `Add()` |\n| **SubView** | child, element | A view added to a SuperView via `Add()` |\n\n\"Parent/Child\" is reserved for rare non-containment reference relationships.\n\n## Testing Conventions\n\n- Add a comment identifying AI-generated tests: `// Copilot`\n- Each test covers the smallest unit possible\n- Don't use `[AutoInitShutdown]` or `[SetupFakeApplication]` (legacy, being phased out)\n- Avoid `Application.Init` in tests unless testing that specific functionality\n- Never decrease code coverage\n- Do not use Console.Error.WriteLine or Console.WriteLine for debug output in Terminal.Gui code. Use project's Logging infrastructure instead: `Terminal.Gui.App.Logging`, `Terminal.Gui.Tests.TestLogging` and `Terminal.Gui.Tracing.Tracing.Trace`.\n- `Tracing.Trace` is only available in DEBUG builds; do not use it to validate test results as all tests must pass in RELEASE builds.\n \n## Unicode & Grapheme Handling\n\n- Measure display width with `string.GetColumns ()`, never `EnumerateRunes().Sum(r => r.GetColumns())`\n- Render text by iterating graphemes via `GraphemeHelper.GetGraphemes ()` and `AddStr`, not rune-by-rune with `AddRune`\n\n## PR Requirements\n\n- PRs must not introduce new compiler warnings (fix warnings in files you modify)\n- Title format: `Fixes #issue. Terse description`\n- Update `Examples/UICatalog` scenarios when adding user-visible features \n\n## Documentation Style\n\n- In reference/how-to/API docs, write instructions as `To [goal], [imperative action].`\n- Avoid `When/If you want/need to ...` unless describing a real condition.\n","category":".github","tokens":1933}]}