Browse Source

Merge branch 'v2_develop' into copilot/enable-menubar-replacement

Tig 1 week ago
parent
commit
dedaaed911
89 changed files with 4513 additions and 2038 deletions
  1. 3 16
      .github/workflows/api-docs.yml
  2. 108 119
      Examples/UICatalog/Scenarios/ColorPicker.cs
  3. 1 1
      Examples/UICatalog/Scenarios/ContextMenus.cs
  4. 13 13
      Examples/UICatalog/Scenarios/CsvEditor.cs
  5. 2 2
      Examples/UICatalog/Scenarios/DynamicStatusBar.cs
  6. 9 9
      Examples/UICatalog/Scenarios/Editor.cs
  7. 5 5
      Examples/UICatalog/Scenarios/FileDialogExamples.cs
  8. 1 1
      Examples/UICatalog/Scenarios/Generic.cs
  9. 4 4
      Examples/UICatalog/Scenarios/HexEditor.cs
  10. 3 3
      Examples/UICatalog/Scenarios/Images.cs
  11. 1 1
      Examples/UICatalog/Scenarios/InteractiveTree.cs
  12. 4 4
      Examples/UICatalog/Scenarios/KeyBindings.cs
  13. 1 1
      Examples/UICatalog/Scenarios/ListColumns.cs
  14. 2 2
      Examples/UICatalog/Scenarios/MessageBoxes.cs
  15. 1 1
      Examples/UICatalog/Scenarios/MultiColouredTable.cs
  16. 1 1
      Examples/UICatalog/Scenarios/Navigation.cs
  17. 2 2
      Examples/UICatalog/Scenarios/Notepad.cs
  18. 3 3
      Examples/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs
  19. 1 1
      Examples/UICatalog/Scenarios/WindowsAndFrameViews.cs
  20. 3 3
      Examples/UICatalog/Scenarios/WizardAsView.cs
  21. 72 36
      README.md
  22. 17 1
      Terminal.Gui/App/Application.Lifecycle.cs
  23. 0 117
      Terminal.Gui/App/Application.cd
  24. 1 1
      Terminal.Gui/App/ApplicationImpl.Driver.cs
  25. 1 1
      Terminal.Gui/App/ApplicationImpl.Lifecycle.cs
  26. 1 1
      Terminal.Gui/App/ApplicationImpl.Run.cs
  27. 1 1
      Terminal.Gui/App/ApplicationImpl.Screen.cs
  28. 2 2
      Terminal.Gui/App/ApplicationImpl.cs
  29. 32 17
      Terminal.Gui/App/Timeout/TimedEvents.cs
  30. 0 68
      Terminal.Gui/Drawing/Color/AnsiColorNameResolver.cs
  31. 34 50
      Terminal.Gui/Drawing/Color/Color.cs
  32. 6 5
      Terminal.Gui/Drawing/Color/ColorModel.cs
  33. 3 3
      Terminal.Gui/Drawing/Color/ColorQuantizer.cs
  34. 6 53
      Terminal.Gui/Drawing/Color/ColorStrings.cs
  35. 0 83
      Terminal.Gui/Drawing/Color/MultiStandardColorNameResolver.cs
  36. 60 1
      Terminal.Gui/Drawing/Color/StandardColor.cs
  37. 5 2
      Terminal.Gui/Drawing/Color/StandardColors.cs
  38. 10 10
      Terminal.Gui/ViewBase/Runnable/Runnable.cs
  39. 0 79
      Terminal.Gui/Views/Autocomplete/Autocomplete.cd
  40. 0 124
      Terminal.Gui/Views/CollectionNavigation/CollectionNavigation.cd
  41. 0 2
      Terminal.Gui/Views/Color/BBar.cs
  42. 1 4
      Terminal.Gui/Views/Color/ColorBar.cs
  43. 28 45
      Terminal.Gui/Views/Color/ColorModelStrategy.cs
  44. 0 3
      Terminal.Gui/Views/Color/ColorPicker.Style.cs
  45. 0 2
      Terminal.Gui/Views/Color/GBar.cs
  46. 1 2
      Terminal.Gui/Views/Color/IColorBar.cs
  47. 0 2
      Terminal.Gui/Views/Color/LightnessBar.cs
  48. 0 2
      Terminal.Gui/Views/Color/RBar.cs
  49. 0 2
      Terminal.Gui/Views/Color/SaturationBar.cs
  50. 0 168
      Terminal.Gui/Views/FileDialogs/FileDialog.cd
  51. 1 1
      Terminal.Gui/Views/MessageBox.cs
  52. 1 1
      Terminal.Gui/Views/Shortcut.cs
  53. 1 0
      Terminal.sln.DotSettings
  54. 63 41
      Tests/StressTests/ApplicationStressTests.cs
  55. 0 89
      Tests/TerminalGuiFluentTesting/ClassDiagram1.cd
  56. 2 3
      Tests/UnitTestsParallelizable/Application/ApplicationImplTests.cs
  57. 0 40
      Tests/UnitTestsParallelizable/Application/ApplicationTests.cs
  58. 462 0
      Tests/UnitTestsParallelizable/Application/NestedRunTimeoutTests.cs
  59. 856 0
      Tests/UnitTestsParallelizable/Application/TimeoutTests.cs
  60. 3 3
      Tests/UnitTestsParallelizable/Configuration/ColorJsonConverterTests.cs
  61. 6 6
      Tests/UnitTestsParallelizable/Configuration/SourcesManagerTests.cs
  62. 0 168
      Tests/UnitTestsParallelizable/Drawing/Color/AnsiColorNameResolverTests.cs
  63. 2 2
      Tests/UnitTestsParallelizable/Drawing/Color/ColorClassTests.Constructors.cs
  64. 2 2
      Tests/UnitTestsParallelizable/Drawing/Color/ColorClassTests.Operators.cs
  65. 2 2
      Tests/UnitTestsParallelizable/Drawing/Color/ColorClassTests.ParsingAndFormatting.cs
  66. 2 2
      Tests/UnitTestsParallelizable/Drawing/Color/ColorClassTests.TypeChecks.cs
  67. 3 4
      Tests/UnitTestsParallelizable/Drawing/Color/ColorClassTests.cs
  68. 0 27
      Tests/UnitTestsParallelizable/Drawing/Color/ColorStandardColorTests.cs
  69. 326 0
      Tests/UnitTestsParallelizable/Drawing/Color/ColorStringsTests.cs
  70. 0 156
      Tests/UnitTestsParallelizable/Drawing/Color/MultiStandardColorNameResolverTests.cs
  71. 2 4
      Tests/UnitTestsParallelizable/Drawing/Color/StandardColorNameResolverTests.cs
  72. 268 0
      Tests/UnitTestsParallelizable/Drawing/Color/StandardColorsTests.cs
  73. 1 1
      Tests/UnitTestsParallelizable/Drawing/Lines/LineCanvasTests.cs
  74. 1 1
      Tests/UnitTestsParallelizable/Drawing/Lines/StraightLineExtensionsTests.cs
  75. 1 1
      Tests/UnitTestsParallelizable/Drawing/Lines/StraightLineTests.cs
  76. 1 1
      Tests/UnitTestsParallelizable/Drawing/Region/DifferenceTests.cs
  77. 1 1
      Tests/UnitTestsParallelizable/Drawing/Region/DrawOuterBoundaryTests.cs
  78. 1 1
      Tests/UnitTestsParallelizable/Drawing/Region/MergeRectanglesTests.cs
  79. 2 2
      Tests/UnitTestsParallelizable/Drawing/Region/RegionClassTests.cs
  80. 1 1
      Tests/UnitTestsParallelizable/Drawing/Region/SubtractRectangleTests.cs
  81. 1 1
      Tests/UnitTestsParallelizable/runsettings.coverage.xml
  82. 1 1
      Tests/UnitTestsParallelizable/runsettings.xml
  83. 1 1
      Tests/UnitTestsParallelizable/xunit.runner.json
  84. 192 185
      docfx/docs/application.md
  85. 71 0
      docfx/docs/drawing.md
  86. 3 4
      docfx/docs/drivers.md
  87. 1 1
      docfx/docs/keyboard.md
  88. 1114 0
      docfx/docs/migratingfromv1.md
  89. 669 206
      docfx/docs/newinv2.md

+ 3 - 16
.github/workflows/api-docs.yml

@@ -1,8 +1,8 @@
-name: Build and publish API docs
+name: Build and publish v2 API docs
 
 on:
   push:
-    branches: [v1_release, v2_develop]
+    branches: [v2_develop]
 
 permissions:
   id-token: write 
@@ -10,7 +10,7 @@ permissions:
 
 jobs:
   deploy:
-    name: Build and Deploy API docs to github-pages ${{ github.ref_name }}
+    name: Build and Deploy v2 API docs to github-pages ${{ github.ref_name }}
     environment:
       name: github-pages
       url: ${{ steps.deployment.outputs.page_url }}
@@ -20,7 +20,6 @@ jobs:
       uses: actions/checkout@v4
 
     - name: DocFX Build
-      #if: github.ref_name == 'v1_release' ||  github.ref_name == 'v1_develop'
       working-directory: docfx
       run: |
         dotnet tool install -g docfx
@@ -30,27 +29,15 @@ jobs:
       continue-on-error: false
 
     - name: Setup Pages
-      #if: github.ref_name == 'v1_release' ||  github.ref_name == 'v1_develop'
       uses: actions/configure-pages@v5
       
     - name: Upload artifact
-      #if: github.ref_name == 'v1_release' ||  github.ref_name == 'v1_develop'
       uses: actions/upload-pages-artifact@v3
       with:
         path: docfx/_site
        
     - name: Deploy to GitHub Pages
-      if: github.ref_name == 'v2_release' ||  github.ref_name == 'v2_develop'
       id: deployment
       uses: actions/deploy-pages@v4
       with:
         token: ${{ secrets.GITHUB_TOKEN }}
-
-    # - name: v1_release Repository Dispatch ${{ github.ref_name }}
-    #   if: github.ref_name == 'v2_develop'
-    #   uses: peter-evans/repository-dispatch@v3
-    #   with:
-    #     token: ${{ secrets.V2DOCS_TOKEN }}
-    #     repository: gui-cs/Terminal.GuiV1Docs
-    #     event-type: v2_develop_push
-    #     client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

+ 108 - 119
Examples/UICatalog/Scenarios/ColorPicker.cs

@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-
-namespace UICatalog.Scenarios;
+namespace UICatalog.Scenarios;
 
 [ScenarioMetadata ("ColorPicker", "Color Picker and TrueColor demonstration.")]
 [ScenarioCategory ("Colors")]
@@ -18,25 +15,25 @@ public class ColorPickers : Scenario
     private Label _foregroundColorLabel;
 
     /// <summary>Background ColorPicker.</summary>
-    private ColorPicker backgroundColorPicker;
+    private ColorPicker _backgroundColorPicker;
 
     /// <summary>Foreground ColorPicker.</summary>
-    private ColorPicker foregroundColorPicker;
+    private ColorPicker _foregroundColorPicker;
 
     /// <summary>Background ColorPicker.</summary>
-    private ColorPicker16 backgroundColorPicker16;
+    private ColorPicker16 _backgroundColorPicker16;
 
     /// <summary>Foreground ColorPicker.</summary>
-    private ColorPicker16 foregroundColorPicker16;
+    private ColorPicker16 _foregroundColorPicker16;
 
-    /// <summary>Setup the scenario.</summary>
+    /// <summary>Set up the scenario.</summary>
     public override void Main ()
     {
         Application.Init ();
 
         Window app = new ()
         {
-            Title = GetQuitKeyAndName (),
+            Title = GetQuitKeyAndName ()
         };
 
         ///////////////////////////////////////
@@ -44,23 +41,23 @@ public class ColorPickers : Scenario
         ///////////////////////////////////////
 
         // Foreground ColorPicker.
-        foregroundColorPicker = new ColorPicker
+        _foregroundColorPicker = new ()
         {
             Title = "_Foreground Color",
             BorderStyle = LineStyle.Single,
             Width = Dim.Percent (50)
         };
-        foregroundColorPicker.ColorChanged += ForegroundColor_ColorChanged;
-        app.Add (foregroundColorPicker);
+        _foregroundColorPicker.ColorChanged += ForegroundColor_ColorChanged;
+        app.Add (_foregroundColorPicker);
 
-        _foregroundColorLabel = new Label
+        _foregroundColorLabel = new ()
         {
-            X = Pos.Left (foregroundColorPicker), Y = Pos.Bottom (foregroundColorPicker) + 1
+            X = Pos.Left (_foregroundColorPicker), Y = Pos.Bottom (_foregroundColorPicker) + 1
         };
         app.Add (_foregroundColorLabel);
 
         // Background ColorPicker.
-        backgroundColorPicker = new ColorPicker
+        _backgroundColorPicker = new ()
         {
             Title = "_Background Color",
             X = Pos.AnchorEnd (),
@@ -68,49 +65,47 @@ public class ColorPickers : Scenario
             BorderStyle = LineStyle.Single
         };
 
-        backgroundColorPicker.ColorChanged += BackgroundColor_ColorChanged;
-        app.Add (backgroundColorPicker);
-        _backgroundColorLabel = new Label ()
+        _backgroundColorPicker.ColorChanged += BackgroundColor_ColorChanged;
+        app.Add (_backgroundColorPicker);
+
+        _backgroundColorLabel = new ()
         {
             X = Pos.AnchorEnd (),
-            Y = Pos.Bottom (backgroundColorPicker) + 1
+            Y = Pos.Bottom (_backgroundColorPicker) + 1
         };
 
         app.Add (_backgroundColorLabel);
 
-
         ///////////////////////////////////////
         // 16 Color Pickers
         ///////////////////////////////////////
 
-
         // Foreground ColorPicker 16.
-        foregroundColorPicker16 = new ColorPicker16
+        _foregroundColorPicker16 = new ()
         {
             Title = "_Foreground Color",
             BorderStyle = LineStyle.Single,
             Width = Dim.Percent (50),
-            Visible = false  // We default to HSV so hide old one
+            Visible = false // We default to HSV so hide old one
         };
-        foregroundColorPicker16.ColorChanged += ForegroundColor_ColorChanged;
-        app.Add (foregroundColorPicker16);
+        _foregroundColorPicker16.ColorChanged += ForegroundColor_ColorChanged;
+        app.Add (_foregroundColorPicker16);
 
         // Background ColorPicker 16.
-        backgroundColorPicker16 = new ColorPicker16
+        _backgroundColorPicker16 = new ()
         {
             Title = "_Background Color",
             X = Pos.AnchorEnd (),
             Width = Dim.Percent (50),
             BorderStyle = LineStyle.Single,
-            Visible = false  // We default to HSV so hide old one
+            Visible = false // We default to HSV so hide old one
         };
 
-        backgroundColorPicker16.ColorChanged += BackgroundColor_ColorChanged;
-        app.Add (backgroundColorPicker16);
-
+        _backgroundColorPicker16.ColorChanged += BackgroundColor_ColorChanged;
+        app.Add (_backgroundColorPicker16);
 
         // Demo Label.
-        _demoView = new View
+        _demoView = new ()
         {
             Title = "Color Sample",
             Text = "Lorem Ipsum",
@@ -124,8 +119,7 @@ public class ColorPickers : Scenario
         };
         app.Add (_demoView);
 
-
-        var osColorModel = new OptionSelector ()
+        var osColorModel = new OptionSelector
         {
             Y = Pos.Bottom (_demoView),
             Width = Dim.Auto (),
@@ -137,87 +131,38 @@ public class ColorPickers : Scenario
                 "H_SL",
                 "_16 Colors"
             ],
-            Value = (int)foregroundColorPicker.Style.ColorModel,
+            Value = (int)_foregroundColorPicker.Style.ColorModel
         };
 
-        osColorModel.ValueChanged += (_, e) =>
-                                            {
-                                                // 16 colors
-                                                if (e.Value == 3)
-                                                {
-
-                                                    foregroundColorPicker16.Visible = true;
-                                                    foregroundColorPicker.Visible = false;
-
-                                                    backgroundColorPicker16.Visible = true;
-                                                    backgroundColorPicker.Visible = false;
-
-                                                    // Switching to 16 colors
-                                                    ForegroundColor_ColorChanged (null, null);
-                                                    BackgroundColor_ColorChanged (null, null);
-                                                }
-                                                else
-                                                {
-                                                    foregroundColorPicker16.Visible = false;
-                                                    foregroundColorPicker.Visible = true;
-
-                                                    if (e.Value is { })
-                                                    {
-                                                        foregroundColorPicker.Style.ColorModel = (ColorModel)e.Value;
-                                                        foregroundColorPicker.ApplyStyleChanges ();
-
-                                                        backgroundColorPicker16.Visible = false;
-                                                        backgroundColorPicker.Visible = true;
-                                                        backgroundColorPicker.Style.ColorModel = (ColorModel)e.Value;
-                                                    }
-
-                                                    backgroundColorPicker.ApplyStyleChanges ();
-
-
-                                                    // Switching to true colors
-                                                    foregroundColorPicker.SelectedColor = foregroundColorPicker16.SelectedColor;
-                                                    backgroundColorPicker.SelectedColor = backgroundColorPicker16.SelectedColor;
-                                                }
-                                            };
+        osColorModel.ValueChanged += OnOsColorModelOnValueChanged;
 
         app.Add (osColorModel);
 
         // Checkbox for switching show text fields on and off
-        var cbShowTextFields = new CheckBox ()
+        var cbShowTextFields = new CheckBox
         {
             Text = "Show _Text Fields",
             Y = Pos.Bottom (osColorModel) + 1,
             Width = Dim.Auto (),
             Height = Dim.Auto (),
-            CheckedState = foregroundColorPicker.Style.ShowTextFields ? CheckState.Checked : CheckState.UnChecked,
+            CheckedState = _foregroundColorPicker.Style.ShowTextFields ? CheckState.Checked : CheckState.UnChecked
         };
 
-        cbShowTextFields.CheckedStateChanging += (_, e) =>
-                                                {
-                                                    foregroundColorPicker.Style.ShowTextFields = e.Result == CheckState.Checked;
-                                                    foregroundColorPicker.ApplyStyleChanges ();
-                                                    backgroundColorPicker.Style.ShowTextFields = e.Result == CheckState.Checked;
-                                                    backgroundColorPicker.ApplyStyleChanges ();
-                                                };
+        cbShowTextFields.CheckedStateChanging += OnCbShowTextFieldsOnCheckedStateChanging;
         app.Add (cbShowTextFields);
 
         // Checkbox for switching show text fields on and off
-        var cbShowName = new CheckBox ()
+        var cbShowName = new CheckBox
         {
             Text = "Show Color _Name",
             Y = Pos.Bottom (cbShowTextFields) + 1,
             Width = Dim.Auto (),
             Height = Dim.Auto (),
-            CheckedState = foregroundColorPicker.Style.ShowColorName ? CheckState.Checked : CheckState.UnChecked,
+            CheckedState = _foregroundColorPicker.Style.ShowColorName ? CheckState.Checked : CheckState.UnChecked
         };
 
-        cbShowName.CheckedStateChanging += (_, e) =>
-                                           {
-                                               foregroundColorPicker.Style.ShowColorName = e.Result == CheckState.Checked;
-                                               foregroundColorPicker.ApplyStyleChanges ();
-                                               backgroundColorPicker.Style.ShowColorName = e.Result == CheckState.Checked;
-                                               backgroundColorPicker.ApplyStyleChanges ();
-                                           };
+        cbShowName.CheckedStateChanging += OnCbShowTextFieldsOnCheckedStateChanging;
+
         app.Add (cbShowName);
 
         var lblDriverName = new Label
@@ -247,41 +192,88 @@ public class ColorPickers : Scenario
         };
         cbUseTrueColor.CheckedStateChanging += (_, evt) => { Application.Force16Colors = evt.Result == CheckState.Checked; };
         app.Add (lblDriverName, cbSupportsTrueColor, cbUseTrueColor);
+
         // Set default colors.
-        foregroundColorPicker.SelectedColor = _demoView.SuperView!.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ();
-        backgroundColorPicker.SelectedColor = _demoView.SuperView.GetAttributeForRole (VisualRole.Normal).Background.GetClosestNamedColor16 ();
+        _foregroundColorPicker.SelectedColor = _demoView.SuperView!.GetAttributeForRole (VisualRole.Normal).Foreground.GetClosestNamedColor16 ();
+        _backgroundColorPicker.SelectedColor = _demoView.SuperView.GetAttributeForRole (VisualRole.Normal).Background.GetClosestNamedColor16 ();
 
         Application.Run (app);
         app.Dispose ();
         Application.Shutdown ();
+
+        return;
+
+        void OnCbShowTextFieldsOnCheckedStateChanging (object _, ResultEventArgs<CheckState> e)
+        {
+            _foregroundColorPicker.Style.ShowTextFields = e.Result == CheckState.Checked;
+            _foregroundColorPicker.ApplyStyleChanges ();
+            _backgroundColorPicker.Style.ShowTextFields = e.Result == CheckState.Checked;
+            _backgroundColorPicker.ApplyStyleChanges ();
+        }
+
+        void OnOsColorModelOnValueChanged (object _, EventArgs<int?> e)
+        {
+            // 16 colors
+            if (e.Value == 3)
+            {
+                _foregroundColorPicker16.Visible = true;
+                _foregroundColorPicker.Visible = false;
+
+                _backgroundColorPicker16.Visible = true;
+                _backgroundColorPicker.Visible = false;
+
+                // Switching to 16 colors
+                ForegroundColor_ColorChanged (null, null);
+                BackgroundColor_ColorChanged (null, null);
+            }
+            else
+            {
+                _foregroundColorPicker16.Visible = false;
+                _foregroundColorPicker.Visible = true;
+
+                if (e.Value is { })
+                {
+                    _foregroundColorPicker.Style.ColorModel = (ColorModel)e.Value;
+                    _foregroundColorPicker.ApplyStyleChanges ();
+
+                    _backgroundColorPicker16.Visible = false;
+                    _backgroundColorPicker.Visible = true;
+                    _backgroundColorPicker.Style.ColorModel = (ColorModel)e.Value;
+                }
+
+                _backgroundColorPicker.ApplyStyleChanges ();
+
+                // Switching to true colors
+                _foregroundColorPicker.SelectedColor = _foregroundColorPicker16.SelectedColor;
+                _backgroundColorPicker.SelectedColor = _backgroundColorPicker16.SelectedColor;
+            }
+        }
     }
 
     /// <summary>Fired when background color is changed.</summary>
     private void BackgroundColor_ColorChanged (object sender, ResultEventArgs<Color> e)
     {
-        UpdateColorLabel (_backgroundColorLabel,
-                          backgroundColorPicker.Visible ?
-                              backgroundColorPicker.SelectedColor :
-                              backgroundColorPicker16.SelectedColor
-                          );
+        UpdateColorLabel (
+                          _backgroundColorLabel,
+                          _backgroundColorPicker.Visible ? _backgroundColorPicker.SelectedColor : _backgroundColorPicker16.SelectedColor
+                         );
         UpdateDemoLabel ();
     }
 
     /// <summary>Fired when foreground color is changed.</summary>
     private void ForegroundColor_ColorChanged (object sender, ResultEventArgs<Color> e)
     {
-        UpdateColorLabel (_foregroundColorLabel,
-                          foregroundColorPicker.Visible ?
-                                 foregroundColorPicker.SelectedColor :
-                                 foregroundColorPicker16.SelectedColor
-                          );
+        UpdateColorLabel (
+                          _foregroundColorLabel,
+                          _foregroundColorPicker.Visible ? _foregroundColorPicker.SelectedColor : _foregroundColorPicker16.SelectedColor
+                         );
         UpdateDemoLabel ();
     }
 
     /// <summary>Update a color label from his ColorPicker.</summary>
     private void UpdateColorLabel (Label label, Color color)
     {
-        label.ClearViewport (null);
+        label.ClearViewport ();
 
         label.Text =
             $"{color} ({(int)color}) #{color.R:X2}{color.G:X2}{color.B:X2}";
@@ -290,17 +282,14 @@ public class ColorPickers : Scenario
     /// <summary>Update Demo Label.</summary>
     private void UpdateDemoLabel ()
     {
-        _demoView.SetScheme (new Scheme
-        {
-            Normal = new Attribute (
-                                    foregroundColorPicker.Visible ?
-                                        foregroundColorPicker.SelectedColor :
-                                        foregroundColorPicker16.SelectedColor,
-                                    backgroundColorPicker.Visible ?
-                                        backgroundColorPicker.SelectedColor :
-                                        backgroundColorPicker16.SelectedColor
-                                   )
-        });
+        _demoView.SetScheme (
+                             new ()
+                             {
+                                 Normal = new (
+                                               _foregroundColorPicker.Visible ? _foregroundColorPicker.SelectedColor : _foregroundColorPicker16.SelectedColor,
+                                               _backgroundColorPicker.Visible ? _backgroundColorPicker.SelectedColor : _backgroundColorPicker16.SelectedColor
+                                              )
+                             });
     }
 
     public override List<Key> GetDemoKeyStrokes ()
@@ -310,7 +299,7 @@ public class ColorPickers : Scenario
             Key.B.WithAlt
         ];
 
-        for (int i = 0; i < 200; i++)
+        for (var i = 0; i < 200; i++)
         {
             keys.Add (Key.CursorRight);
         }
@@ -318,7 +307,7 @@ public class ColorPickers : Scenario
         keys.Add (Key.Tab);
         keys.Add (Key.Tab);
 
-        for (int i = 0; i < 200; i++)
+        for (var i = 0; i < 200; i++)
         {
             keys.Add (Key.CursorLeft);
         }
@@ -326,7 +315,7 @@ public class ColorPickers : Scenario
         keys.Add (Key.Tab);
         keys.Add (Key.Tab);
 
-        for (int i = 0; i < 200; i++)
+        for (var i = 0; i < 200; i++)
         {
             keys.Add (Key.CursorLeft);
         }

+ 1 - 1
Examples/UICatalog/Scenarios/ContextMenus.cs

@@ -49,7 +49,7 @@ public class ContextMenus : Scenario
             var text = "Context Menu";
             var width = 20;
 
-            CreateWinContextMenu (ApplicationImpl.Instance);
+            CreateWinContextMenu (Application.Instance);
 
             var label = new Label
             {

+ 13 - 13
Examples/UICatalog/Scenarios/CsvEditor.cs

@@ -215,7 +215,7 @@ public class CsvEditor : Scenario
                                       _tableView.Table.Columns
                                      );
 
-            int? result = MessageBox.Query (ApplicationImpl.Instance,
+            int? result = MessageBox.Query (Application.Instance,
                                            "Column Type",
                                            "Pick a data type for the column",
                                            "Date",
@@ -308,7 +308,7 @@ public class CsvEditor : Scenario
 
         if (_tableView.SelectedColumn == -1)
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance, "No Column", "No column selected", "Ok");
+            MessageBox.ErrorQuery (Application.Instance, "No Column", "No column selected", "Ok");
 
             return;
         }
@@ -320,7 +320,7 @@ public class CsvEditor : Scenario
         }
         catch (Exception ex)
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance, "Could not remove column", ex.Message, "Ok");
+            MessageBox.ErrorQuery (Application.Instance, "Could not remove column", ex.Message, "Ok");
         }
     }
 
@@ -342,7 +342,7 @@ public class CsvEditor : Scenario
             }
             catch (Exception ex)
             {
-                MessageBox.ErrorQuery (ApplicationImpl.Instance, 60, 20, "Failed to set text", ex.Message, "Ok");
+                MessageBox.ErrorQuery (Application.Instance, 60, 20, "Failed to set text", ex.Message, "Ok");
             }
 
             _tableView.Update ();
@@ -388,7 +388,7 @@ public class CsvEditor : Scenario
 
         if (_tableView.SelectedColumn == -1)
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance, "No Column", "No column selected", "Ok");
+            MessageBox.ErrorQuery (Application.Instance, "No Column", "No column selected", "Ok");
 
             return;
         }
@@ -413,7 +413,7 @@ public class CsvEditor : Scenario
         }
         catch (Exception ex)
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance, "Error moving column", ex.Message, "Ok");
+            MessageBox.ErrorQuery (Application.Instance, "Error moving column", ex.Message, "Ok");
         }
     }
 
@@ -426,7 +426,7 @@ public class CsvEditor : Scenario
 
         if (_tableView.SelectedRow == -1)
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance, "No Rows", "No row selected", "Ok");
+            MessageBox.ErrorQuery (Application.Instance, "No Rows", "No row selected", "Ok");
 
             return;
         }
@@ -462,7 +462,7 @@ public class CsvEditor : Scenario
         }
         catch (Exception ex)
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance, "Error moving column", ex.Message, "Ok");
+            MessageBox.ErrorQuery (Application.Instance, "Error moving column", ex.Message, "Ok");
         }
     }
 
@@ -470,7 +470,7 @@ public class CsvEditor : Scenario
     {
         if (_tableView?.Table is null)
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance, "No Table Loaded", "No table has currently be opened", "Ok");
+            MessageBox.ErrorQuery (Application.Instance, "No Table Loaded", "No table has currently be opened", "Ok");
 
             return true;
         }
@@ -582,7 +582,7 @@ public class CsvEditor : Scenario
         }
         catch (Exception ex)
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance,
+            MessageBox.ErrorQuery (Application.Instance,
                                    "Open Failed",
                                    $"Error on line {lineNumber}{Environment.NewLine}{ex.Message}",
                                    "Ok"
@@ -612,7 +612,7 @@ public class CsvEditor : Scenario
     {
         if (_tableView?.Table is null || string.IsNullOrWhiteSpace (_currentFile) || _currentTable is null)
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance, "No file loaded", "No file is currently loaded", "Ok");
+            MessageBox.ErrorQuery (Application.Instance, "No file loaded", "No file is currently loaded", "Ok");
 
             return;
         }
@@ -674,7 +674,7 @@ public class CsvEditor : Scenario
 
         if (col.DataType == typeof (string))
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance,
+            MessageBox.ErrorQuery (Application.Instance,
                                    "Cannot Format Column",
                                    "String columns cannot be Formatted, try adding a new column to the table with a date/numerical Type",
                                    "Ok"
@@ -711,7 +711,7 @@ public class CsvEditor : Scenario
 
         if (_tableView.SelectedColumn == -1)
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance, "No Column", "No column selected", "Ok");
+            MessageBox.ErrorQuery (Application.Instance, "No Column", "No column selected", "Ok");
 
             return;
         }

+ 2 - 2
Examples/UICatalog/Scenarios/DynamicStatusBar.cs

@@ -79,7 +79,7 @@ public class DynamicStatusBar : Scenario
             }
             catch (Exception ex)
             {
-                MessageBox.ErrorQuery (ApplicationImpl.Instance, "Binding Error", $"Binding failed: {ex}.", "Ok");
+                MessageBox.ErrorQuery (Application.Instance, "Binding Error", $"Binding failed: {ex}.", "Ok");
             }
         }
     }
@@ -140,7 +140,7 @@ public class DynamicStatusBar : Scenario
         public TextView TextAction { get; }
         public TextField TextShortcut { get; }
         public TextField TextTitle { get; }
-        public Action CreateAction (DynamicStatusItem item) { return () => MessageBox.ErrorQuery (ApplicationImpl.Instance, item.Title, item.Action, "Ok"); }
+        public Action CreateAction (DynamicStatusItem item) { return () => MessageBox.ErrorQuery (Application.Instance, item.Title, item.Action, "Ok"); }
 
         public void EditStatusItem (Shortcut statusItem)
         {

+ 9 - 9
Examples/UICatalog/Scenarios/Editor.cs

@@ -201,7 +201,7 @@ public class Editor : Scenario
         Debug.Assert (_textView.IsDirty);
 
         int? r = MessageBox.ErrorQuery (
-                                       ApplicationImpl.Instance,
+                                       Application.Instance,
                                        "Save File",
                                        $"Do you want save changes in {_appWindow.Title}?",
                                        "Yes",
@@ -236,7 +236,7 @@ public class Editor : Scenario
         }
         catch (Exception ex)
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance, "Error", ex.Message, "Ok");
+            MessageBox.ErrorQuery (Application.Instance, "Error", ex.Message, "Ok");
         }
     }
 
@@ -315,11 +315,11 @@ public class Editor : Scenario
 
         if (!found)
         {
-            MessageBox.Query (ApplicationImpl.Instance, "Find", $"The following specified text was not found: '{_textToFind}'", "Ok");
+            MessageBox.Query (Application.Instance, "Find", $"The following specified text was not found: '{_textToFind}'", "Ok");
         }
         else if (gaveFullTurn)
         {
-            MessageBox.Query (ApplicationImpl.Instance,
+            MessageBox.Query (Application.Instance,
                               "Find",
                               $"No more occurrences were found for the following specified text: '{_textToFind}'",
                               "Ok"
@@ -895,7 +895,7 @@ public class Editor : Scenario
 
         if (_textView.ReplaceAllText (_textToFind, _matchCase, _matchWholeWord, _textToReplace))
         {
-            MessageBox.Query (ApplicationImpl.Instance,
+            MessageBox.Query (Application.Instance,
                               "Replace All",
                               $"All occurrences were replaced for the following specified text: '{_textToReplace}'",
                               "Ok"
@@ -903,7 +903,7 @@ public class Editor : Scenario
         }
         else
         {
-            MessageBox.Query (ApplicationImpl.Instance,
+            MessageBox.Query (Application.Instance,
                               "Replace All",
                               $"None of the following specified text was found: '{_textToFind}'",
                               "Ok"
@@ -1155,7 +1155,7 @@ public class Editor : Scenario
         {
             if (File.Exists (path))
             {
-                if (MessageBox.Query (ApplicationImpl.Instance,
+                if (MessageBox.Query (Application.Instance,
                                       "Save File",
                                       "File already exists. Overwrite any way?",
                                       "No",
@@ -1194,11 +1194,11 @@ public class Editor : Scenario
             _originalText = Encoding.Unicode.GetBytes (_textView.Text);
             _saved = true;
             _textView.ClearHistoryChanges ();
-            MessageBox.Query (ApplicationImpl.Instance, "Save File", "File was successfully saved.", "Ok");
+            MessageBox.Query (Application.Instance, "Save File", "File was successfully saved.", "Ok");
         }
         catch (Exception ex)
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance, "Error", ex.Message, "Ok");
+            MessageBox.ErrorQuery (Application.Instance, "Error", ex.Message, "Ok");
 
             return false;
         }

+ 5 - 5
Examples/UICatalog/Scenarios/FileDialogExamples.cs

@@ -133,7 +133,7 @@ public class FileDialogExamples : Scenario
                              }
                              catch (Exception ex)
                              {
-                                 MessageBox.ErrorQuery (ApplicationImpl.Instance, "Error", ex.ToString (), "_Ok");
+                                 MessageBox.ErrorQuery (Application.Instance, "Error", ex.ToString (), "_Ok");
                              }
                              finally
                              {
@@ -153,7 +153,7 @@ public class FileDialogExamples : Scenario
         {
             if (File.Exists (e.Dialog.Path))
             {
-                int? result = MessageBox.Query (ApplicationImpl.Instance, "Overwrite?", "File already exists", "_Yes", "_No");
+                int? result = MessageBox.Query (Application.Instance, "Overwrite?", "File already exists", "_Yes", "_No");
                 e.Cancel = result == 1;
             }
         }
@@ -248,7 +248,7 @@ public class FileDialogExamples : Scenario
 
             if (canceled)
             {
-                MessageBox.Query (ApplicationImpl.Instance,
+                MessageBox.Query (Application.Instance,
                                   "Canceled",
                                   "You canceled navigation and did not pick anything",
                                   "Ok"
@@ -256,7 +256,7 @@ public class FileDialogExamples : Scenario
             }
             else if (_cbAllowMultipleSelection.CheckedState == CheckState.Checked)
             {
-                MessageBox.Query (ApplicationImpl.Instance,
+                MessageBox.Query (Application.Instance,
                                   "Chosen!",
                                   "You chose:" + Environment.NewLine + string.Join (Environment.NewLine, multiSelected.Select (m => m)),
                                   "Ok"
@@ -264,7 +264,7 @@ public class FileDialogExamples : Scenario
             }
             else
             {
-                MessageBox.Query (ApplicationImpl.Instance,
+                MessageBox.Query (Application.Instance,
                                   "Chosen!",
                                   "You chose:" + Environment.NewLine + path,
                                   "Ok"

+ 1 - 1
Examples/UICatalog/Scenarios/Generic.cs

@@ -29,7 +29,7 @@ public sealed class Generic : Scenario
                             {
                                 // When Accepting is handled, set e.Handled to true to prevent further processing.
                                 e.Handled = true;
-                                MessageBox.ErrorQuery (ApplicationImpl.Instance, "Error", "You pressed the button!", "_Ok");
+                                MessageBox.ErrorQuery (Application.Instance, "Error", "You pressed the button!", "_Ok");
                             };
 
         appWindow.Add (button);

+ 4 - 4
Examples/UICatalog/Scenarios/HexEditor.cs

@@ -181,7 +181,7 @@ public class HexEditor : Scenario
         }
     }
 
-    private void Copy () { MessageBox.ErrorQuery (ApplicationImpl.Instance, "Not Implemented", "Functionality not yet implemented.", "Ok"); }
+    private void Copy () { MessageBox.ErrorQuery (Application.Instance, "Not Implemented", "Functionality not yet implemented.", "Ok"); }
 
     private void CreateDemoFile (string fileName)
     {
@@ -208,7 +208,7 @@ public class HexEditor : Scenario
         ms.Close ();
     }
 
-    private void Cut () { MessageBox.ErrorQuery (ApplicationImpl.Instance, "Not Implemented", "Functionality not yet implemented.", "Ok"); }
+    private void Cut () { MessageBox.ErrorQuery (Application.Instance, "Not Implemented", "Functionality not yet implemented.", "Ok"); }
 
     private Stream LoadFile ()
     {
@@ -216,7 +216,7 @@ public class HexEditor : Scenario
 
         if (!_saved && _hexView!.Edits.Count > 0 && _hexView.Source is {})
         {
-            if (MessageBox.ErrorQuery (ApplicationImpl.Instance,
+            if (MessageBox.ErrorQuery (Application.Instance,
                                        "Save",
                                        "The changes were not saved. Want to open without saving?",
                                        "_Yes",
@@ -267,7 +267,7 @@ public class HexEditor : Scenario
         d.Dispose ();
     }
 
-    private void Paste () { MessageBox.ErrorQuery (ApplicationImpl.Instance, "Not Implemented", "Functionality not yet implemented.", "_Ok"); }
+    private void Paste () { MessageBox.ErrorQuery (Application.Instance, "Not Implemented", "Functionality not yet implemented.", "_Ok"); }
     private void Quit () { Application.RequestStop (); }
 
     private void Save ()

+ 3 - 3
Examples/UICatalog/Scenarios/Images.cs

@@ -183,7 +183,7 @@ public class Images : Scenario
 
         if (!_sixelSupportResult.SupportsTransparency)
         {
-            if (MessageBox.Query (ApplicationImpl.Instance,
+            if (MessageBox.Query (Application.Instance,
                                   "Transparency Not Supported",
                                   "It looks like your terminal does not support transparent sixel backgrounds. Do you want to try anyway?",
                                   "Yes",
@@ -288,7 +288,7 @@ public class Images : Scenario
         }
         catch (Exception ex)
         {
-            MessageBox.ErrorQuery (ApplicationImpl.Instance, "Could not open file", ex.Message, "Ok");
+            MessageBox.ErrorQuery (Application.Instance, "Could not open file", ex.Message, "Ok");
 
             return;
         }
@@ -492,7 +492,7 @@ public class Images : Scenario
     {
         if (_imageView.FullResImage == null)
         {
-            MessageBox.Query (ApplicationImpl.Instance, "No Image Loaded", "You must first open an image.  Use the 'Open Image' button above.", "Ok");
+            MessageBox.Query (Application.Instance, "No Image Loaded", "You must first open an image.  Use the 'Open Image' button above.", "Ok");
 
             return;
         }

+ 1 - 1
Examples/UICatalog/Scenarios/InteractiveTree.cs

@@ -173,7 +173,7 @@ public class InteractiveTree : Scenario
 
                 if (parent is null)
                 {
-                    MessageBox.ErrorQuery (ApplicationImpl.Instance,
+                    MessageBox.ErrorQuery (Application.Instance,
                                            "Could not delete",
                                            $"Parent of '{toDelete}' was unexpectedly null",
                                            "Ok"

+ 4 - 4
Examples/UICatalog/Scenarios/KeyBindings.cs

@@ -164,17 +164,17 @@ public class KeyBindingsDemo : View
 
         AddCommand (Command.Save, ctx =>
                                  {
-                                     MessageBox.Query (ApplicationImpl.Instance, $"{ctx.Command}", $"Ctx: {ctx}", buttons: "Ok");
+                                     MessageBox.Query (Application.Instance, $"{ctx.Command}", $"Ctx: {ctx}", buttons: "Ok");
                                      return true;
                                  });
         AddCommand (Command.New, ctx =>
                                 {
-                                    MessageBox.Query (ApplicationImpl.Instance, $"{ctx.Command}", $"Ctx: {ctx}", buttons: "Ok");
+                                    MessageBox.Query (Application.Instance, $"{ctx.Command}", $"Ctx: {ctx}", buttons: "Ok");
                                     return true;
                                 });
         AddCommand (Command.HotKey, ctx =>
         {
-            MessageBox.Query (ApplicationImpl.Instance, $"{ctx.Command}", $"Ctx: {ctx}\nCommand: {ctx.Command}", buttons: "Ok");
+            MessageBox.Query (Application.Instance, $"{ctx.Command}", $"Ctx: {ctx}\nCommand: {ctx.Command}", buttons: "Ok");
             SetFocus ();
             return true;
         });
@@ -189,7 +189,7 @@ public class KeyBindingsDemo : View
                                              {
                                                  return false;
                                              }
-                                             MessageBox.Query (ApplicationImpl.Instance, $"{keyCommandContext.Binding}", $"Key: {keyCommandContext.Binding.Key}\nCommand: {ctx.Command}", buttons: "Ok");
+                                             MessageBox.Query (Application.Instance, $"{keyCommandContext.Binding}", $"Key: {keyCommandContext.Binding.Key}\nCommand: {ctx.Command}", buttons: "Ok");
                                              Application.RequestStop ();
                                              return true;
                                          });

+ 1 - 1
Examples/UICatalog/Scenarios/ListColumns.cs

@@ -336,7 +336,7 @@ public class ListColumns : Scenario
             }
             catch (Exception ex)
             {
-                MessageBox.ErrorQuery (ApplicationImpl.Instance, 60, 20, "Failed to set", ex.Message, "Ok");
+                MessageBox.ErrorQuery (Application.Instance, 60, 20, "Failed to set", ex.Message, "Ok");
             }
         }
     }

+ 2 - 2
Examples/UICatalog/Scenarios/MessageBoxes.cs

@@ -251,7 +251,7 @@ public class MessageBoxes : Scenario
                                                {
                                                    buttonPressedLabel.Text =
                                                        $"{MessageBox.Query (
-                                                                            ApplicationImpl.Instance, width,
+                                                                            Application.Instance, width,
                                                                              height,
                                                                              titleEdit.Text,
                                                                              messageEdit.Text,
@@ -263,7 +263,7 @@ public class MessageBoxes : Scenario
                                                else
                                                {
                                                    buttonPressedLabel.Text =
-                                                       $"{MessageBox.ErrorQuery (ApplicationImpl.Instance,
+                                                       $"{MessageBox.ErrorQuery (Application.Instance,
                                                                                  width,
                                                                                  height,
                                                                                  titleEdit.Text,

+ 1 - 1
Examples/UICatalog/Scenarios/MultiColouredTable.cs

@@ -99,7 +99,7 @@ public class MultiColouredTable : Scenario
             }
             catch (Exception ex)
             {
-                MessageBox.ErrorQuery (ApplicationImpl.Instance, 60, 20, "Failed to set text", ex.Message, "Ok");
+                MessageBox.ErrorQuery (Application.Instance, 60, 20, "Failed to set text", ex.Message, "Ok");
             }
 
             _tableView.Update ();

+ 1 - 1
Examples/UICatalog/Scenarios/Navigation.cs

@@ -59,7 +59,7 @@ public class Navigation : Scenario
             Y = 0,
             Title = $"TopButton _{GetNextHotKey ()}"
         };
-        button.Accepting += (sender, args) => MessageBox.Query (ApplicationImpl.Instance, "hi", button.Title, "_Ok");
+        button.Accepting += (sender, args) => MessageBox.Query (Application.Instance, "hi", button.Title, "_Ok");
 
         testFrame.Add (button);
 

+ 2 - 2
Examples/UICatalog/Scenarios/Notepad.cs

@@ -71,7 +71,7 @@ public class Notepad : Scenario
                                        new MenuItem
                                        {
                                            Title = "_About",
-                                           Action = () => MessageBox.Query (ApplicationImpl.Instance,  "Notepad", "About Notepad...", "Ok")
+                                           Action = () => MessageBox.Query (Application.Instance,  "Notepad", "About Notepad...", "Ok")
                                        }
                                    ]
                                   )
@@ -196,7 +196,7 @@ public class Notepad : Scenario
 
         if (tab.UnsavedChanges)
         {
-            int? result = MessageBox.Query (ApplicationImpl.Instance,
+            int? result = MessageBox.Query (Application.Instance,
                                             "Save Changes",
                                             $"Save changes to {tab.Text.TrimEnd ('*')}",
                                             "Yes",

+ 3 - 3
Examples/UICatalog/Scenarios/RuneWidthGreaterThanOne.cs

@@ -166,7 +166,7 @@ public class RuneWidthGreaterThanOne : Scenario
     {
         if (_text is { })
         {
-            MessageBox.Query (ApplicationImpl.Instance, "Say Hello 你", $"Hello {_text.Text}", "Ok");
+            MessageBox.Query (Application.Instance, "Say Hello 你", $"Hello {_text.Text}", "Ok");
         }
     }
 
@@ -197,7 +197,7 @@ public class RuneWidthGreaterThanOne : Scenario
     {
         if (_text is { })
         {
-            MessageBox.Query (ApplicationImpl.Instance, "Say Hello", $"Hello {_text.Text}", "Ok");
+            MessageBox.Query (Application.Instance, "Say Hello", $"Hello {_text.Text}", "Ok");
         }
     }
 
@@ -252,7 +252,7 @@ public class RuneWidthGreaterThanOne : Scenario
     {
         if (_text is { })
         {
-            MessageBox.Query (ApplicationImpl.Instance, "こんにちはと言う", $"こんにちは {_text.Text}", "Ok");
+            MessageBox.Query (Application.Instance, "こんにちはと言う", $"こんにちは {_text.Text}", "Ok");
         }
     }
 

+ 1 - 1
Examples/UICatalog/Scenarios/WindowsAndFrameViews.cs

@@ -18,7 +18,7 @@ public class WindowsAndFrameViews : Scenario
 
         static int? About ()
         {
-            return MessageBox.Query (ApplicationImpl.Instance,
+            return MessageBox.Query (Application.Instance,
                                      "About UI Catalog",
                                      "UI Catalog is a comprehensive sample library for Terminal.Gui",
                                      "Ok"

+ 3 - 3
Examples/UICatalog/Scenarios/WizardAsView.cs

@@ -21,7 +21,7 @@ public class WizardAsView : Scenario
                                        {
                                            Title = "_Restart Configuration...",
                                            Action = () => MessageBox.Query (
-                                                                            ApplicationImpl.Instance,
+                                                                            Application.Instance,
                                                                             "Wizard",
                                                                             "Are you sure you want to reset the Wizard and start over?",
                                                                             "Ok",
@@ -32,7 +32,7 @@ public class WizardAsView : Scenario
                                        {
                                            Title = "Re_boot Server...",
                                            Action = () => MessageBox.Query (
-                                                                            ApplicationImpl.Instance,
+                                                                            Application.Instance,
                                                                             "Wizard",
                                                                             "Are you sure you want to reboot the server start over?",
                                                                             "Ok",
@@ -43,7 +43,7 @@ public class WizardAsView : Scenario
                                        {
                                            Title = "_Shutdown Server...",
                                            Action = () => MessageBox.Query (
-                                                                            ApplicationImpl.Instance,
+                                                                            Application.Instance,
                                                                             "Wizard",
                                                                             "Are you sure you want to cancel setup and shutdown?",
                                                                             "Ok",

+ 72 - 36
README.md

@@ -6,27 +6,23 @@
 
 # Terminal.Gui v2
 
-The premier toolkit for building rich console apps for Windows, the Mac, and Linux/Unix.
+Cross-platform UI toolkit for building sophisticated terminal UI (TUI) applications on Windows, macOS, and Linux/Unix.
 
 ![logo](docfx/images/logo.png)
 
-* The current, stable, release of Terminal.Gui v1 is [![Version](https://img.shields.io/nuget/v/Terminal.Gui.svg)](https://www.nuget.org/packages/Terminal.Gui).
+* **v2 Alpha** (Current): ![NuGet Version](https://img.shields.io/nuget/vpre/Terminal.Gui) - Recommended for new projects
+* **v1 (Legacy)**: [![Version](https://img.shields.io/nuget/v/Terminal.Gui.svg)](https://www.nuget.org/packages/Terminal.Gui) - Maintenance mode only
 
-> :warning: **Note:**  
-> `v1` is in maintenance mode and we will only accept PRs for issues impacting existing functionality.
-
-* The current `Alpha` release of Terminal.Gui v2 is ![NuGet Version](https://img.shields.io/nuget/vpre/Terminal.Gui)
-
-> :warning: **Note:**  
-> Developers starting new TUI projects are encouraged to target `v2 Alpha`. The API is significantly changed, and significantly improved. There will be breaking changes in the API before Beta, but the core API is stable.
+> **Important:**
+> - **v1** is in maintenance mode - only critical bug fixes accepted
+> - **v2 Alpha** is recommended for new projects - API is stable with comprehensive features
+> - Breaking changes possible before Beta, but core architecture is solid
 
 ![Sample app](docfx/images/sample.gif)
 
 # Quick Start
 
-Paste these commands into your favorite terminal on Windows, Mac, or Linux. This will install the [Terminal.Gui.Templates](https://github.com/gui-cs/Terminal.Gui.templates), create a new "Hello World" TUI app, and run it.
-
-(Press `CTRL-Q` to exit the app)
+Install the [Terminal.Gui.Templates](https://github.com/gui-cs/Terminal.Gui.templates), create a new TUI app, and run it:
 
 ```powershell
 dotnet new --install Terminal.Gui.templates
@@ -35,60 +31,100 @@ cd myproj
 dotnet run
 ```
 
-To run the UICatalog demo app that shows all the controls and features of the toolkit, use the following command:
+Press `Esc` to exit (the default [QuitKey](https://gui-cs.github.io/Terminal.Gui/api/Terminal.Gui.App.Application.html#Terminal_Gui_App_Application_QuitKey)).
+
+Run the comprehensive [UI Catalog](Examples/UICatalog) demo to explore all controls:
 
 ```powershell
 dotnet run --project Examples/UICatalog/UICatalog.csproj
 ```
 
-There is also a [visual designer](https://github.com/gui-cs/TerminalGuiDesigner) (uses Terminal.Gui itself).
+# Simple Example
+
+```csharp
+using Terminal.Gui;
+
+using IApplication app = Application.Create ();
+app.Init ();
+
+using Window window = new () { Title = "Hello World (Esc to quit)" };
+Label label = new ()
+{
+    Text = "Hello, Terminal.Gui v2!",
+    X = Pos.Center (),
+    Y = Pos.Center ()
+};
+window.Add (label);
+
+app.Run (window);
+```
+
+See the [Examples](Examples/) directory for more.
+
+# Build Powerful Terminal Applications
+
+Terminal.Gui enables building sophisticated console applications with modern UIs:
+
+- **Rich Forms and Dialogs** - Text fields, buttons, checkboxes, radio buttons, and data validation
+- **Interactive Data Views** - Tables, lists, and trees with sorting, filtering, and in-place editing  
+- **Visualizations** - Charts, graphs, progress indicators, and color pickers with TrueColor support
+- **Text Editors** - Full-featured text editing with clipboard, undo/redo, and Unicode support
+- **File Management** - File and directory browsers with search and filtering
+- **Wizards and Multi-Step Processes** - Guided workflows with navigation and validation
+- **System Monitoring Tools** - Real-time dashboards with scrollable, resizable views
+- **Configuration UIs** - Settings editors with persistent themes and user preferences
+- **Cross-Platform CLI Tools** - Consistent experience on Windows, macOS, and Linux
+- **Server Management Interfaces** - SSH-compatible UIs for remote administration
+
+See the [Views Overview](https://gui-cs.github.io/Terminal.Gui/docs/views) for available controls and [What's New in v2](https://gui-cs.github.io/Terminal.Gui/docs/newinv2) for architectural improvements.
 
 # Documentation 
 
-The full developer documentation for Terminal.Gui is available at [gui-cs.github.io/Terminal.Gui](https://gui-cs.github.io/Terminal.Gui).
+Comprehensive documentation is at [gui-cs.github.io/Terminal.Gui](https://gui-cs.github.io/Terminal.Gui).
 
 ## Getting Started
 
-- [Getting Started](https://gui-cs.github.io/Terminal.Gui/docs/getting-started) - Quick start guide to create your first Terminal.Gui application
-- [Migrating from v1 to v2](https://gui-cs.github.io/Terminal.Gui/docs/migratingfromv1) - Complete guide for upgrading existing applications
-- [What's New in v2](https://gui-cs.github.io/Terminal.Gui/docs/newinv2) - Overview of new features and improvements
+- **[Getting Started Guide](https://gui-cs.github.io/Terminal.Gui/docs/getting-started)** - First Terminal.Gui application
+- **[API Reference](https://gui-cs.github.io/Terminal.Gui/api/Terminal.Gui.App.html)** - Complete API documentation
+- **[What's New in v2](https://gui-cs.github.io/Terminal.Gui/docs/newinv2)** - New features and improvements
 
-## API Reference
+## Migration & Deep Dives
 
-For detailed API documentation, see the [API Reference](https://gui-cs.github.io/Terminal.Gui/api/Terminal.Gui.App.html).
+- **[Migrating from v1 to v2](https://gui-cs.github.io/Terminal.Gui/docs/migratingfromv1)** - Complete migration guide
+- **[Application Architecture](https://gui-cs.github.io/Terminal.Gui/docs/application)** - Instance-based model and IRunnable pattern
+- **[Layout System](https://gui-cs.github.io/Terminal.Gui/docs/layout)** - Positioning, sizing, and adornments
+- **[Keyboard Handling](https://gui-cs.github.io/Terminal.Gui/docs/keyboard)** - Key bindings and commands
+- **[View Documentation](https://gui-cs.github.io/Terminal.Gui/docs/View)** - View hierarchy and lifecycle
+- **[Configuration](https://gui-cs.github.io/Terminal.Gui/docs/config)** - Themes and persistent settings
 
-# Installing
+See the [documentation index](https://gui-cs.github.io/Terminal.Gui/docs/index) for all topics.
 
-Use NuGet to install the `Terminal.Gui` NuGet package: 
+# Installing
 
-## v2 Alpha 
+## v2 Alpha (Recommended)
 
-(Infrequently updated, but stable enough for production use)
-```
+```powershell
 dotnet add package Terminal.Gui --version "2.0.0-alpha.*"
 ```
 
-## v2 Develop
+## v2 Develop (Latest)
 
-(Frequently updated, but may have breaking changes)
-```
+```powershell
 dotnet add package Terminal.Gui --version "2.0.0-develop.*"
 ```
 
-## Legacy v1
+## v1 Legacy
 
-```
-dotnet add package Terminal.Gui --version "1.*
+```powershell
+dotnet add package Terminal.Gui --version "1.*"
 ```
 
-Or, you can use the [Terminal.Gui.Templates](https://github.com/gui-cs/Terminal.Gui.templates).
+Or use the [Terminal.Gui.Templates](https://github.com/gui-cs/Terminal.Gui.templates).
 
 # Contributing
 
-See [CONTRIBUTING.md](CONTRIBUTING.md) for complete contribution guidelines.
-
-Debates on architecture and design can be found in Issues tagged with [design](https://github.com/gui-cs/Terminal.Gui/issues?q=is%3Aopen+is%3Aissue+label%3Av2+label%3Adesign).
+Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md).
 
 # History
 
-See [gui-cs](https://github.com/gui-cs/) for how this project came to be.
+See [gui-cs](https://github.com/gui-cs/) for project history and origins.

+ 17 - 1
Terminal.Gui/App/Application.Lifecycle.cs

@@ -10,6 +10,22 @@ namespace Terminal.Gui.App;
 
 public static partial class Application // Lifecycle (Init/Shutdown)
 {
+    /// <summary>
+    ///     Gets the singleton <see cref="IApplication"/> instance used by the legacy static Application model.
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         For new code, prefer using <see cref="Create"/> to get an instance-based application.
+    ///         This property is provided for backward compatibility and internal use.
+    ///     </para>
+    ///     <para>
+    ///         This property returns the same singleton instance used by the legacy static <see cref="Application"/>
+    ///         methods like <see cref="Init"/> and <see cref="Run(IRunnable, Func{Exception, bool}?)"/>.
+    ///     </para>
+    /// </remarks>
+    [Obsolete ("The legacy static Application object is going away. Use Application.Create() for new code.")]
+    public static IApplication Instance => ApplicationImpl.Instance;
+
     /// <summary>
     ///     Creates a new <see cref="IApplication"/> instance.
     /// </summary>
@@ -49,7 +65,7 @@ public static partial class Application // Lifecycle (Init/Shutdown)
         internal set => ApplicationImpl.Instance.MainThreadId = value;
     }
 
-    /// <inheritdoc cref="IApplication.Dispose"/>
+    /// <inheritdoc cref="IDisposable.Dispose"/>
     [Obsolete ("The legacy static Application object is going away.")]
     public static void Shutdown () => ApplicationImpl.Instance.Dispose ();
 

+ 0 - 117
Terminal.Gui/App/Application.cd

@@ -1,117 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ClassDiagram MajorVersion="1" MinorVersion="1">
-  <Class Name="Terminal.Gui.App.Application">
-    <Position X="2.25" Y="1.5" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>gEK4FIgQOAQIuhQeBwoUgSCgAAJL0AACESIKoAiBWw8=</HashCode>
-      <FileName>App\Application.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.App.ApplicationNavigation" Collapsed="true">
-    <Position X="14.75" Y="2.75" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AABAAAAAAABCAAAAAAAAAAAAAAAAIgIAAAAAAAAAAAA=</HashCode>
-      <FileName>App\ApplicationNavigation.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.App.IterationEventArgs" Collapsed="true">
-    <Position X="17" Y="3" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
-      <FileName>App\IterationEventArgs.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.App.MainLoop" Collapsed="true" BaseTypeListCollapsed="true">
-    <Position X="11.25" Y="3.75" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAACAAAAAAAAAAAAAACBAAEAAIIAIAgAAAEAI=</HashCode>
-      <FileName>App\MainLoop.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" Collapsed="true" />
-  </Class>
-  <Class Name="Terminal.Gui.App.MainLoopSyncContext" Collapsed="true">
-    <Position X="13" Y="3.75" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AAAAAgAAAAAAAAAAAEAAAAAACAAAAAAAAAAAAAAAAAA=</HashCode>
-      <FileName>App\MainLoopSyncContext.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.App.SessionToken" Collapsed="true" BaseTypeListCollapsed="true">
-    <Position X="15.25" Y="4" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAACACAgAAAAAAAAAAAAAAAAACQAAAAAAAAAA=</HashCode>
-      <FileName>App\SessionToken.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" Collapsed="true" />
-  </Class>
-  <Class Name="Terminal.Gui.App.SessionTokenEventArgs" Collapsed="true">
-    <Position X="17" Y="4" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAA=</HashCode>
-      <FileName>App\SessionTokenEventArgs.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.App.Timeout" Collapsed="true">
-    <Position X="11.25" Y="4.75" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAQAA=</HashCode>
-      <FileName>App\Timeout.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.App.TimeoutEventArgs" Collapsed="true">
-    <Position X="13" Y="4.75" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAACAIAAAAAAAAAAAA=</HashCode>
-      <FileName>App\TimeoutEventArgs.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.App.ApplicationImpl" BaseTypeListCollapsed="true">
-    <Position X="4" Y="5" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AABgAAAAIAAIAgQUAAAAAQAAAAAAAAAAQAAKgAAAEAI=</HashCode>
-      <FileName>App\ApplicationImpl.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.App.MouseGrabHandler" Collapsed="true">
-    <Position X="6.25" Y="9.25" Width="2" />
-    <TypeIdentifier>
-      <HashCode>BAAgAAAAgABAAoAAAAAAABAAACEAAAAAAABAAgAAAAA=</HashCode>
-      <FileName>App\MouseGrabHandler.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Interface Name="Terminal.Gui.App.IMainLoopDriver">
-    <Position X="11.25" Y="1.5" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAACAAAAAQAAAAABAAAAAAAEAAAAAAAAAAAAAA=</HashCode>
-      <FileName>App\MainLoop.cs</FileName>
-    </TypeIdentifier>
-  </Interface>
-  <Interface Name="Terminal.Gui.App.IApplication">
-    <Position X="4" Y="1.5" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAgAAAAAAAIAgQUAAAAAQAAAAAAAAAAAAAKgAAAEAI=</HashCode>
-      <FileName>App\IApplication.cs</FileName>
-    </TypeIdentifier>
-    <ShowAsAssociation>
-      <Property Name="MouseGrabHandler" />
-      <Property Name="TimedEvents" />
-    </ShowAsAssociation>
-  </Interface>
-  <Interface Name="Terminal.Gui.App.IMouseGrabHandler">
-    <Position X="7" Y="1.5" Width="2" />
-    <TypeIdentifier>
-      <HashCode>BAAgAAAAAAAAAgAAAAAAABAAACEAAAAAAAAAAgAAAAA=</HashCode>
-      <FileName>App\IMouseGrabHandler.cs</FileName>
-    </TypeIdentifier>
-  </Interface>
-  <Interface Name="Terminal.Gui.App.ITimedEvents">
-    <Position X="7" Y="4.5" Width="2" />
-    <TypeIdentifier>
-      <HashCode>BAAAIAAAAQAAAAAQACAAAIBAAQAAAAAAAAAIgAAAAAA=</HashCode>
-      <FileName>App\ITimedEvents.cs</FileName>
-    </TypeIdentifier>
-  </Interface>
-  <Font Name="Segoe UI" Size="9" />
-</ClassDiagram>

+ 1 - 1
Terminal.Gui/App/ApplicationImpl.Driver.cs

@@ -2,7 +2,7 @@ using System.Collections.Concurrent;
 
 namespace Terminal.Gui.App;
 
-public partial class ApplicationImpl
+internal partial class ApplicationImpl
 {
     /// <inheritdoc/>
     public IDriver? Driver { get; set; }

+ 1 - 1
Terminal.Gui/App/ApplicationImpl.Lifecycle.cs

@@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis;
 
 namespace Terminal.Gui.App;
 
-public partial class ApplicationImpl
+internal partial class ApplicationImpl
 {
     /// <inheritdoc/>
     public int? MainThreadId { get; set; }

+ 1 - 1
Terminal.Gui/App/ApplicationImpl.Run.cs

@@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis;
 
 namespace Terminal.Gui.App;
 
-public partial class ApplicationImpl
+internal partial class ApplicationImpl
 {
     // Lock object to protect session stack operations and cached state updates
     private readonly object _sessionStackLock = new ();

+ 1 - 1
Terminal.Gui/App/ApplicationImpl.Screen.cs

@@ -1,7 +1,7 @@
 
 namespace Terminal.Gui.App;
 
-public partial class ApplicationImpl
+internal partial class ApplicationImpl
 {
     /// <inheritdoc/>
     public event EventHandler<EventArgs<Rectangle>>? ScreenChanged;

+ 2 - 2
Terminal.Gui/App/ApplicationImpl.cs

@@ -6,7 +6,7 @@ namespace Terminal.Gui.App;
 ///     Implementation of core <see cref="Application"/> methods using the modern
 ///     main loop architecture with component factories for different platforms.
 /// </summary>
-public partial class ApplicationImpl : IApplication
+internal partial class ApplicationImpl : IApplication
 {
     /// <summary>
     ///     INTERNAL: Creates a new instance of the Application backend and subscribes to Application configuration property
@@ -75,7 +75,7 @@ public partial class ApplicationImpl : IApplication
     /// <summary>
     ///     Gets the currently configured backend implementation of <see cref="Application"/> gateway methods.
     /// </summary>
-    public static IApplication Instance
+    internal static IApplication Instance
     {
         get
         {

+ 32 - 17
Terminal.Gui/App/Timeout/TimedEvents.cs

@@ -201,32 +201,47 @@ public class TimedEvents : ITimedEvents
     private void RunTimersImpl ()
     {
         long now = GetTimestampTicks ();
-        SortedList<long, Timeout> copy;
 
-        // lock prevents new timeouts being added
-        // after we have taken the copy but before
-        // we have allocated a new list (which would
-        // result in lost timeouts or errors during enumeration)
-        lock (_timeoutsLockToken)
+        // Process due timeouts one at a time, without blocking the entire queue
+        while (true)
         {
-            copy = _timeouts;
-            _timeouts = new ();
-        }
+            Timeout? timeoutToExecute = null;
+            long scheduledTime = 0;
 
-        foreach ((long k, Timeout timeout) in copy)
-        {
-            if (k < now)
+            // Find the next due timeout
+            lock (_timeoutsLockToken)
             {
-                if (timeout.Callback! ())
+                if (_timeouts.Count == 0)
+                {
+                    break; // No more timeouts
+                }
+
+                // Re-evaluate current time for each iteration
+                now = GetTimestampTicks ();
+                
+                // Check if the earliest timeout is due
+                scheduledTime = _timeouts.Keys [0];
+                
+                if (scheduledTime >= now)
                 {
-                    AddTimeout (timeout.Span, timeout);
+                    // Earliest timeout is not yet due, we're done
+                    break;
                 }
+
+                // This timeout is due - remove it from the queue
+                timeoutToExecute = _timeouts.Values [0];
+                _timeouts.RemoveAt (0);
             }
-            else
+
+            // Execute the callback outside the lock
+            // This allows nested Run() calls to access the timeout queue
+            if (timeoutToExecute != null)
             {
-                lock (_timeoutsLockToken)
+                bool repeat = timeoutToExecute.Callback! ();
+                
+                if (repeat)
                 {
-                    _timeouts.Add (NudgeToUniqueKey (k), timeout);
+                    AddTimeout (timeoutToExecute.Span, timeoutToExecute);
                 }
             }
         }

+ 0 - 68
Terminal.Gui/Drawing/Color/AnsiColorNameResolver.cs

@@ -1,68 +0,0 @@
-using System.Collections.Immutable;
-using System.Diagnostics.CodeAnalysis;
-
-namespace Terminal.Gui.Drawing;
-
-/// <summary>
-/// Color name resolver for <see cref="ColorName16"/>.
-/// </summary>
-public class AnsiColorNameResolver : IColorNameResolver
-{
-    private static readonly ImmutableArray<string> _ansiColorNames = ImmutableArray.Create (Enum.GetNames<ColorName16> ());
-
-    /// <inheritdoc/>
-    public IEnumerable<string> GetColorNames ()
-    {
-        return _ansiColorNames;
-    }
-
-    /// <inheritdoc/>
-    public bool TryNameColor (Color color, [NotNullWhen (true)] out string? name)
-    {
-        if (Color.TryGetExactNamedColor16 (color, out ColorName16 colorName16))
-        {
-            name = Color16Name (colorName16);
-            return true;
-        }
-        name = null;
-        return false;
-    }
-
-    /// <inheritdoc/>
-    public bool TryParseColor (ReadOnlySpan<char> name, out Color color)
-    {
-        if (Enum.TryParse (name, ignoreCase: true, out ColorName16 colorName16) &&
-            // Any numerical value converts to undefined enum value.
-            Enum.IsDefined (colorName16))
-        {
-            color = new Color (colorName16);
-            return true;
-        }
-        color = default;
-        return false;
-    }
-
-    private static string Color16Name (ColorName16 color16)
-    {
-        return color16 switch
-        {
-            ColorName16.Black => nameof (ColorName16.Black),
-            ColorName16.Blue => nameof (ColorName16.Blue),
-            ColorName16.Green => nameof (ColorName16.Green),
-            ColorName16.Cyan => nameof (ColorName16.Cyan),
-            ColorName16.Red => nameof (ColorName16.Red),
-            ColorName16.Magenta => nameof (ColorName16.Magenta),
-            ColorName16.Yellow => nameof (ColorName16.Yellow),
-            ColorName16.Gray => nameof (ColorName16.Gray),
-            ColorName16.DarkGray => nameof (ColorName16.DarkGray),
-            ColorName16.BrightBlue => nameof (ColorName16.BrightBlue),
-            ColorName16.BrightGreen => nameof (ColorName16.BrightGreen),
-            ColorName16.BrightCyan => nameof (ColorName16.BrightCyan),
-            ColorName16.BrightRed => nameof (ColorName16.BrightRed),
-            ColorName16.BrightMagenta => nameof (ColorName16.BrightMagenta),
-            ColorName16.BrightYellow => nameof (ColorName16.BrightYellow),
-            ColorName16.White => nameof (ColorName16.White),
-            _ => throw new NotSupportedException ($"ColorName16 '{color16}' is not supported.")
-        };
-    }
-}

+ 34 - 50
Terminal.Gui/Drawing/Color/Color.cs

@@ -11,8 +11,28 @@ namespace Terminal.Gui.Drawing;
 
 /// <summary>
 ///     Represents a 24-bit color encoded in ARGB32 format.
-///     <para/>
+///     <para>
+///         The RGB components define the color identity (what color it is), while the alpha channel defines
+///         rendering intent (how transparent it should be when drawn).
+///     </para>
 /// </summary>
+/// <remarks>
+///     <para>
+///         When matching colors to standard color names (e.g., via <see cref="ColorStrings.GetColorName"/>),
+///         the alpha channel is ignored. This means colors with the same RGB values but different alpha values
+///         will resolve to the same color name. This design supports transparency features while maintaining
+///         semantic color identity.
+///     </para>
+///     <para>
+///         While Terminal.Gui does not currently support alpha blending during rendering, the alpha channel
+///         is used to indicate rendering intent:
+///         <list type="bullet">
+///             <item><description>Alpha = 0: Fully transparent (don't render)</description></item>
+///             <item><description>Alpha = 255: Fully opaque (normal rendering)</description></item>
+///             <item><description>Other values: Reserved for future alpha blending support</description></item>
+///         </list>
+///     </para>
+/// </remarks>
 /// <seealso cref="Attribute"/>
 /// <seealso cref="ColorExtensions"/>
 /// <seealso cref="ColorName16"/>
@@ -23,8 +43,16 @@ public readonly partial record struct Color : ISpanParsable<Color>, IUtf8SpanPar
 {
     /// <summary>The value of the alpha channel component</summary>
     /// <remarks>
-    ///     The alpha channel is not currently supported, so the value of the alpha channel bits will not affect
-    ///     rendering.
+    ///     <para>
+    ///         The alpha channel represents rendering intent (transparency) rather than color identity.
+    ///         Terminal.Gui does not currently perform alpha blending, but uses this value to determine
+    ///         whether to render the color at all (alpha = 0 means don't render).
+    ///     </para>
+    ///     <para>
+    ///         When matching colors to standard color names, the alpha channel is ignored. For example,
+    ///         <c>new Color(255, 0, 0, 255)</c> and <c>new Color(255, 0, 0, 128)</c> will both be
+    ///         identified as "Red".
+    ///     </para>
     /// </remarks>
     [JsonIgnore]
     [field: FieldOffset (3)]
@@ -32,8 +60,8 @@ public readonly partial record struct Color : ISpanParsable<Color>, IUtf8SpanPar
 
     /// <summary>The value of this <see cref="Color"/> as a <see langword="uint"/> in ARGB32 format.</summary>
     /// <remarks>
-    ///     The alpha channel is not currently supported, so the value of the alpha channel bits will not affect
-    ///     rendering.
+    ///     The alpha channel in the ARGB value represents rendering intent (transparency), not color identity.
+    ///     When matching to standard color names, only the RGB components are considered.
     /// </remarks>
     [JsonIgnore]
     [field: FieldOffset (0)]
@@ -134,8 +162,6 @@ public readonly partial record struct Color : ISpanParsable<Color>, IUtf8SpanPar
     /// <summary>Initializes a new instance of the <see cref="Color"/> with all channels set to 0.</summary>
     public Color () { Argb = 0u; }
 
-    // TODO: ColorName and AnsiColorCode are only needed when a driver is in Force16Color mode and we
-    // TODO: should be able to remove these from any non-Driver-specific usages.
     /// <summary>Gets or sets the 3-byte/6-character hexadecimal value for each of the legacy 16-color values.</summary>
     [ConfigurationProperty (Scope = typeof (SettingsScope), OmitClassName = true)]
     public static Dictionary<ColorName16, string> Colors16
@@ -203,31 +229,6 @@ public readonly partial record struct Color : ISpanParsable<Color>, IUtf8SpanPar
     [MethodImpl (MethodImplOptions.AggressiveInlining)]
     public bool IsClosestToNamedColor16 (in ColorName16 namedColor) { return GetClosestNamedColor16 () == namedColor; }
 
-    /// <summary>
-    ///     Determines if the closest named <see cref="Color"/> to <paramref name="color"/>/> is the provided
-    ///     <paramref name="namedColor"/>.
-    /// </summary>
-    /// <param name="color">
-    ///     The color to test against the <see cref="GetClosestNamedColor16(Color)"/> value in
-    ///     <paramref name="namedColor"/>.
-    /// </param>
-    /// <param name="namedColor">
-    ///     The <see cref="GetClosestNamedColor16(Color)"/> to check if this <see cref="Color"/> is closer
-    ///     to than any other configured named color.
-    /// </param>
-    /// <returns>
-    ///     <see langword="true"/> if the closest named color to <paramref name="color"/> is the provided value. <br/>
-    ///     <see langword="false"/> if any other named color is closer to <paramref name="color"/> than
-    ///     <paramref name="namedColor"/>.
-    /// </returns>
-    /// <remarks>
-    ///     If <paramref name="color"/> is equidistant from two named colors, the result of this method is not guaranteed
-    ///     to be determinate.
-    /// </remarks>
-    [Pure]
-    [MethodImpl (MethodImplOptions.AggressiveInlining)]
-    public static bool IsColorClosestToNamedColor16 (in Color color, in ColorName16 namedColor) { return color.IsClosestToNamedColor16 (in namedColor); }
-
     /// <summary>Gets the "closest" named color to this <see cref="Color"/> value.</summary>
     /// <param name="inputColor"></param>
     /// <remarks>
@@ -240,15 +241,6 @@ public readonly partial record struct Color : ISpanParsable<Color>, IUtf8SpanPar
         return ColorExtensions.ColorToName16Map!.MinBy (pair => CalculateColorDistance (inputColor, pair.Key)).Value;
     }
 
-    /// <summary>Converts the given color value to exact named color represented by <see cref="ColorName16"/>.</summary>
-    /// <param name="inputColor"></param>
-    /// <param name="colorName16">Successfully converted named color.</param>
-    /// <returns>True if conversion succeeded; otherwise false.</returns>
-    internal static bool TryGetExactNamedColor16 (Color inputColor, out ColorName16 colorName16)
-    {
-        return ColorExtensions.ColorToName16Map!.TryGetValue (inputColor, out colorName16);
-    }
-
     [SkipLocalsInit]
     private static float CalculateColorDistance (in Vector4 color1, in Vector4 color2) { return Vector4.Distance (color1, color2); }
 
@@ -297,16 +289,8 @@ public readonly partial record struct Color : ISpanParsable<Color>, IUtf8SpanPar
         HSL? hsl = ColorConverter.RgbToHsl (new (R, G, B));
 
         double lNorm = hsl.L / 255.0;
-        double newL;
 
-        if (lNorm < 0.5)
-        {
-            newL = Math.Min (1.0, lNorm + brightenAmount);
-        }
-        else
-        {
-            newL = Math.Max (0.0, lNorm - brightenAmount);
-        }
+        double newL = lNorm < 0.5 ? Math.Min (1.0, lNorm + brightenAmount) : Math.Max (0.0, lNorm - brightenAmount);
 
         if (Math.Abs (newL - lNorm) < 0.1)
         {

+ 6 - 5
Terminal.Gui/Drawing/Color/ColorModel.cs

@@ -1,23 +1,24 @@
+// ReSharper disable InconsistentNaming
+
 namespace Terminal.Gui.Drawing;
 
 /// <summary>
-/// Describes away of modelling color e.g. Hue
-/// Saturation Lightness.
+///     Describes a way of modelling color e.g. Hue, Saturation, and Lightness.
 /// </summary>
 public enum ColorModel
 {
     /// <summary>
-    /// Color modelled by storing Red, Green and Blue as (0-255) ints
+    ///     Color modelled by storing Red, Green and Blue as (0-255) ints
     /// </summary>
     RGB,
 
     /// <summary>
-    /// Color modelled by storing Hue (360 degrees), Saturation (100%) and Value (100%)
+    ///     Color modelled by storing Hue (360 degrees), Saturation (100%) and Value (100%)
     /// </summary>
     HSV,
 
     /// <summary>
-    /// Color modelled by storing Hue (360 degrees), Saturation (100%) and Lightness (100%)
+    ///     Color modelled by storing Hue (360 degrees), Saturation (100%) and Lightness (100%)
     /// </summary>
     HSL
 }

+ 3 - 3
Terminal.Gui/Drawing/Color/ColorQuantizer.cs

@@ -39,7 +39,7 @@ public class ColorQuantizer
     /// <param name="pixels"></param>
     public void BuildPalette (Color [,] pixels)
     {
-        List<Color> allColors = new ();
+        List<Color> allColors = [];
         int width = pixels.GetLength (0);
         int height = pixels.GetLength (1);
 
@@ -56,8 +56,8 @@ public class ColorQuantizer
     }
 
     /// <summary>
-    /// Returns the closest color in <see cref="Palette"/> that matches <paramref name="toTranslate"/>
-    /// based on the color comparison algorithm defined by <see cref="DistanceAlgorithm"/>
+    ///     Returns the closest color in <see cref="Palette"/> that matches <paramref name="toTranslate"/>
+    ///     based on the color comparison algorithm defined by <see cref="DistanceAlgorithm"/>
     /// </summary>
     /// <param name="toTranslate"></param>
     /// <returns></returns>

+ 6 - 53
Terminal.Gui/Drawing/Color/ColorStrings.cs

@@ -7,47 +7,16 @@ namespace Terminal.Gui.Drawing;
 /// </summary>
 public static class ColorStrings
 {
-    private static readonly AnsiColorNameResolver _ansi = new();
     private static readonly StandardColorsNameResolver _standard = new();
-    private static readonly MultiStandardColorNameResolver _multi = new();
 
     /// <summary>
-    ///     Gets the W3C+  standard string for <paramref name="color"/>.
-    /// </summary>
-    /// <param name="color">The color.</param>
-    /// <returns><see langword="null"/> if there is no standard color name for the specified color.</returns>
-    public static string? GetStandardColorName (Color color)
-    {
-        if (_standard.TryNameColor (color, out string? name))
-        {
-            return name;
-        }
-        return null;
-    }
-
-    /// <summary>
-    ///     Gets the ANSI 4-bit (16) color name for <paramref name="color"/>.
-    /// </summary>
-    /// <param name="color">The color.</param>
-    /// <returns><see langword="null"/> if there is no standard color name for the specified color.</returns>
-    // ReSharper disable once InconsistentNaming
-    public static string? GetANSIColor16Name (Color color)
-    {
-        if (_ansi.TryNameColor (color, out string? name))
-        {
-            return name;
-        }
-        return null;
-    }
-
-    /// <summary>
-    ///     Gets backwards compatible color name for <paramref name="color"/>.
+    ///     Gets the color name for <paramref name="color"/>.
     /// </summary>
     /// <param name="color">The color.</param>
     /// <returns>Standard color name for the specified color; otherwise <see langword="null"/>.</returns>
     public static string? GetColorName (Color color)
     {
-        if (_multi.TryNameColor (color, out string? name))
+        if (_standard.TryNameColor (color, out string? name))
         {
             return name;
         }
@@ -80,30 +49,14 @@ public static class ColorStrings
     }
 
     /// <summary>
-    ///     Parses <paramref name="name"/> and returns <paramref name="color"/> if name is a ANSI 4-bit standard named color.
-    /// </summary>
-    /// <param name="name">The name to parse.</param>
-    /// <param name="color">If successful, the color.</param>
-    /// <returns><see langword="true"/> if <paramref name="name"/> was parsed successfully.</returns>
-    public static bool TryParseColor16 (ReadOnlySpan<char> name, out Color color)
-    {
-        if (_ansi.TryParseColor (name, out color))
-        {
-            return true;
-        }
-        color = default;
-        return false;
-    }
-
-    /// <summary>
-    ///     Parses <paramref name="name"/> and returns <paramref name="color"/> if name is either ANSI 4-bit or W3C standard named color.
+    ///     Parses <paramref name="name"/> and returns <paramref name="color"/> if name is a W3C+ standard named color.
     /// </summary>
     /// <param name="name">The name to parse.</param>
     /// <param name="color">If successful, the color.</param>
     /// <returns><see langword="true"/> if <paramref name="name"/> was parsed successfully.</returns>
     public static bool TryParseNamedColor (ReadOnlySpan<char> name, out Color color)
     {
-        if (_multi.TryParseColor (name, out color))
+        if (_standard.TryParseColor (name, out color))
         {
             return true;
         }
@@ -113,7 +66,7 @@ public static class ColorStrings
             return true;
         }
 
-        color = default;
+        color = default (Color);
         return false;
     }
 
@@ -130,7 +83,7 @@ public static class ColorStrings
             }
         }
 
-        color = default;
+        color = default (Color);
         return false;
     }
 }

+ 0 - 83
Terminal.Gui/Drawing/Color/MultiStandardColorNameResolver.cs

@@ -1,83 +0,0 @@
-using System.Collections.Frozen;
-using System.Collections.Immutable;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-
-namespace Terminal.Gui.Drawing;
-
-/// <summary>
-/// Color name resolver prioritizing Standard (W3C+) colors with fallback to ANSI 4-bit (16) colors.
-/// </summary>
-public class MultiStandardColorNameResolver : IColorNameResolver
-{
-    private static readonly AnsiColorNameResolver _ansi = new ();
-    private static readonly StandardColorsNameResolver _standard = new ();
-
-    private static readonly ImmutableArray<string> _combinedColorNames;
-    private static readonly FrozenDictionary<string, Color> _nameToColorMap;
-    private static readonly FrozenDictionary<uint, string> _colorToNameMap;
-
-    static MultiStandardColorNameResolver ()
-    {
-        Dictionary<string, Color> nameToColor = new (StringComparer.OrdinalIgnoreCase);
-        Dictionary<uint, string> colorToName = new ();
-
-        foreach (string name in _standard.GetColorNames ())
-        {
-            if (_standard.TryParseColor (name, out Color color))
-            {
-                if (nameToColor.TryAdd (name, color))
-                {
-                    _ = colorToName.TryAdd (color.Argb, name);
-                }
-            }
-        }
-
-        foreach (string name in _ansi.GetColorNames ())
-        {
-            if (_ansi.TryParseColor (name, out Color color))
-            {
-                nameToColor.TryAdd (name, color);
-                colorToName.TryAdd (color.Argb, name);
-            }
-        }
-
-        _nameToColorMap = nameToColor.ToFrozenDictionary ();
-        _colorToNameMap = colorToName.ToFrozenDictionary ();
-        _combinedColorNames = nameToColor.Keys.Order ().ToImmutableArray ();
-    }
-
-    /// <inheritdoc/>
-    public IEnumerable<string> GetColorNames () => _combinedColorNames;
-
-    /// <inheritdoc/>
-    public bool TryParseColor (ReadOnlySpan<char> name, out Color color)
-    {
-        if (name.StartsWith ("#") || name.StartsWith ("0x", StringComparison.OrdinalIgnoreCase))
-        {
-            try
-            {
-                color = Color.Parse (name.ToString (), CultureInfo.InvariantCulture);
-                return true;
-            }
-            catch
-            {
-                color = default;
-                return false;
-            }
-        }
-
-        if (_ansi.TryParseColor (name, out color)) return true;
-        if (_standard.TryParseColor (name, out color)) return true;
-
-        color = default;
-        return false;
-    }
-
-
-    /// <inheritdoc/>
-    public bool TryNameColor (Color color, [NotNullWhen (true)] out string? name)
-    {
-        return _colorToNameMap.TryGetValue (color.Argb, out name);
-    }
-}

+ 60 - 1
Terminal.Gui/Drawing/Color/StandardColor.cs

@@ -1248,5 +1248,64 @@ public enum StandardColor
     ///         A bright yellowish-green color.
     ///     </para>
     /// </summary>
-    YellowGreen = 0x9ACD32
+    YellowGreen = 0x9ACD32,
+
+    // Legacy 16-color names for backwards compatibility
+    // These match the RGB values used in ColorName16 mapping
+
+    /// <summary>
+    ///     Bright Black RGB(118, 118, 118).
+    ///     <para>
+    ///         A bright black (dark gray) color from the legacy 16-color palette. This is the ColorName16.DarkGray color.
+    ///     </para>
+    /// </summary>
+    BrightBlack = 0x767676,
+
+    /// <summary>
+    ///     Bright Blue RGB(59, 120, 255).
+    ///     <para>
+    ///         A bright blue color from the legacy 16-color palette.
+    ///     </para>
+    /// </summary>
+    BrightBlue = 0x3B78FF,
+
+    /// <summary>
+    ///     Bright Cyan RGB(97, 214, 214).
+    ///     <para>
+    ///         A bright cyan color from the legacy 16-color palette.
+    ///     </para>
+    /// </summary>
+    BrightCyan = 0x61D6D6,
+
+    /// <summary>
+    ///     Bright Green RGB(22, 198, 12).
+    ///     <para>
+    ///         A bright green color from the legacy 16-color palette.
+    ///     </para>
+    /// </summary>
+    BrightGreen = 0x16C60C,
+
+    /// <summary>
+    ///     Bright Magenta RGB(180, 0, 158).
+    ///     <para>
+    ///         A bright magenta color from the legacy 16-color palette.
+    ///     </para>
+    /// </summary>
+    BrightMagenta = 0xB4009E,
+
+    /// <summary>
+    ///     Bright Red RGB(231, 72, 86).
+    ///     <para>
+    ///         A bright red color from the legacy 16-color palette.
+    ///     </para>
+    /// </summary>
+    BrightRed = 0xE74856,
+
+    /// <summary>
+    ///     Bright Yellow RGB(249, 241, 165).
+    ///     <para>
+    ///         A bright yellow color from the legacy 16-color palette.
+    ///     </para>
+    /// </summary>
+    BrightYellow = 0xF9F1A5
 }

+ 5 - 2
Terminal.Gui/Drawing/Color/StandardColors.cs

@@ -18,7 +18,7 @@ internal static class StandardColors
     {
         string [] standardNames = Enum.GetNames<StandardColor> ().Order ().ToArray ();
 
-        return ImmutableArray.Create (standardNames);
+        return [.. standardNames];
     }
 
     private static readonly Lazy<FrozenDictionary<uint, string>> _argbNameMap = new (
@@ -82,7 +82,10 @@ internal static class StandardColors
     /// <returns>True if conversion succeeded; otherwise false.</returns>
     public static bool TryNameColor (Color color, [NotNullWhen (true)] out string? name)
     {
-        if (_argbNameMap.Value.TryGetValue (color.Argb, out name))
+        // Ignore alpha channel when matching - alpha represents transparency, not color identity
+        uint opaqueArgb = color.Argb | 0xFF000000;
+
+        if (_argbNameMap.Value.TryGetValue (opaqueArgb, out name))
         {
             return true;
         }

+ 10 - 10
Terminal.Gui/ViewBase/Runnable/Runnable.cs

@@ -170,16 +170,6 @@ public class Runnable : View, IRunnable
     /// <inheritdoc/>
     public void RaiseIsModalChangedEvent (bool newIsModal)
     {
-        // CWP Phase 3: Post-notification (work already done by Application)
-        OnIsModalChanged (newIsModal);
-
-        EventArgs<bool> args = new (newIsModal);
-        IsModalChanged?.Invoke (this, args);
-
-        // Layout may need to change when modal state changes
-        SetNeedsLayout ();
-        SetNeedsDraw ();
-
         if (newIsModal)
         {
             // Set focus to self if becoming modal
@@ -194,6 +184,16 @@ public class Runnable : View, IRunnable
                 App?.Driver?.UpdateCursor ();
             }
         }
+
+        // CWP Phase 3: Post-notification (work already done by Application)
+        OnIsModalChanged (newIsModal);
+
+        EventArgs<bool> args = new (newIsModal);
+        IsModalChanged?.Invoke (this, args);
+
+        // Layout may need to change when modal state changes
+        SetNeedsLayout ();
+        SetNeedsDraw ();
     }
 
     /// <inheritdoc/>

+ 0 - 79
Terminal.Gui/Views/Autocomplete/Autocomplete.cd

@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ClassDiagram MajorVersion="1" MinorVersion="1">
-  <Class Name="Terminal.Gui.Views.AppendAutocomplete" Collapsed="true">
-    <Position X="0.5" Y="6.5" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AAAgAABAAQIAAAAAAAAAAAAABAAAIAQAgAEIAggAIAA=</HashCode>
-      <FileName>Core\Autocomplete\AppendAutocomplete.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.Views.AutocompleteBase" Collapsed="true">
-    <Position X="1.75" Y="5.25" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAQgAAAAAUAAIAAAAAIAAAAAAAEAIAQIgQAIQAAAMBA=</HashCode>
-      <FileName>Core\Autocomplete\AutocompleteBase.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Views.PopupAutocomplete" Collapsed="true">
-    <Position X="2.75" Y="6.5" Width="1.5" />
-    <NestedTypes>
-      <Class Name="Terminal.Gui.Views.PopupAutocomplete.Popup" Collapsed="true">
-        <TypeIdentifier>
-          <NewMemberFileName>Core\Autocomplete\PopupAutocomplete.cs</NewMemberFileName>
-        </TypeIdentifier>
-      </Class>
-    </NestedTypes>
-    <TypeIdentifier>
-      <HashCode>IAEhAAQAASBEQAAAAAIBAAgYAAAAIAwAwKAAQACBAAA=</HashCode>
-      <FileName>Core\Autocomplete\PopupAutocomplete.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.Views.SingleWordSuggestionGenerator" BaseTypeListCollapsed="true">
-    <Position X="6.25" Y="3.5" Width="3" />
-    <TypeIdentifier>
-      <HashCode>CEAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAIAA=</HashCode>
-      <FileName>Core\Autocomplete\SingleWordSuggestionGenerator.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Views.Suggestion">
-    <Position X="4.5" Y="2.5" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAEAAAAAABAAAAAAAAAAAAAAAAAAAAAE=</HashCode>
-      <FileName>Core\Autocomplete\Suggestion.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.Views.TextFieldAutocomplete" Collapsed="true">
-    <Position X="1.5" Y="7.5" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAgAAAAAAAAAA=</HashCode>
-      <FileName>Views\TextField.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.Views.TextViewAutocomplete" Collapsed="true">
-    <Position X="3.75" Y="7.5" Width="2.25" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAgAAAAAAAAAA=</HashCode>
-      <FileName>Views\TextView.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Interface Name="Terminal.Gui.Views.IAutocomplete">
-    <Position X="1.75" Y="0.5" Width="2.5" />
-    <TypeIdentifier>
-      <HashCode>AAQgAAAAAUAAIAAAAAAAAAAAAAEAIAQIgQAIQAAAMBA=</HashCode>
-      <FileName>Core\Autocomplete\IAutocomplete.cs</FileName>
-    </TypeIdentifier>
-    <ShowAsAssociation>
-      <Property Name="SuggestionGenerator" />
-    </ShowAsAssociation>
-  </Interface>
-  <Interface Name="Terminal.Gui.Views.ISuggestionGenerator">
-    <Position X="6.25" Y="1.75" Width="2.25" />
-    <TypeIdentifier>
-      <HashCode>AEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAA=</HashCode>
-      <FileName>Core\Autocomplete\ISuggestionGenerator.cs</FileName>
-    </TypeIdentifier>
-  </Interface>
-  <Font Name="Segoe UI" Size="9" />
-</ClassDiagram>

+ 0 - 124
Terminal.Gui/Views/CollectionNavigation/CollectionNavigation.cd

@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ClassDiagram MajorVersion="1" MinorVersion="1">
-  <Comment CommentText="Views that use the CollectionNavigation system">
-    <Position X="0.5" Y="0.5" Height="0.458" Width="1.856" />
-  </Comment>
-  <Comment CommentText="Specialized navigators for each collection type (e.g. list, tree etc)">
-    <Position X="4.646" Y="0.5" Height="0.5" Width="3.169" />
-  </Comment>
-  <Comment CommentText="Shared matching component (users should provide alternative implementations of this class if they want to modify collection navigation behaviour)">
-    <Position X="9.448" Y="0.5" Height="0.708" Width="3.169" />
-  </Comment>
-  <Class Name="Terminal.Gui.Views.CollectionNavigatorBase" Collapsed="true">
-    <Position X="6.25" Y="1.5" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AAgEAAAAAAAQAAAIAAEAAgAAAAAABAAEAAAAACwAAAA=</HashCode>
-      <FileName>Views\CollectionNavigation\CollectionNavigatorBase.cs</FileName>
-    </TypeIdentifier>
-    <ShowAsAssociation>
-      <Property Name="Matcher" />
-    </ShowAsAssociation>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Views.CollectionNavigator" Collapsed="true">
-    <Position X="4.5" Y="3.5" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAQAAAAAAAAgAAAAAAAAAEAAAAAAAAAAA=</HashCode>
-      <FileName>Views\CollectionNavigation\CollectionNavigator.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Views.DefaultCollectionNavigatorMatcher">
-    <Position X="9.5" Y="2.5" Width="2.75" />
-    <TypeIdentifier>
-      <HashCode>AAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAQA=</HashCode>
-      <FileName>Views\CollectionNavigation\DefaultCollectionNavigatorMatcher.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Views.TableCollectionNavigator" Collapsed="true">
-    <Position X="4.75" Y="6.5" Width="2.25" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAEAAAAIAAAAAA=</HashCode>
-      <FileName>Views\CollectionNavigation\TableCollectionNavigator.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.Views.ListView" Collapsed="true">
-    <Position X="0.5" Y="4.25" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAE+ASAkEnAAABAAKGAggYAZJAIAABEAcBAaAwAQIAA=</HashCode>
-      <FileName>Views\ListView.cs</FileName>
-    </TypeIdentifier>
-    <ShowAsAssociation>
-      <Property Name="KeystrokeNavigator" />
-    </ShowAsAssociation>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Views.TableView" Collapsed="true" BaseTypeListCollapsed="true">
-    <Position X="0.5" Y="6.5" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>QwUeAxwgICIAcABIABeR0oBAkhoFGGOBDABgAN3oPEI=</HashCode>
-      <FileName>Views\TableView\TableView.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Views.TreeView" Collapsed="true">
-    <Position X="0.5" Y="3" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAA=</HashCode>
-      <FileName>Views\TreeView\TreeView.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Views.TreeView&lt;T&gt;" Collapsed="true">
-    <Position X="0.5" Y="2" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>UwAGySBgBSBGMAQgIiCaBDUItJIBSAWwRMQOSgQCwJI=</HashCode>
-      <FileName>Views\TreeView\TreeView.cs</FileName>
-    </TypeIdentifier>
-    <ShowAsAssociation>
-      <Property Name="KeystrokeNavigator" />
-    </ShowAsAssociation>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Views.FileDialog" Collapsed="true">
-    <Position X="0.5" Y="5.5" Width="1.75" />
-    <Compartments>
-      <Compartment Name="Nested Types" Collapsed="false" />
-    </Compartments>
-    <TypeIdentifier>
-      <HashCode>iIY4LQFUHDKVIHIESBoigQcFT6GxhBDABGJItBQAwAQ=</HashCode>
-      <FileName>Views\FileDialogs\FileDialog.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Views.FileDialogCollectionNavigator" Collapsed="true">
-    <Position X="4.75" Y="5.5" Width="2.25" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAEAAAAAAAAAAA=</HashCode>
-      <FileName>Views\FileDialogs\FileDialogCollectionNavigator.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Interface Name="Terminal.Gui.Views.ICollectionNavigatorMatcher" Collapsed="true">
-    <Position X="9.5" Y="1.5" Width="2.75" />
-    <TypeIdentifier>
-      <HashCode>AAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAA=</HashCode>
-      <FileName>Views\CollectionNavigation\ICollectionNavigatorMatcher.cs</FileName>
-    </TypeIdentifier>
-  </Interface>
-  <Interface Name="Terminal.Gui.Views.IListCollectionNavigator" Collapsed="true">
-    <Position X="3.75" Y="2.25" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
-      <FileName>Views\CollectionNavigation\IListCollectionNavigator.cs</FileName>
-    </TypeIdentifier>
-  </Interface>
-  <Interface Name="Terminal.Gui.Views.ICollectionNavigator" Collapsed="true">
-    <Position X="3.75" Y="1.5" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AAgAAAAAAAAAAAAIAAAAAAAAAAAABAAAAAAAACgAAAA=</HashCode>
-      <FileName>Views\CollectionNavigation\ICollectionNavigator.cs</FileName>
-    </TypeIdentifier>
-  </Interface>
-  <Font Name="Segoe UI" Size="9" />
-</ClassDiagram>

+ 0 - 2
Terminal.Gui/Views/Color/BBar.cs

@@ -1,5 +1,3 @@
-
-
 using ColorHelper;
 
 namespace Terminal.Gui.Views;

+ 1 - 4
Terminal.Gui/Views/Color/ColorBar.cs

@@ -1,5 +1,3 @@
-
-
 using ColorHelper;
 
 namespace Terminal.Gui.Views;
@@ -15,7 +13,7 @@ internal abstract class ColorBar : View, IColorBar
     /// </summary>
     protected ColorBar ()
     {
-        Height = Dim.Auto(minimumContentDim: 1);
+        Height = Dim.Auto (minimumContentDim: 1);
         Width = Dim.Fill ();
         CanFocus = true;
 
@@ -135,7 +133,6 @@ internal abstract class ColorBar : View, IColorBar
 
             mouseEvent.Handled = true;
             SetFocus ();
-
         }
 
         return mouseEvent.Handled;

+ 28 - 45
Terminal.Gui/Views/Color/ColorModelStrategy.cs

@@ -1,5 +1,3 @@
-
-
 using ColorHelper;
 using ColorConverter = ColorHelper.ColorConverter;
 
@@ -7,39 +5,23 @@ namespace Terminal.Gui.Views;
 
 internal class ColorModelStrategy
 {
-    public IEnumerable<ColorBar> CreateBars (ColorModel model)
-    {
-        switch (model)
+    public IEnumerable<ColorBar> CreateBars (ColorModel model) =>
+        model switch
         {
-            case ColorModel.RGB:
-                return CreateRgbBars ();
-            case ColorModel.HSV:
-                return CreateHsvBars ();
-            case ColorModel.HSL:
-                return CreateHslBars ();
-            default:
-                throw new ArgumentOutOfRangeException (nameof (model), model, null);
-        }
-    }
+            ColorModel.RGB => CreateRgbBars (),
+            ColorModel.HSV => CreateHsvBars (),
+            ColorModel.HSL => CreateHslBars (),
+            _ => throw new ArgumentOutOfRangeException (nameof (model), model, null)
+        };
 
-    public Color GetColorFromBars (IList<IColorBar> bars, ColorModel model)
-    {
-        switch (model)
+    public Color GetColorFromBars (IList<IColorBar> bars, ColorModel model) =>
+        model switch
         {
-            case ColorModel.RGB:
-                return ToColor (new ((byte)bars [0].Value, (byte)bars [1].Value, (byte)bars [2].Value));
-            case ColorModel.HSV:
-                return ToColor (
-                                ColorConverter.HsvToRgb (new (bars [0].Value, (byte)bars [1].Value, (byte)bars [2].Value))
-                               );
-            case ColorModel.HSL:
-                return ToColor (
-                                ColorConverter.HslToRgb (new (bars [0].Value, (byte)bars [1].Value, (byte)bars [2].Value))
-                               );
-            default:
-                throw new ArgumentOutOfRangeException (nameof (model), model, null);
-        }
-    }
+            ColorModel.RGB => ToColor (new ((byte)bars [0].Value, (byte)bars [1].Value, (byte)bars [2].Value)),
+            ColorModel.HSV => ToColor (ColorConverter.HsvToRgb (new (bars [0].Value, (byte)bars [1].Value, (byte)bars [2].Value))),
+            ColorModel.HSL => ToColor (ColorConverter.HslToRgb (new (bars [0].Value, (byte)bars [1].Value, (byte)bars [2].Value))),
+            _ => throw new ArgumentOutOfRangeException (nameof (model), model, null)
+        };
 
     public void SetBarsToColor (IList<IColorBar> bars, Color newValue, ColorModel model)
     {
@@ -47,6 +29,7 @@ internal class ColorModelStrategy
         {
             return;
         }
+
         switch (model)
         {
             case ColorModel.RGB:
@@ -75,21 +58,21 @@ internal class ColorModelStrategy
         }
     }
 
-    private IEnumerable<ColorBar> CreateHslBars ()
+    private static IEnumerable<ColorBar> CreateHslBars ()
     {
-        var h = new HueBar
+        HueBar h = new ()
         {
             Text = "H:"
         };
 
         yield return h;
 
-        var s = new SaturationBar
+        SaturationBar s = new ()
         {
             Text = "S:"
         };
 
-        var l = new LightnessBar
+        LightnessBar l = new ()
         {
             Text = "L:"
         };
@@ -104,21 +87,21 @@ internal class ColorModelStrategy
         yield return l;
     }
 
-    private IEnumerable<ColorBar> CreateHsvBars ()
+    private static IEnumerable<ColorBar> CreateHsvBars ()
     {
-        var h = new HueBar
+        HueBar h = new ()
         {
             Text = "H:"
         };
 
         yield return h;
 
-        var s = new SaturationBar
+        SaturationBar s = new ()
         {
             Text = "S:"
         };
 
-        var v = new ValueBar
+        ValueBar v = new ()
         {
             Text = "V:"
         };
@@ -133,19 +116,19 @@ internal class ColorModelStrategy
         yield return v;
     }
 
-    private IEnumerable<ColorBar> CreateRgbBars ()
+    private static IEnumerable<ColorBar> CreateRgbBars ()
     {
-        var r = new RBar
+        RBar r = new ()
         {
             Text = "R:"
         };
 
-        var g = new GBar
+        GBar g = new ()
         {
             Text = "G:"
         };
 
-        var b = new BBar
+        BBar b = new ()
         {
             Text = "B:"
         };
@@ -163,5 +146,5 @@ internal class ColorModelStrategy
         yield return b;
     }
 
-    private Color ToColor (RGB rgb) { return new (rgb.R, rgb.G, rgb.B); }
+    private static Color ToColor (RGB rgb) { return new (rgb.R, rgb.G, rgb.B); }
 }

+ 0 - 3
Terminal.Gui/Views/Color/ColorPicker.Style.cs

@@ -1,6 +1,3 @@
-
-
-
 namespace Terminal.Gui.Views;
 
 /// <summary>

+ 0 - 2
Terminal.Gui/Views/Color/GBar.cs

@@ -1,5 +1,3 @@
-
-
 using ColorHelper;
 
 namespace Terminal.Gui.Views;

+ 1 - 2
Terminal.Gui/Views/Color/IColorBar.cs

@@ -1,5 +1,4 @@
-#nullable disable
-namespace Terminal.Gui.Views;
+namespace Terminal.Gui.Views;
 
 internal interface IColorBar
 {

+ 0 - 2
Terminal.Gui/Views/Color/LightnessBar.cs

@@ -1,5 +1,3 @@
-
-
 using ColorHelper;
 using ColorConverter = ColorHelper.ColorConverter;
 

+ 0 - 2
Terminal.Gui/Views/Color/RBar.cs

@@ -1,5 +1,3 @@
-
-
 using ColorHelper;
 
 namespace Terminal.Gui.Views;

+ 0 - 2
Terminal.Gui/Views/Color/SaturationBar.cs

@@ -1,5 +1,3 @@
-
-
 using ColorHelper;
 using ColorConverter = ColorHelper.ColorConverter;
 

+ 0 - 168
Terminal.Gui/Views/FileDialogs/FileDialog.cd

@@ -1,168 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ClassDiagram MajorVersion="1" MinorVersion="1">
-  <Class Name="Terminal.Gui.FileServices.DefaultSearchMatcher" Collapsed="true" BaseTypeListCollapsed="true">
-    <Position X="9.25" Y="6" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AAACAAAAAAgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
-      <FileName>FileServices\DefaultSearchMatcher.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.FileServices.FileSystemInfoStats">
-    <Position X="14" Y="0.5" Width="2.5" />
-    <TypeIdentifier>
-      <HashCode>ABAIQAIIIAAAAAACQAAAAIQAAAQAAIAAAQAAAAAIAAI=</HashCode>
-      <FileName>FileServices\FileSystemInfoStats.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.Views.FileDialog">
-    <Position X="0.5" Y="0.5" Width="2.75" />
-    <Compartments>
-      <Compartment Name="Fields" Collapsed="true" />
-      <Compartment Name="Methods" Collapsed="true" />
-      <Compartment Name="Nested Types" Collapsed="false" />
-    </Compartments>
-    <NestedTypes>
-      <Class Name="Terminal.Gui.Views.FileDialog.SearchState" Collapsed="true">
-        <TypeIdentifier>
-          <NewMemberFileName>Views\FileDialogs\FileDialog.cs</NewMemberFileName>
-        </TypeIdentifier>
-      </Class>
-    </NestedTypes>
-    <TypeIdentifier>
-      <HashCode>iIY4LQFUHDKVIHIESBoigQcFT6GxhBDABGJItBQAwAQ=</HashCode>
-      <FileName>Views\FileDialogs\FileDialog.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Views.FileDialogStyle">
-    <Position X="3.5" Y="0.5" Width="2.75" />
-    <TypeIdentifier>
-      <HashCode>GgBAAAFHAAAAuAAAAAAAEAQQBYAAKREAAAAYQCCAAAA=</HashCode>
-      <FileName>Views\FileDialogs\FileDialogStyle.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.Views.FilesSelectedEventArgs">
-    <Position X="6.5" Y="0.5" Width="2" />
-    <Compartments>
-      <Compartment Name="Methods" Collapsed="true" />
-    </Compartments>
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAA=</HashCode>
-      <FileName>Views\FileDialogs\FilesSelectedEventArgs.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.Views.FileDialogHistory">
-    <Position X="9.25" Y="0.5" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AQABAgEAAAAAAAAAIACAAAAAAAAAAQAAAAAAAAAADAI=</HashCode>
-      <FileName>Views\FileDialogs\FileDialogHistory.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.Views.FileDialogState">
-    <Position X="11.5" Y="0.5" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AABAABAAAAAAAAIAAAAEQAAAAAAAQAAAAgAAAAAAAAI=</HashCode>
-      <FileName>Views\FileDialogs\FileDialogState.cs</FileName>
-    </TypeIdentifier>
-    <ShowAsCollectionAssociation>
-      <Property Name="Children" />
-    </ShowAsCollectionAssociation>
-  </Class>
-  <Class Name="Terminal.Gui.Views.AllowedType" BaseTypeListCollapsed="true">
-    <Position X="13.25" Y="5.75" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAgAAAEAAAAAAAAAAAAAAAAAAgAAAAABAA=</HashCode>
-      <FileName>Views\FileDialogs\AllowedType.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Views.AllowedTypeAny" BaseTypeListCollapsed="true">
-    <Position X="11.75" Y="5.75" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAABAA=</HashCode>
-      <FileName>Views\FileDialogs\AllowedType.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Text.NerdFonts">
-    <Position X="9.25" Y="6.75" Width="2" />
-    <Compartments>
-      <Compartment Name="Fields" Collapsed="true" />
-    </Compartments>
-    <TypeIdentifier>
-      <HashCode>AIACAAABQAAAAAAAAAAACAAAIACAAAAAAAIAAAAAAAA=</HashCode>
-      <FileName>Text\NerdFonts.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.FileServices.FileSystemTreeBuilder" BaseTypeListCollapsed="true">
-    <Position X="0.5" Y="6.75" Width="1.75" />
-    <TypeIdentifier>
-      <HashCode>EAAAAAAAAAAAAAAAAAAABAAwAAAAQAAAAABAAAAACAA=</HashCode>
-      <FileName>FileServices\FileSystemTreeBuilder.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.Views.DefaultFileOperations" BaseTypeListCollapsed="true">
-    <Position X="7" Y="6" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAACAAAAAAACAAAAEAAAAAAAAAAAAAgAA=</HashCode>
-      <FileName>Views\FileDialogs\DefaultFileOperations.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="Terminal.Gui.FileServices.FileSystemColorProvider" Collapsed="true">
-    <Position X="7" Y="8.5" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AgAAAAAAAEAAAAAAAAAAAAEAAAAAAACAAAAAAAAAAAA=</HashCode>
-      <FileName>FileServices\FileSystemColorProvider.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.FileServices.FileSystemIconProvider" Collapsed="true">
-    <Position X="7" Y="7.75" Width="2" />
-    <TypeIdentifier>
-      <HashCode>ABAAAAAAAACAQAAAAAAAAEAgAAAAAQAAAAAAAAAAAiA=</HashCode>
-      <FileName>FileServices\FileSystemIconProvider.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="Terminal.Gui.Views.FileDialogTableSource">
-    <Position X="2.5" Y="8" Width="2.5" />
-    <Compartments>
-      <Compartment Name="Fields" Collapsed="true" />
-    </Compartments>
-    <TypeIdentifier>
-      <HashCode>AQAAAAAAIAACAEAACAAAAAACAAAEAAAEAAAAgAgBBAA=</HashCode>
-      <FileName>Views\FileDialogs\FileDialogTableSource.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Interface Name="Terminal.Gui.FileServices.IFileOperations">
-    <Position X="7" Y="4.25" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAACAAAAAAAAAAAAEAAAAAAAAAAAAAgAA=</HashCode>
-      <FileName>FileServices\IFileOperations.cs</FileName>
-    </TypeIdentifier>
-  </Interface>
-  <Interface Name="Terminal.Gui.FileServices.ISearchMatcher">
-    <Position X="9.25" Y="4.25" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAACAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
-      <FileName>FileServices\ISearchMatcher.cs</FileName>
-    </TypeIdentifier>
-  </Interface>
-  <Interface Name="Terminal.Gui.Views.IAllowedType" Collapsed="true">
-    <Position X="12" Y="4.25" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAA=</HashCode>
-      <FileName>Views\FileDialogs\AllowedType.cs</FileName>
-    </TypeIdentifier>
-  </Interface>
-  <Enum Name="Terminal.Gui.Views.OpenMode">
-    <Position X="7.5" Y="2.5" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAABAAAAAAACAAAAAAAAAAAAAEAAAAAAAAAAAAAAA=</HashCode>
-      <FileName>Views\FileDialogs\OpenMode.cs</FileName>
-    </TypeIdentifier>
-  </Enum>
-  <Font Name="Segoe UI" Size="9" />
-</ClassDiagram>

+ 1 - 1
Terminal.Gui/Views/MessageBox.cs

@@ -18,7 +18,7 @@ namespace Terminal.Gui.Views;
 ///         <b>Important:</b> All MessageBox methods require an <see cref="IApplication"/> instance to be passed.
 ///         This enables proper modal dialog management and respects the application's lifecycle. Pass your
 ///         application instance (from <see cref="Application.Create()"/>) or use the legacy
-///         <see cref="ApplicationImpl.Instance"/> if using the static Application pattern.
+///         <see cref="Application.Instance"/> if using the static Application pattern.
 ///     </para>
 ///     <para>
 ///         Example using instance-based pattern:

+ 1 - 1
Terminal.Gui/Views/Shortcut.cs

@@ -634,7 +634,7 @@ public class Shortcut : View, IOrientation, IDesignable
         get => _bindKeyToApplication;
         set
         {
-            App ??= SuperView?.App ?? ApplicationImpl.Instance; // HACK: Remove once legacy static Application is gone
+            App ??= SuperView?.App ?? Application.Instance; // HACK: Remove once legacy static Application is gone
             Debug.Assert (App is { });
 
             if (value == _bindKeyToApplication)

+ 1 - 0
Terminal.sln.DotSettings

@@ -424,6 +424,7 @@
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=ogonek/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=Quattro/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=Roslynator/@EntryIndexedValue">True</s:Boolean>
+	<s:Boolean x:Key="/Default/UserDictionary/Words/=RRGGBB/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=runnables/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=Toplevel/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=Runnables/@EntryIndexedValue">True</s:Boolean>

+ 63 - 41
Tests/StressTests/ApplicationStressTests.cs

@@ -1,41 +1,44 @@
+using System.Diagnostics;
 using Xunit.Abstractions;
 
+// ReSharper disable AccessToDisposedClosure
+
 namespace StressTests;
 
 public class ApplicationStressTests
 {
-    public ApplicationStressTests (ITestOutputHelper output)
-    {
-    }
+    private const int NUM_INCREMENTS = 500;
+
+    private const int NUM_PASSES = 50;
+    private const int POLL_MS_DEBUGGER = 500;
+    private const int POLL_MS_NORMAL = 100;
 
     private static volatile int _tbCounter;
 #pragma warning disable IDE1006 // Naming Styles
     private static readonly ManualResetEventSlim _wakeUp = new (false);
 #pragma warning restore IDE1006 // Naming Styles
 
-    private const int NUM_PASSES = 50;
-    private const int NUM_INCREMENTS = 500;
-    private const int POLL_MS = 100;
 
     /// <summary>
-    /// Stress test for Application.Invoke to verify that invocations from background threads
-    /// are not lost or delayed indefinitely. Tests 25,000 concurrent invocations (50 passes × 500 increments).
+    ///     Stress test for Application.Invoke to verify that invocations from background threads
+    ///     are not lost or delayed indefinitely. Tests 25,000 concurrent invocations (50 passes × 500 increments).
     /// </summary>
     /// <remarks>
-    /// <para>
-    /// This test automatically adapts its timeout when running under a debugger (500ms vs 100ms)
-    /// to account for slower iteration times caused by debugger overhead.
-    /// </para>
-    /// <para>
-    /// See InvokeLeakTest_Analysis.md for technical details about the timing improvements made
-    /// to TimedEvents (Stopwatch-based timing) and Application.Invoke (MainLoop wakeup).
-    /// </para>
+    ///     <para>
+    ///         This test automatically adapts its timeout when running under a debugger (500ms vs 100ms)
+    ///         to account for slower iteration times caused by debugger overhead.
+    ///     </para>
+    ///     <para>
+    ///         See InvokeLeakTest_Analysis.md for technical details about the timing improvements made
+    ///         to TimedEvents (Stopwatch-based timing) and Application.Invoke (MainLoop wakeup).
+    ///     </para>
     /// </remarks>
     [Fact]
     public async Task InvokeLeakTest ()
     {
+        IApplication app = Application.Create ();
+        app.Init ("fake");
 
-        Application.Init (driverName: "fake");
         Random r = new ();
         TextField tf = new ();
         var top = new Window ();
@@ -43,20 +46,21 @@ public class ApplicationStressTests
 
         _tbCounter = 0;
 
-        Task task = Task.Run (() => RunTest (r, tf, NUM_PASSES, NUM_INCREMENTS, POLL_MS));
+        int pollMs = Debugger.IsAttached ? POLL_MS_DEBUGGER : POLL_MS_NORMAL;
+        Task task = Task.Run (() => RunTest (app, r, tf, NUM_PASSES, NUM_INCREMENTS, pollMs));
 
         // blocks here until the RequestStop is processed at the end of the test
-        Application.Run (top);
+        app.Run (top);
 
         await task; // Propagate exception if any occurred
 
         Assert.Equal (NUM_INCREMENTS * NUM_PASSES, _tbCounter);
         top.Dispose ();
-        Application.Shutdown ();
+        app.Dispose ();
 
         return;
 
-        static void RunTest (Random r, TextField tf, int numPasses, int numIncrements, int pollMs)
+        void RunTest (IApplication application, Random random, TextField textField, int numPasses, int numIncrements, int pollMsValue)
         {
             for (var j = 0; j < numPasses; j++)
             {
@@ -64,52 +68,70 @@ public class ApplicationStressTests
 
                 for (var i = 0; i < numIncrements; i++)
                 {
-                    Launch (r, tf, (j + 1) * numIncrements);
+                    Launch (application, random, textField, (j + 1) * numIncrements);
                 }
 
+                int maxWaitMs = pollMsValue * 50; // Maximum total wait time (5s normal, 25s debugger)
+                var elapsedMs = 0;
+
                 while (_tbCounter != (j + 1) * numIncrements) // Wait for tbCounter to reach expected value
                 {
                     int tbNow = _tbCounter;
 
                     // Wait for Application.TopRunnable to be running to ensure timed events can be processed
-                    while (Application.TopRunnableView is null || Application.TopRunnableView is IRunnable { IsRunning: false })
+                    var topRunnableWaitMs = 0;
+
+                    while (application.TopRunnableView is null or IRunnable { IsRunning: false })
                     {
                         Thread.Sleep (1);
+                        topRunnableWaitMs++;
+
+                        if (topRunnableWaitMs > maxWaitMs)
+                        {
+                            application.Invoke (application.Dispose);
+
+                            throw new TimeoutException (
+                                                        $"Timeout: TopRunnableView never started running on pass {j + 1}"
+                                                       );
+                        }
                     }
 
-                    _wakeUp.Wait (pollMs);
+                    _wakeUp.Wait (pollMsValue);
+                    elapsedMs += pollMsValue;
 
                     if (_tbCounter != tbNow)
                     {
+                        elapsedMs = 0; // Reset elapsed time on progress
+
                         continue;
                     }
 
-                    // No change after wait: Idle handlers added via Application.Invoke have gone missing
-                    Application.Invoke (() => Application.RequestStop ());
-
-                    throw new TimeoutException (
-                                                $"Timeout: Increment lost. _tbCounter ({_tbCounter}) didn't "
-                                                + $"change after waiting {pollMs} ms. Failed to reach {(j + 1) * numIncrements} on pass {j + 1}"
-                                               );
+                    if (elapsedMs > maxWaitMs)
+                    {
+                        // No change after maximum wait: Idle handlers added via Application.Invoke have gone missing
+                        application.Invoke (application.Dispose);
+
+                        throw new TimeoutException (
+                                                    $"Timeout: Increment lost. _tbCounter ({_tbCounter}) didn't "
+                                                    + $"change after waiting {maxWaitMs} ms (pollMs={pollMsValue}). "
+                                                    + $"Failed to reach {(j + 1) * numIncrements} on pass {j + 1}"
+                                                   );
+                    }
                 }
-
-                ;
             }
 
-            Application.Invoke (() => Application.RequestStop ());
+            application.Invoke (application.Dispose);
         }
 
-        static void Launch (Random r, TextField tf, int target)
+        static void Launch (IApplication application, Random random, TextField textField, int target)
         {
-            Task.Run (
-                      () =>
+            Task.Run (() =>
                       {
-                          Thread.Sleep (r.Next (2, 4));
+                          Thread.Sleep (random.Next (2, 4));
 
-                          Application.Invoke (
-                                              () =>
+                          application.Invoke (() =>
                                               {
-                                                  tf.Text = $"index{r.Next ()}";
+                                                  textField.Text = $"index{random.Next ()}";
                                                   Interlocked.Increment (ref _tbCounter);
 
                                                   if (target == _tbCounter)

+ 0 - 89
Tests/TerminalGuiFluentTesting/ClassDiagram1.cd

@@ -1,89 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ClassDiagram MajorVersion="1" MinorVersion="1">
-  <Class Name="TerminalGuiFluentTesting.With" Collapsed="true">
-    <Position X="0.5" Y="1.5" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAIAAAAAA=</HashCode>
-      <FileName>With.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="TerminalGuiFluentTesting.FakeInput&lt;T&gt;" Collapsed="true">
-    <Position X="7" Y="1.5" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AQAAAAAAACAAAQEAAAAgAAAAAAAAAAAAAAAAAAAAAAI=</HashCode>
-      <FileName>FakeInput.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="TerminalGuiFluentTesting.FakeNetInput" Collapsed="true">
-    <Position X="8.25" Y="2.75" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
-      <FileName>FakeNetInput.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="TerminalGuiFluentTesting.FakeWindowsInput" Collapsed="true">
-    <Position X="6" Y="2.75" Width="1.75" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
-      <FileName>FakeWindowsInput.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="TerminalGuiFluentTesting.FakeOutput" Collapsed="true" BaseTypeListCollapsed="true">
-    <Position X="5.5" Y="0.5" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAgCAAgAAAAAAAAAAAAAAAQAAAMAAAAAEAAAA=</HashCode>
-      <FileName>FakeOutput.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="TerminalGuiFluentTesting.GuiTestContext" BaseTypeListCollapsed="true">
-    <Position X="2.25" Y="0.5" Width="2.25" />
-    <Compartments>
-      <Compartment Name="Fields" Collapsed="true" />
-    </Compartments>
-    <TypeIdentifier>
-      <HashCode>ABJAAAIAACBACRAAg4IAAAAgAJIEgQQAKACIBACAIgI=</HashCode>
-      <FileName>GuiTestContext.cs</FileName>
-    </TypeIdentifier>
-    <ShowAsAssociation>
-      <Field Name="_output" />
-      <Field Name="_winInput" />
-      <Field Name="_netInput" />
-    </ShowAsAssociation>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="TerminalGuiFluentTesting.TextWriterLoggerProvider" Collapsed="true">
-    <Position X="10" Y="2.75" Width="2" />
-    <TypeIdentifier>
-      <HashCode>AAAAAIAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
-      <FileName>TextWriterLoggerProvider.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="TerminalGuiFluentTesting.TextWriterLogger" Collapsed="true">
-    <Position X="10" Y="1.75" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAEAAAAAAAgAAAAAAAAIAAAAAAA=</HashCode>
-      <FileName>TextWriterLogger.cs</FileName>
-    </TypeIdentifier>
-    <Lollipop Position="0.2" />
-  </Class>
-  <Class Name="TerminalGuiFluentTesting.NetSequences">
-    <Position X="11" Y="4.5" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAACACAAAAAAgI=</HashCode>
-      <FileName>NetSequences.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Enum Name="TerminalGuiFluentTesting.V2TestDriver">
-    <Position X="9.25" Y="4.5" Width="1.5" />
-    <TypeIdentifier>
-      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAACAAA=</HashCode>
-      <FileName>V2TestDriver.cs</FileName>
-    </TypeIdentifier>
-  </Enum>
-  <Font Name="Segoe UI" Size="9" />
-</ClassDiagram>

+ 2 - 3
Tests/UnitTestsParallelizable/Application/ApplicationImplTests.cs

@@ -380,11 +380,10 @@ public class ApplicationImplTests
         if (app.TopRunnableView != null)
         {
             app.RequestStop ();
-
-            return true;
         }
 
-        return true;
+        // Return false so the timer does not repeat
+        return false;
     }
 
     [Fact]

+ 0 - 40
Tests/UnitTestsParallelizable/Application/ApplicationTests.cs

@@ -11,42 +11,6 @@ public class ApplicationTests (ITestOutputHelper output)
 {
     private readonly ITestOutputHelper _output = output;
 
-    [Fact]
-    public void AddTimeout_Fires ()
-    {
-        IApplication app = Application.Create ();
-        app.Init ("fake");
-
-        uint timeoutTime = 100;
-        var timeoutFired = false;
-
-        // Setup a timeout that will fire
-        app.AddTimeout (
-                        TimeSpan.FromMilliseconds (timeoutTime),
-                        () =>
-                        {
-                            timeoutFired = true;
-
-                            // Return false so the timer does not repeat
-                            return false;
-                        }
-                       );
-
-        // The timeout has not fired yet
-        Assert.False (timeoutFired);
-
-        // Block the thread to prove the timeout does not fire on a background thread
-        Thread.Sleep ((int)timeoutTime * 2);
-        Assert.False (timeoutFired);
-
-        app.StopAfterFirstIteration = true;
-        app.Run<Runnable> ();
-
-        // The timeout should have fired
-        Assert.True (timeoutFired);
-
-        app.Dispose ();
-    }
 
     [Fact]
     public void Begin_Null_Runnable_Throws ()
@@ -281,10 +245,6 @@ public class ApplicationTests (ITestOutputHelper output)
 
         void Application_Iteration (object? sender, EventArgs<IApplication?> e)
         {
-            if (iteration > 0)
-            {
-                Assert.Fail ();
-            }
 
             iteration++;
             app.RequestStop ();

+ 462 - 0
Tests/UnitTestsParallelizable/Application/NestedRunTimeoutTests.cs

@@ -0,0 +1,462 @@
+using Xunit.Abstractions;
+
+namespace ApplicationTests.Timeout;
+
+/// <summary>
+///     Tests for timeout behavior with nested Application.Run() calls.
+///     These tests verify that timeouts scheduled in a parent run loop continue to fire
+///     correctly when a nested modal dialog is shown via Application.Run().
+/// </summary>
+public class NestedRunTimeoutTests (ITestOutputHelper output)
+{
+    [Fact]
+    public void Multiple_Timeouts_Fire_In_Correct_Order_With_Nested_Run ()
+    {
+        // Arrange
+        using IApplication? app = Application.Create ();
+        app.Init ("FakeDriver");
+
+        List<string> executionOrder = new ();
+
+        var mainWindow = new Window { Title = "Main Window" };
+        var dialog = new Dialog { Title = "Nested Dialog", Buttons = [new() { Text = "Ok" }] };
+        var nestedRunCompleted = false;
+
+        // Use iteration counter for safety instead of time-based timeout
+        var iterations = 0;
+        app.Iteration += IterationHandler;
+
+        try
+        {
+            // Schedule multiple timeouts
+            app.AddTimeout (
+                            TimeSpan.FromMilliseconds (100),
+                            () =>
+                            {
+                                executionOrder.Add ("Timeout1-100ms");
+                                output.WriteLine ("Timeout1 fired at 100ms");
+
+                                return false;
+                            }
+                           );
+
+            app.AddTimeout (
+                            TimeSpan.FromMilliseconds (200),
+                            () =>
+                            {
+                                executionOrder.Add ("Timeout2-200ms-StartNestedRun");
+                                output.WriteLine ("Timeout2 fired at 200ms - Starting nested run");
+
+                                // Start nested run
+                                app.Run (dialog);
+
+                                executionOrder.Add ("Timeout2-NestedRunEnded");
+                                nestedRunCompleted = true;
+                                output.WriteLine ("Nested run ended");
+
+                                return false;
+                            }
+                           );
+
+            app.AddTimeout (
+                            TimeSpan.FromMilliseconds (300),
+                            () =>
+                            {
+                                executionOrder.Add ("Timeout3-300ms-InNestedRun");
+                                output.WriteLine ($"Timeout3 fired at 300ms - TopRunnable: {app.TopRunnableView?.Title}");
+
+                                // This should fire while dialog is running
+                                Assert.Equal (dialog, app.TopRunnableView);
+
+                                return false;
+                            }
+                           );
+
+            app.AddTimeout (
+                            TimeSpan.FromMilliseconds (400),
+                            () =>
+                            {
+                                executionOrder.Add ("Timeout4-400ms-CloseDialog");
+                                output.WriteLine ("Timeout4 fired at 400ms - Closing dialog");
+
+                                // Close the dialog
+                                app.RequestStop (dialog);
+
+                                return false;
+                            }
+                           );
+
+            // Event-driven: Only stop main window AFTER nested run completes
+            // Use a repeating timeout that checks the condition
+            app.AddTimeout (
+                            TimeSpan.FromMilliseconds (50),
+                            () =>
+                            {
+                                // Keep checking until nested run completes
+                                if (nestedRunCompleted)
+                                {
+                                    executionOrder.Add ("Timeout5-AfterNestedRun-StopMain");
+                                    output.WriteLine ("Timeout5 fired after nested run completed - Stopping main window");
+                                    app.RequestStop (mainWindow);
+
+                                    return false; // Don't repeat
+                                }
+
+                                return true; // Keep checking
+                            }
+                           );
+
+            // Act
+            app.Run (mainWindow);
+
+            // Assert - Verify all timeouts fired in the correct order
+            output.WriteLine ($"Execution order: {string.Join (", ", executionOrder)}");
+
+            Assert.Equal (6, executionOrder.Count); // 5 timeout events + 1 nested run end marker
+            Assert.Equal ("Timeout1-100ms", executionOrder [0]);
+            Assert.Equal ("Timeout2-200ms-StartNestedRun", executionOrder [1]);
+            Assert.Equal ("Timeout3-300ms-InNestedRun", executionOrder [2]);
+            Assert.Equal ("Timeout4-400ms-CloseDialog", executionOrder [3]);
+            Assert.Equal ("Timeout2-NestedRunEnded", executionOrder [4]);
+            Assert.Equal ("Timeout5-AfterNestedRun-StopMain", executionOrder [5]);
+        }
+        finally
+        {
+            app.Iteration -= IterationHandler;
+            dialog.Dispose ();
+            mainWindow.Dispose ();
+        }
+
+        return;
+
+        void IterationHandler (object? s, EventArgs<IApplication?> e)
+        {
+            iterations++;
+
+            // Safety limit - should never be hit with event-driven logic
+            if (iterations > 2000)
+            {
+                output.WriteLine ($"SAFETY: Hit iteration limit. Execution order: {string.Join (", ", executionOrder)}");
+                app.RequestStop ();
+            }
+        }
+    }
+
+    [Fact]
+    public void Timeout_Fires_In_Nested_Run ()
+    {
+        // Arrange
+        using IApplication? app = Application.Create ();
+
+        app.Init ("FakeDriver");
+
+        var timeoutFired = false;
+        var nestedRunStarted = false;
+        var nestedRunEnded = false;
+
+        // Create a simple window for the main run loop
+        var mainWindow = new Window { Title = "Main Window" };
+
+        // Create a dialog for the nested run loop
+        var dialog = new Dialog { Title = "Nested Dialog", Buttons = [new() { Text = "Ok" }] };
+
+        // Schedule a safety timeout that will ensure the app quits if test hangs
+        var requestStopTimeoutFired = false;
+
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (5000),
+                        () =>
+                        {
+                            output.WriteLine ("SAFETY: RequestStop Timeout fired - test took too long!");
+                            requestStopTimeoutFired = true;
+                            app.RequestStop ();
+
+                            return false;
+                        }
+                       );
+
+        // Schedule a timeout that will fire AFTER the nested run starts and stop the dialog
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (200),
+                        () =>
+                        {
+                            output.WriteLine ($"DialogRequestStop Timeout fired! TopRunnable: {app.TopRunnableView?.Title ?? "null"}");
+                            timeoutFired = true;
+
+                            // Close the dialog when timeout fires
+                            if (app.TopRunnableView == dialog)
+                            {
+                                app.RequestStop (dialog);
+                            }
+
+                            return false;
+                        }
+                       );
+
+        // After 100ms, start the nested run loop
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (100),
+                        () =>
+                        {
+                            output.WriteLine ("Starting nested run...");
+                            nestedRunStarted = true;
+
+                            // This blocks until the dialog is closed (by the timeout at 200ms)
+                            app.Run (dialog);
+
+                            output.WriteLine ("Nested run ended");
+                            nestedRunEnded = true;
+
+                            // Stop the main window after nested run completes
+                            app.RequestStop ();
+
+                            return false;
+                        }
+                       );
+
+        // Act - Start the main run loop
+        app.Run (mainWindow);
+
+        // Assert
+        Assert.True (nestedRunStarted, "Nested run should have started");
+        Assert.True (timeoutFired, "Timeout should have fired during nested run");
+        Assert.True (nestedRunEnded, "Nested run should have ended");
+
+        Assert.False (requestStopTimeoutFired, "Safety timeout should NOT have fired");
+
+        dialog.Dispose ();
+        mainWindow.Dispose ();
+    }
+
+    [Fact]
+    public void Timeout_Fires_With_Single_Session ()
+    {
+        // Arrange
+        using IApplication? app = Application.Create ();
+
+        app.Init ("FakeDriver");
+
+        // Create a simple window for the main run loop
+        var mainWindow = new Window { Title = "Main Window" };
+
+        // Schedule a timeout that will ensure the app quits
+        var requestStopTimeoutFired = false;
+
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (100),
+                        () =>
+                        {
+                            output.WriteLine ("RequestStop Timeout fired!");
+                            requestStopTimeoutFired = true;
+                            app.RequestStop ();
+
+                            return false;
+                        }
+                       );
+
+        // Act - Start the main run loop
+        app.Run (mainWindow);
+
+        // Assert
+        Assert.True (requestStopTimeoutFired, "RequestStop Timeout should have fired");
+
+        mainWindow.Dispose ();
+    }
+
+    [Fact]
+    public void Timeout_Queue_Persists_Across_Nested_Runs ()
+    {
+        // Verify that the timeout queue is not cleared when nested runs start/end
+
+        // Arrange
+        using IApplication? app = Application.Create ();
+        app.Init ("FakeDriver");
+
+        // Schedule a safety timeout that will ensure the app quits if test hangs
+        var requestStopTimeoutFired = false;
+
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (10000),
+                        () =>
+                        {
+                            output.WriteLine ("SAFETY: RequestStop Timeout fired - test took too long!");
+                            requestStopTimeoutFired = true;
+                            app.RequestStop ();
+
+                            return false;
+                        }
+                       );
+
+        var mainWindow = new Window { Title = "Main Window" };
+        var dialog = new Dialog { Title = "Dialog", Buttons = [new() { Text = "Ok" }] };
+
+        var initialTimeoutCount = 0;
+        var timeoutCountDuringNestedRun = 0;
+        var timeoutCountAfterNestedRun = 0;
+
+        // Schedule 5 timeouts at different times with wider spacing
+        for (var i = 0; i < 5; i++)
+        {
+            int capturedI = i;
+
+            app.AddTimeout (
+                            TimeSpan.FromMilliseconds (150 * (i + 1)), // Increased spacing from 100ms to 150ms
+                            () =>
+                            {
+                                output.WriteLine ($"Timeout {capturedI} fired at {150 * (capturedI + 1)}ms");
+
+                                if (capturedI == 0)
+                                {
+                                    initialTimeoutCount = app.TimedEvents!.Timeouts.Count;
+                                    output.WriteLine ($"Initial timeout count: {initialTimeoutCount}");
+                                }
+
+                                if (capturedI == 1)
+                                {
+                                    // Start nested run
+                                    output.WriteLine ("Starting nested run");
+                                    app.Run (dialog);
+                                    output.WriteLine ("Nested run ended");
+
+                                    timeoutCountAfterNestedRun = app.TimedEvents!.Timeouts.Count;
+                                    output.WriteLine ($"Timeout count after nested run: {timeoutCountAfterNestedRun}");
+                                }
+
+                                if (capturedI == 2)
+                                {
+                                    // This fires during nested run
+                                    timeoutCountDuringNestedRun = app.TimedEvents!.Timeouts.Count;
+                                    output.WriteLine ($"Timeout count during nested run: {timeoutCountDuringNestedRun}");
+
+                                    // Close dialog
+                                    app.RequestStop (dialog);
+                                }
+
+                                if (capturedI == 4)
+                                {
+                                    // Stop main window
+                                    app.RequestStop (mainWindow);
+                                }
+
+                                return false;
+                            }
+                           );
+        }
+
+        // Act
+        app.Run (mainWindow);
+
+        // Assert
+        output.WriteLine ($"Final counts - Initial: {initialTimeoutCount}, During: {timeoutCountDuringNestedRun}, After: {timeoutCountAfterNestedRun}");
+
+        // The timeout queue should have pending timeouts throughout
+        Assert.True (initialTimeoutCount >= 0, "Should have timeouts in queue initially");
+        Assert.True (timeoutCountDuringNestedRun >= 0, "Should have timeouts in queue during nested run");
+        Assert.True (timeoutCountAfterNestedRun >= 0, "Should have timeouts in queue after nested run");
+
+        Assert.False (requestStopTimeoutFired, "Safety timeout should NOT have fired");
+
+        dialog.Dispose ();
+        mainWindow.Dispose ();
+    }
+
+    [Fact]
+    public void Timeout_Scheduled_Before_Nested_Run_Fires_During_Nested_Run ()
+    {
+        // This test specifically reproduces the ESC key issue scenario:
+        // - Timeouts are scheduled upfront (like demo keys)
+        // - A timeout fires and triggers a nested run (like Enter opening MessageBox)
+        // - A subsequent timeout should still fire during the nested run (like ESC closing MessageBox)
+
+        // Arrange
+        using IApplication? app = Application.Create ();
+        app.Init ("FakeDriver");
+
+        var enterFired = false;
+        var escFired = false;
+        var messageBoxShown = false;
+        var messageBoxClosed = false;
+
+        var mainWindow = new Window { Title = "Login Window" };
+        var messageBox = new Dialog { Title = "Success", Buttons = [new() { Text = "Ok" }] };
+
+        // Schedule a safety timeout that will ensure the app quits if test hangs
+        var requestStopTimeoutFired = false;
+
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (10000),
+                        () =>
+                        {
+                            output.WriteLine ("SAFETY: RequestStop Timeout fired - test took too long!");
+                            requestStopTimeoutFired = true;
+                            app.RequestStop ();
+
+                            return false;
+                        }
+                       );
+
+        // Schedule "Enter" timeout at 100ms
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (100),
+                        () =>
+                        {
+                            output.WriteLine ("Enter timeout fired - showing MessageBox");
+                            enterFired = true;
+
+                            // Simulate Enter key opening MessageBox
+                            messageBoxShown = true;
+                            app.Run (messageBox);
+                            messageBoxClosed = true;
+
+                            output.WriteLine ("MessageBox closed");
+
+                            return false;
+                        }
+                       );
+
+        // Schedule "ESC" timeout at 200ms (should fire while MessageBox is running)
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (200),
+                        () =>
+                        {
+                            output.WriteLine ($"ESC timeout fired - TopRunnable: {app.TopRunnableView?.Title}");
+                            escFired = true;
+
+                            // Simulate ESC key closing MessageBox
+                            if (app.TopRunnableView == messageBox)
+                            {
+                                output.WriteLine ("Closing MessageBox with ESC");
+                                app.RequestStop (messageBox);
+                            }
+
+                            return false;
+                        }
+                       );
+
+        // Increased delay from 300ms to 500ms to ensure nested run completes before stopping main
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (500),
+                        () =>
+                        {
+                            output.WriteLine ("Stopping main window");
+                            app.RequestStop (mainWindow);
+
+                            return false;
+                        }
+                       );
+
+        // Act
+        app.Run (mainWindow);
+
+        // Assert
+        Assert.True (enterFired, "Enter timeout should have fired");
+        Assert.True (messageBoxShown, "MessageBox should have been shown");
+        Assert.True (escFired, "ESC timeout should have fired during MessageBox"); // THIS WAS THE BUG - NOW FIXED!
+        Assert.True (messageBoxClosed, "MessageBox should have been closed");
+
+        Assert.False (requestStopTimeoutFired, "Safety timeout should NOT have fired");
+
+        messageBox.Dispose ();
+        mainWindow.Dispose ();
+    }
+}

+ 856 - 0
Tests/UnitTestsParallelizable/Application/TimeoutTests.cs

@@ -0,0 +1,856 @@
+using Xunit.Abstractions;
+// ReSharper disable AccessToDisposedClosure
+#pragma warning disable xUnit1031
+
+namespace ApplicationTests.Timeout;
+
+/// <summary>
+///     Tests for timeout behavior and functionality.
+///     These tests verify that timeouts fire correctly, can be added/removed,
+///     handle exceptions properly, and work with Application.Run() calls.
+/// </summary>
+public class TimeoutTests
+{
+    [Fact]
+    public void AddTimeout_Callback_Can_Add_New_Timeout ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        var firstFired = false;
+        var secondFired = false;
+
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (50),
+                        () =>
+                        {
+                            firstFired = true;
+
+                            // Add another timeout from within callback
+                            app.AddTimeout (
+                                            TimeSpan.FromMilliseconds (50),
+                                            () =>
+                                            {
+                                                secondFired = true;
+                                                app.RequestStop ();
+
+                                                return false;
+                                            }
+                                           );
+
+                            return false;
+                        }
+                       );
+
+        // Defensive: use iteration counter instead of time-based safety timeout
+        var iterations = 0;
+        app.Iteration += IterationHandler;
+
+        try
+        {
+            app.Run<Runnable> ();
+
+            Assert.True (firstFired);
+            Assert.True (secondFired);
+        }
+        finally
+        {
+            app.Iteration -= IterationHandler;
+        }
+
+        return;
+
+        void IterationHandler (object? s, EventArgs<IApplication?> e)
+        {
+            iterations++;
+
+            // Stop if test objectives met or safety limit reached
+            if ((firstFired && secondFired) || iterations > 1000)
+            {
+                app.RequestStop ();
+            }
+        }
+    }
+
+    [Fact]
+    public void AddTimeout_Exception_In_Callback_Propagates ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        var exceptionThrown = false;
+
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (50),
+                        () =>
+                        {
+                            exceptionThrown = true;
+                            throw new InvalidOperationException ("Test exception");
+                        });
+
+        // Defensive: use iteration counter
+        var iterations = 0;
+        app.Iteration += IterationHandler;
+
+        try
+        {
+            Assert.Throws<InvalidOperationException> (() => app.Run<Runnable> ());
+            Assert.True (exceptionThrown, "Exception callback should have been invoked");
+        }
+        finally
+        {
+            app.Iteration -= IterationHandler;
+        }
+
+        return;
+
+        void IterationHandler (object? s, EventArgs<IApplication?> e)
+        {
+            iterations++;
+
+            // Safety stop if exception not thrown after many iterations
+            if (iterations > 1000 && !exceptionThrown)
+            {
+                app.RequestStop ();
+            }
+        }
+    }
+
+    [Fact]
+    public void AddTimeout_Fires ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        uint timeoutTime = 100;
+        var timeoutFired = false;
+
+        // Setup a timeout that will fire
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (timeoutTime),
+                        () =>
+                        {
+                            timeoutFired = true;
+
+                            // Return false so the timer does not repeat
+                            return false;
+                        }
+                       );
+
+        // The timeout has not fired yet
+        Assert.False (timeoutFired);
+
+        // Block the thread to prove the timeout does not fire on a background thread
+        Thread.Sleep ((int)timeoutTime * 2);
+        Assert.False (timeoutFired);
+
+        app.StopAfterFirstIteration = true;
+        app.Run<Runnable> ();
+
+        // The timeout should have fired
+        Assert.True (timeoutFired);
+    }
+
+    [Fact]
+    public void AddTimeout_From_Background_Thread_Fires ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        var timeoutFired = false;
+        using var taskCompleted = new ManualResetEventSlim (false);
+
+        Task.Run (() =>
+                  {
+                      Thread.Sleep (50); // Ensure we're on background thread
+
+                      app.Invoke (() =>
+                                  {
+                                      app.AddTimeout (
+                                                      TimeSpan.FromMilliseconds (100),
+                                                      () =>
+                                                      {
+                                                          timeoutFired = true;
+                                                          taskCompleted.Set ();
+                                                          app.RequestStop ();
+
+                                                          return false;
+                                                      }
+                                                     );
+                                  }
+                                 );
+                  }
+                 );
+
+        // Use iteration counter for safety instead of time
+        var iterations = 0;
+        app.Iteration += IterationHandler;
+
+        try
+        {
+            app.Run<Runnable> ();
+
+            // Defensive: wait with timeout
+            Assert.True (taskCompleted.Wait (TimeSpan.FromSeconds (5)), "Timeout from background thread should have completed");
+            Assert.True (timeoutFired);
+        }
+        finally
+        {
+            app.Iteration -= IterationHandler;
+        }
+
+        return;
+
+        void IterationHandler (object? s, EventArgs<IApplication?> e)
+        {
+            iterations++;
+
+            // Safety stop
+            if (iterations > 1000)
+            {
+                app.RequestStop ();
+            }
+        }
+    }
+
+    [Fact]
+    public void AddTimeout_High_Frequency_All_Fire ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        const int TIMEOUT_COUNT = 50; // Reduced from 100 for performance
+        var firedCount = 0;
+
+        for (var i = 0; i < TIMEOUT_COUNT; i++)
+        {
+            app.AddTimeout (
+                            TimeSpan.FromMilliseconds (10 + i * 5),
+                            () =>
+                            {
+                                Interlocked.Increment (ref firedCount);
+
+                                return false;
+                            }
+                           );
+        }
+
+        // Use iteration counter and event completion instead of time-based safety
+        var iterations = 0;
+        app.Iteration += IterationHandler;
+
+        try
+        {
+            app.Run<Runnable> ();
+
+            Assert.Equal (TIMEOUT_COUNT, firedCount);
+        }
+        finally
+        {
+            app.Iteration -= IterationHandler;
+        }
+
+        return;
+
+        void IterationHandler (object? s, EventArgs<IApplication?> e)
+        {
+            iterations++;
+
+            // Stop when all timeouts fired or safety limit reached
+            if (firedCount >= TIMEOUT_COUNT || iterations > 2000)
+            {
+                app.RequestStop ();
+            }
+        }
+    }
+
+    [Fact]
+    public void Long_Running_Callback_Delays_Subsequent_Timeouts ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        var firstStarted = false;
+        var secondFired = false;
+        var firstCompleted = false;
+
+        // Long-running timeout
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (50),
+                        () =>
+                        {
+                            firstStarted = true;
+                            Thread.Sleep (200); // Simulate long operation
+                            firstCompleted = true;
+
+                            return false;
+                        }
+                       );
+
+        // This should fire even though first is still running
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (100),
+                        () =>
+                        {
+                            secondFired = true;
+
+                            return false;
+                        }
+                       );
+
+        // Use iteration counter instead of time-based timeout
+        var iterations = 0;
+        app.Iteration += IterationHandler;
+
+        try
+        {
+            app.Run<Runnable> ();
+
+            Assert.True (firstStarted);
+            Assert.True (secondFired);
+            Assert.True (firstCompleted);
+        }
+        finally
+        {
+            app.Iteration -= IterationHandler;
+        }
+
+        return;
+
+        void IterationHandler (object? s, EventArgs<IApplication?> e)
+        {
+            iterations++;
+
+            // Stop when both complete or safety limit
+            if ((firstCompleted && secondFired) || iterations > 2000)
+            {
+                app.RequestStop ();
+            }
+        }
+    }
+
+    [Fact]
+    public void AddTimeout_Multiple_Fire_In_Order ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        List<int> executionOrder = new ();
+
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (300),
+                        () =>
+                        {
+                            executionOrder.Add (3);
+
+                            return false;
+                        });
+
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (100),
+                        () =>
+                        {
+                            executionOrder.Add (1);
+
+                            return false;
+                        });
+
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (200),
+                        () =>
+                        {
+                            executionOrder.Add (2);
+
+                            return false;
+                        });
+
+        var iterations = 0;
+
+        app.Iteration += IterationHandler;
+
+        try
+        {
+            app.Run<Runnable> ();
+
+            Assert.Equal (new [] { 1, 2, 3 }, executionOrder);
+        }
+        finally
+        {
+            app.Iteration -= IterationHandler;
+        }
+
+        return;
+
+        void IterationHandler (object? s, EventArgs<IApplication?> e)
+        {
+            iterations++;
+
+            // Stop after timeouts fire or max iterations (defensive)
+            if (executionOrder.Count == 3 || iterations > 1000)
+            {
+                app.RequestStop ();
+            }
+        }
+    }
+
+    [Fact]
+    public void AddTimeout_Multiple_TimeSpan_Zero_All_Fire ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        const int TIMEOUT_COUNT = 10;
+        var firedCount = 0;
+
+        for (var i = 0; i < TIMEOUT_COUNT; i++)
+        {
+            app.AddTimeout (
+                            TimeSpan.Zero,
+                            () =>
+                            {
+                                Interlocked.Increment (ref firedCount);
+
+                                return false;
+                            }
+                           );
+        }
+
+        var iterations = 0;
+
+        app.Iteration += IterationHandler;
+
+        try
+        {
+            app.Run<Runnable> ();
+
+            Assert.Equal (TIMEOUT_COUNT, firedCount);
+        }
+        finally
+        {
+            app.Iteration -= IterationHandler;
+        }
+
+        return;
+
+        void IterationHandler (object? s, EventArgs<IApplication?> e)
+        {
+            iterations++;
+
+            // Defensive: stop after timeouts fire or max iterations
+            if (firedCount == TIMEOUT_COUNT || iterations > 100)
+            {
+                app.RequestStop ();
+            }
+        }
+    }
+
+    [Fact]
+    public void AddTimeout_Nested_Run_Parent_Timeout_Fires ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        var parentTimeoutFired = false;
+        var childTimeoutFired = false;
+        var nestedRunCompleted = false;
+
+        // Parent timeout - fires after child modal opens
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (200),
+                        () =>
+                        {
+                            parentTimeoutFired = true;
+
+                            return false;
+                        }
+                       );
+
+        // After 100ms, open nested modal
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (100),
+                        () =>
+                        {
+                            var childRunnable = new Runnable ();
+
+                            // Child timeout
+                            app.AddTimeout (
+                                            TimeSpan.FromMilliseconds (50),
+                                            () =>
+                                            {
+                                                childTimeoutFired = true;
+                                                app.RequestStop (childRunnable);
+
+                                                return false;
+                                            }
+                                           );
+
+                            app.Run (childRunnable);
+                            nestedRunCompleted = true;
+                            childRunnable.Dispose ();
+
+                            return false;
+                        }
+                       );
+
+        // Use iteration counter instead of time-based safety
+        var iterations = 0;
+        app.Iteration += IterationHandler;
+
+        try
+        {
+            app.Run<Runnable> ();
+
+            Assert.True (childTimeoutFired, "Child timeout should fire during nested Run");
+            Assert.True (parentTimeoutFired, "Parent timeout should continue firing during nested Run");
+            Assert.True (nestedRunCompleted, "Nested run should have completed");
+        }
+        finally
+        {
+            app.Iteration -= IterationHandler;
+        }
+
+        return;
+
+        void IterationHandler (object? s, EventArgs<IApplication?> e)
+        {
+            iterations++;
+
+            // Stop when objectives met or safety limit
+            if ((parentTimeoutFired && nestedRunCompleted) || iterations > 2000)
+            {
+                app.RequestStop ();
+            }
+        }
+    }
+
+    [Fact]
+    public void AddTimeout_Repeating_Fires_Multiple_Times ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        var fireCount = 0;
+
+        app.AddTimeout (
+                        TimeSpan.FromMilliseconds (50),
+                        () =>
+                        {
+                            fireCount++;
+
+                            return fireCount < 3; // Repeat 3 times
+                        }
+                       );
+
+        var iterations = 0;
+
+        app.Iteration += IterationHandler;
+
+        try
+        {
+            app.Run<Runnable> ();
+
+            Assert.Equal (3, fireCount);
+        }
+        finally
+        {
+            app.Iteration -= IterationHandler;
+        }
+
+        return;
+
+        void IterationHandler (object? s, EventArgs<IApplication?> e)
+        {
+            iterations++;
+
+            // Stop after 3 fires or max iterations (defensive)
+            if (fireCount >= 3 || iterations > 1000)
+            {
+                app.RequestStop ();
+            }
+        }
+    }
+
+    [Fact]
+    public void AddTimeout_StopAfterFirstIteration_Immediate_Fires ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        var timeoutFired = false;
+
+        app.AddTimeout (
+                        TimeSpan.Zero,
+                        () =>
+                        {
+                            timeoutFired = true;
+
+                            return false;
+                        }
+                       );
+
+        app.StopAfterFirstIteration = true;
+        app.Run<Runnable> ();
+
+        Assert.True (timeoutFired);
+    }
+
+    [Fact]
+    public void AddTimeout_TimeSpan_Zero_Fires ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+        var timeoutFired = false;
+
+        app.AddTimeout (
+                        TimeSpan.Zero,
+                        () =>
+                        {
+                            timeoutFired = true;
+
+                            return false;
+                        });
+
+        app.StopAfterFirstIteration = true;
+        app.Run<Runnable> ();
+
+        Assert.True (timeoutFired);
+    }
+
+    [Fact]
+    public void RemoveTimeout_Already_Removed_Returns_False ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        object? token = app.AddTimeout (TimeSpan.FromMilliseconds (100), () => false);
+
+        // Remove once
+        bool removed1 = app.RemoveTimeout (token!);
+        Assert.True (removed1);
+
+        // Try to remove again
+        bool removed2 = app.RemoveTimeout (token!);
+        Assert.False (removed2);
+    }
+
+    [Fact]
+    public void RemoveTimeout_Cancels_Timeout ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        var timeoutFired = false;
+
+        object? token = app.AddTimeout (
+                                        TimeSpan.FromMilliseconds (100),
+                                        () =>
+                                        {
+                                            timeoutFired = true;
+
+                                            return false;
+                                        }
+                                       );
+
+        // Remove timeout before it fires
+        bool removed = app.RemoveTimeout (token!);
+        Assert.True (removed);
+
+        // Use iteration counter instead of time-based timeout
+        var iterations = 0;
+        app.Iteration += IterationHandler;
+
+        try
+        {
+            app.Run<Runnable> ();
+
+            Assert.False (timeoutFired);
+        }
+        finally
+        {
+            app.Iteration -= IterationHandler;
+        }
+
+        return;
+
+        void IterationHandler (object? s, EventArgs<IApplication?> e)
+        {
+            iterations++;
+
+            // Since timeout was removed, just need enough iterations to prove it won't fire
+            // With 100ms timeout, give ~50 iterations which is more than enough
+            if (iterations > 50)
+            {
+                app.RequestStop ();
+            }
+        }
+    }
+
+    [Fact]
+    public void RemoveTimeout_Invalid_Token_Returns_False ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        var fakeToken = new object ();
+        bool removed = app.RemoveTimeout (fakeToken);
+
+        Assert.False (removed);
+    }
+
+    [Fact]
+    public void TimedEvents_GetTimeout_Invalid_Token_Returns_Null ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        var fakeToken = new object ();
+        TimeSpan? actualTimeSpan = app.TimedEvents?.GetTimeout (fakeToken);
+
+        Assert.Null (actualTimeSpan);
+    }
+
+    [Fact]
+    public void TimedEvents_GetTimeout_Returns_Correct_TimeSpan ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        TimeSpan expectedTimeSpan = TimeSpan.FromMilliseconds (500);
+        object? token = app.AddTimeout (expectedTimeSpan, () => false);
+
+        TimeSpan? actualTimeSpan = app.TimedEvents?.GetTimeout (token!);
+
+        Assert.NotNull (actualTimeSpan);
+        Assert.Equal (expectedTimeSpan, actualTimeSpan.Value);
+    }
+
+    [Fact]
+    public void TimedEvents_StopAll_Clears_Timeouts ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        var firedCount = 0;
+
+        for (var i = 0; i < 10; i++)
+        {
+            app.AddTimeout (
+                            TimeSpan.FromMilliseconds (100),
+                            () =>
+                            {
+                                Interlocked.Increment (ref firedCount);
+
+                                return false;
+                            }
+                           );
+        }
+
+        Assert.NotEmpty (app.TimedEvents!.Timeouts);
+
+        app.TimedEvents.StopAll ();
+
+        Assert.Empty (app.TimedEvents.Timeouts);
+
+        // Use iteration counter for safety
+        var iterations = 0;
+        app.Iteration += IterationHandler;
+
+        try
+        {
+            app.Run<Runnable> ();
+
+            Assert.Equal (0, firedCount);
+        }
+        finally
+        {
+            app.Iteration -= IterationHandler;
+        }
+
+        return;
+
+        void IterationHandler (object? s, EventArgs<IApplication?> e)
+        {
+            iterations++;
+
+            // Since all timeouts were cleared, just need enough iterations to prove they won't fire
+            // With 100ms timeouts, give ~50 iterations which is more than enough
+            if (iterations > 50)
+            {
+                app.RequestStop ();
+            }
+        }
+    }
+
+    [Fact]
+    public void TimedEvents_Timeouts_Property_Is_Thread_Safe ()
+    {
+        using IApplication app = Application.Create ();
+        app.Init ("fake");
+
+        const int THREAD_COUNT = 10;
+        var addedCount = 0;
+        var tasksCompleted = new CountdownEvent (THREAD_COUNT);
+
+        // Add timeouts from multiple threads using Invoke
+        for (var i = 0; i < THREAD_COUNT; i++)
+        {
+            Task.Run (() =>
+                      {
+                          app.Invoke (() =>
+                                      {
+                                          // Add timeout with immediate execution
+                                          app.AddTimeout (
+                                                          TimeSpan.Zero,
+                                                          () =>
+                                                          {
+                                                              Interlocked.Increment (ref addedCount);
+
+                                                              return false;
+                                                          }
+                                                         );
+
+                                          tasksCompleted.Signal ();
+                                      }
+                                     );
+                      }
+                     );
+        }
+
+        // Use iteration counter to stop when all tasks complete
+        var iterations = 0;
+        app.Iteration += IterationHandler;
+
+        try
+        {
+            app.Run<Runnable> ();
+
+            // Verify we can safely access the Timeouts property from main thread
+            int timeoutCount = app.TimedEvents?.Timeouts.Count ?? 0;
+
+            // Verify no exceptions occurred
+            Assert.True (timeoutCount >= 0, "Should be able to access Timeouts property without exception");
+
+            // Verify all tasks completed and all timeouts fired
+            Assert.True (tasksCompleted.IsSet, "All background tasks should have completed");
+            Assert.Equal (THREAD_COUNT, addedCount);
+        }
+        finally
+        {
+            app.Iteration -= IterationHandler;
+            tasksCompleted.Dispose ();
+        }
+
+        return;
+
+        void IterationHandler (object? s, EventArgs<IApplication?> e)
+        {
+            iterations++;
+
+            // Stop when all tasks completed and all timeouts fired, or safety limit
+            if ((tasksCompleted.IsSet && addedCount >= THREAD_COUNT) || iterations > 200)
+            {
+                app.RequestStop ();
+            }
+        }
+    }
+}

+ 3 - 3
Tests/UnitTestsParallelizable/Configuration/ColorJsonConverterTests.cs

@@ -52,7 +52,7 @@ public class ColorJsonConverterTests
     [InlineData (ColorName16.Red, "Red")]
     [InlineData (ColorName16.Magenta, "Fuchsia")]   // W3C+ Standard overrides
     [InlineData (ColorName16.Yellow, "Yellow")]
-    [InlineData (ColorName16.DarkGray, "DarkGray")]
+    [InlineData (ColorName16.DarkGray, "BrightBlack")] // Legacy ColorName16.DarkGray now serializes as BrightBlack (first alphabetical match)
     [InlineData (ColorName16.BrightBlue, "BrightBlue")]
     [InlineData (ColorName16.BrightGreen, "BrightGreen")]
     [InlineData (ColorName16.BrightCyan, "BrightCyan")]
@@ -98,7 +98,7 @@ public class ColorJsonConverterTests
     [InlineData ("BrightYellow", Color.BrightYellow)]
     [InlineData ("Yellow", Color.Yellow)]
     [InlineData ("Cyan", Color.Cyan)]
-    [InlineData ("DarkGray", Color.DarkGray)]
+    [InlineData ("BrightBlack", Color.DarkGray)] // Legacy ColorName16.DarkGray is now accessible as BrightBlack
     [InlineData ("Gray", Color.Gray)]
     [InlineData ("Green", Color.Green)]
     [InlineData ("Magenta", Color.Magenta)]
@@ -113,7 +113,7 @@ public class ColorJsonConverterTests
         var actualColor = JsonSerializer.Deserialize<Color> (json, JsonOptions);
 
         // Assert
-        Assert.Equal (new Color (expectedColor), actualColor);
+        Assert.Equal (new (expectedColor), actualColor);
     }
 
     [Fact]

+ 6 - 6
Tests/UnitTestsParallelizable/Configuration/SourcesManagerTests.cs

@@ -12,7 +12,7 @@ public class SourcesManagerTests
         // Arrange
         var sourcesManager = new SourcesManager ();
         var stream = new MemoryStream ();
-        var source = "test.json";
+        var source = "Load_WithNullSettingsScope_ReturnsFalse";
         var location = ConfigLocations.AppCurrent;
 
         // Act
@@ -37,7 +37,7 @@ public class SourcesManagerTests
                    }
                    """;
         var location = ConfigLocations.HardCoded;
-        var source = "stream";
+        var source = "Load_WithValidStream_UpdatesSettingsScope";
 
         var stream = new MemoryStream ();
         var writer = new StreamWriter (stream);
@@ -69,7 +69,7 @@ public class SourcesManagerTests
         writer.Flush ();
         stream.Position = 0;
 
-        var source = "test.json";
+        var source = "Load_WithInvalidJson_AddsJsonError";
         var location = ConfigLocations.AppCurrent;
 
         // Act
@@ -180,7 +180,7 @@ public class SourcesManagerTests
         var sourcesManager = new SourcesManager ();
 
         var settingsScope = new SettingsScope ();
-        var source = "test.json";
+        var source = "Load_WithNullOrEmptyJson_ReturnsFalse";
         var location = ConfigLocations.AppCurrent;
 
         // Act
@@ -206,7 +206,7 @@ public class SourcesManagerTests
                         "Application.QuitKey": "Ctrl+Z"
                    }
                    """;
-        var source = "test.json";
+        var source = "Load_WithValidJson_UpdatesSettingsScope";
         var location = ConfigLocations.HardCoded;
 
         // Act
@@ -233,7 +233,7 @@ public class SourcesManagerTests
     //                    "Button.DefaultShadowStyle": "None"
     //               }
     //               """;
-    //    var source = "test.json";
+    //    var source = "Update_WithValidJson_UpdatesThemeScope";
     //    var location = ConfigLocations.HardCoded;
 
     //    // Act

+ 0 - 168
Tests/UnitTestsParallelizable/Drawing/Color/AnsiColorNameResolverTests.cs

@@ -1,168 +0,0 @@
-#nullable enable
-
-namespace DrawingTests;
-
-public class AnsiColorNameResolverTests
-{
-    private readonly AnsiColorNameResolver _candidate = new ();
-    [Fact]
-    public void TryNameColor_Resolves_All_ColorName16 ()
-    {
-        var resolver = new AnsiColorNameResolver ();
-
-        foreach (ColorName16 name in Enum.GetValues<ColorName16> ())
-        {
-            var color = new Color (name);
-            bool success = resolver.TryNameColor (color, out string? resultName);
-
-            Assert.True (success, $"Expected TryNameColor to succeed for {name}");
-            Assert.Equal (name.ToString (), resultName);
-        }
-    }
-
-    [Fact]
-    public void TryParseColor_Resolves_All_ColorName16_Names ()
-    {
-        var resolver = new AnsiColorNameResolver ();
-
-        foreach (ColorName16 name in Enum.GetValues<ColorName16> ())
-        {
-            bool success = resolver.TryParseColor (name.ToString (), out Color parsed);
-
-            Assert.True (success, $"Expected TryParseColor to succeed for {name}");
-            Assert.Equal (new Color (name), parsed);
-        }
-    }
-
-    public static IEnumerable<object []> AnsiColorName16NumericValues =>
-        Enum.GetValues<ColorName16> ()
-            .Select (e => new object [] { ((int)e).ToString () });
-    [Theory]
-    [MemberData (nameof (AnsiColorName16NumericValues))]
-    public void TryParseColor_Accepts_Enum_UnderlyingNumbers (string numeric)
-    {
-        var resolver = new AnsiColorNameResolver ();
-
-        bool success = resolver.TryParseColor (numeric, out _);
-
-        Assert.True (success, $"Expected numeric enum value '{numeric}' to resolve successfully.");
-    }
-
-
-
-    [Fact]
-    public void GetNames_Returns16ColorNames ()
-    {
-        string [] expected = Enum.GetNames<ColorName16> ();
-
-        string [] actual = _candidate.GetColorNames ().ToArray ();
-
-        Assert.Equal (expected, actual);
-    }
-
-    [Theory]
-    [InlineData (0, 0, 0, nameof (ColorName16.Black))]
-    [InlineData (0, 0, 255, nameof (ColorName16.Blue))]
-    [InlineData (59, 120, 255, nameof (ColorName16.BrightBlue))]
-    [InlineData (97, 214, 214, nameof (ColorName16.BrightCyan))]
-    [InlineData (22, 198, 12, nameof (ColorName16.BrightGreen))]
-    [InlineData (180, 0, 158, nameof (ColorName16.BrightMagenta))]
-    [InlineData (231, 72, 86, nameof (ColorName16.BrightRed))]
-    [InlineData (249, 241, 165, nameof (ColorName16.BrightYellow))]
-    [InlineData (0, 255, 255, nameof (ColorName16.Cyan))]
-    [InlineData (118, 118, 118, nameof (ColorName16.DarkGray))]
-    [InlineData (128, 128, 128, nameof (ColorName16.Gray))]
-    [InlineData (0, 128, 0, nameof (ColorName16.Green))]
-    [InlineData (255, 0, 255, nameof (ColorName16.Magenta))]
-    [InlineData (255, 0, 0, nameof (ColorName16.Red))]
-    [InlineData (255, 255, 255, nameof (ColorName16.White))]
-    [InlineData (255, 255, 0, nameof (ColorName16.Yellow))]
-    public void TryNameColor_ReturnsExpectedColorName (byte r, byte g, byte b, string expectedName)
-    {
-        var expected = (true, expectedName);
-
-        bool actualSuccess = _candidate.TryNameColor (new Color (r, g, b), out string? actualName);
-        var actual = (actualSuccess, actualName);
-
-        Assert.Equal (expected, actual);
-    }
-
-    [Fact]
-    public void TryNameColor_NoMatchFails ()
-    {
-        (bool, string?) expected = (false, null);
-
-        bool actualSuccess = _candidate.TryNameColor (new Color (1, 2, 3), out string? actualName);
-        var actual = (actualSuccess, actualName);
-
-        Assert.Equal (expected, actual);
-    }
-
-    [Theory]
-    [InlineData (nameof (ColorName16.Black), 0, 0, 0)]
-    [InlineData (nameof (ColorName16.Blue), 0, 0, 255)]
-    [InlineData (nameof (ColorName16.BrightBlue), 59, 120, 255)]
-    [InlineData (nameof (ColorName16.BrightCyan), 97, 214, 214)]
-    [InlineData (nameof (ColorName16.BrightGreen), 22, 198, 12)]
-    [InlineData (nameof (ColorName16.BrightMagenta), 180, 0, 158)]
-    [InlineData (nameof (ColorName16.BrightRed), 231, 72, 86)]
-    [InlineData (nameof (ColorName16.BrightYellow), 249, 241, 165)]
-    [InlineData (nameof (ColorName16.Cyan), 0, 255, 255)]
-    [InlineData (nameof (ColorName16.DarkGray), 118, 118, 118)]
-    [InlineData (nameof (ColorName16.Gray), 128, 128, 128)]
-    [InlineData (nameof (ColorName16.Green), 0, 128, 0)]
-    [InlineData (nameof (ColorName16.Magenta), 255, 0, 255)]
-    [InlineData (nameof (ColorName16.Red), 255, 0, 0)]
-    [InlineData (nameof (ColorName16.White), 255, 255, 255)]
-    [InlineData (nameof (ColorName16.Yellow), 255, 255, 0)]
-    // Case-insensitive
-    [InlineData ("BRIGHTBLUE", 59, 120, 255)]
-    [InlineData ("brightblue", 59, 120, 255)]
-    public void TryParseColor_ReturnsExpectedColor (string inputName, byte r, byte g, byte b)
-    {
-        var expected = (true, new Color (r, g, b));
-
-        bool actualSuccess = _candidate.TryParseColor (inputName, out Color actualColor);
-        var actual = (actualSuccess, actualColor);
-
-        Assert.Equal (expected, actual);
-    }
-
-    [Theory]
-    [InlineData ("12", 231, 72, 86)] // ColorName16.BrightRed
-    public void TryParseColor_ResolvesValidEnumNumber (string inputName, byte r, byte g, byte b)
-    {
-        var expected = (true, new Color (r, g, b));
-
-        bool actualSuccess = _candidate.TryParseColor (inputName, out Color actualColor);
-        var actual = (actualSuccess, actualColor);
-
-        Assert.Equal (expected, actual);
-    }
-
-    [Theory]
-    [InlineData (null)]
-    [InlineData ("")]
-    [InlineData ("brightlight")]
-    public void TryParseColor_FailsOnInvalidColorName (string? invalidName)
-    {
-        var expected = (false, default (Color));
-
-        bool actualSuccess = _candidate.TryParseColor (invalidName, out Color actualColor);
-        var actual = (actualSuccess, actualColor);
-
-        Assert.Equal (expected, actual);
-    }
-
-    [Theory]
-    [InlineData ("-12")]
-    public void TryParseColor_FailsOnInvalidEnumNumber (string invalidName)
-    {
-        var expected = (false, default (Color));
-
-        bool actualSuccess = _candidate.TryParseColor (invalidName, out Color actualColor);
-        var actual = (actualSuccess, actualColor);
-
-        Assert.Equal (expected, actual);
-    }
-}

+ 2 - 2
Tests/UnitTestsParallelizable/Drawing/ColorTests.Constructors.cs → Tests/UnitTestsParallelizable/Drawing/Color/ColorClassTests.Constructors.cs

@@ -1,6 +1,6 @@
-namespace DrawingTests;
+namespace DrawingTests.ColorTests;
 
-public partial class ColorTests
+public partial class ColorClassTests
 {
     [Fact]
     public void Constructor_Empty_ReturnsColorWithZeroValue ()

+ 2 - 2
Tests/UnitTestsParallelizable/Drawing/ColorTests.Operators.cs → Tests/UnitTestsParallelizable/Drawing/Color/ColorClassTests.Operators.cs

@@ -1,9 +1,9 @@
 using System.Numerics;
 using System.Reflection;
 
-namespace DrawingTests;
+namespace DrawingTests.ColorTests;
 
-public partial class ColorTests
+public partial class ColorClassTests
 {
     [Theory]
     [Trait ("Category", "Operators")]

+ 2 - 2
Tests/UnitTestsParallelizable/Drawing/ColorTests.ParsingAndFormatting.cs → Tests/UnitTestsParallelizable/Drawing/Color/ColorClassTests.ParsingAndFormatting.cs

@@ -2,9 +2,9 @@
 using System.Buffers.Binary;
 using System.Globalization;
 
-namespace DrawingTests;
+namespace DrawingTests.ColorTests;
 
-public partial class ColorTests
+public partial class ColorClassTests
 {
     [Fact]
     public void Color_ToString_WithNamedColor ()

+ 2 - 2
Tests/UnitTestsParallelizable/Drawing/ColorTests.TypeChecks.cs → Tests/UnitTestsParallelizable/Drawing/Color/ColorClassTests.TypeChecks.cs

@@ -1,9 +1,9 @@
 using System.Numerics;
 using System.Runtime.CompilerServices;
 
-namespace DrawingTests;
+namespace DrawingTests.ColorTests;
 
-public partial class ColorTests
+public partial class ColorClassTests
 {
     [Fact]
     [Trait ("Category", "Type Checks")]

+ 3 - 4
Tests/UnitTestsParallelizable/Drawing/ColorTests.cs → Tests/UnitTestsParallelizable/Drawing/Color/ColorClassTests.cs

@@ -1,8 +1,7 @@
-#nullable enable
+
+namespace DrawingTests.ColorTests;
 
-namespace DrawingTests;
-
-public partial class ColorTests
+public partial class ColorClassTests
 {
     [Theory]
     [CombinatorialData]

+ 0 - 27
Tests/UnitTestsParallelizable/Drawing/Color/ColorStandardColorTests.cs

@@ -1,27 +0,0 @@
-using Xunit;
-
-namespace DrawingTests;
-
-public class ColorStandardColorTests
-{
-    [Fact]
-    public void ToString_Returns_Standard_Name_For_StandardColor_CadetBlue()
-    {
-        // Without the fix, this uses Color(in StandardColor) -> this((int)colorName),
-        // which sets A=0x00 and prevents name resolution (expects A=0xFF).
-        var c = new Terminal.Gui.Drawing.Color(Terminal.Gui.Drawing.StandardColor.CadetBlue);
-
-        // Expected: named color
-        Assert.Equal("CadetBlue", c.ToString());
-    }
-
-    [Fact]
-    public void ToString_G_Prints_Opaque_ARGB_For_StandardColor_CadetBlue()
-    {
-        // Without the fix, A=0x00, so "G" prints "#005F9EA0" instead of "#FF5F9EA0".
-        var c = new Terminal.Gui.Drawing.Color(Terminal.Gui.Drawing.StandardColor.CadetBlue);
-
-        // Expected: #AARRGGBB with A=FF (opaque)
-        Assert.Equal("#FF5F9EA0", c.ToString("G", null));
-    }
-}

+ 326 - 0
Tests/UnitTestsParallelizable/Drawing/Color/ColorStringsTests.cs

@@ -0,0 +1,326 @@
+namespace DrawingTests.ColorTests;
+public class ColorStringsTests
+{
+    [Fact]
+    public void GetColorName_ReturnsNameForStandardColor ()
+    {
+        Color red = new (255, 0);
+        string? name = ColorStrings.GetColorName (red);
+
+        Assert.Equal ("Red", name);
+    }
+
+    [Fact]
+    public void GetColorName_ReturnsNullForNonStandardColor ()
+    {
+        Color custom = new (1, 2, 3);
+        string? name = ColorStrings.GetColorName (custom);
+
+        Assert.Null (name);
+    }
+
+    [Fact]
+    public void GetColorName_IgnoresAlphaChannel ()
+    {
+        Color opaqueRed = new (255, 0, 0, 255);
+        Color transparentRed = new (255, 0, 0, 128);
+        Color fullyTransparentRed = new (255, 0, 0, 0);
+
+        string? name1 = ColorStrings.GetColorName (opaqueRed);
+        string? name2 = ColorStrings.GetColorName (transparentRed);
+        string? name3 = ColorStrings.GetColorName (fullyTransparentRed);
+
+        Assert.Equal ("Red", name1);
+        Assert.Equal ("Red", name2);
+        Assert.Equal ("Red", name3);
+    }
+
+    [Theory]
+    [InlineData (240, 248, 255, "AliceBlue")]
+    [InlineData (0, 255, 255, "Aqua")]
+    [InlineData (0, 0, 0, "Black")]
+    [InlineData (0, 0, 255, "Blue")]
+    [InlineData (0, 128, 0, "Green")]
+    [InlineData (255, 0, 0, "Red")]
+    [InlineData (255, 255, 255, "White")]
+    [InlineData (255, 255, 0, "Yellow")]
+    public void GetColorName_ReturnsCorrectNameForKnownColors (int r, int g, int b, string expectedName)
+    {
+        Color color = new (r, g, b);
+        string? name = ColorStrings.GetColorName (color);
+
+        Assert.Equal (expectedName, name);
+    }
+
+    [Fact]
+    public void GetStandardColorNames_ReturnsNonEmptyCollection ()
+    {
+        IEnumerable<string> names = ColorStrings.GetStandardColorNames ();
+
+        Assert.NotNull (names);
+        Assert.NotEmpty (names);
+    }
+
+    [Fact]
+    public void GetStandardColorNames_ReturnsAlphabeticallySortedNames ()
+    {
+        IEnumerable<string> names = ColorStrings.GetStandardColorNames ();
+        string [] namesArray = names.ToArray ();
+        string [] sortedNames = namesArray.OrderBy (n => n).ToArray ();
+
+        Assert.Equal (sortedNames, namesArray);
+    }
+
+    [Fact]
+    public void GetStandardColorNames_ContainsKnownColors ()
+    {
+        IEnumerable<string> names = ColorStrings.GetStandardColorNames ();
+        string [] namesArray = names.ToArray ();
+
+        Assert.Contains ("Red", namesArray);
+        Assert.Contains ("Green", namesArray);
+        Assert.Contains ("Blue", namesArray);
+        Assert.Contains ("White", namesArray);
+        Assert.Contains ("Black", namesArray);
+        Assert.Contains ("AliceBlue", namesArray);
+        Assert.Contains ("Tomato", namesArray);
+    }
+
+    [Fact]
+    public void GetStandardColorNames_ContainsAllStandardColorEnumValues ()
+    {
+        IEnumerable<string> names = ColorStrings.GetStandardColorNames ();
+        string [] namesArray = names.ToArray ();
+        string [] enumNames = Enum.GetNames<StandardColor> ();
+
+        // All enum names should be in the returned collection
+        foreach (string enumName in enumNames)
+        {
+            Assert.Contains (enumName, namesArray);
+        }
+
+        // The counts should match
+        Assert.Equal (enumNames.Length, namesArray.Length);
+    }
+
+    [Theory]
+    [InlineData ("Red")]
+    [InlineData ("red")]
+    [InlineData ("RED")]
+    [InlineData ("Green")]
+    [InlineData ("green")]
+    [InlineData ("Blue")]
+    [InlineData ("AliceBlue")]
+    [InlineData ("aliceblue")]
+    [InlineData ("ALICEBLUE")]
+    public void TryParseStandardColorName_ParsesValidColorNamesCaseInsensitively (string colorName)
+    {
+        bool result = ColorStrings.TryParseStandardColorName (colorName, out Color color);
+
+        Assert.True (result);
+        Assert.NotEqual (default (Color), color);
+    }
+
+    [Theory]
+    [InlineData ("Red", 255, 0, 0)]
+    [InlineData ("Green", 0, 128, 0)]
+    [InlineData ("Blue", 0, 0, 255)]
+    [InlineData ("White", 255, 255, 255)]
+    [InlineData ("Black", 0, 0, 0)]
+    [InlineData ("AliceBlue", 240, 248, 255)]
+    [InlineData ("Tomato", 255, 99, 71)]
+    public void TryParseStandardColorName_ParsesCorrectRgbValues (string colorName, int expectedR, int expectedG, int expectedB)
+    {
+        bool result = ColorStrings.TryParseStandardColorName (colorName, out Color color);
+
+        Assert.True (result);
+        Assert.Equal (expectedR, color.R);
+        Assert.Equal (expectedG, color.G);
+        Assert.Equal (expectedB, color.B);
+    }
+
+    [Theory]
+    [InlineData ("#FF0000", 255, 0, 0)]
+    [InlineData ("#00FF00", 0, 255, 0)]
+    [InlineData ("#0000FF", 0, 0, 255)]
+    [InlineData ("#FFFFFF", 255, 255, 255)]
+    [InlineData ("#000000", 0, 0, 0)]
+    [InlineData ("#F0F8FF", 240, 248, 255)]
+    public void TryParseStandardColorName_ParsesHexColorFormat (string hexColor, int expectedR, int expectedG, int expectedB)
+    {
+        bool result = ColorStrings.TryParseStandardColorName (hexColor, out Color color);
+
+        Assert.True (result);
+        Assert.Equal (expectedR, color.R);
+        Assert.Equal (expectedG, color.G);
+        Assert.Equal (expectedB, color.B);
+    }
+
+    [Theory]
+    [InlineData ("#ff0000")]
+    [InlineData ("#FF0000")]
+    [InlineData ("#Ff0000")]
+    public void TryParseStandardColorName_ParsesHexColorCaseInsensitively (string hexColor)
+    {
+        bool result = ColorStrings.TryParseStandardColorName (hexColor, out Color color);
+
+        Assert.True (result);
+        Assert.Equal (255, color.R);
+        Assert.Equal (0, color.G);
+        Assert.Equal (0, color.B);
+    }
+
+    [Theory]
+    [InlineData ("")]
+    [InlineData ("NotAColor")]
+    [InlineData ("Invalid")]
+    [InlineData ("123")]
+    [InlineData ("#FF")]
+    [InlineData ("#FFFF")]
+    [InlineData ("#FFFFFFFF")]
+    [InlineData ("FF0000")]
+    public void TryParseStandardColorName_ReturnsFalseForInvalidInput (string invalidInput)
+    {
+        bool result = ColorStrings.TryParseStandardColorName (invalidInput, out Color color);
+
+        Assert.False (result);
+        Assert.Equal (default (Color), color);
+    }
+
+    [Fact]
+    public void TryParseStandardColorName_SetsAlphaToFullyOpaque ()
+    {
+        bool result = ColorStrings.TryParseStandardColorName ("Red", out Color color);
+
+        Assert.True (result);
+        Assert.Equal (255, color.A);
+    }
+
+    [Fact]
+    public void TryParseStandardColorName_WorksWithReadOnlySpan ()
+    {
+        ReadOnlySpan<char> span = "Red".AsSpan ();
+        bool result = ColorStrings.TryParseStandardColorName (span, out Color color);
+
+        Assert.True (result);
+        Assert.Equal (255, color.R);
+        Assert.Equal (0, color.G);
+        Assert.Equal (0, color.B);
+    }
+
+    [Theory]
+    [InlineData ("Red")]
+    [InlineData ("Green")]
+    [InlineData ("Blue")]
+    [InlineData ("AliceBlue")]
+    [InlineData ("#FF0000")]
+    public void TryParseNamedColor_ParsesValidColorNames (string colorName)
+    {
+        bool result = ColorStrings.TryParseNamedColor (colorName, out Color color);
+
+        Assert.True (result);
+        Assert.NotEqual (default (Color), color);
+    }
+
+    [Theory]
+    [InlineData ("Red", 255, 0, 0)]
+    [InlineData ("Green", 0, 128, 0)]
+    [InlineData ("Blue", 0, 0, 255)]
+    [InlineData ("#FF0000", 255, 0, 0)]
+    [InlineData ("#00FF00", 0, 255, 0)]
+    public void TryParseNamedColor_ParsesCorrectRgbValues (string colorName, int expectedR, int expectedG, int expectedB)
+    {
+        bool result = ColorStrings.TryParseNamedColor (colorName, out Color color);
+
+        Assert.True (result);
+        Assert.Equal (expectedR, color.R);
+        Assert.Equal (expectedG, color.G);
+        Assert.Equal (expectedB, color.B);
+    }
+
+    [Theory]
+    [InlineData ("")]
+    [InlineData ("NotAColor")]
+    [InlineData ("Invalid")]
+    [InlineData ("#ZZ0000")]
+    public void TryParseNamedColor_ReturnsFalseForInvalidInput (string invalidInput)
+    {
+        bool result = ColorStrings.TryParseNamedColor (invalidInput, out Color color);
+
+        Assert.False (result);
+        Assert.Equal (default (Color), color);
+    }
+
+    [Fact]
+    public void TryParseNamedColor_WorksWithReadOnlySpan ()
+    {
+        ReadOnlySpan<char> span = "Blue".AsSpan ();
+        bool result = ColorStrings.TryParseNamedColor (span, out Color color);
+
+        Assert.True (result);
+        Assert.Equal (0, color.R);
+        Assert.Equal (0, color.G);
+        Assert.Equal (255, color.B);
+    }
+
+    [Theory]
+    [InlineData (nameof (StandardColor.Aqua), nameof (StandardColor.Cyan))]
+    [InlineData (nameof (StandardColor.Fuchsia), nameof (StandardColor.Magenta))]
+    public void TryParseNamedColor_HandlesColorAliases (string name1, string name2)
+    {
+        bool result1 = ColorStrings.TryParseNamedColor (name1, out Color color1);
+        bool result2 = ColorStrings.TryParseNamedColor (name2, out Color color2);
+
+        Assert.True (result1);
+        Assert.True (result2);
+        Assert.Equal (color1.R, color2.R);
+        Assert.Equal (color1.G, color2.G);
+        Assert.Equal (color1.B, color2.B);
+    }
+
+    [Fact]
+    public void GetColorName_And_TryParseNamedColor_RoundTrip ()
+    {
+        // Get a standard color name
+        Color originalColor = new (255, 0);
+        string? colorName = ColorStrings.GetColorName (originalColor);
+
+        Assert.NotNull (colorName);
+
+        // Parse it back
+        bool result = ColorStrings.TryParseNamedColor (colorName, out Color parsedColor);
+
+        Assert.True (result);
+        Assert.Equal (originalColor.R, parsedColor.R);
+        Assert.Equal (originalColor.G, parsedColor.G);
+        Assert.Equal (originalColor.B, parsedColor.B);
+    }
+
+    [Fact]
+    public void GetStandardColorNames_And_TryParseStandardColorName_RoundTrip ()
+    {
+        // Get all standard color names
+        IEnumerable<string> names = ColorStrings.GetStandardColorNames ();
+
+        // Each name should parse successfully
+        foreach (string name in names)
+        {
+            bool result = ColorStrings.TryParseStandardColorName (name, out Color color);
+            Assert.True (result, $"Failed to parse standard color name: {name}");
+
+            // And should get the same name back (for non-aliases)
+            string? retrievedName = ColorStrings.GetColorName (color);
+            Assert.NotNull (retrievedName);
+
+            // The retrieved name should be one of the valid names for this color
+            // (could be different if there are aliases)
+            Assert.True (
+                         ColorStrings.TryParseStandardColorName (retrievedName, out Color retrievedColor),
+                         $"Retrieved name '{retrievedName}' should be parseable"
+                        );
+            Assert.Equal (color.R, retrievedColor.R);
+            Assert.Equal (color.G, retrievedColor.G);
+            Assert.Equal (color.B, retrievedColor.B);
+        }
+    }
+}

+ 0 - 156
Tests/UnitTestsParallelizable/Drawing/Color/MultiStandardColorNameResolverTests.cs

@@ -1,156 +0,0 @@
-#nullable enable
-
-using System.Collections.Generic;
-using Xunit.Abstractions;
-using Terminal.Gui;
-
-namespace DrawingTests;
-
-public class MultiStandardColorNameResolverTests (ITestOutputHelper output)
-{
-    private readonly MultiStandardColorNameResolver _candidate = new ();
-
-    public static IEnumerable<object []> StandardColors =>
-        Enum.GetValues<StandardColor> ().Select (sc => new object [] { sc });
-
-    [Theory]
-    [MemberData (nameof (StandardColors))]
-    public void TryParseColor_ResolvesAllStandardColorNames (StandardColor standardColor)
-    {
-        string name = standardColor.ToString ();
-        bool parsed = _candidate.TryParseColor (name, out Color actualColor);
-
-        Assert.True (parsed, $"TryParseColor should succeed for {name}");
-
-        Color expectedColor = new (Terminal.Gui.Drawing.StandardColors.GetArgb (standardColor));
-
-        Assert.Equal (expectedColor.R, actualColor.R);
-        Assert.Equal (expectedColor.G, actualColor.G);
-        Assert.Equal (expectedColor.B, actualColor.B);
-    }
-
-    [Theory]
-    [MemberData (nameof (StandardColors))]
-    public void TryNameColor_ResolvesAllStandardColors (StandardColor standardColor)
-    {
-        Color color = new (Terminal.Gui.Drawing.StandardColors.GetArgb (standardColor));
-
-        bool success = _candidate.TryNameColor (color, out string? resolvedName);
-
-        if (!success)
-        {
-            output.WriteLine ($"Unmapped: {standardColor} → {color}");
-        }
-
-        Assert.True (success, $"TryNameColor should succeed for {standardColor}");
-
-        List<string> expectedNames = Enum.GetNames<StandardColor> ()
-            .Where (name => Terminal.Gui.Drawing.StandardColors.GetArgb (Enum.Parse<StandardColor> (name)) == color.Argb)
-            .ToList ();
-
-        Assert.Contains (resolvedName, expectedNames);
-    }
-
-    [Fact]
-    public void TryNameColor_Logs_Unmapped_StandardColors ()
-    {
-        List<StandardColor> unmapped = new ();
-
-        foreach (StandardColor sc in Enum.GetValues<StandardColor> ())
-        {
-            Color color = new (Terminal.Gui.Drawing.StandardColors.GetArgb (sc));
-            if (!_candidate.TryNameColor (color, out _))
-            {
-                unmapped.Add (sc);
-            }
-        }
-
-        output.WriteLine ("Unmapped StandardColor entries:");
-        foreach (StandardColor sc in unmapped.Distinct ())
-        {
-            output.WriteLine ($"- {sc}");
-        }
-
-        Assert.True (unmapped.Count < 10, $"Too many StandardColor values are not name-resolvable. Got {unmapped.Count}.");
-    }
-
-    [Theory]
-    [InlineData (nameof (ColorName16.Black))]
-    [InlineData (nameof (ColorName16.White))]
-    [InlineData (nameof (ColorName16.Red))]
-    [InlineData (nameof (ColorName16.Green))]
-    [InlineData (nameof (ColorName16.Blue))]
-    [InlineData (nameof (ColorName16.Cyan))]
-    [InlineData (nameof (ColorName16.Magenta))]
-    [InlineData (nameof (ColorName16.DarkGray))]
-    [InlineData (nameof (ColorName16.BrightGreen))]
-    [InlineData (nameof (ColorName16.BrightMagenta))]
-    [InlineData (nameof (StandardColor.AliceBlue))]
-    [InlineData (nameof (StandardColor.BlanchedAlmond))]
-    public void GetNames_ContainsKnownNames (string name)
-    {
-        string [] names = _candidate.GetColorNames ().ToArray ();
-        Assert.Contains (name, names);
-    }
-
-    [Theory]
-    [InlineData (0, 0, 0, nameof (ColorName16.Black))]
-    [InlineData (0, 0, 255, nameof (ColorName16.Blue))]
-    [InlineData (59, 120, 255, nameof (ColorName16.BrightBlue))]
-    [InlineData (255, 0, 0, nameof (ColorName16.Red))]
-    [InlineData (255, 255, 255, nameof (ColorName16.White))]
-    [InlineData (240, 248, 255, nameof (StandardColor.AliceBlue))]
-    [InlineData (178, 34, 34, nameof (StandardColor.FireBrick))]
-    [InlineData (245, 245, 245, nameof (StandardColor.WhiteSmoke))]
-    public void TryNameColor_ReturnsExpectedColorNames (byte r, byte g, byte b, string expectedName)
-    {
-        Color color = new (r, g, b);
-        bool actualSuccess = _candidate.TryNameColor (color, out string? actualName);
-
-        Assert.True (actualSuccess);
-        Assert.Equal (expectedName, actualName);
-    }
-
-    [Fact]
-    public void TryNameColor_NoMatchFails ()
-    {
-        Color input = new (1, 2, 3);
-        bool success = _candidate.TryNameColor (input, out string? actualName);
-        Assert.False (success);
-        Assert.Null (actualName);
-    }
-
-    [Theory]
-    [InlineData ("12", 231, 72, 86)] // ColorName16.BrightRed
-    [InlineData ("16737095", 255, 99, 71)] // StandardColor.Tomato
-    [InlineData ("#FF0000", 255, 0, 0)] // Red
-    public void TryParseColor_ResolvesValidEnumNumber (string inputName, byte r, byte g, byte b)
-    {
-        bool success = _candidate.TryParseColor (inputName, out Color actualColor);
-        Assert.True (success);
-        Assert.Equal (r, actualColor.R);
-        Assert.Equal (g, actualColor.G);
-        Assert.Equal (b, actualColor.B);
-    }
-
-    [Theory]
-    [InlineData (null)]
-    [InlineData ("")]
-    [InlineData ("brightlight")]
-    public void TryParseColor_FailsOnInvalidColorName (string? input)
-    {
-        bool success = _candidate.TryParseColor (input, out Color actualColor);
-        Assert.False (success);
-        Assert.Equal (default, actualColor);
-    }
-
-    [Theory]
-    [InlineData ("-12")]
-    [InlineData ("-16737095")]
-    public void TryParseColor_FailsOnInvalidEnumNumber (string input)
-    {
-        bool success = _candidate.TryParseColor (input, out Color actualColor);
-        Assert.False (success);
-        Assert.Equal (default, actualColor);
-    }
-}

+ 2 - 4
Tests/UnitTestsParallelizable/Drawing/Color/StandardColorNameResolverTests.cs

@@ -1,8 +1,6 @@
-#nullable enable
+using Xunit.Abstractions;
 
-using Xunit.Abstractions;
-
-namespace DrawingTests;
+namespace DrawingTests.ColorTests;
 
 public class StandardColorNameResolverTests (ITestOutputHelper output)
 {

+ 268 - 0
Tests/UnitTestsParallelizable/Drawing/Color/StandardColorsTests.cs

@@ -0,0 +1,268 @@
+#pragma warning disable xUnit1031
+
+namespace DrawingTests.ColorTests;
+
+public class StandardColorsTests
+{
+    [Fact]
+    public void GetArgb_HandlesAllStandardColorValues ()
+    {
+        foreach (StandardColor sc in Enum.GetValues<StandardColor> ())
+        {
+            uint argb = StandardColors.GetArgb (sc);
+
+            // Verify alpha is always 0xFF (fully opaque)
+            var alpha = (byte)((argb >> 24) & 0xFF);
+            Assert.Equal (255, alpha);
+
+            // Verify the RGB components match the enum value
+            var enumRgb = (int)sc;
+            uint expectedArgb = (uint)enumRgb | 0xFF000000;
+            Assert.Equal (expectedArgb, argb);
+        }
+    }
+
+    [Theory]
+    [InlineData (StandardColor.Red, 255, 0, 0)]
+    [InlineData (StandardColor.Green, 0, 128, 0)]
+    [InlineData (StandardColor.Blue, 0, 0, 255)]
+    [InlineData (StandardColor.White, 255, 255, 255)]
+    [InlineData (StandardColor.Black, 0, 0, 0)]
+    [InlineData (StandardColor.AliceBlue, 240, 248, 255)]
+    [InlineData (StandardColor.YellowGreen, 154, 205, 50)]
+    public void GetArgb_ReturnsCorrectArgbWithFullAlpha (StandardColor standardColor, byte r, byte g, byte b)
+    {
+        uint argb = StandardColors.GetArgb (standardColor);
+
+        var actualA = (byte)((argb >> 24) & 0xFF);
+        var actualR = (byte)((argb >> 16) & 0xFF);
+        var actualG = (byte)((argb >> 8) & 0xFF);
+        var actualB = (byte)(argb & 0xFF);
+
+        Assert.Equal (255, actualA);
+        Assert.Equal (r, actualR);
+        Assert.Equal (g, actualG);
+        Assert.Equal (b, actualB);
+    }
+
+    [Fact]
+    public void GetColorNames_ContainsAllStandardColorEnumValues ()
+    {
+        string [] enumNames = Enum.GetNames<StandardColor> ().Order ().ToArray ();
+        IReadOnlyList<string> colorNames = StandardColors.GetColorNames ();
+
+        Assert.Equal (enumNames.Length, colorNames.Count);
+        Assert.Equal (enumNames, colorNames);
+    }
+
+    [Fact]
+    public void GetColorNames_IsAlphabeticallySorted ()
+    {
+        IReadOnlyList<string> colorNames = StandardColors.GetColorNames ();
+        string [] sortedNames = colorNames.OrderBy (n => n).ToArray ();
+
+        Assert.Equal (sortedNames, colorNames);
+    }
+
+    [Fact]
+    public void LazyInitialization_IsThreadSafe ()
+    {
+        // Force initialization by calling GetColorNames multiple times in parallel
+        Task [] tasks = new Task [10];
+
+        for (var i = 0; i < tasks.Length; i++)
+        {
+            tasks [i] = Task.Run (() =>
+                                  {
+                                      IReadOnlyList<string> names = StandardColors.GetColorNames ();
+                                      Assert.NotNull (names);
+                                      Assert.NotEmpty (names);
+                                  }
+                                 );
+        }
+
+        Task.WaitAll (tasks);
+    }
+
+    [Fact]
+    public void MapValueFactory_CreatesConsistentMapping ()
+    {
+        // Call TryNameColor multiple times for the same color
+        var testColor = new Color (255, 0);
+
+        bool result1 = StandardColors.TryNameColor (testColor, out string? name1);
+        bool result2 = StandardColors.TryNameColor (testColor, out string? name2);
+
+        Assert.True (result1);
+        Assert.True (result2);
+        Assert.Equal (name1, name2);
+    }
+
+    [Fact]
+    public void ToString_G_Prints_Opaque_ARGB_For_StandardColor_CadetBlue ()
+    {
+        // Without the fix, A=0x00, so "G" prints "#005F9EA0" instead of "#FF5F9EA0".
+        var c = new Color (StandardColor.CadetBlue);
+
+        // Expected: #AARRGGBB with A=FF (opaque)
+        Assert.Equal ("#FF5F9EA0", c.ToString ("G"));
+    }
+
+    [Fact]
+    public void ToString_Returns_Standard_Name_For_StandardColor_CadetBlue ()
+    {
+        // Without the fix, this uses Color(in StandardColor) -> this((int)colorName),
+        // which sets A=0x00 and prevents name resolution (expects A=0xFF).
+        var c = new Color (StandardColor.CadetBlue);
+
+        // Expected: named color
+        Assert.Equal ("CadetBlue", c.ToString ());
+    }
+
+    [Fact]
+    public void TryNameColor_IgnoresAlphaChannel ()
+    {
+        var opaqueRed = new Color (255, 0, 0, 255);
+        var transparentRed = new Color (255, 0, 0, 128);
+
+        Assert.True (StandardColors.TryNameColor (opaqueRed, out string? name1));
+        Assert.True (StandardColors.TryNameColor (transparentRed, out string? name2));
+
+        Assert.Equal (name1, name2);
+        Assert.Equal ("Red", name1);
+    }
+
+    [Fact]
+    public void TryNameColor_ReturnsConsistentResultsForSameArgb ()
+    {
+        List<Color> colors = new ();
+
+        // Create multiple Color instances with the same ARGB values
+        for (var i = 0; i < 5; i++)
+        {
+            colors.Add (new (255, 0));
+        }
+
+        HashSet<string?> names = new ();
+
+        foreach (Color color in colors)
+        {
+            StandardColors.TryNameColor (color, out string? name);
+            names.Add (name);
+        }
+
+        // All should resolve to the same name
+        Assert.Single (names);
+        Assert.Equal ("Red", names.First ());
+    }
+
+    [Fact]
+    public void TryNameColor_ReturnsFalseForUnknownColor ()
+    {
+        var unknownColor = new Color (1, 2, 3);
+        bool result = StandardColors.TryNameColor (unknownColor, out string? name);
+
+        Assert.False (result);
+        Assert.Null (name);
+    }
+
+    [Fact]
+    public void TryNameColor_ReturnsFirstAlphabeticalNameForAliasedColors ()
+    {
+        // Aqua and Cyan have the same RGB values
+        var aqua = new Color (0, 255, 255);
+        Assert.True (StandardColors.TryNameColor (aqua, out string? name));
+
+        // Should return the alphabetically first name
+        Assert.Equal ("Aqua", name);
+    }
+
+    [Theory]
+    [InlineData (nameof (StandardColor.Aqua), nameof (StandardColor.Cyan))]
+    [InlineData (nameof (StandardColor.Fuchsia), nameof (StandardColor.Magenta))]
+    [InlineData (nameof (StandardColor.DarkGray), nameof (StandardColor.DarkGrey))]
+    [InlineData (nameof (StandardColor.DarkSlateGray), nameof (StandardColor.DarkSlateGrey))]
+    [InlineData (nameof (StandardColor.DimGray), nameof (StandardColor.DimGrey))]
+    [InlineData (nameof (StandardColor.Gray), nameof (StandardColor.Grey))]
+    [InlineData (nameof (StandardColor.LightGray), nameof (StandardColor.LightGrey))]
+    [InlineData (nameof (StandardColor.LightSlateGray), nameof (StandardColor.LightSlateGrey))]
+    [InlineData (nameof (StandardColor.SlateGray), nameof (StandardColor.SlateGrey))]
+    public void TryParseColor_HandlesColorAliases (string name1, string name2)
+    {
+        Assert.True (StandardColors.TryParseColor (name1, out Color color1));
+        Assert.True (StandardColors.TryParseColor (name2, out Color color2));
+
+        Assert.Equal (color1, color2);
+    }
+
+    [Theory]
+    [InlineData (StandardColor.AmberPhosphor, 255, 191, 0)]
+    [InlineData (StandardColor.GreenPhosphor, 0, 255, 102)]
+    [InlineData (StandardColor.GuppieGreen, 173, 255, 47)]
+    public void TryParseColor_HandlesNonW3CColors (StandardColor color, byte r, byte g, byte b)
+    {
+        bool result = StandardColors.TryParseColor (color.ToString (), out Color parsedColor);
+
+        Assert.True (result);
+        Assert.Equal (r, parsedColor.R);
+        Assert.Equal (g, parsedColor.G);
+        Assert.Equal (b, parsedColor.B);
+    }
+
+    [Fact]
+    public void TryParseColor_IsCaseInsensitive ()
+    {
+        Assert.True (StandardColors.TryParseColor ("RED", out Color upperColor));
+        Assert.True (StandardColors.TryParseColor ("red", out Color lowerColor));
+        Assert.True (StandardColors.TryParseColor ("Red", out Color mixedColor));
+
+        Assert.Equal (upperColor, lowerColor);
+        Assert.Equal (upperColor, mixedColor);
+        Assert.Equal (255, upperColor.R);
+        Assert.Equal (0, upperColor.G);
+        Assert.Equal (0, upperColor.B);
+    }
+
+    [Theory]
+    [InlineData ("")]
+    [InlineData ("NotAColor")]
+    [InlineData ("123456")]
+    [InlineData ("-1")]
+    public void TryParseColor_ReturnsFalseForInvalidInput (string invalidInput)
+    {
+        bool result = StandardColors.TryParseColor (invalidInput, out Color color);
+
+        Assert.False (result);
+        Assert.Equal (default (Color), color);
+    }
+
+    [Fact]
+    public void TryParseColor_SetsAlphaToFullyOpaque ()
+    {
+        Assert.True (StandardColors.TryParseColor ("Red", out Color color));
+
+        Assert.Equal (255, color.A);
+    }
+
+    [Fact]
+    public void TryParseColor_WithEmptySpan_ReturnsFalse ()
+    {
+        ReadOnlySpan<char> emptySpan = ReadOnlySpan<char>.Empty;
+        bool result = StandardColors.TryParseColor (emptySpan, out Color color);
+
+        Assert.False (result);
+        Assert.Equal (default (Color), color);
+    }
+
+    [Fact]
+    public void TryParseColor_WithReadOnlySpan_WorksCorrectly ()
+    {
+        ReadOnlySpan<char> span = "Red".AsSpan ();
+        bool result = StandardColors.TryParseColor (span, out Color color);
+
+        Assert.True (result);
+        Assert.Equal (255, color.R);
+        Assert.Equal (0, color.G);
+        Assert.Equal (0, color.B);
+    }
+}

+ 1 - 1
Tests/UnitTestsParallelizable/Drawing/LineCanvasTests.cs → Tests/UnitTestsParallelizable/Drawing/Lines/LineCanvasTests.cs

@@ -2,7 +2,7 @@
 using UnitTests;
 using Xunit.Abstractions;
 
-namespace DrawingTests;
+namespace DrawingTests.Lines;
 
 /// <summary>
 ///     Pure unit tests for <see cref="LineCanvas"/> that don't require Application.Driver or View context.

+ 1 - 1
Tests/UnitTestsParallelizable/Drawing/StraightLineExtensionsTests.cs → Tests/UnitTestsParallelizable/Drawing/Lines/StraightLineExtensionsTests.cs

@@ -1,7 +1,7 @@
 using UnitTests;
 using Xunit.Abstractions;
 
-namespace DrawingTests;
+namespace UnitTests.Parallelizable.Drawing.Lines;
 
 public class StraightLineExtensionsTests (ITestOutputHelper output)
 {

+ 1 - 1
Tests/UnitTestsParallelizable/Drawing/StraightLineTests.cs → Tests/UnitTestsParallelizable/Drawing/Lines/StraightLineTests.cs

@@ -1,6 +1,6 @@
 using Xunit.Abstractions;
 
-namespace DrawingTests;
+namespace UnitTests.Parallelizable.Drawing.Lines;
 
 public class StraightLineTests (ITestOutputHelper output)
 {

+ 1 - 1
Tests/UnitTestsParallelizable/Drawing/Region/DifferenceTests.cs

@@ -1,6 +1,6 @@
 using Xunit.Sdk;
 
-namespace DrawingTests;
+namespace DrawingTests.RegionTests;
 
 public class DifferenceTests
 {

+ 1 - 1
Tests/UnitTestsParallelizable/Drawing/Region/DrawOuterBoundaryTests.cs

@@ -1,7 +1,7 @@
 using System.Collections.Concurrent;
 using Xunit.Abstractions;
 
-namespace DrawingTests;
+namespace DrawingTests.RegionTests;
 
 /// <summary>
 ///     Tests for <see cref="Region.DrawOuterBoundary"/>.

+ 1 - 1
Tests/UnitTestsParallelizable/Drawing/Region/MergeRectanglesTests.cs

@@ -1,4 +1,4 @@
-namespace DrawingTests;
+namespace DrawingTests.RegionTests;
 
 
 public class MergeRectanglesTests

+ 2 - 2
Tests/UnitTestsParallelizable/Drawing/Region/RegionTests.cs → Tests/UnitTestsParallelizable/Drawing/Region/RegionClassTests.cs

@@ -1,6 +1,6 @@
-namespace DrawingTests;
+namespace DrawingTests.RegionTests;
 
-public class RegionTests
+public class RegionClassTests
 {
     [Fact]
     public void Clone_CreatesExactCopy ()

+ 1 - 1
Tests/UnitTestsParallelizable/Drawing/Region/SubtractRectangleTests.cs

@@ -1,4 +1,4 @@
-namespace DrawingTests;
+namespace DrawingTests.RegionTests;
 
 using Xunit;
 

+ 1 - 1
Tests/UnitTestsParallelizable/runsettings.coverage.xml

@@ -21,7 +21,7 @@
 		<ParallelizeAssembly>true</ParallelizeAssembly>
 		<ParallelizeTestCollections>true</ParallelizeTestCollections>
 		<!-- Enable collection parallelism -->
-		<MaxParallelThreads>unlimited</MaxParallelThreads>
+		<MaxParallelThreads>2x</MaxParallelThreads>
 		<!-- Or 'unlimited' / '2x' for CPU multiplier -->
 		<StopOnFail>true</StopOnFail>
 		<!-- Still stop on first failure -->

+ 1 - 1
Tests/UnitTestsParallelizable/runsettings.xml

@@ -6,7 +6,7 @@
 		<ParallelizeAssembly>true</ParallelizeAssembly>
 		<ParallelizeTestCollections>true</ParallelizeTestCollections>
 		<!-- Enable collection parallelism -->
-		<MaxParallelThreads>unlimited</MaxParallelThreads>
+		<MaxParallelThreads>2x</MaxParallelThreads>
 		<!-- Or 'unlimited' / '2x' for CPU multiplier -->
 		<StopOnFail>true</StopOnFail>
 		<!-- Still stop on first failure -->

+ 1 - 1
Tests/UnitTestsParallelizable/xunit.runner.json

@@ -3,5 +3,5 @@
   "parallelizeTestCollections": true,
   "parallelizeAssembly": true,
   "stopOnFail": false,
-  "maxParallelThreads": "default"
+  "maxParallelThreads": "4x"
 }

+ 192 - 185
docfx/docs/application.md

@@ -18,7 +18,7 @@ Terminal.Gui v2 uses an instance-based application architecture with the **IRunn
 graph TB
     subgraph ViewTree["View Hierarchy (SuperView/SubView)"]
         direction TB
-        Top[app.Current<br/>Window]
+        Top[app.TopRunnable<br/>Window]
         Menu[MenuBar]
         Status[StatusBar]
         Content[Content View]
@@ -59,19 +59,19 @@ sequenceDiagram
     
     App->>Main: Run(mainWindow)
     activate Main
-    Note over App: SessionStack: [Main]<br/>Current: Main
+    Note over App: SessionStack: [Main]<br/>TopRunnable: Main
     
     Main->>Dialog: Run(dialog)
     activate Dialog
-    Note over App: SessionStack: [Dialog, Main]<br/>Current: Dialog
+    Note over App: SessionStack: [Dialog, Main]<br/>TopRunnable: Dialog
     
     Dialog->>App: RequestStop()
     deactivate Dialog
-    Note over App: SessionStack: [Main]<br/>Current: Main
+    Note over App: SessionStack: [Main]<br/>TopRunnable: Main
     
     Main->>App: RequestStop()
     deactivate Main
-    Note over App: SessionStack: []<br/>Current: null
+    Note over App: SessionStack: []<br/>TopRunnable: null
 ```
 
 ## Key Concepts
@@ -82,37 +82,37 @@ sequenceDiagram
 
 ```csharp
 // OLD (v1 / early v2 - still works but obsolete):
-Application.Init();
-var top = new Window();
-top.Add(myView);
-Application.Run(top);
-top.Dispose();
-Application.Shutdown(); // Obsolete - use Dispose() instead
+Application.Init ();
+Window top = new ();
+top.Add (myView);
+Application.Run (top);
+top.Dispose ();
+Application.Shutdown (); // Obsolete - use Dispose() instead
 
 // RECOMMENDED (v2 - instance-based with using statement):
-using (var app = Application.Create().Init())
+using (IApplication app = Application.Create ().Init ())
 {
-    var top = new Window();
-    top.Add(myView);
-    app.Run(top);
-    top.Dispose();
+    Window top = new ();
+    top.Add (myView);
+    app.Run (top);
+    top.Dispose ();
 } // app.Dispose() called automatically
 
 // WITH IRunnable (fluent API with automatic disposal):
-using (var app = Application.Create().Init())
+using (IApplication app = Application.Create ().Init ())
 {
-    app.Run<ColorPickerDialog>();
-    Color? result = app.GetResult<Color>();
+    app.Run<ColorPickerDialog> ();
+    Color? result = app.GetResult<Color> ();
 }
 
 // SIMPLEST (manual disposal):
-var app = Application.Create().Init();
-app.Run<ColorPickerDialog>();
-Color? result = app.GetResult<Color>();
-app.Dispose();
+IApplication app = Application.Create ().Init ();
+app.Run<ColorPickerDialog> ();
+Color? result = app.GetResult<Color> ();
+app.Dispose ();
 ```
 
-**Note:** The static `Application` class delegates to `ApplicationImpl.Instance` (a singleton). `Application.Create()` creates a **new** `ApplicationImpl` instance, enabling multiple application contexts and better testability.
+**Note:** The static `Application` class delegates to a singleton instance accessible via `Application.Instance`. `Application.Create()` creates a **new** application instance, enabling multiple application contexts and better testability.
 
 ### View.App Property
 
@@ -130,7 +130,7 @@ public class View
     /// Gets the application context, checking parent hierarchy if needed.
     /// Override to customize application resolution.
     /// </summary>
-    public virtual IApplication? GetApp() => App ?? SuperView?.GetApp();
+    public virtual IApplication? GetApp () => App ?? SuperView?.GetApp ();
 }
 ```
 
@@ -147,10 +147,10 @@ public class View
 ```csharp
 public class MyView : View
 {
-    public override void OnEnter(View view)
+    public override void OnEnter (View view)
     {
         // Use View.App instead of static Application
-        App?.Current?.SetNeedsDraw();
+        App?.TopRunnable?.SetNeedsDraw ();
         
         // Access SessionStack
         if (App?.SessionStack.Count > 0)
@@ -168,15 +168,15 @@ public class MyView : View
 {
     private readonly IApplication _app;
     
-    public MyView(IApplication app)
+    public MyView (IApplication app)
     {
         _app = app;
         // Now completely decoupled from static Application
     }
     
-    public void DoWork()
+    public void DoWork ()
     {
-        _app.Current?.SetNeedsDraw();
+        _app.TopRunnable?.SetNeedsDraw ();
     }
 }
 ```
@@ -199,26 +199,26 @@ The fluent API enables elegant method chaining with automatic resource managemen
 
 ```csharp
 // Recommended: using statement with GetResult
-using (var app = Application.Create().Init())
+using (IApplication app = Application.Create ().Init ())
 {
-    app.Run<ColorPickerDialog>();
-    Color? result = app.GetResult<Color>();
+    app.Run<ColorPickerDialog> ();
+    Color? result = app.GetResult<Color> ();
     
     if (result is { })
     {
-        ApplyColor(result);
+        ApplyColor (result);
     }
 }
 
 // Alternative: Manual disposal
-var app = Application.Create().Init();
-app.Run<ColorPickerDialog>();
-Color? result = app.GetResult<Color>();
-app.Dispose();
+IApplication app = Application.Create ().Init ();
+app.Run<ColorPickerDialog> ();
+Color? result = app.GetResult<Color> ();
+app.Dispose ();
 
 if (result is { })
 {
-    ApplyColor(result);
+    ApplyColor (result);
 }
 ```
 
@@ -240,19 +240,19 @@ if (result is { })
 
 ```csharp
 // Framework ownership - automatic disposal
-using (var app = Application.Create().Init())
+using (IApplication app = Application.Create ().Init ())
 {
-    app.Run<MyDialog>(); // Dialog disposed automatically when Run returns
-    var result = app.GetResult<MyResultType>();
+    app.Run<MyDialog> (); // Dialog disposed automatically when Run returns
+    MyResultType? result = app.GetResult<MyResultType> ();
 }
 
 // Caller ownership - manual disposal
-using (var app = Application.Create().Init())
+using (IApplication app = Application.Create ().Init ())
 {
-    var dialog = new MyDialog();
-    app.Run(dialog);
-    var result = dialog.Result;
-    dialog.Dispose();  // Caller must dispose
+    MyDialog dialog = new ();
+    app.Run (dialog);
+    MyResultType? result = dialog.Result;
+    dialog.Dispose ();  // Caller must dispose
 }
 ```
 
@@ -265,35 +265,36 @@ public class FileDialog : Runnable<string?>
 {
     private TextField _pathField;
     
-    public FileDialog()
+    public FileDialog ()
     {
         Title = "Select File";
         
-        _pathField = new TextField { X = 1, Y = 1, Width = Dim.Fill(1) };
+        _pathField = new () { X = 1, Y = 1, Width = Dim.Fill (1) };
         
-        var okButton = new Button { Text = "OK", IsDefault = true };
-        okButton.Accepting += (s, e) => {
+        Button okButton = new () { Text = "OK", IsDefault = true };
+        okButton.Accepting += (s, e) =>
+        {
             Result = _pathField.Text;
-            Application.RequestStop();
+            Application.RequestStop ();
         };
         
-        Add(_pathField, okButton);
+        Add (_pathField, okButton);
     }
     
-    protected override bool OnIsRunningChanging(bool oldValue, bool newValue)
+    protected override bool OnIsRunningChanging (bool oldValue, bool newValue)
     {
         if (!newValue)  // Stopping - extract result before disposal
         {
             Result = _pathField?.Text;
         }
-        return base.OnIsRunningChanging(oldValue, newValue);
+        return base.OnIsRunningChanging (oldValue, newValue);
     }
 }
 ```
 
 ### Lifecycle Properties
 
-- **`IsRunning`** - True when runnable is on `RunnableSessionStack`
+- **`IsRunning`** - True when runnable is on `SessionStack`
 - **`IsModal`** - True when runnable is at top of stack (capturing all input)
 - **`Result`** - Typed result value set before stopping
 
@@ -310,7 +311,7 @@ All events follow Terminal.Gui's Cancellable Work Pattern:
 **Example - Result Extraction:**
 
 ```csharp
-protected override bool OnIsRunningChanging(bool oldValue, bool newValue)
+protected override bool OnIsRunningChanging (bool oldValue, bool newValue)
 {
     if (!newValue)  // Stopping
     {
@@ -318,33 +319,39 @@ protected override bool OnIsRunningChanging(bool oldValue, bool newValue)
         Result = _colorPicker.SelectedColor;
         
         // Optionally cancel stop (e.g., unsaved changes)
-        if (HasUnsavedChanges())
+        if (HasUnsavedChanges ())
         {
-            int response = MessageBox.Query("Save?", "Save changes?", "Yes", "No", "Cancel");
-            if (response == 2) return true;  // Cancel stop
-            if (response == 0) Save();
+            var response = MessageBox.Query ("Save?", "Save changes?", "Yes", "No", "Cancel");
+            if (response == 2)
+            {
+                return true;  // Cancel stop
+            }
+            if (response == 0)
+            {
+                Save ();
+            }
         }
     }
     
-    return base.OnIsRunningChanging(oldValue, newValue);
+    return base.OnIsRunningChanging (oldValue, newValue);
 }
 ```
 
-### RunnableSessionStack
+### SessionStack
 
-The `RunnableSessionStack` manages all running `IRunnable` sessions:
+The `SessionStack` manages all running `IRunnable` sessions:
 
 ```csharp
 public interface IApplication
 {
     /// <summary>
     /// Stack of running IRunnable sessions.
-    /// Each entry is a RunnableSessionToken wrapping an IRunnable.
+    /// Each entry is a SessionToken wrapping an IRunnable.
     /// </summary>
-    ConcurrentStack<RunnableSessionToken>? RunnableSessionStack { get; }
+    ConcurrentStack<SessionToken>? SessionStack { get; }
     
     /// <summary>
-    /// The IRunnable at the top of RunnableSessionStack (currently modal).
+    /// The IRunnable at the top of SessionStack (currently modal).
     /// </summary>
     IRunnable? TopRunnable { get; }
 }
@@ -353,9 +360,9 @@ public interface IApplication
 **Stack Behavior:**
 
 - Push: `Begin(IRunnable)` adds to top of stack
-- Pop: `End(RunnableSessionToken)` removes from stack
+- Pop: `End(SessionToken)` removes from stack
 - Peek: `TopRunnable` returns current modal runnable
-- All: `RunnableSessionStack` enumerates all running sessions
+- All: `SessionStack` enumerates all running sessions
 
 ## IApplication Interface
 
@@ -374,19 +381,19 @@ public interface IApplication
     IMainLoopCoordinator? Coordinator { get; }
     
     // Fluent API methods  
-    IApplication Init(string? driverName = null);
-    void Dispose(); // IDisposable
+    IApplication Init (string? driverName = null);
+    void Dispose (); // IDisposable
     
     // Runnable methods
-    SessionToken? Begin(IRunnable runnable);
-    object? Run(IRunnable runnable, Func<Exception, bool>? errorHandler = null);
-    IApplication Run<TRunnable>(Func<Exception, bool>? errorHandler = null) where TRunnable : IRunnable, new();
-    void RequestStop(IRunnable? runnable);
-    void End(SessionToken sessionToken);
+    SessionToken? Begin (IRunnable runnable);
+    object? Run (IRunnable runnable, Func<Exception, bool>? errorHandler = null);
+    IApplication Run<TRunnable> (Func<Exception, bool>? errorHandler = null) where TRunnable : IRunnable, new();
+    void RequestStop (IRunnable? runnable);
+    void End (SessionToken sessionToken);
     
     // Result extraction
-    object? GetResult();
-    T? GetResult<T>() where T : class;
+    object? GetResult ();
+    T? GetResult<T> () where T : class;
     
     // ... other members
 }
@@ -423,13 +430,13 @@ The `SessionStack` property is the stack of running sessions:
 
 ```csharp
 // Access all running sessions
-foreach (var runnable in app.SessionStack)
+foreach (SessionToken runnable in app.SessionStack)
 {
     // Process each session
 }
 
 // From within a view
-int sessionCount = App?.SessionStack.Count ?? 0;
+var sessionCount = App?.SessionStack.Count ?? 0;
 ```
 
 **Why "SessionStack" instead of "Runnables"?**
@@ -439,25 +446,25 @@ int sessionCount = App?.SessionStack.Count ?? 0;
 
 ## Migration from Static Application
 
-The static `Application` class delegates to `ApplicationImpl.Instance` (a singleton) and is marked obsolete. All static methods and properties are marked with `[Obsolete]` but remain functional for backward compatibility:
+The static `Application` class delegates to a singleton instance and is marked obsolete. All static methods and properties are marked with `[Obsolete]` but remain functional for backward compatibility:
 
 ```csharp
 public static partial class Application
 {
-    [Obsolete("The legacy static Application object is going away.")]
-    public static View? TopRunnableView => ApplicationImpl.Instance.TopRunnableView;
+    [Obsolete ("The legacy static Application object is going away.")]
+    public static View? TopRunnableView => Instance.TopRunnableView;
     
-    [Obsolete("The legacy static Application object is going away.")]
-    public static IRunnable? TopRunnable => ApplicationImpl.Instance.TopRunnable;
+    [Obsolete ("The legacy static Application object is going away.")]
+    public static IRunnable? TopRunnable => Instance.TopRunnable;
     
-    [Obsolete("The legacy static Application object is going away.")]
-    public static ConcurrentStack<SessionToken>? SessionStack => ApplicationImpl.Instance.SessionStack;
+    [Obsolete ("The legacy static Application object is going away.")]
+    public static ConcurrentStack<SessionToken>? SessionStack => Instance.SessionStack;
     
     // ... other obsolete static members
 }
 ```
 
-**Important:** The static `Application` class uses a singleton (`ApplicationImpl.Instance`), while `Application.Create()` creates new instances. For new code, prefer the instance-based pattern using `Application.Create()`.
+**Important:** The static `Application` class uses a singleton (`Application.Instance`), while `Application.Create()` creates new instances. For new code, prefer the instance-based pattern using `Application.Create()`.
 
 ### Migration Strategies
 
@@ -465,15 +472,15 @@ public static partial class Application
 
 ```csharp
 // OLD:
-void MyMethod()
+void MyMethod ()
 {
-    Application.TopRunnable?.SetNeedsDraw();
+    Application.TopRunnable?.SetNeedsDraw ();
 }
 
 // NEW:
-void MyMethod(View view)
+void MyMethod (View view)
 {
-    view.App?.TopRunnableView?.SetNeedsDraw();
+    view.App?.TopRunnableView?.SetNeedsDraw ();
 }
 ```
 
@@ -481,18 +488,18 @@ void MyMethod(View view)
 
 ```csharp
 // OLD:
-void ProcessSessions()
+void ProcessSessions ()
 {
-    foreach (var runnable in Application.SessionStack)
+    foreach (SessionToken runnable in Application.SessionStack)
     {
         // Process
     }
 }
 
 // NEW:
-void ProcessSessions(IApplication app)
+void ProcessSessions (IApplication app)
 {
-    foreach (var runnable in app.SessionStack)
+    foreach (SessionToken runnable in app.SessionStack)
     {
         // Process
     }
@@ -506,14 +513,14 @@ public class MyService
 {
     private readonly IApplication _app;
     
-    public MyService(IApplication app)
+    public MyService (IApplication app)
     {
         _app = app;
     }
     
-    public void DoWork()
+    public void DoWork ()
     {
-        _app.Current?.Title = "Processing...";
+        _app.TopRunnable?.Title = "Processing...";
     }
 }
 ```
@@ -530,9 +537,9 @@ Terminal.Gui v2 implements the `IDisposable` pattern for proper resource cleanup
 
 ```csharp
 // Automatic disposal with using statement
-using (var app = Application.Create().Init())
+using (IApplication app = Application.Create ().Init ())
 {
-    app.Run<MyDialog>();
+    app.Run<MyDialog> ();
     // app.Dispose() automatically called when scope exits
 }
 ```
@@ -541,15 +548,15 @@ using (var app = Application.Create().Init())
 
 ```csharp
 // Manual disposal
-var app = Application.Create();
+IApplication app = Application.Create ();
 try
 {
-    app.Init();
-    app.Run<MyDialog>();
+    app.Init ();
+    app.Run<MyDialog> ();
 }
 finally
 {
-    app.Dispose(); // Ensure cleanup even if exception occurs
+    app.Dispose (); // Ensure cleanup even if exception occurs
 }
 ```
 
@@ -561,44 +568,44 @@ finally
 
 ```csharp
 // RECOMMENDED (using statement):
-using (var app = Application.Create().Init())
+using (IApplication app = Application.Create ().Init ())
 {
-    app.Run<MyDialog>();
-    var result = app.GetResult<MyResult>();
+    app.Run<MyDialog> ();
+    MyResult? result = app.GetResult<MyResult> ();
     // app.Dispose() called automatically here
 }
 
 // ALTERNATIVE (manual disposal):
-var app = Application.Create().Init();
-app.Run<MyDialog>();
-var result = app.GetResult<MyResult>();
-app.Dispose(); // Must call explicitly
+IApplication app = Application.Create ().Init ();
+app.Run<MyDialog> ();
+MyResult? result = app.GetResult<MyResult> ();
+app.Dispose (); // Must call explicitly
 
 // OLD (obsolete - do not use):
-var result = app.Run<MyDialog>().Shutdown() as MyResult;
+object? result = app.Run<MyDialog> ().Shutdown ();
 ```
 
 ### Input Thread Lifecycle
 
-When you call `Init()`, Terminal.Gui starts a dedicated input thread that continuously polls for console input. This thread must be stopped properly:
+When calling `Init()`, Terminal.Gui starts a dedicated input thread that continuously polls for console input. This thread must be stopped properly:
 
 ```csharp
-var app = Application.Create();
-app.Init("fake"); // Input thread starts here
+IApplication app = Application.Create ();
+app.Init ("fake"); // Input thread starts here
 
 // Input thread runs in background at ~50 polls/second (20ms throttle)
 
-app.Dispose(); // Cancels input thread and waits for it to exit
+app.Dispose (); // Cancels input thread and waits for it to exit
 ```
 
 **Important for Tests**: Always dispose applications in tests to prevent thread leaks:
 
 ```csharp
 [Fact]
-public void My_Test()
+public void My_Test ()
 {
-    using var app = Application.Create();
-    app.Init("fake");
+    using IApplication app = Application.Create ();
+    app.Init ("fake");
     
     // Test code here
     
@@ -612,22 +619,22 @@ The legacy static `Application` singleton can be re-initialized after disposal (
 
 ```csharp
 // Test 1
-Application.Init();
-Application.Shutdown(); // Obsolete but still works for legacy singleton
+Application.Init ();
+Application.Shutdown (); // Obsolete but still works for legacy singleton
 
 // Test 2 - singleton resets and can be re-initialized
-Application.Init(); // ✅ Works!
-Application.Shutdown(); // Obsolete but still works for legacy singleton
+Application.Init (); // ✅ Works!
+Application.Shutdown (); // Obsolete but still works for legacy singleton
 ```
 
 However, instance-based applications follow standard `IDisposable` semantics and cannot be reused after disposal:
 
 ```csharp
-var app = Application.Create();
-app.Init();
-app.Dispose();
+IApplication app = Application.Create ();
+app.Init ();
+app.Dispose ();
 
-app.Init(); // ❌ Throws ObjectDisposedException
+app.Init (); // ❌ Throws ObjectDisposedException
 ```
 
 ## Session Management
@@ -637,21 +644,21 @@ app.Init(); // ❌ Throws ObjectDisposedException
 Applications manage sessions through `Begin()` and `End()`:
 
 ```csharp
-using var app = Application.Create ();
-app.Init();
+using IApplication app = Application.Create ();
+app.Init ();
 
-var window = new Window();
+Window window = new ();
 
 // Begin a new session - pushes to SessionStack
-SessionToken? token = app.Begin(window);
+SessionToken? token = app.Begin (window);
 
 // TopRunnable now points to this window
-Debug.Assert(app.TopRunnable == window);
+Debug.Assert (app.TopRunnable == window);
 
 // End the session - pops from SessionStack
 if (token != null)
 {
-    app.End(token);
+    app.End (token);
 }
 
 // TopRunnable restored to previous runnable (if any)
@@ -662,25 +669,25 @@ if (token != null)
 Multiple sessions can run nested:
 
 ```csharp
-using var app = Application.Create ();
-app.Init();
+using IApplication app = Application.Create ();
+app.Init ();
 
 // Session 1
-var main = new Window { Title = "Main" };
-var token1 = app.Begin(main);
+Window main = new () { Title = "Main" };
+SessionToken? token1 = app.Begin (main);
 // app.TopRunnable == main, SessionStack.Count == 1
 
 // Session 2 (nested)
-var dialog = new Dialog { Title = "Dialog" };
-var token2 = app.Begin(dialog);
+Dialog dialog = new () { Title = "Dialog" };
+SessionToken? token2 = app.Begin (dialog);
 // app.TopRunnable == dialog, SessionStack.Count == 2
 
 // End dialog
-app.End(token2);
+app.End (token2);
 // app.TopRunnable == main, SessionStack.Count == 1
 
 // End main
-app.End(token1);
+app.End (token1);
 // app.TopRunnable == null, SessionStack.Count == 0
 ```
 
@@ -694,24 +701,24 @@ public class View
     /// <summary>
     /// Gets the driver for this view.
     /// </summary>
-    public IDriver? Driver => GetDriver();
+    public IDriver? Driver => GetDriver ();
     
     /// <summary>
     /// Gets the driver, checking application context if needed.
     /// Override to customize driver resolution.
     /// </summary>
-    public virtual IDriver? GetDriver() => App?.Driver;
+    public virtual IDriver? GetDriver () => App?.Driver;
 }
 ```
 
 **Usage:**
 
 ```csharp
-public override void OnDrawContent(Rectangle viewport)
+public override void OnDrawContent (Rectangle viewport)
 {
     // Use view's driver instead of Application.Driver
-    Driver?.Move(0, 0);
-    Driver?.AddStr("Hello");
+    Driver?.Move (0, 0);
+    Driver?.AddStr ("Hello");
 }
 ```
 
@@ -723,44 +730,44 @@ The instance-based architecture dramatically improves testability:
 
 ```csharp
 [Fact]
-public void MyView_DisplaysCorrectly()
+public void MyView_DisplaysCorrectly ()
 {
     // Create mock application
-    var mockApp = new Mock<IApplication>();
-    mockApp.Setup(a => a.Current).Returns(new Runnable());
+    Mock<IApplication> mockApp = new ();
+    mockApp.Setup (a => a.TopRunnable).Returns (new Runnable ());
     
     // Create view with mock app
-    var view = new MyView { App = mockApp.Object };
+    MyView view = new () { App = mockApp.Object };
     
     // Test without Application.Init()!
-    view.SetNeedsDraw();
-    Assert.True(view.NeedsDraw);
+    view.SetNeedsDraw ();
+    Assert.True (view.NeedsDraw);
     
     // No Application.Shutdown() needed!
 }
 ```
 
-### Testing with Real ApplicationImpl
+### Testing with Real Application
 
 ```csharp
 [Fact]
-public void MyView_WorksWithRealApplication()
+public void MyView_WorksWithRealApplication ()
 {
-    using var app = Application.Create ();
-    app.Init("fake");
+    using IApplication app = Application.Create ();
+    app.Init ("fake");
     
-    var view = new MyView();
-    var top = new Window();
-    top.Add(view);
+    MyView view = new ();
+    Window top = new ();
+    top.Add (view);
     
-    app.Begin(top);
+    app.Begin (top);
     
     // View.App automatically set
-    Assert.NotNull(view.App);
-    Assert.Same(app, view.App);
+    Assert.NotNull (view.App);
+    Assert.Same (app, view.App);
     
     // Test view behavior
-    view.DoSomething();
+    view.DoSomething ();
 }
 ```
 
@@ -770,9 +777,9 @@ public void MyView_WorksWithRealApplication()
 
 ```csharp
 ✅ GOOD:
-public void Refresh()
+public void Refresh ()
 {
-    App?.TopRunnableView?.SetNeedsDraw();
+    App?.TopRunnableView?.SetNeedsDraw ();
 }
 ```
 
@@ -780,9 +787,9 @@ public void Refresh()
 
 ```csharp
 ❌ AVOID:
-public void Refresh()
+public void Refresh ()
 {
-    Application.TopRunnableView?.SetNeedsDraw(); // Obsolete!
+    Application.TopRunnableView?.SetNeedsDraw (); // Obsolete!
 }
 ```
 
@@ -792,7 +799,7 @@ public void Refresh()
 ✅ GOOD:
 public class Service
 {
-    public Service(IApplication app) { }
+    public Service (IApplication app) { }
 }
 ```
 
@@ -800,15 +807,15 @@ public class Service
 
 ```csharp
 ❌ AVOID (obsolete pattern):
-public void Refresh()
+public void Refresh ()
 {
-    Application.TopRunnableView?.SetNeedsDraw(); // Obsolete static access
+    Application.TopRunnableView?.SetNeedsDraw (); // Obsolete static access
 }
 
 ✅ PREFERRED:
-public void Refresh()
+public void Refresh ()
 {
-    App?.TopRunnableView?.SetNeedsDraw(); // Use View.App property
+    App?.TopRunnableView?.SetNeedsDraw (); // Use View.App property
 }
 ```
 
@@ -820,9 +827,9 @@ public class SpecialView : View
 {
     private IApplication? _customApp;
     
-    public override IApplication? GetApp()
+    public override IApplication? GetApp ()
     {
-        return _customApp ?? base.GetApp();
+        return _customApp ?? base.GetApp ();
     }
 }
 ```
@@ -835,15 +842,15 @@ The instance-based architecture enables multiple applications:
 
 ```csharp
 // Application 1
-using var app1 = Application.Create ();
-app1.Init("windows");
-var top1 = new Window { Title = "App 1" };
+using IApplication app1 = Application.Create ();
+app1.Init ("windows");
+Window top1 = new () { Title = "App 1" };
 // ... configure top1
 
 // Application 2 (different driver!)
-using var app2 = Application.Create ();
-app2.Init("unix");
-var top2 = new Window { Title = "App 2" };
+using IApplication app2 = Application.Create ();
+app2.Init ("unix");
+Window top2 = new () { Title = "App 2" };
 // ... configure top2
 
 // Views in top1 use app1
@@ -857,14 +864,14 @@ Create views that work with any application:
 ```csharp
 public class UniversalView : View
 {
-    public void ShowMessage(string message)
+    public void ShowMessage (string message)
     {
         // Works regardless of which application context
-        var app = GetApp();
+        IApplication? app = GetApp ();
         if (app != null)
         {
-            var msg = new MessageBox(message);
-            app.Begin(msg);
+            MessageBox msg = new (message);
+            app.Begin (msg);
         }
     }
 }

+ 71 - 0
docfx/docs/drawing.md

@@ -10,6 +10,27 @@ Terminal.Gui provides a set of APIs for formatting text, line drawing, and chara
 
 Terminal.Gui apps draw using the @Terminal.Gui.ViewBase.View.Move(System.Int32,System.Int32) and @Terminal.Gui.ViewBase.View.AddRune(System.Text.Rune) APIs. Move selects the column and row of the cell and AddRune places the specified glyph in that cell using the @Terminal.Gui.Drawing.Attribute that was most recently set via @Terminal.Gui.ViewBase.View.SetAttribute(Terminal.Gui.Drawing.Attribute). The driver caches all changed Cells and efficiently outputs them to the terminal each iteration of the Application. In other words, Terminal.Gui uses deferred rendering. 
 
+## Drawing Lifecycle
+
+**Drawing occurs during Application MainLoop iterations**, not immediately when draw-related methods are called. This deferred rendering approach provides better performance and ensures visual consistency.
+
+### MainLoop Iteration Process
+
+Each iteration of the @Terminal.Gui.App.Application MainLoop (throttled to a maximum rate) performs these steps in order:
+
+1. **Layout** - Views that need layout are measured and positioned (@Terminal.Gui.ViewBase.View.LayoutSubviews is called)
+2. **Draw** - Views that need drawing update the driver's back buffer (@Terminal.Gui.ViewBase.View.Draw is called)
+3. **Write** - The driver writes changed portions of the back buffer to the actual terminal
+4. **Cursor** - The driver ensures the cursor is positioned correctly with appropriate visibility
+
+### When Drawing Actually Occurs
+
+- **Normal Operation**: Drawing happens automatically during MainLoop iterations when @Terminal.Gui.ViewBase.View.NeedsDraw or @Terminal.Gui.ViewBase.View.SubViewNeedsDraw is set
+- **Forced Update**: @Terminal.Gui.App.Application.LayoutAndDraw can be called to immediately trigger layout and drawing outside of the normal iteration cycle
+- **Testing**: Tests can call @Terminal.Gui.ViewBase.View.Draw directly to update the back buffer, then call @Terminal.Gui.Drivers.IDriver.Refresh to output to the terminal
+
+**Important**: Calling `View.Draw()` does not immediately update the terminal screen. It only updates the driver's back buffer. The actual terminal output occurs when the driver's `Refresh()` method is called, which happens automatically during MainLoop iterations.
+
 ## Coordinate System for Drawing
 
 The @Terminal.Gui.ViewBase.View draw APIs all take coordinates specified in *Viewport-Relative* coordinates. That is, `0, 0` is the top-left cell visible to the user.
@@ -60,6 +81,8 @@ Then, after the above steps have completed, the Mainloop will iterate through al
 
 If a View need to redraw because something changed within it's Content Area it can call @Terminal.Gui.ViewBase.View.SetNeedsDraw. If a View needs to be redrawn because something has changed the size of the Viewport, it can call @Terminal.Gui.ViewBase.View.SetNeedsLayout.
 
+**Note**: Calling `SetNeedsDraw()` does not immediately cause drawing to occur. It marks the view as needing to be redrawn, which will happen in the next MainLoop iteration. To force immediate drawing (typically only needed in tests), call @Terminal.Gui.App.Application.LayoutAndDraw.
+
 ## Clipping
 
 Clipping enables better performance and features like transparent margins by ensuring regions of the terminal that need to be drawn actually get drawn by the driver. Terminal.Gui supports non-rectangular clip regions with @Terminal.Gui.Drawing.Region. The driver.Clip is the application managed clip region and is managed by @Terminal.Gui.App.Application. Developers cannot change this directly, but can use @Terminal.Gui.ViewBase.View.SetClipToScreen, @Terminal.Gui.ViewBase.View.SetClip(Terminal.Gui.Drawing.Region), @Terminal.Gui.ViewBase.View.SetClipToFrame, etc...
@@ -98,6 +121,54 @@ SetAttributeForRole (VisualRole.Focus);
 AddStr ("Red on Black Underlined.");
 ```
 
+## Color
+
+Terminal.Gui supports 24-bit true color (16.7 million colors) via the @Terminal.Gui.Drawing.Color struct. The @Terminal.Gui.Drawing.Color struct represents colors in ARGB32 format, with separate bytes for Alpha (transparency), Red, Green, and Blue components.
+
+### Standard Colors (W3C+)
+
+Terminal.Gui provides comprehensive support for W3C standard color names plus additional common terminal colors via the @Terminal.Gui.Drawing.StandardColor enum. This includes all standard W3C colors (like `AliceBlue`, `Red`, `Tomato`, etc.) as well as classic terminal colors (like `AmberPhosphor`, `GreenPhosphor`).
+
+Colors can be created from standard color names:
+
+```cs
+var color1 = new Color(StandardColor.CornflowerBlue);
+var color2 = new Color(StandardColor.Tomato);
+var color3 = new Color("Red");  // Case-insensitive color name parsing
+```
+
+Standard colors can also be parsed from strings:
+
+```cs
+if (Color.TryParse("CornflowerBlue", out Color color))
+{
+    // Use the color
+}
+```
+
+### Alpha Channel and Transparency
+
+While @Terminal.Gui.Drawing.Color supports an alpha channel for transparency (values 0-255), **terminal rendering does not currently support alpha blending**. The alpha channel is primarily used to:
+
+- Indicate whether a color should be rendered at all (alpha = 0 means fully transparent/don't render)
+- Support future transparency features
+- Enable terminal background pass-through (see [#2381](https://github.com/gui-cs/Terminal.Gui/issues/2381) and [#4229](https://github.com/gui-cs/Terminal.Gui/issues/4229))
+
+**Important**: When matching colors to standard color names, the alpha channel is **ignored**. This means `Color(255, 0, 0, 255)` (opaque red) and `Color(255, 0, 0, 128)` (semi-transparent red) will both be recognized as "Red". This design decision supports the vision of enabling transparent backgrounds while still being able to identify colors semantically.
+
+```cs
+var opaqueRed = new Color(255, 0, 0, 255);
+var transparentRed = new Color(255, 0, 0, 0);
+
+// Both will resolve to "Red"
+ColorStrings.GetColorName(opaqueRed);      // Returns "Red"
+ColorStrings.GetColorName(transparentRed); // Returns "Red"
+```
+
+### Legacy 16-Color Support
+
+For backwards compatibility and terminals with limited color support, Terminal.Gui maintains the legacy 16-color system via @Terminal.Gui.Drawing.ColorName16. When true color is not available or when `Application.Force16Colors` is set, Terminal.Gui will map true colors to the nearest 16-color equivalent.
+
 ## VisualRole
 
 Represents the semantic visual role of a visual element rendered by a View (e.g., Normal text, Focused item, Active selection).

+ 3 - 4
docfx/docs/drivers.md

@@ -97,7 +97,7 @@ The driver architecture employs a **multi-threaded design** for optimal responsi
 
 ```
 ┌─────────────────────────────────────────────┐
-│         ApplicationImpl.Init()              │
+│         IApplication.Init()              │
 │  Creates MainLoopCoordinator<T> with        │
 │  ComponentFactory<T>                        │
 └────────────────┬────────────────────────────┘
@@ -128,7 +128,7 @@ This separation ensures that input is never lost and the UI remains responsive d
 
 When you call `Application.Init()`:
 
-1. **ApplicationImpl.Init()** is invoked
+1. **IApplication.Init()** is invoked
 2. Creates a `MainLoopCoordinator<T>` with the appropriate `ComponentFactory<T>`
 3. **MainLoopCoordinator.StartAsync()** begins:
    - Starts the input thread which creates `IInput<T>`
@@ -220,6 +220,5 @@ This ensures Terminal.Gui applications can be debugged directly in Visual Studio
 ## See Also
 
 - @Terminal.Gui.Drivers - API Reference
-- @Terminal.Gui.App.Application - Application class
-- @Terminal.Gui.App.ApplicationImpl - Application implementation
+- @Terminal.Gui.App.IApplication - Application interface
 - @Terminal.Gui.App.MainLoopCoordinator`1 - Main loop coordination

+ 1 - 1
docfx/docs/keyboard.md

@@ -230,7 +230,7 @@ The @Terminal.Gui.App.Keyboard class implements @Terminal.Gui.App.IKeyboard and
 - **Events**: KeyDown, KeyUp events for application-level keyboard monitoring
 - **Command Implementations**: Handlers for Application-scoped commands (Quit, Suspend, Navigation, Refresh, Arrange)
 
-The @Terminal.Gui.App.ApplicationImpl class creates and manages the @Terminal.Gui.App.IKeyboard instance, setting its `IApplication` property to `this` to provide the necessary @Terminal.Gui.App.IApplication reference.
+The @Terminal.Gui.App.IApplication implementations create and manage the @Terminal.Gui.App.IKeyboard instance, setting its `IApplication` property to `this` to provide the necessary @Terminal.Gui.App.IApplication reference.
 
 ## Driver
 

+ 1114 - 0
docfx/docs/migratingfromv1.md

@@ -0,0 +1,1114 @@
+# Migrating From v1 To v2
+
+This document provides a comprehensive guide for migrating applications from Terminal.Gui v1 to v2. 
+
+For detailed breaking change documentation, check out this Discussion: https://github.com/gui-cs/Terminal.Gui/discussions/2448
+
+## Table of Contents
+
+- [Overview of Major Changes](#overview-of-major-changes)
+- [Application Architecture](#application-architecture)
+- [View Construction and Initialization](#view-construction-and-initialization)
+- [Layout System Changes](#layout-system-changes)
+- [Color and Attribute Changes](#color-and-attribute-changes)
+- [Type Changes](#type-changes)
+- [Unicode and Text](#unicode-and-text)
+- [Keyboard API](#keyboard-api)
+- [Mouse API](#mouse-api)
+- [Navigation Changes](#navigation-changes)
+- [Scrolling Changes](#scrolling-changes)
+- [Adornments](#adornments)
+- [Event Pattern Changes](#event-pattern-changes)
+- [View-Specific Changes](#view-specific-changes)
+- [Disposal and Resource Management](#disposal-and-resource-management)
+- [API Terminology Changes](#api-terminology-changes)
+
+---
+
+## Overview of Major Changes
+
+Terminal.Gui v2 represents a major architectural evolution with these key improvements:
+
+1. **Instance-Based Application Model** - Move from static `Application` to `IApplication` instances
+2. **IRunnable Architecture** - Interface-based runnable pattern with type-safe results
+3. **Simplified Layout** - Removed Absolute/Computed distinction, improved adornments
+4. **24-bit TrueColor** - Full color support by default
+5. **Enhanced Input** - Better keyboard and mouse APIs
+6. **Built-in Scrolling** - All views support scrolling inherently
+7. **Fluent API** - Method chaining for elegant code
+8. **Proper Disposal** - IDisposable pattern throughout
+
+---
+
+## Application Architecture
+
+### Instance-Based Application Model
+
+**v1 Pattern (Static):**
+```csharp
+// v1 - static Application
+Application.Init();
+var top = Application.Top;
+top.Add(myView);
+Application.Run();
+Application.Shutdown();
+```
+
+**v2 Recommended Pattern (Instance-Based):**
+```csharp
+// v2 - instance-based with using statement
+using (var app = Application.Create().Init())
+{
+    var top = new Window();
+    top.Add(myView);
+    app.Run(top);
+    top.Dispose();
+} // app.Dispose() called automatically
+```
+
+**v2 Legacy Pattern (Still Works):**
+```csharp
+// v2 - legacy static (marked obsolete but functional)
+Application.Init();
+var top = new Window();
+top.Add(myView);
+Application.Run(top);
+top.Dispose();
+Application.Shutdown(); // Obsolete - use Dispose() instead
+```
+
+### IRunnable Architecture
+
+v2 introduces `IRunnable<TResult>` for type-safe, runnable views:
+
+```csharp
+// Create a dialog that returns a typed result
+public class FileDialog : Runnable<string?>
+{
+    private TextField _pathField;
+    
+    public FileDialog()
+    {
+        Title = "Select File";
+        _pathField = new TextField { Width = Dim.Fill() };
+        Add(_pathField);
+        
+        var okButton = new Button { Text = "OK", IsDefault = true };
+        okButton.Accepting += (s, e) => {
+            Result = _pathField.Text;
+            Application.RequestStop();
+        };
+        AddButton(okButton);
+    }
+    
+    protected override bool OnIsRunningChanging(bool oldValue, bool newValue)
+    {
+        if (!newValue)  // Stopping - extract result before disposal
+        {
+            Result = _pathField?.Text;
+        }
+        return base.OnIsRunningChanging(oldValue, newValue);
+    }
+}
+
+// Use with fluent API
+using (var app = Application.Create().Init())
+{
+    app.Run<FileDialog>();
+    string? result = app.GetResult<string>();
+    
+    if (result is { })
+    {
+        OpenFile(result);
+    }
+}
+```
+
+**Key Benefits:**
+- Type-safe results (no casting)
+- Automatic disposal of framework-created runnables
+- CWP-compliant lifecycle events
+- Works with any View (not just Toplevel)
+
+### Disposal and Resource Management
+
+v2 requires explicit disposal:
+
+```csharp
+// ❌ v1 - Application.Shutdown() disposed everything
+Application.Init();
+var top = new Window();
+Application.Run(top);
+Application.Shutdown(); // Disposed top automatically
+
+// ✅ v2 - Dispose views explicitly
+using (var app = Application.Create().Init())
+{
+    var top = new Window();
+    app.Run(top);
+    top.Dispose(); // Must dispose
+}
+
+// ✅ v2 - Framework-created runnables disposed automatically
+using (var app = Application.Create().Init())
+{
+    app.Run<MyDialog>(); // Dialog disposed automatically
+    var result = app.GetResult<MyResult>();
+}
+```
+
+**Disposal Rules:**
+- "Whoever creates it, owns it"
+- `Run<TRunnable>()`: Framework creates → Framework disposes
+- `Run(IRunnable)`: Caller creates → Caller disposes
+- Always dispose `IApplication` (use `using` statement)
+
+### View.App Property
+
+Views now have an `App` property for accessing the application context:
+
+```csharp
+// ❌ v1 - Direct static reference
+Application.Driver.Move(x, y);
+
+// ✅ v2 - Use View.App
+App?.Driver.Move(x, y);
+
+// ✅ v2 - Dependency injection
+public class MyView : View
+{
+    private readonly IApplication _app;
+    
+    public MyView(IApplication app)
+    {
+        _app = app;
+    }
+}
+```
+
+---
+
+## View Construction and Initialization
+
+### Constructors → Initializers
+
+**v1:**
+```csharp
+var myView = new View(new Rect(10, 10, 40, 10));
+```
+
+**v2:**
+```csharp
+var myView = new View 
+{ 
+    X = 10, 
+    Y = 10, 
+    Width = 40, 
+    Height = 10 
+};
+```
+
+### Initialization Pattern
+
+v2 uses `ISupportInitializeNotification`:
+
+```csharp
+// v1 - No explicit initialization
+var view = new View();
+Application.Run(view);
+
+// v2 - Automatic initialization via BeginInit/EndInit
+var view = new View();
+// BeginInit() called automatically when added to SuperView
+// EndInit() called automatically
+// Initialized event raised after EndInit()
+```
+
+---
+
+## Layout System Changes
+
+### Removed LayoutStyle Distinction
+
+v1 had `Absolute` and `Computed` layout styles. v2 removed this distinction.
+
+**v1:**
+```csharp
+view.LayoutStyle = LayoutStyle.Computed;
+```
+
+**v2:**
+```csharp
+// No LayoutStyle - all layout is declarative via Pos/Dim
+view.X = Pos.Center();
+view.Y = Pos.Center();
+view.Width = Dim.Percent(50);
+view.Height = Dim.Fill();
+```
+
+### Frame vs Bounds
+
+**v1:**
+- `Frame` - Position/size in SuperView coordinates
+- `Bounds` - Always `{0, 0, Width, Height}` (location always empty)
+
+**v2:**
+- `Frame` - Position/size in SuperView coordinates (same as v1)
+- `Viewport` - Visible area in content coordinates (replaces Bounds)
+  - **Important**: `Viewport.Location` can now be non-zero for scrolling
+
+```csharp
+// ❌ v1
+var size = view.Bounds.Size;
+Debug.Assert(view.Bounds.Location == Point.Empty); // Always true
+
+// ✅ v2
+var visibleArea = view.Viewport;
+var contentSize = view.GetContentSize();
+
+// Viewport.Location can be non-zero when scrolled
+view.ScrollVertical(10);
+Debug.Assert(view.Viewport.Location.Y == 10);
+```
+
+### Pos and Dim API Changes
+
+| v1 | v2 |
+|----|-----|
+| `Pos.At(x)` | `Pos.Absolute(x)` |
+| `Dim.Sized(width)` | `Dim.Absolute(width)` |
+| `Pos.Anchor()` | `Pos.GetAnchor()` |
+| `Dim.Anchor()` | `Dim.GetAnchor()` |
+
+```csharp
+// ❌ v1
+view.X = Pos.At(10);
+view.Width = Dim.Sized(20);
+
+// ✅ v2
+view.X = Pos.Absolute(10);
+view.Width = Dim.Absolute(20);
+```
+
+### View.AutoSize Removed
+
+**v1:**
+```csharp
+view.AutoSize = true;
+```
+
+**v2:**
+```csharp
+view.Width = Dim.Auto();
+view.Height = Dim.Auto();
+```
+
+See [Dim.Auto Deep Dive](dimauto.md) for details.
+
+---
+
+## Adornments
+
+v2 adds `Border`, `Margin`, and `Padding` as built-in adornments.
+
+**v1:**
+```csharp
+// Custom border drawing
+view.Border = new Border { /* ... */ };
+```
+
+**v2:**
+```csharp
+// Built-in Border adornment
+view.BorderStyle = LineStyle.Single;
+view.Border.Thickness = new Thickness(1);
+view.Title = "My View";
+
+// Built-in Margin and Padding
+view.Margin.Thickness = new Thickness(2);
+view.Padding.Thickness = new Thickness(1);
+```
+
+See [Layout Deep Dive](layout.md) for complete details.
+
+---
+
+## Color and Attribute Changes
+
+### 24-bit TrueColor Default
+
+v2 uses 24-bit color by default.
+
+```csharp
+// v1 - Limited color palette
+var color = Color.Brown;
+
+// v2 - ANSI-compliant names + TrueColor
+var color = Color.Yellow; // Brown renamed
+var customColor = new Color(0xFF, 0x99, 0x00); // 24-bit RGB
+```
+
+### Attribute.Make Removed
+
+**v1:**
+```csharp
+var attr = Attribute.Make(Color.BrightMagenta, Color.Blue);
+```
+
+**v2:**
+```csharp
+var attr = new Attribute(Color.BrightMagenta, Color.Blue);
+```
+
+### Color Name Changes
+
+| v1 | v2 |
+|----|-----|
+| `Color.Brown` | `Color.Yellow` |
+
+---
+
+## Type Changes
+
+### Low-Level Types
+
+| v1 | v2 |
+|----|-----|
+| `Rect` | `Rectangle` |
+| `Point` | `Point` |
+| `Size` | `Size` |
+
+```csharp
+// ❌ v1
+Rect rect = new Rect(0, 0, 10, 10);
+
+// ✅ v2
+Rectangle rect = new Rectangle(0, 0, 10, 10);
+```
+
+---
+
+## Unicode and Text
+
+### NStack.ustring Removed
+
+**v1:**
+```csharp
+using NStack;
+ustring text = "Hello";
+var width = text.Sum(c => Rune.ColumnWidth(c));
+```
+
+**v2:**
+```csharp
+using System.Text;
+string text = "Hello";
+var width = text.GetColumns(); // Extension method
+```
+
+### Rune Changes
+
+**v1:**
+```csharp
+// Implicit cast
+myView.AddRune(col, row, '▄');
+
+// Width
+var width = Rune.ColumnWidth(rune);
+```
+
+**v2:**
+```csharp
+// Explicit constructor
+myView.AddRune(col, row, new Rune('▄'));
+
+// Width
+var width = rune.GetColumns();
+```
+
+See [Unicode](https://gui-cs.github.io/Terminal.GuiV2Docs/docs/overview.html#unicode) for details.
+
+---
+
+## Keyboard API
+
+v2 has a completely redesigned keyboard API.
+
+### Key Class
+
+**v1:**
+```csharp
+KeyEvent keyEvent;
+if (keyEvent.KeyCode == KeyCode.Enter) { }
+```
+
+**v2:**
+```csharp
+Key key;
+if (key == Key.Enter) { }
+
+// Modifiers
+if (key.Shift) { }
+if (key.Ctrl) { }
+
+// With modifiers
+Key ctrlC = Key.C.WithCtrl;
+Key shiftF1 = Key.F1.WithShift;
+```
+
+### Key Bindings
+
+**v1:**
+```csharp
+// Override OnKeyPress
+protected override bool OnKeyPress(KeyEvent keyEvent)
+{
+    if (keyEvent.KeyCode == KeyCode.Enter)
+    {
+        // Handle
+        return true;
+    }
+    return base.OnKeyPress(keyEvent);
+}
+```
+
+**v2:**
+```csharp
+// Use KeyBindings + Commands
+AddCommand(Command.Accept, HandleAccept);
+KeyBindings.Add(Key.Enter, Command.Accept);
+
+private bool HandleAccept()
+{
+    // Handle
+    return true;
+}
+```
+
+### Application-Wide Keys
+
+**v1:**
+```csharp
+// Hard-coded Ctrl+Q
+if (keyEvent.Key == Key.CtrlMask | Key.Q)
+{
+    Application.RequestStop();
+}
+```
+
+**v2:**
+```csharp
+// Configurable quit key
+if (key == Application.QuitKey)
+{
+    Application.RequestStop();
+}
+
+// Change the quit key
+Application.QuitKey = Key.Esc;
+```
+
+### Navigation Keys
+
+v2 has consistent, configurable navigation keys:
+
+| Key | Purpose |
+|-----|---------|
+| `Tab` | Next TabStop |
+| `Shift+Tab` | Previous TabStop |
+| `F6` | Next TabGroup |
+| `Shift+F6` | Previous TabGroup |
+
+```csharp
+// Configurable
+Application.NextTabStopKey = Key.Tab;
+Application.PrevTabStopKey = Key.Tab.WithShift;
+Application.NextTabGroupKey = Key.F6;
+Application.PrevTabGroupKey = Key.F6.WithShift;
+```
+
+See [Keyboard Deep Dive](keyboard.md) for complete details.
+
+---
+
+## Mouse API
+
+### MouseEventEventArgs → MouseEventArgs
+
+**v1:**
+```csharp
+void HandleMouse(MouseEventEventArgs args) { }
+```
+
+**v2:**
+```csharp
+void HandleMouse(object? sender, MouseEventArgs args) { }
+```
+
+### Mouse Coordinates
+
+**v1:**
+- Mouse coordinates were screen-relative
+
+**v2:**
+- Mouse coordinates are now **Viewport-relative**
+
+```csharp
+// v2 - Viewport-relative coordinates
+view.MouseClick += (s, e) =>
+{
+    // e.Position is relative to view's Viewport
+    var x = e.Position.X; // 0 = left edge of viewport
+    var y = e.Position.Y; // 0 = top edge of viewport
+};
+```
+
+### Highlight Event
+
+v2 adds a `Highlight` event for visual feedback:
+
+```csharp
+view.Highlight += (s, e) =>
+{
+    // Provide visual feedback on mouse hover
+};
+view.HighlightStyle = HighlightStyle.Hover;
+```
+
+See [Mouse Deep Dive](mouse.md) for complete details.
+
+---
+
+## Navigation Changes
+
+### Focus Properties
+
+**v1:**
+```csharp
+view.CanFocus = true; // Default was true
+```
+
+**v2:**
+```csharp
+view.CanFocus = true; // Default is FALSE - must opt-in
+```
+
+**Important:** In v2, `CanFocus` defaults to `false`. Views that want focus must explicitly set it.
+
+### Focus Changes
+
+**v1:**
+```csharp
+// HasFocus was read-only
+bool hasFocus = view.HasFocus;
+```
+
+**v2:**
+```csharp
+// HasFocus can be set
+view.HasFocus = true; // Equivalent to SetFocus()
+view.HasFocus = false; // Equivalent to SuperView.AdvanceFocus()
+```
+
+### TabStop Behavior
+
+**v1:**
+```csharp
+view.TabStop = true; // Boolean
+```
+
+**v2:**
+```csharp
+view.TabStop = TabBehavior.TabStop; // Enum with more options
+
+// Options:
+// - NoStop: Focusable but not via Tab
+// - TabStop: Normal tab navigation
+// - TabGroup: Advance via F6
+```
+
+### Navigation Events
+
+**v1:**
+```csharp
+view.Enter += (s, e) => { }; // Gained focus
+view.Leave += (s, e) => { }; // Lost focus
+```
+
+**v2:**
+```csharp
+view.HasFocusChanging += (s, e) => 
+{ 
+    // Before focus changes (cancellable)
+    if (preventFocusChange)
+        e.Cancel = true;
+};
+
+view.HasFocusChanged += (s, e) => 
+{ 
+    // After focus changed
+    if (e.Value)
+        Console.WriteLine("Gained focus");
+    else
+        Console.WriteLine("Lost focus");
+};
+```
+
+See [Navigation Deep Dive](navigation.md) for complete details.
+
+---
+
+## Scrolling Changes
+
+### ScrollView Removed
+
+**v1:**
+```csharp
+var scrollView = new ScrollView
+{
+    ContentSize = new Size(100, 100),
+    ShowHorizontalScrollIndicator = true,
+    ShowVerticalScrollIndicator = true
+};
+```
+
+**v2:**
+```csharp
+// Built-in scrolling on every View
+var view = new View();
+view.SetContentSize(new Size(100, 100));
+
+// Built-in scrollbars
+view.VerticalScrollBar.Visible = true;
+view.HorizontalScrollBar.Visible = true;
+view.VerticalScrollBar.AutoShow = true;
+```
+
+### Scrolling API
+
+**v2:**
+```csharp
+// Set content larger than viewport
+view.SetContentSize(new Size(100, 100));
+
+// Scroll by changing Viewport location
+view.Viewport = view.Viewport with { Location = new Point(10, 10) };
+
+// Or use helper methods
+view.ScrollVertical(5);
+view.ScrollHorizontal(3);
+```
+
+See [Scrolling Deep Dive](scrolling.md) for complete details.
+
+---
+
+## Event Pattern Changes
+
+v2 standardizes all events to use `object sender, EventArgs args` pattern.
+
+### Button.Clicked → Button.Accepting
+
+**v1:**
+```csharp
+button.Clicked += () => { /* do something */ };
+```
+
+**v2:**
+```csharp
+button.Accepting += (s, e) => { /* do something */ };
+```
+
+### Event Signatures
+
+**v1:**
+```csharp
+// Various patterns
+event Action SomeEvent;
+event Action<string> OtherEvent;
+event Action<EventArgs> ThirdEvent;
+```
+
+**v2:**
+```csharp
+// Consistent pattern
+event EventHandler<EventArgs>? SomeEvent;
+event EventHandler<EventArgs<string>>? OtherEvent;
+event EventHandler<CancelEventArgs<bool>>? ThirdEvent;
+```
+
+**Benefits:**
+- Named parameters
+- Cancellable events via `CancelEventArgs`
+- Future-proof (new properties can be added)
+
+---
+
+## View-Specific Changes
+
+### CheckBox
+
+**v1:**
+```csharp
+var cb = new CheckBox("_Checkbox", true);
+cb.Toggled += (e) => { };
+cb.Toggle();
+```
+
+**v2:**
+```csharp
+var cb = new CheckBox 
+{ 
+    Title = "_Checkbox",
+    CheckState = CheckState.Checked
+};
+cb.CheckStateChanging += (s, e) => 
+{
+    e.Cancel = preventChange;
+};
+cb.AdvanceCheckState();
+```
+
+### StatusBar
+
+**v1:**
+```csharp
+var statusBar = new StatusBar(
+    new StatusItem[]
+    {
+        new StatusItem(Application.QuitKey, "Quit", () => Quit())
+    }
+);
+```
+
+**v2:**
+```csharp
+var statusBar = new StatusBar(
+    new Shortcut[] 
+    { 
+        new Shortcut(Application.QuitKey, "Quit", Quit) 
+    }
+);
+```
+
+### PopoverMenu
+
+v2 replaces `ContextMenu` with `PopoverMenu`:
+
+**v1:**
+```csharp
+var contextMenu = new ContextMenu();
+```
+
+**v2:**
+```csharp
+var popoverMenu = new PopoverMenu();
+```
+
+### MenuItem
+
+**v1:**
+```csharp
+new MenuItem(
+    "Copy",
+    "",
+    CopyGlyph,
+    null,
+    null,
+    (KeyCode)Key.G.WithCtrl
+)
+```
+
+**v2:**
+```csharp
+new MenuItem(
+    "Copy",
+    "",
+    CopyGlyph,
+    Key.G.WithCtrl
+)
+```
+
+---
+
+## Disposal and Resource Management
+
+v2 implements proper `IDisposable` throughout.
+
+### View Disposal
+
+```csharp
+// v1 - No explicit disposal needed
+var view = new View();
+Application.Run(view);
+Application.Shutdown();
+
+// v2 - Explicit disposal required
+var view = new View();
+app.Run(view);
+view.Dispose();
+app.Dispose();
+```
+
+### Disposal Patterns
+
+```csharp
+// ✅ Best practice - using statement
+using (var app = Application.Create().Init())
+{
+    using (var view = new View())
+    {
+        app.Run(view);
+    }
+}
+
+// ✅ Alternative - explicit try/finally
+var app = Application.Create();
+try
+{
+    app.Init();
+    var view = new View();
+    try
+    {
+        app.Run(view);
+    }
+    finally
+    {
+        view.Dispose();
+    }
+}
+finally
+{
+    app.Dispose();
+}
+```
+
+### SubView Disposal
+
+When a View is disposed, it automatically disposes all SubViews:
+
+```csharp
+var container = new View();
+var child1 = new View();
+var child2 = new View();
+
+container.Add(child1, child2);
+
+// Disposes container, child1, and child2
+container.Dispose();
+```
+
+See [Resource Management](#disposal-and-resource-management) for complete details.
+
+---
+
+## API Terminology Changes
+
+v2 modernizes terminology for clarity:
+
+### Application.Top → Application.TopRunnable
+
+**v1:**
+```csharp
+Application.Top.SetNeedsDraw();
+```
+
+**v2:**
+```csharp
+// Use TopRunnable (or TopRunnableView for View reference)
+app.TopRunnable?.SetNeedsDraw();
+app.TopRunnableView?.SetNeedsDraw();
+
+// From within a view
+App?.TopRunnableView?.SetNeedsDraw();
+```
+
+**Why "TopRunnable"?**
+- Clearly indicates it's the top of the runnable session stack
+- Aligns with `IRunnable` architecture
+- Works with any `IRunnable`, not just `Toplevel`
+
+### Application.TopLevels → Application.SessionStack
+
+**v1:**
+```csharp
+foreach (var tl in Application.TopLevels)
+{
+    // Process
+}
+```
+
+**v2:**
+```csharp
+foreach (var token in app.SessionStack)
+{
+    var runnable = token.Runnable;
+    // Process
+}
+
+// Count of sessions
+int sessionCount = app.SessionStack.Count;
+```
+
+**Why "SessionStack"?**
+- Describes both content (sessions) and structure (stack)
+- Aligns with `SessionToken` terminology
+- Follows .NET naming patterns
+
+### View Arrangement
+
+**v1:**
+```csharp
+view.SendSubViewToBack();
+view.SendSubViewBackward();
+view.SendSubViewToFront();
+view.SendSubViewForward();
+```
+
+**v2:**
+```csharp
+// Fixed naming (methods worked opposite to their names in v1)
+view.MoveSubViewToStart();
+view.MoveSubViewTowardsStart();
+view.MoveSubViewToEnd();
+view.MoveSubViewTowardsEnd();
+```
+
+### Mdi → ViewArrangement.Overlapped
+
+**v1:**
+```csharp
+Application.MdiTop = true;
+toplevel.IsMdiContainer = true;
+```
+
+**v2:**
+```csharp
+view.Arrangement = ViewArrangement.Overlapped;
+
+// Additional flags
+view.Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable;
+```
+
+See [Arrangement Deep Dive](arrangement.md) for complete details.
+
+---
+
+## Complete Migration Example
+
+Here's a complete v1 to v2 migration:
+
+**v1:**
+```csharp
+using NStack;
+using Terminal.Gui;
+
+Application.Init();
+
+var win = new Window(new Rect(0, 0, 50, 20), "Hello");
+
+var label = new Label(1, 1, "Name:");
+
+var textField = new TextField(10, 1, 30, "");
+
+var button = new Button(10, 3, "OK");
+button.Clicked += () =>
+{
+    MessageBox.Query(50, 7, "Info", $"Hello, {textField.Text}", "Ok");
+};
+
+win.Add(label, textField, button);
+
+Application.Top.Add(win);
+Application.Run();
+Application.Shutdown();
+```
+
+**v2:**
+```csharp
+using System;
+using Terminal.Gui;
+
+using (var app = Application.Create().Init())
+{
+    var win = new Window
+    {
+        Title = "Hello",
+        Width = 50,
+        Height = 20
+    };
+
+    var label = new Label
+    {
+        Text = "Name:",
+        X = 1,
+        Y = 1
+    };
+
+    var textField = new TextField
+    {
+        X = 10,
+        Y = 1,
+        Width = 30
+    };
+
+    var button = new Button
+    {
+        Text = "OK",
+        X = 10,
+        Y = 3
+    };
+    button.Accepting += (s, e) =>
+    {
+        MessageBox.Query(app, "Info", $"Hello, {textField.Text}", "Ok");
+    };
+
+    win.Add(label, textField, button);
+
+    app.Run(win);
+    win.Dispose();
+}
+```
+
+---
+
+## Summary of Major Breaking Changes
+
+| Category | v1 | v2 |
+|----------|----|----|
+| **Application** | Static `Application` | `IApplication` instances via `Application.Create()` |
+| **Disposal** | Automatic | Explicit (`IDisposable` pattern) |
+| **View Construction** | Constructors with Rect | Initializers with X, Y, Width, Height |
+| **Layout** | Absolute/Computed distinction | Unified Pos/Dim system |
+| **Colors** | Limited palette | 24-bit TrueColor default |
+| **Types** | `Rect`, `NStack.ustring` | `Rectangle`, `System.String` |
+| **Keyboard** | `KeyEvent`, hard-coded keys | `Key`, configurable bindings |
+| **Mouse** | Screen-relative | Viewport-relative |
+| **Scrolling** | `ScrollView` | Built-in on all Views |
+| **Focus** | `CanFocus` default true | `CanFocus` default false |
+| **Navigation** | `Enter`/`Leave` events | `HasFocusChanging`/`HasFocusChanged` |
+| **Events** | Mixed patterns | Standard `EventHandler<EventArgs>` |
+| **Terminology** | `Application.Top`, `TopLevels` | `TopRunnable`, `SessionStack` |
+
+---
+
+## Additional Resources
+
+- [Application Deep Dive](application.md) - Complete application architecture
+- [View Deep Dive](View.md) - View system details
+- [Layout Deep Dive](layout.md) - Comprehensive layout guide
+- [Keyboard Deep Dive](keyboard.md) - Keyboard input handling
+- [Mouse Deep Dive](mouse.md) - Mouse input handling
+- [Navigation Deep Dive](navigation.md) - Focus and navigation
+- [Scrolling Deep Dive](scrolling.md) - Built-in scrolling system
+- [Arrangement Deep Dive](arrangement.md) - Movable/resizable views
+- [Configuration Deep Dive](config.md) - Configuration system
+- [What's New in v2](newinv2.md) - New features overview
+
+---
+
+## Getting Help
+
+- [GitHub Discussions](https://github.com/gui-cs/Terminal.Gui/discussions)
+- [GitHub Issues](https://github.com/gui-cs/Terminal.Gui/issues)
+- [API Documentation](~/api/index.md)

+ 669 - 206
docfx/docs/newinv2.md

@@ -1,322 +1,785 @@
-# Terminal.Gui v2
+# Terminal.Gui v2 - What's New
 
 This document provides an in-depth overview of the new features, improvements, and architectural changes in Terminal.Gui v2 compared to v1.
 
-For information on how to port code from v1 to v2, see the [v1 To v2 Migration Guide](migratingfromv1.md).
+**For migration guidance**, see the [v1 To v2 Migration Guide](migratingfromv1.md).
 
-## Architectural Overhaul and Design Philosophy
+## Table of Contents
 
-Terminal.Gui v2 represents a fundamental rethinking of the library's architecture, driven by the need for better maintainability, performance, and developer experience. The primary design goals in v2 include:
+- [Overview](#overview)
+- [Architectural Overhaul](#architectural-overhaul)
+- [Instance-Based Application Model](#instance-based-application-model)
+- [IRunnable Architecture](#irunnable-architecture)
+- [Modern Look & Feel](#modern-look--feel)
+- [Simplified API](#simplified-api)
+- [View Improvements](#view-improvements)
+- [New and Improved Views](#new-and-improved-views)
+- [Enhanced Input Handling](#enhanced-input-handling)
+- [Configuration and Persistence](#configuration-and-persistence)
+- [Debugging and Performance](#debugging-and-performance)
+- [Additional Features](#additional-features)
 
-- **Decoupling of Concepts**: In v1, many concepts like focus management, layout, and input handling were tightly coupled, leading to fragile and hard-to-predict behavior. v2 explicitly separates these concerns, resulting in a more modular and testable codebase.
-- **Performance Optimization**: v2 reduces overhead in rendering, event handling, and view management by streamlining internal data structures and algorithms.
-- **Modern .NET Practices**: The API has been updated to align with contemporary .NET conventions, such as using events with `EventHandler<T>` and leveraging modern C# features like target-typed `new` and file-scoped namespaces.
-- **Accessibility and Usability**: v2 places a stronger emphasis on ensuring that terminal applications are accessible, with improved keyboard navigation and visual feedback.
+---
 
-This architectural shift has resulted in the removal of thousands of lines of redundant or overly complex code from v1, replaced with cleaner, more focused implementations.
+## Overview
 
-## Instance-Based Application Architecture
+Terminal.Gui v2 represents a fundamental redesign of the library's architecture, API, and capabilities. Key improvements include:
 
-See the [Application Deep Dive](application.md) for complete details on the new application architecture.
+- **Instance-Based Application Model** - Move from static singletons to `IApplication` instances
+- **IRunnable Architecture** - Interface-based pattern for type-safe, runnable views
+- **Proper Resource Management** - Full IDisposable pattern with automatic cleanup
+- **Built-in Scrolling** - Every view supports scrolling inherently
+- **24-bit TrueColor** - Full color spectrum by default
+- **Enhanced Input** - Modern keyboard and mouse APIs
+- **Improved Layout** - Simplified with adornments (Margin, Border, Padding)
+- **Better Navigation** - Decoupled focus and tab navigation
+- **Configuration System** - Persistent themes and settings
+- **Logging and Metrics** - Built-in debugging and performance tracking
 
-Terminal.Gui v2 introduces an instance-based application architecture that decouples views from global application state, dramatically improving testability and enabling multiple application contexts.
+---
 
-### Key Changes
+## Architectural Overhaul
 
-- **Instance-Based Pattern**: The recommended pattern is to use `Application.Create()` to get an `IApplication` instance, rather than using the static `Application` class (which is marked obsolete but still functional for backward compatibility).
-- **View.App Property**: Every view now has an `App` property that references its `IApplication` context, enabling views to access application services without static dependencies.
-- **Session Management**: Applications manage sessions through `Begin()` and `End()` methods, with a `SessionStack` tracking nested sessions and `Current` representing the active session.
-- **Improved Testability**: Views can be tested in isolation by setting their `App` property to a mock `IApplication`, eliminating the need for `Application.Init()` in unit tests.
+### Design Philosophy
 
-### Example Usage
+Terminal.Gui v2 was designed with these core principles:
+
+1. **Separation of Concerns** - Layout, focus, input, and drawing are cleanly decoupled
+2. **Performance** - Reduced overhead in rendering and event handling
+3. **Modern .NET Practices** - Standard patterns like `EventHandler<T>` and `IDisposable`
+4. **Testability** - Views can be tested in isolation without global state
+5. **Accessibility** - Improved keyboard navigation and visual feedback
+
+### Result
+
+- Thousands of lines of redundant or complex code removed
+- More modular and maintainable codebase
+- Better performance and predictability
+- Easier to extend and customize
+
+---
+
+## Instance-Based Application Model
+
+See the [Application Deep Dive](application.md) for complete details.
+
+v2 introduces an instance-based architecture that eliminates global state and enables multiple application contexts.
+
+### Key Features
+
+**IApplication Interface:**
+- `Application.Create()` returns an `IApplication` instance
+- Multiple applications can coexist (useful for testing)
+- Each instance manages its own driver, session stack, and resources
+
+**View.App Property:**
+- Every view has an `App` property referencing its `IApplication` context
+- Views access application services through `App` (driver, session management, etc.)
+- Eliminates static dependencies, improving testability
+
+**Session Management:**
+- `SessionStack` tracks all running sessions as a stack
+- `TopRunnable` property references the currently active session
+- `Begin()` and `End()` methods manage session lifecycle
+
+### Example
 
 ```csharp
-// Recommended v2 pattern (instance-based)
-var app = Application.Create();
-app.Init();
-var top = new Runnable { Title = "My App" };
-top.Add(myView);
-app.Run(top);
-top.Dispose();
-app.Shutdown();
-
-// Static pattern (obsolete but still works)
-Application.Init();
-var top = new Runnable { Title = "My App" };
-top.Add(myView);
-Application.Run(top);
-top.Dispose();
-Application.Shutdown();
+// Instance-based pattern (recommended)
+IApplication app = Application.Create ().Init ();
+Window window = new () { Title = "My App" };
+app.Run (window);
+window.Dispose ();
+app.Dispose ();
+
+// With using statement for automatic disposal
+using (IApplication app = Application.Create ().Init ())
+{
+    Window window = new () { Title = "My App" };
+    app.Run (window);
+    window.Dispose ();
+} // app.Dispose() called automatically
+
+// Access from within a view
+public class MyView : View
+{
+    public void DoWork ()
+    {
+        App?.Driver.Move (0, 0);
+        App?.TopRunnableView?.SetNeedsDraw ();
+    }
+}
 ```
 
 ### Benefits
 
-- **Testability**: Views can be tested without initializing the entire application
-- **Multiple Contexts**: Multiple `IApplication` instances can coexist (useful for testing or complex scenarios)
-- **Clear Ownership**: Views explicitly know their application context via the `App` property
-- **Reduced Global State**: Less reliance on static singletons improves code maintainability
-- **Proper Resource Management**: IDisposable pattern ensures clean shutdown of input threads and driver resources
+- **Testability** - Mock `IApplication` for unit tests
+- **No Global State** - Multiple contexts can coexist
+- **Clear Ownership** - Views explicitly know their context
+- **Proper Cleanup** - IDisposable ensures resources are released
 
 ### Resource Management
 
-Terminal.Gui v2 implements the `IDisposable` pattern for proper resource cleanup:
+v2 implements full `IDisposable` pattern:
 
 ```csharp
-// Recommended pattern with using statement
-using (var app = Application.Create().Init())
+// Recommended: using statement
+using (IApplication app = Application.Create ().Init ())
 {
-    app.Run<MyDialog>();
-    var result = app.GetResult<MyResult>();
+    app.Run<MyDialog> ();
+    MyResult? result = app.GetResult<MyResult> ();
 }
 
-// Or with try/finally
-var app = Application.Create();
-try
+// Ensures:
+// - Input thread stopped cleanly
+// - Driver resources released
+// - No thread leaks in tests
+```
+
+**Important Changes:**
+- `Shutdown()` method is obsolete - use `Dispose()` instead
+- Always dispose applications (especially in tests)
+- Input thread runs at ~50 polls/second (20ms throttle) until disposed
+
+---
+
+## IRunnable Architecture
+
+See the [Application Deep Dive](application.md) for complete details.
+
+v2 introduces `IRunnable<TResult>` - an interface-based pattern for runnable views with type-safe results.
+
+### Key Features
+
+**Interface-Based:**
+- Implement `IRunnable<TResult>` without inheriting from `Runnable`
+- Any view can be runnable
+- Decouples runnability from view hierarchy
+
+**Type-Safe Results:**
+- Generic `TResult` parameter provides compile-time type safety
+- `null` indicates cancellation/non-acceptance
+- Results extracted before disposal in lifecycle events
+
+**Lifecycle Events (CWP-Compliant):**
+- `IsRunningChanging` - Cancellable, before stack change
+- `IsRunningChanged` - Non-cancellable, after stack change
+- `IsModalChanging` - Cancellable, before modal state change
+- `IsModalChanged` - Non-cancellable, after modal state change
+
+### Example
+
+```csharp
+public class FileDialog : Runnable<string?>
 {
-    app.Init();
-    app.Run<MyDialog>();
+    private TextField _pathField;
+    
+    public FileDialog ()
+    {
+        Title = "Select File";
+        _pathField = new () { Width = Dim.Fill () };
+        Add (_pathField);
+        
+        Button okButton = new () { Text = "OK", IsDefault = true };
+        okButton.Accepting += (s, e) =>
+        {
+            Result = _pathField.Text;
+            Application.RequestStop ();
+        };
+        AddButton (okButton);
+    }
+    
+    protected override bool OnIsRunningChanging (bool oldValue, bool newValue)
+    {
+        if (!newValue)  // Stopping - extract result before disposal
+        {
+            Result = _pathField?.Text;
+            
+            // Optionally cancel stop
+            if (HasUnsavedChanges ())
+            {
+                return true; // Cancel
+            }
+        }
+        return base.OnIsRunningChanging (oldValue, newValue);
+    }
 }
-finally
+
+// Use with fluent API
+using (IApplication app = Application.Create ().Init ())
 {
-    app.Dispose(); // Stops input thread, releases resources
+    app.Run<FileDialog> ();
+    string? path = app.GetResult<string> ();
+    
+    if (path is { })
+    {
+        OpenFile (path);
+    }
 }
 ```
 
-**Key Changes from v1:**
-- **Input Thread Management**: v2 starts a dedicated input thread that polls console input at ~50 polls/second (20ms throttle) to prevent CPU spinning
-- **Clean Shutdown**: `Dispose()` cancels the input thread and waits for it to exit, preventing thread leaks
-- **Test-Friendly**: Always dispose applications in tests to prevent thread pool exhaustion from leaked input threads
+### Fluent API
 
-**Obsolete `Shutdown()` Method:**
-The `Shutdown()` method is marked obsolete. Use `Dispose()` and `GetResult()` instead:
+v2 enables elegant method chaining:
 
 ```csharp
-// OLD (v1/early v2):
-var result = app.Run<MyDialog>().Shutdown() as MyResult;
-
-// NEW (v2 recommended):
-using (var app = Application.Create().Init())
+// Concise and readable
+using (IApplication app = Application.Create ().Init ())
 {
-    app.Run<MyDialog>();
-    var result = app.GetResult<MyResult>();
+    app.Run<ColorPickerDialog> ();
+    Color? result = app.GetResult<Color> ();
 }
 ```
 
-## Modern Look & Feel - Technical Details
+**Key Methods:**
+- `Init()` - Returns `IApplication` for chaining
+- `Run<TRunnable>()` - Creates and runs runnable, returns `IApplication`
+- `GetResult<T>()` - Extract typed result after run
+- `Dispose()` - Release all resources
+
+### Disposal Semantics
+
+**"Whoever creates it, owns it":**
+
+| Method | Creator | Owner | Disposal |
+|--------|---------|-------|----------|
+| `Run<TRunnable>()` | Framework | Framework | Automatic when returns |
+| `Run(IRunnable)` | Caller | Caller | Manual by caller |
+
+```csharp
+// Framework ownership - automatic disposal
+app.Run<MyDialog> (); // Dialog disposed automatically
+
+// Caller ownership - manual disposal
+MyDialog dialog = new ();
+app.Run (dialog);
+dialog.Dispose (); // Caller must dispose
+```
+
+### Benefits
+
+- **Type Safety** - No casting, compile-time checking
+- **Clean Lifecycle** - CWP-compliant events
+- **Automatic Disposal** - Framework manages created runnables
+- **Flexible** - Works with any View, not just Toplevel
+
+---
+
+## Modern Look & Feel
 
-### TrueColor Support
+### 24-bit TrueColor Support
 
-See the [Drawing Deep Dive](drawing.md) for complete details on the color system.
+See the [Drawing Deep Dive](drawing.md) for complete details.
 
-- **Implementation**: v2 introduces 24-bit color support by extending the [Attribute](~/api/Terminal.Gui.Drawing.Attribute.yml) class to handle RGB values, with fallback to 16-color mode for older terminals. This is evident in the [IConsoleDriver](~/api/Terminal.Gui.Drivers.IConsoleDriver.yml) implementations, which now map colors to the appropriate terminal escape sequences.
-- **Impact**: Developers can now use a full spectrum of colors without manual palette management, as seen in v1. The [Color](~/api/Terminal.Gui.Drawing.Color.yml) struct in v2 supports direct RGB input, and drivers handle the translation to terminal capabilities via [IConsoleDriver.SupportsTrueColor](~/api/Terminal.Gui.Drivers.IConsoleDriver.yml#Terminal_Gui_Drivers_IConsoleDriver_SupportsTrueColor).
-- **Usage**: See the [ColorPicker](~/api/Terminal.Gui.Views.ColorPicker.yml) view for an example of how TrueColor is leveraged to provide a rich color selection UI.
+v2 provides full 24-bit color support by default:
 
-### Enhanced Borders and Padding (Adornments)
+- **Implementation**: [Attribute](~/api/Terminal.Gui.Drawing.Attribute.yml) class handles RGB values
+- **Fallback**: Automatic 16-color mode for older terminals
+- **Driver Support**: [IConsoleDriver.SupportsTrueColor](~/api/Terminal.Gui.Drivers.IConsoleDriver.yml#Terminal_Gui_Drivers_IConsoleDriver_SupportsTrueColor) detection
+- **Usage**: Direct RGB input via [Color](~/api/Terminal.Gui.Drawing.Color.yml) struct
 
-See the [Layout Deep Dive](layout.md) for complete details on the adornments system.
+```csharp
+// 24-bit RGB color
+Color customColor = new (0xFF, 0x99, 0x00);
+
+// Or use named colors (ANSI-compliant)
+Color color = Color.Yellow; // Was "Brown" in v1
+```
 
-- **Implementation**: v2 introduces a new [Adornment](~/api/Terminal.Gui.ViewBase.Adornment.yml) class hierarchy, with [Margin](~/api/Terminal.Gui.ViewBase.Margin.yml), [Border](~/api/Terminal.Gui.ViewBase.Border.yml), and [Padding](~/api/Terminal.Gui.ViewBase.Padding.yml) as distinct view-like entities that wrap content. This is a significant departure from v1, where borders were often hardcoded or required custom drawing.
-- **Code Change**: In v1, [View](~/api/Terminal.Gui.ViewBase.View.yml) had rudimentary border support via properties like `BorderStyle`. In v2, [View](~/api/Terminal.Gui.ViewBase.View.yml) has a [View.Border](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_Border) property of type [Border](~/api/Terminal.Gui.ViewBase.Border.yml), which is itself a configurable entity with properties like [Thickness](~/api/Terminal.Gui.Drawing.Thickness.yml), [Border.LineStyle](~/api/Terminal.Gui.ViewBase.Border.yml#Terminal_Gui_ViewBase_Border_LineStyle), and [Border.Settings](~/api/Terminal.Gui.ViewBase.Border.yml#Terminal_Gui_ViewBase_Border_Settings).
-- **Impact**: This allows for consistent border rendering across all views and simplifies custom view development by providing a reusable adornment framework.
+### Enhanced Borders and Adornments
 
-### User Configurable Color Themes and Text Styles
+See the [Layout Deep Dive](layout.md) for complete details.
 
-See the [Configuration Deep Dive](config.md) and [Scheme Deep Dive](scheme.md) for complete details.
+v2 introduces a comprehensive [Adornment](~/api/Terminal.Gui.ViewBase.Adornment.yml) system:
 
-- **Implementation**: v2 adds a [ConfigurationManager](~/api/Terminal.Gui.Configuration.ConfigurationManager.yml) that supports loading and saving color schemes from configuration files. Themes are applied via [Scheme](~/api/Terminal.Gui.Drawing.Scheme.yml) objects, which can be customized per view or globally. Each [Attribute](~/api/Terminal.Gui.Drawing.Attribute.yml) in a [Scheme](~/api/Terminal.Gui.Drawing.Scheme.yml) now includes a [TextStyle](~/api/Terminal.Gui.Drawing.TextStyle.yml) property supporting Bold, Italic, Underline, Strikethrough, Blink, Reverse, and Faint text styles.
-- **Impact**: Unlike v1, where color schemes were static or required manual override, v2 enables end-users to personalize not just colors but also text styling (bold, italic, underline, etc.) without code changes, significantly enhancing accessibility and user preference support.
+- **[Margin](~/api/Terminal.Gui.ViewBase.Margin.yml)** - Transparent spacing outside the border
+- **[Border](~/api/Terminal.Gui.ViewBase.Border.yml)** - Visual frame with title, multiple styles
+- **[Padding](~/api/Terminal.Gui.ViewBase.Padding.yml)** - Spacing inside the border
 
-### Enhanced Unicode/Wide Character Support
-- **Implementation**: v2 improves Unicode handling by correctly managing wide characters in text rendering and input processing. The [TextFormatter](~/api/Terminal.Gui.Text.TextFormatter.yml) class now accounts for Unicode width in layout calculations.
-- **Impact**: This fixes v1 issues where wide characters (e.g., CJK scripts) could break layout or input handling, making Terminal.Gui v2 suitable for international applications.
+**Border Features:**
+- Multiple [LineStyle](~/api/Terminal.Gui.Drawing.LineStyle.yml) options: Single, Double, Heavy, Rounded, Dashed, Dotted
+- Automatic line intersection handling via [LineCanvas](~/api/Terminal.Gui.Drawing.LineCanvas.yml)
+- Configurable thickness per side via [Thickness](~/api/Terminal.Gui.Drawing.Thickness.yml)
+- Title display with alignment options
+
+```csharp
+view.BorderStyle = LineStyle.Double;
+view.Border.Thickness = new (1);
+view.Title = "My View";
+
+view.Margin.Thickness = new (2);
+view.Padding.Thickness = new (1);
+```
+
+### User Configurable Themes
+
+See the [Configuration Deep Dive](config.md) and [Scheme Deep Dive](scheme.md) for details.
+
+v2 adds comprehensive theme support:
+
+- **ConfigurationManager**: Loads/saves color schemes from files
+- **Schemes**: Applied per-view or globally via [Scheme](~/api/Terminal.Gui.Drawing.Scheme.yml)
+- **Text Styles**: [TextStyle](~/api/Terminal.Gui.Drawing.TextStyle.yml) supports Bold, Italic, Underline, Strikethrough, Blink, Reverse, Faint
+- **User Customization**: End-users can personalize without code changes
+
+```csharp
+// Apply a theme
+ConfigurationManager.Themes.Theme = "Dark";
+
+// Customize text style
+view.Scheme.Normal = new (
+    Color.White, 
+    Color.Black, 
+    TextStyle.Bold | TextStyle.Underline
+);
+```
 
 ### LineCanvas
 
-See the [Drawing Deep Dive](drawing.md) for complete details on LineCanvas and the drawing system.
+See the [Drawing Deep Dive](drawing.md) for complete details.
 
-- **Implementation**: A new [LineCanvas](~/api/Terminal.Gui.Drawing.LineCanvas.yml) class provides a drawing API for creating lines and shapes using box-drawing characters. It includes logic for auto-joining lines at intersections, selecting appropriate glyphs dynamically.
-- **Code Example**: In v2, [LineCanvas](~/api/Terminal.Gui.Drawing.LineCanvas.yml) is used internally by views like [Border](~/api/Terminal.Gui.ViewBase.Border.yml) and [Line](~/api/Terminal.Gui.Views.Line.yml) to draw clean, connected lines, a feature absent in v1.
-- **Impact**: Developers can create complex diagrams or UI elements with minimal effort, improving the visual fidelity of terminal applications.
+[LineCanvas](~/api/Terminal.Gui.Drawing.LineCanvas.yml) provides sophisticated line drawing:
 
-## Simplified API - Under the Hood
+- Auto-joining lines at intersections
+- Multiple line styles (Single, Double, Heavy, etc.)
+- Automatic glyph selection for corners and T-junctions
+- Used by [Border](~/api/Terminal.Gui.ViewBase.Border.yml), [Line](~/api/Terminal.Gui.Views.Line.yml), and custom views
 
-### API Consistency and Reduction
-- **Change**: v2 revisits every public API, consolidating redundant methods and properties. For example, v1 had multiple focus-related methods scattered across [View](~/api/Terminal.Gui.ViewBase.View.yml) and [Application](~/api/Terminal.Gui.App.Application.yml); v2 centralizes these in [ApplicationNavigation](~/api/Terminal.Gui.App.ApplicationNavigation.yml).
-- **Impact**: This reduces the learning curve for new developers and minimizes the risk of using deprecated or inconsistent APIs.
-- **Example**: The v1 `View.MostFocused` property is replaced by `Application.Navigation.GetFocused()`, reducing traversal overhead and clarifying intent.
+```csharp
+// Line view uses LineCanvas
+Line line = new () { Orientation = Orientation.Horizontal };
+line.LineStyle = LineStyle.Double;
+```
+
+### Gradients
+
+See the [Drawing Deep Dive](drawing.md) for details.
+
+v2 adds gradient support:
+
+- [Gradient](~/api/Terminal.Gui.Drawing.Gradient.yml) - Color transitions
+- [GradientFill](~/api/Terminal.Gui.Drawing.GradientFill.yml) - Fill patterns
+- Uses TrueColor for smooth effects
+- Apply to borders, backgrounds, or custom elements
+
+```csharp
+Gradient gradient = new (Color.Blue, Color.Cyan);
+view.BackgroundGradient = new (gradient, Orientation.Vertical);
+```
+
+---
+
+## Simplified API
+
+### Consistency and Reduction
+
+v2 consolidates redundant APIs:
+
+- **Centralized Navigation**: [ApplicationNavigation](~/api/Terminal.Gui.App.ApplicationNavigation.yml) replaces scattered focus methods
+- **Standard Events**: All events use `EventHandler<T>` pattern
+- **Consistent Naming**: Methods follow .NET conventions (e.g., `OnHasFocusChanged`)
+- **Reduced Surface**: Fewer but more powerful APIs
+
+**Example:**
+```csharp
+// v1 - Multiple scattered methods
+View.MostFocused
+View.EnsureFocus ()
+View.FocusNext ()
+
+// v2 - Centralized
+Application.Navigation.GetFocused ()
+view.SetFocus ()
+view.AdvanceFocus ()
+```
 
 ### Modern .NET Standards
-- **Change**: Events in v2 use `EventHandler<T>` instead of v1's custom delegate types. Methods follow consistent naming (e.g., `OnHasFocusChanged` vs. v1's varied naming).
-- **Impact**: Developers familiar with .NET conventions will find v2 more intuitive, and tools like IntelliSense provide better support due to standardized signatures.
 
-### Performance Gains
-- **Change**: v2 optimizes rendering by minimizing unnecessary redraws through a smarter `NeedsDisplay` system and reducing object allocations in hot paths like event handling.
-- **Impact**: Applications built with v2 will feel snappier, especially in complex UIs with many views or frequent updates, addressing v1 performance bottlenecks.
+- Events: `EventHandler<EventArgs>` instead of custom delegates
+- Properties: Consistent get/set patterns
+- Disposal: IDisposable throughout
+- Nullability: Enabled in core library files
+
+### Performance Optimizations
+
+v2 reduces overhead through:
 
-## View Improvements - Deep Dive
+- Smarter `NeedsDraw` system (only draw what changed)
+- Reduced allocations in hot paths (event handling, rendering)
+- Optimized layout calculations
+- Efficient input processing
 
-### Deterministic View Lifetime Management
-- **v1 Issue**: Lifetime rules for `View` objects were unclear, leading to memory leaks or premature disposal, especially with `Application.Run`.
-- **v2 Solution**: v2 defines explicit rules for view disposal and ownership, enforced by unit tests. `Application.Run` now clearly manages the lifecycle of `Runnable` views, ensuring deterministic cleanup.
-- **Impact**: Developers can predict when resources are released, reducing bugs related to dangling references or uninitialized states.
+**Result**: Snappier UIs, especially with many views or frequent updates
 
-### Adornments Framework
+---
 
-See the [Layout Deep Dive](layout.md) and [View Deep Dive](View.md) for complete details.
+## View Improvements
 
-- **Technical Detail**: Adornments are implemented as nested views that surround the content area, each with its own drawing and layout logic. [Border](~/api/Terminal.Gui.ViewBase.Border.yml) supports multiple [LineStyle](~/api/Terminal.Gui.Drawing.LineStyle.yml) options (Single, Double, Heavy, Rounded, Dashed, Dotted) with automatic line intersection handling via [LineCanvas](~/api/Terminal.Gui.Drawing.LineCanvas.yml).
-- **Code Change**: In v2, [View](~/api/Terminal.Gui.ViewBase.View.yml) has properties [View.Margin](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_Margin), [View.Border](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_Border), and [View.Padding](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_Padding), each configurable independently, unlike v1's limited border support.
-- **Impact**: This modular approach allows for reusable UI elements and simplifies creating visually consistent applications.
+### Deterministic Lifetime Management
 
-### Built-in Scrolling/Virtual Content Area
+v2 clarifies view ownership:
 
-See the [Scrolling Deep Dive](scrolling.md) and [Layout Deep Dive](layout.md) for complete details.
+- Explicit disposal rules enforced by unit tests
+- `Application.Run` manages `Runnable` lifecycle
+- SubViews disposed automatically with SuperView
+- Clear documentation of ownership semantics
 
-- **v1 Issue**: Scrolling required using `ScrollView` or manual offset management, which was error-prone.
-- **v2 Solution**: Every [View](~/api/Terminal.Gui.ViewBase.View.yml) in v2 has a [View.Viewport](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_Viewport) rectangle representing the visible portion of a potentially larger content area defined by [View.GetContentSize](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_GetContentSize). Changing `Viewport.Location` scrolls the content.
-- **Code Example**: In v2, [TextView](~/api/Terminal.Gui.Views.TextView.yml) uses this to handle large text buffers without additional wrapper views.
-- **Impact**: Simplifies implementing scrollable content and reduces the need for specialized container views.
+### Built-in Scrolling
 
-### Improved ScrollBar
-- **Change**: v2 replaces `ScrollBarView` with [ScrollBar](~/api/Terminal.Gui.Views.ScrollBar.yml), a cleaner implementation integrated with the built-in scrolling system. [View.VerticalScrollBar](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_VerticalScrollBar) and [View.HorizontalScrollBar](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_HorizontalScrollBar) properties enable scroll bars with minimal code.
-- **Impact**: Developers can add scroll bars to any view without managing separate view hierarchies, a significant usability improvement over v1.
+See the [Scrolling Deep Dive](scrolling.md) for complete details.
 
-### DimAuto, PosAnchorEnd, and PosAlign
+Every [View](~/api/Terminal.Gui.ViewBase.View.yml) supports scrolling inherently:
 
-See the [Layout Deep Dive](layout.md) and [DimAuto Deep Dive](dimauto.md) for complete details.
+- **[Viewport](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_Viewport)** - Visible rectangle (can have non-zero location)
+- **[GetContentSize](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_GetContentSize)** - Returns total content size
+- **[SetContentSize](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_SetContentSize_System_Nullable_System_Drawing_Size__)** - Sets scrollable content size
+- **ScrollVertical/ScrollHorizontal** - Helper methods
 
-- **[Dim.Auto](~/api/Terminal.Gui.Dim.yml#Terminal_Gui_Dim_Auto_Terminal_Gui_DimAutoStyle_Terminal_Gui_Dim_Terminal_Gui_Dim_)**: Automatically sizes views based on content or subviews, reducing manual layout calculations.
-- **[Pos.AnchorEnd](~/api/Terminal.Gui.Pos.yml#Terminal_Gui_Pos_AnchorEnd_System_Int32_)**: Allows anchoring to the right or bottom of a superview, enabling flexible layouts not easily achievable in v1.
-- **[Pos.Align](~/api/Terminal.Gui.Pos.yml)**: Provides alignment options (left, center, right) for multiple views, streamlining UI design.
-- **Impact**: These features reduce boilerplate layout code and support responsive designs in terminal constraints.
+**No need for ScrollView wrapper!**
+
+```csharp
+// Enable scrolling
+view.SetContentSize (new (100, 100));
+
+// Scroll by changing Viewport location
+view.ScrollVertical (5);
+view.ScrollHorizontal (3);
+
+// Built-in scrollbars
+view.VerticalScrollBar.Visible = true;
+view.HorizontalScrollBar.Visible = true;
+view.VerticalScrollBar.AutoShow = true;
+```
+
+### Enhanced ScrollBar
+
+v2 replaces `ScrollBarView` with [ScrollBar](~/api/Terminal.Gui.Views.ScrollBar.yml):
+
+- Cleaner implementation
+- Automatic show/hide
+- Proportional sizing with `ScrollSlider`
+- Integrated with View's scrolling system
+- Simple to add via [View.VerticalScrollBar](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_VerticalScrollBar) / [View.HorizontalScrollBar](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_HorizontalScrollBar)
+
+### Advanced Layout Features
+
+See the [Layout Deep Dive](layout.md) and [DimAuto Deep Dive](dimauto.md) for details.
+
+**[Dim.Auto](~/api/Terminal.Gui.Dim.yml#Terminal_Gui_Dim_Auto_Terminal_Gui_DimAutoStyle_Terminal_Gui_Dim_Terminal_Gui_Dim_):**
+- Automatically sizes views based on content or subviews
+- Reduces manual layout calculations
+- Supports multiple styles (Text, Content, Position)
+
+**[Pos.AnchorEnd](~/api/Terminal.Gui.Pos.yml#Terminal_Gui_Pos_AnchorEnd_System_Int32_):**
+- Anchor to right or bottom of SuperView
+- Enables flexible, responsive layouts
+
+**[Pos.Align](~/api/Terminal.Gui.Pos.yml):**
+- Align multiple views (Left, Center, Right)
+- Simplifies creating aligned layouts
+
+```csharp
+// Auto-size based on text
+label.Width = Dim.Auto ();
+label.Height = Dim.Auto ();
+
+// Anchor to bottom-right
+button.X = Pos.AnchorEnd (10);
+button.Y = Pos.AnchorEnd (2);
+
+// Center align
+label1.X = Pos.Center ();
+label2.X = Pos.Center ();
+```
 
 ### View Arrangement
 
 See the [Arrangement Deep Dive](arrangement.md) for complete details.
 
-- **Technical Detail**: The [View.Arrangement](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_Arrangement) property supports flags like [ViewArrangement.Movable](~/api/Terminal.Gui.ViewBase.ViewArrangement.yml), [ViewArrangement.Resizable](~/api/Terminal.Gui.ViewBase.ViewArrangement.yml), and [ViewArrangement.Overlapped](~/api/Terminal.Gui.ViewBase.ViewArrangement.yml), enabling dynamic UI interactions via keyboard and mouse.
-- **Code Example**: [Window](~/api/Terminal.Gui.Views.Window.yml) in v2 uses [View.Arrangement](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_Arrangement) to allow dragging and resizing, a feature requiring custom logic in v1.
-- **Impact**: Developers can create desktop-like experiences in the terminal with minimal effort.
+[View.Arrangement](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_Arrangement) enables interactive UI:
+
+- **[ViewArrangement.Movable](~/api/Terminal.Gui.ViewBase.ViewArrangement.yml)** - Drag with mouse or move with keyboard
+- **[ViewArrangement.Resizable](~/api/Terminal.Gui.ViewBase.ViewArrangement.yml)** - Resize edges with mouse or keyboard
+- **[ViewArrangement.Overlapped](~/api/Terminal.Gui.ViewBase.ViewArrangement.yml)** - Z-order management for overlapping views
+
+**Arrangement Key**: Press `Ctrl+F5` (configurable via [Application.ArrangeKey](~/api/Terminal.Gui.App.Application.yml#Terminal_Gui_App_Application_ArrangeKey)) to enter arrange mode
+
+```csharp
+// Movable and resizable window
+window.Arrangement = ViewArrangement.Movable | ViewArrangement.Resizable;
+
+// Overlapped windows
+container.Arrangement = ViewArrangement.Overlapped;
+```
+
+### Enhanced Navigation
+
+See the [Navigation Deep Dive](navigation.md) for complete details.
+
+v2 decouples navigation concepts:
+
+- **[CanFocus](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_CanFocus)** - Whether view can receive focus (defaults to `false` in v2)
+- **[TabStop](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_TabStop)** - [TabBehavior](~/api/Terminal.Gui.Input.TabBehavior.yml) enum (TabStop, TabGroup, NoStop)
+- **[ApplicationNavigation](~/api/Terminal.Gui.App.ApplicationNavigation.yml)** - Centralized navigation logic
+
+**Navigation Keys (Configurable):**
+- `Tab` / `Shift+Tab` - Next/previous TabStop
+- `F6` / `Shift+F6` - Next/previous TabGroup
+- Arrow keys - Same as Tab navigation
+
+```csharp
+// Configure navigation keys
+Application.NextTabStopKey = Key.Tab;
+Application.PrevTabStopKey = Key.Tab.WithShift;
+Application.NextTabGroupKey = Key.F6;
+Application.PrevTabGroupKey = Key.F6.WithShift;
+
+// Set tab behavior
+view.CanFocus = true;
+view.TabStop = TabBehavior.TabStop; // Normal tab navigation
+```
+
+---
+
+## New and Improved Views
+
+See the [Views Overview](views.md) for a complete catalog.
+
+### New Views in v2
+
+- **[Bar](~/api/Terminal.Gui.Views.Bar.yml)** - Foundation for StatusBar, MenuBar, PopoverMenu
+- **[CharMap](~/api/Terminal.Gui.Views.CharMap.yml)** - Scrollable Unicode character map with UCD support
+- **[ColorPicker](~/api/Terminal.Gui.Views.ColorPicker.yml)** - TrueColor selection with multiple color models
+- **[DatePicker](~/api/Terminal.Gui.Views.DatePicker.yml)** - Calendar-based date selection
+- **[FlagSelector](~/api/Terminal.Gui.Views.FlagSelector.yml)** - Non-mutually-exclusive flag selection
+- **[GraphView](~/api/Terminal.Gui.Views.GraphView.yml)** - Data visualization (bar, scatter, line graphs)
+- **[Line](~/api/Terminal.Gui.Views.Line.yml)** - Single lines with LineCanvas integration
+- **[NumericUpDown<T>](~/api/Terminal.Gui.Views.NumericUpDown-1.yml)** - Type-safe numeric input
+- **[OptionSelector](~/api/Terminal.Gui.Views.OptionSelector.yml)** - Mutually-exclusive option selection
+- **[Shortcut](~/api/Terminal.Gui.Views.Shortcut.yml)** - Command display with key bindings
+- **[Slider](~/api/Terminal.Gui.Views.Slider.yml)** - Sophisticated range selection control
+- **[SpinnerView](~/api/Terminal.Gui.Views.SpinnerView.yml)** - Animated progress indicators
+
+### Significantly Improved Views
 
-### Keyboard Navigation Overhaul
+- **[FileDialog](~/api/Terminal.Gui.Views.FileDialog.yml)** - TreeView navigation, Unicode icons, search, history
+- **[ScrollBar](~/api/Terminal.Gui.Views.ScrollBar.yml)** - Clean implementation with auto-show
+- **[StatusBar](~/api/Terminal.Gui.Views.StatusBar.yml)** - Rebuilt on Bar infrastructure
+- **[TableView](~/api/Terminal.Gui.Views.TableView.yml)** - Generic collections, checkboxes, tree structures, custom rendering
+- **[MenuBar](~/api/Terminal.Gui.Views.MenuBar.yml)** / **[PopoverMenu](~/api/Terminal.Gui.Views.PopoverMenu.yml)** - Redesigned menu system
 
-See the [Navigation Deep Dive](navigation.md) for complete details on the navigation system.
+---
 
-- **v1 Issue**: Navigation was inconsistent, with coupled concepts like [View.CanFocus](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_CanFocus) and `TabStop` leading to unpredictable focus behavior.
-- **v2 Solution**: v2 decouples these concepts, introduces [TabBehavior](~/api/Terminal.Gui.Input.TabBehavior.yml) enum for clearer intent (`TabStop`, `TabGroup`, `NoStop`), and centralizes navigation logic in [ApplicationNavigation](~/api/Terminal.Gui.App.ApplicationNavigation.yml).
-- **Impact**: Ensures accessibility by guaranteeing keyboard access to all focusable elements, with unit tests enforcing navigation keys on built-in views.
+## Enhanced Input Handling
 
-### Sizable/Movable Views
-- **Implementation**: Any view can be made resizable or movable by setting [View.Arrangement](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_Arrangement) flags, with built-in mouse and keyboard handlers for interaction.
-- **Impact**: Enhances user experience by allowing runtime UI customization, a feature limited to specific views like [Window](~/api/Terminal.Gui.Views.Window.yml) in v1.
+### Keyboard API
 
-## New and Improved Built-in Views - Detailed Analysis
+See the [Keyboard Deep Dive](keyboard.md) and [Command Deep Dive](command.md) for details.
 
-See the [Views Overview](views.md) for a complete catalog of all built-in views.
+**[Key](~/api/Terminal.Gui.Input.Key.yml) Class:**
+- Replaces v1's `KeyEvent` struct
+- High-level abstraction over raw key codes
+- Properties for modifiers and key type
+- Platform-independent
 
-### New Views
+```csharp
+// Check keys
+if (key == Key.Enter) { }
+if (key == Key.C.WithCtrl) { }
+
+// Modifiers
+if (key.Shift) { }
+if (key.Ctrl) { }
+```
+
+**Key Bindings:**
+- Map keys to [Command](~/api/Terminal.Gui.Input.Command.yml) enums
+- Scopes: Application, Focused, HotKey
+- Views declare supported commands via [View.AddCommand](~/api/Terminal.Gui.ViewBase.View.yml)
+
+```csharp
+// Add command handler
+view.AddCommand (Command.Accept, HandleAccept);
+
+// Bind key to command
+view.KeyBindings.Add (Key.Enter, Command.Accept);
+
+private bool HandleAccept ()
+{
+    // Handle command
+    return true; // Handled
+}
+```
+
+**Configurable Keys:**
+- [Application.QuitKey](~/api/Terminal.Gui.App.Application.yml#Terminal_Gui_App_Application_QuitKey) - Close app (default: Esc)
+- [Application.ArrangeKey](~/api/Terminal.Gui.App.Application.yml#Terminal_Gui_App_Application_ArrangeKey) - Arrange mode (default: Ctrl+F5)
+- Navigation keys (Tab, F6, arrows)
+
+### Mouse API
+
+See the [Mouse Deep Dive](mouse.md) for complete details.
+
+**[MouseEventArgs](~/api/Terminal.Gui.Input.MouseEventArgs.yml):**
+- Replaces v1's `MouseEventEventArgs`
+- Cleaner structure for mouse data
+- [MouseFlags](~/api/Terminal.Gui.Input.MouseFlags.yml) for button states
+
+**Granular Events:**
+- [View.MouseClick](~/api/Terminal.Gui.ViewBase.View.yml) - High-level click events
+- Double-click support
+- Mouse movement tracking
+- Viewport-relative coordinates (not screen-relative)
+
+**Highlight and Continuous Presses:**
+- [View.Highlight](~/api/Terminal.Gui.ViewBase.View.yml) - Visual feedback on hover/click
+- [View.HighlightStyle](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_HighlightStyle) - Configure highlight appearance
+- [View.WantContinuousButtonPresses](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_WantContinuousButtonPresses) - Repeat [Command.Accept](~/api/Terminal.Gui.Input.Command.yml) during button hold
+
+```csharp
+// Highlight on hover
+view.Highlight += (s, e) => { /* Visual feedback */ };
+view.HighlightStyle = HighlightStyle.Hover;
 
-v2 introduces many new View subclasses that were not present in v1:
+// Continuous button presses
+view.WantContinuousButtonPresses = true;
+```
+
+---
+
+## Configuration and Persistence
+
+See the [Configuration Deep Dive](config.md) for complete details.
+
+### ConfigurationManager
 
-- **Bar**: A foundational view for horizontal or vertical layouts of `Shortcut` or other items, used in `StatusBar`, `MenuBar`, and `PopoverMenu`.
-- **CharMap**: A scrollable, searchable Unicode character map with support for the Unicode Character Database (UCD) API, enabling users to browse and select from all Unicode codepoints with detailed character information. See [Character Map Deep Dive](CharacterMap.md).
-- **ColorPicker**: Leverages TrueColor for a comprehensive color selection experience, supporting multiple color models (HSV, RGB, HSL, Grayscale) with interactive color bars.
-- **DatePicker**: Provides a calendar-based date selection UI with month/year navigation, leveraging v2's improved drawing and navigation systems.
-- **FlagSelector**: Enables selection of non-mutually-exclusive flags with checkbox-based UI, supporting both dictionary-based and enum-based flag definitions.
-- **GraphView**: Displays graphs (bar charts, scatter plots, line graphs) with flexible axes, labels, scaling, scrolling, and annotations - bringing data visualization to the terminal.
-- **Line**: Draws single horizontal or vertical lines using the `LineCanvas` system with automatic intersection handling and multiple line styles (Single, Double, Heavy, Rounded, Dashed, Dotted).
-- **Menu System** (MenuBar, PopoverMenu): A completely redesigned menu system built on the `Bar` infrastructure, providing a more flexible and visually appealing menu experience.
-- **NumericUpDown<T>**: Type-safe numeric input with increment/decrement buttons, supporting `int`, `long`, `float`, `double`, and `decimal` types.
-- **OptionSelector**: Displays a list of mutually-exclusive options with checkbox-style UI (radio button equivalent), supporting both horizontal and vertical orientations.
-- **Shortcut**: An opinionated view for displaying commands with key bindings, simplifying status bar and toolbar creation with consistent visual presentation.
-- **Slider**: A sophisticated control for range selection with multiple styles (horizontal/vertical bars, indicators), multiple options per slider, configurable legends, and event-driven value changes.
-- **SpinnerView**: Displays animated spinner glyphs to indicate progress or activity, with multiple built-in styles (Line, Dots, Bounce, etc.) and support for auto-spin or manual animation control.
+[ConfigurationManager](~/api/Terminal.Gui.Configuration.ConfigurationManager.yml) provides:
 
-### Improved Views
+- JSON-based persistence
+- Theme management
+- Key binding customization
+- View property persistence
+- [SettingsScope](~/api/Terminal.Gui.Configuration.SettingsScope.yml) - User, Application, Machine levels
+- [ConfigLocations](~/api/Terminal.Gui.Configuration.ConfigLocations.yml) - Where to search for configs
 
-Many existing views from v1 have been significantly enhanced in v2:
+```csharp
+// Enable configuration
+ConfigurationManager.Enable (ConfigLocations.All);
 
-- **FileDialog** (OpenDialog, SaveDialog): Completely modernized with `TreeView` for hierarchical file navigation, Unicode glyphs for icons, search functionality, and history tracking - far surpassing v1's basic file dialogs.
-- **ScrollBar**: Replaces v1's `ScrollBarView` with a cleaner implementation featuring automatic show/hide, proportional sizing with `ScrollSlider`, and seamless integration with View's built-in scrolling system.
-- **StatusBar**: Rebuilt on the `Bar` infrastructure, providing more flexible item management, automatic sizing, and better visual presentation.
-- **TableView**: Massively enhanced with support for generic collections (via `IEnumerableTableSource`), checkboxes with `CheckBoxTableSourceWrapper`, tree structures via `TreeTableSource`, custom cell rendering, and significantly improved performance. See [TableView Deep Dive](tableview.md).
-- **ScrollView**: Deprecated in favor of View's built-in scrolling capabilities, eliminating the need for wrapper views and simplifying scrollable content implementation.
+// Load a theme
+ConfigurationManager.Themes.Theme = "Dark";
 
-## Beauty - Visual Enhancements
+// Save current configuration
+ConfigurationManager.Save ();
+```
 
-### Borders
+**User Customization:**
+- End-users can personalize themes, colors, text styles
+- Key bindings can be remapped
+- No code changes required
+- JSON files easily editable
 
-See the [Drawing Deep Dive](drawing.md) for complete details on borders and LineCanvas.
+---
 
-- **Implementation**: Uses the [Border](~/api/Terminal.Gui.ViewBase.Border.yml) adornment with [LineStyle](~/api/Terminal.Gui.Drawing.LineStyle.yml) options and [LineCanvas](~/api/Terminal.Gui.Drawing.LineCanvas.yml) for automatic line intersection handling.
-- **Impact**: Adds visual polish to UI elements, making applications feel more refined compared to v1's basic borders.
+## Debugging and Performance
 
-### Gradient
+See the [Logging Deep Dive](logging.md) for complete details.
 
-See the [Drawing Deep Dive](drawing.md) for complete details on gradients and fills.
+### Logging System
 
-- **Implementation**: [Gradient](~/api/Terminal.Gui.Drawing.Gradient.yml) and [GradientFill](~/api/Terminal.Gui.Drawing.GradientFill.yml) APIs allow rendering color transitions across view elements, using TrueColor for smooth effects.
-- **Impact**: Enables modern-looking UI elements like gradient borders or backgrounds, not possible in v1 without custom drawing.
+[Logging](~/api/Terminal.Gui.App.Logging.yml) integrates with Microsoft.Extensions.Logging:
 
-## Configuration Manager - Persistence and Customization
+- Multi-level logging (Trace, Debug, Info, Warning, Error)
+- Internal operation tracking (rendering, input, layout)
+- Works with standard .NET logging frameworks (Serilog, NLog, etc.)
 
-See the [Configuration Deep Dive](config.md) for complete details on the configuration system.
+```csharp
+// Configure logging
+Logging.ConfigureLogging ("myapp.log", LogLevel.Debug);
 
-- **Technical Detail**: [ConfigurationManager](~/api/Terminal.Gui.Configuration.ConfigurationManager.yml) in v2 uses JSON to persist settings like themes, key bindings, and view properties to disk via [SettingsScope](~/api/Terminal.Gui.Configuration.SettingsScope.yml) and [ConfigLocations](~/api/Terminal.Gui.Configuration.ConfigLocations.yml).
-- **Code Change**: Unlike v1, where settings were ephemeral or hardcoded, v2 provides a centralized system for loading/saving configurations using the [ConfigurationManagerAttribute](~/api/Terminal.Gui.Configuration.ConfigurationManagerAttribute.yml).
-- **Impact**: Allows for user-specific customizations and library-wide settings without recompilation, enhancing flexibility.
+// Use in code
+Logging.Debug ("Rendering view {ViewId}", view.Id);
+```
 
-## Logging & Metrics - Debugging and Performance
+### Metrics
 
-See the [Logging Deep Dive](logging.md) for complete details on the logging and metrics system.
+[Logging.Meter](~/api/Terminal.Gui.App.Logging.yml#Terminal_Gui_App_Logging_Meter) provides performance metrics:
 
-- **Implementation**: v2 introduces a multi-level logging system via [Logging](~/api/Terminal.Gui.App.Logging.yml) for internal operations (e.g., rendering, input handling) using Microsoft.Extensions.Logging.ILogger, and metrics for performance tracking via [Logging.Meter](~/api/Terminal.Gui.App.Logging.yml#Terminal_Gui_App_Logging_Meter) (e.g., frame rate, redraw times, iteration timing).
-- **Impact**: Developers can diagnose issues like slow redraws or terminal compatibility problems using standard .NET logging frameworks (Serilog, NLog, etc.) and metrics tools (dotnet-counters), a capability absent in v1, reducing guesswork in debugging.
+- Frame rate tracking
+- Redraw times
+- Iteration timing
+- Input processing overhead
 
-## Sixel Image Support - Graphics in Terminal
-- **Technical Detail**: v2 supports the Sixel protocol for rendering images and animations directly in compatible terminals (e.g., Windows Terminal, xterm) via [SixelEncoder](~/api/Terminal.Gui.Drawing.SixelEncoder.yml).
-- **Code Change**: New rendering logic in console drivers detects terminal support via [SixelSupportDetector](~/api/Terminal.Gui.Drawing.SixelSupportDetector.yml) and handles Sixel data transmission through [SixelToRender](~/api/Terminal.Gui.Drawing.SixelToRender.yml).
-- **Impact**: Brings graphical capabilities to terminal applications, far beyond v1's text-only rendering, opening up new use cases like image previews.
+**Tools**: Use `dotnet-counters` or other metrics tools to monitor
 
-## Updated Keyboard API - Comprehensive Input Handling
+```bash
+dotnet counters monitor --name MyApp Terminal.Gui
+```
 
-See the [Keyboard Deep Dive](keyboard.md) and [Command Deep Dive](command.md) for complete details.
+---
 
-### Key Class
-- **Change**: Replaces v1's `KeyEvent` struct with a [Key](~/api/Terminal.Gui.Input.Key.yml) class, providing a high-level abstraction over raw key codes with properties for modifiers and key type.
-- **Impact**: Simplifies keyboard handling by abstracting platform differences, making code more portable and readable.
+## Additional Features
 
-### Key Bindings
-- **Implementation**: v2 introduces a binding system mapping keys to [Command](~/api/Terminal.Gui.Input.Command.yml) enums via [View.KeyBindings](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_KeyBindings), with scopes (`Application`, `Focused`, `HotKey`) for priority.
-- **Impact**: Replaces v1's ad-hoc key handling with a structured approach, allowing views to declare supported commands via [View.AddCommand](~/api/Terminal.Gui.ViewBase.View.yml) and customize responses easily.
-- **Example**: [TextField](~/api/Terminal.Gui.Views.TextField.yml) in v2 binds `Key.Tab` to text insertion rather than focus change, customizable by developers.
+### Sixel Image Support
 
-### Default Close Key
-- **Change**: Changed from `Ctrl+Q` in v1 to `Esc` in v2 for closing apps or [Runnable](~/api/Terminal.Gui.Views.Runnable.yml) views, accessible via [Application.QuitKey](~/api/Terminal.Gui.App.Application.yml#Terminal_Gui_App_Application_QuitKey).
-- **Impact**: Aligns with common user expectations, improving UX consistency across terminal applications.
+v2 supports the Sixel protocol for rendering images:
 
-## Updated Mouse API - Enhanced Interaction
+- [SixelEncoder](~/api/Terminal.Gui.Drawing.SixelEncoder.yml) - Encode images as Sixel data
+- [SixelSupportDetector](~/api/Terminal.Gui.Drawing.SixelSupportDetector.yml) - Detect terminal support
+- [SixelToRender](~/api/Terminal.Gui.Drawing.SixelToRender.yml) - Render Sixel images
+- Compatible terminals: Windows Terminal, xterm, others
 
-See the [Mouse Deep Dive](mouse.md) for complete details on mouse handling.
+**Use Cases**: Image previews, graphics in terminal apps
 
-### MouseEventArgs Class
-- **Change**: Replaces v1's `MouseEventEventArgs` with [MouseEventArgs](~/api/Terminal.Gui.Input.MouseEventArgs.yml), providing a cleaner structure for mouse data (position, flags via [MouseFlags](~/api/Terminal.Gui.Input.MouseFlags.yml)).
-- **Impact**: Simplifies event handling with a more intuitive API, reducing errors in mouse interaction logic.
+### AOT Support
 
-### Granular Mouse Handling
-- **Implementation**: v2 offers specific events for clicks ([View.MouseClick](~/api/Terminal.Gui.ViewBase.View.yml)), double-clicks, and movement, with [MouseFlags](~/api/Terminal.Gui.Input.MouseFlags.yml) for button states.
-- **Impact**: Developers can handle complex mouse interactions (e.g., drag-and-drop) more easily than in v1.
+v2 ensures compatibility with Ahead-of-Time compilation:
 
-### Highlight Event and Continuous Button Presses
-- **Highlight**: Views can visually respond to mouse hover or click via the [View.Highlight](~/api/Terminal.Gui.ViewBase.View.yml) event and [View.HighlightStyle](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_HighlightStyle) property.
-- **Continuous Presses**: Setting [View.WantContinuousButtonPresses](~/api/Terminal.Gui.ViewBase.View.yml#Terminal_Gui_ViewBase_View_WantContinuousButtonPresses) = true repeats [Command.Accept](~/api/Terminal.Gui.Input.Command.yml) during button hold, useful for sliders or buttons.
-- **Impact**: Enhances interactive feedback, making terminal UIs feel more responsive.
+- Avoid reflection patterns problematic for AOT
+- Source generators for JSON serialization via [SourceGenerationContext](~/api/Terminal.Gui.Configuration.SourceGenerationContext.yml)
+- Single-file deployment support
+- Faster startup, reduced runtime overhead
 
-## AOT Support - Deployment and Performance
-- **Implementation**: v2 ensures compatibility with Ahead-of-Time compilation and single-file applications by avoiding reflection patterns problematic for AOT, using source generators and [SourceGenerationContext](~/api/Terminal.Gui.Configuration.SourceGenerationContext.yml) for JSON serialization.
-- **Impact**: Simplifies deployment for environments requiring Native AOT (see `Examples/NativeAot`), a feature not explicitly supported in v1, reducing runtime overhead and enabling faster startup times.
+**Example**: See `Examples/NativeAot` for AOT deployment
+
+### Enhanced Unicode Support
+
+- Correctly manages wide characters (CJK scripts)
+- [TextFormatter](~/api/Terminal.Gui.Text.TextFormatter.yml) accounts for Unicode width
+- Fixes v1 layout issues with wide characters
+- International application support
+
+---
 
 ## Conclusion
 
-Terminal.Gui v2 is a transformative update, addressing core limitations of v1 through architectural redesign, performance optimizations, and feature enhancements. From TrueColor and adornments for visual richness to decoupled navigation and modern input APIs for usability, v2 provides a robust foundation for building sophisticated terminal applications. The detailed changes in view management, configuration, and debugging tools empower developers to create more maintainable and user-friendly applications.
+Terminal.Gui v2 represents a comprehensive modernization:
+
+**Architecture:**
+- Instance-based application model
+- IRunnable architecture with type-safe results
+- Proper resource management (IDisposable)
+- Decoupled concerns (layout, focus, input)
+
+**Features:**
+- 24-bit TrueColor
+- Built-in scrolling
+- Enhanced adornments (Margin, Border, Padding)
+- Modern keyboard and mouse APIs
+- Configuration and themes
+- Logging and metrics
+
+**API:**
+- Simplified and consistent
+- Modern .NET patterns
+- Better performance
+- Improved testability
+
+**Views:**
+- Many new views (CharMap, ColorPicker, GraphView, etc.)
+- Significantly improved existing views
+- Easier to create custom views
+
+v2 provides a robust foundation for building sophisticated, maintainable, and user-friendly terminal applications. The architectural improvements, combined with new features and enhanced APIs, enable developers to create modern terminal UIs that feel responsive and polished.
+
+For detailed migration guidance, see the [v1 To v2 Migration Guide](migratingfromv1.md).