Browse Source

Refactored Diagnostics

Tig 1 year ago
parent
commit
a518cb37ee

+ 0 - 23
Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs

@@ -14,26 +14,6 @@ namespace Terminal.Gui;
 /// </remarks>
 public abstract class ConsoleDriver
 {
-    /// <summary>Enables diagnostic functions</summary>
-    [Flags]
-    public enum DiagnosticFlags : uint
-    {
-        /// <summary>All diagnostics off</summary>
-        Off = 0b_0000_0000,
-
-        /// <summary>
-        ///     When enabled, <see cref="View.OnDrawAdornments"/> will draw a ruler in the frame for any side with a padding
-        ///     value greater than 0.
-        /// </summary>
-        FrameRuler = 0b_0000_0001,
-
-        /// <summary>
-        ///     When enabled, <see cref="View.OnDrawAdornments"/> will draw a 'L', 'R', 'T', and 'B' when clearing
-        ///     <see cref="Thickness"/>'s instead of ' '.
-        /// </summary>
-        FramePadding = 0b_0000_0010
-    }
-
     // As performance is a concern, we keep track of the dirty lines and only refresh those.
     // This is in addition to the dirty flag on each cell.
     internal bool [] _dirtyLines;
@@ -75,9 +55,6 @@ public abstract class ConsoleDriver
     /// </summary>
     public Cell [,] Contents { get; internal set; }
 
-    /// <summary>Set flags to enable/disable <see cref="ConsoleDriver"/> diagnostics.</summary>
-    public static DiagnosticFlags Diagnostics { get; set; }
-
     /// <summary>The leftmost column in the terminal.</summary>
     public virtual int Left { get; internal set; } = 0;
 

+ 7 - 11
Terminal.Gui/Drawing/Thickness.cs

@@ -120,10 +120,10 @@ public class Thickness : IEquatable<Thickness>
 
     /// <summary>Draws the <see cref="Thickness"/> rectangle with an optional diagnostics label.</summary>
     /// <remarks>
-    ///     If <see cref="ConsoleDriver.DiagnosticFlags"/> is set to
-    ///     <see cref="ConsoleDriver.DiagnosticFlags.FramePadding"/> then 'T', 'L', 'R', and 'B' glyphs will be used instead of
-    ///     space. If <see cref="ConsoleDriver.DiagnosticFlags"/> is set to
-    ///     <see cref="ConsoleDriver.DiagnosticFlags.FrameRuler"/> then a ruler will be drawn on the outer edge of the
+    ///     If <see cref="ViewDiagnosticFlags"/> is set to
+    ///     <see cref="ViewViewDiagnosticFlags.Paddingthen 'T', 'L', 'R', and 'B' glyphs will be used instead of
+    ///     space. If <see cref="ViewDiagnosticFlags"/> is set to
+    ///     <see cref="ViewViewDiagnosticFlags.Rulerthen a ruler will be drawn on the outer edge of the
     ///     Thickness.
     /// </remarks>
     /// <param name="rect">The location and size of the rectangle that bounds the thickness rectangle, in screen coordinates.</param>
@@ -142,8 +142,7 @@ public class Thickness : IEquatable<Thickness>
         Rune topChar = clearChar;
         Rune bottomChar = clearChar;
 
-        if ((ConsoleDriver.Diagnostics & ConsoleDriver.DiagnosticFlags.FramePadding)
-            == ConsoleDriver.DiagnosticFlags.FramePadding)
+        if (View.Diagnostics.HasFlag (ViewDiagnosticFlags.Padding))
         {
             leftChar = (Rune)'L';
             rightChar = (Rune)'R';
@@ -194,9 +193,7 @@ public class Thickness : IEquatable<Thickness>
                                         );
         }
 
-        // TODO: This should be moved to LineCanvas as a new LineStyle.Ruler
-        if ((ConsoleDriver.Diagnostics & ConsoleDriver.DiagnosticFlags.FrameRuler)
-            == ConsoleDriver.DiagnosticFlags.FrameRuler)
+        if (View.Diagnostics.HasFlag(ViewDiagnosticFlags.Ruler))
         {
             // PERF: This can almost certainly be simplified down to a single point offset and fewer calls to Draw
             // Top
@@ -228,8 +225,7 @@ public class Thickness : IEquatable<Thickness>
             }
         }
 
-        if ((ConsoleDriver.Diagnostics & ConsoleDriver.DiagnosticFlags.FramePadding)
-            == ConsoleDriver.DiagnosticFlags.FramePadding)
+        if (View.Diagnostics.HasFlag (ViewDiagnosticFlags.Padding))
         {
             // Draw the diagnostics label on the bottom
             var tf = new TextFormatter

+ 1 - 2
Terminal.Gui/View/Adornment/Border.cs

@@ -359,8 +359,7 @@ public class Border : Adornment
             Driver.SetAttribute (prevAttr);
 
             // TODO: This should be moved to LineCanvas as a new BorderStyle.Ruler
-            if ((ConsoleDriver.Diagnostics & ConsoleDriver.DiagnosticFlags.FrameRuler)
-                == ConsoleDriver.DiagnosticFlags.FrameRuler)
+            if (View.Diagnostics.HasFlag (ViewDiagnosticFlags.Ruler))
             {
                 // Top
                 var hruler = new Ruler { Length = screenBounds.Width, Orientation = Orientation.Horizontal };

+ 27 - 0
Terminal.Gui/View/ViewDiagnostics.cs

@@ -0,0 +1,27 @@
+
+namespace Terminal.Gui;
+
+/// <summary>Enables diagnostic functions for <see cref="View"/>.</summary>
+[Flags]
+public enum ViewDiagnosticFlags : uint
+{
+    /// <summary>All diagnostics off</summary>
+    Off = 0b_0000_0000,
+
+    /// <summary>
+    ///     When enabled, <see cref="View.OnDrawAdornments"/> will draw a ruler in the Thickness.
+    /// </summary>
+    Ruler = 0b_0000_0001,
+
+    /// <summary>
+    ///     When enabled, <see cref="View.OnDrawAdornments"/> will draw the first letter of the Adornment name ('M', 'B', or 'P')
+    ///     in the Thickness.
+    /// </summary>
+    Padding = 0b_0000_0010
+}
+
+public partial class View
+{
+    /// <summary>Flags to enable/disable <see cref="View"/> diagnostics.</summary>
+    public static ViewDiagnosticFlags Diagnostics { get; set; }
+}

+ 4 - 3
UICatalog/Scenarios/Adornments.cs

@@ -400,17 +400,18 @@ public class Adornments : Scenario
                 Add (_paddingEditor);
 
                 _diagCheckBox = new CheckBox { Text = "_Diagnostics", Y = Pos.Bottom (_paddingEditor) };
+                _diagCheckBox.Checked = View.Diagnostics != ViewDiagnosticFlags.Off;
 
                 _diagCheckBox.Toggled += (s, e) =>
                                          {
                                              if (e.NewValue == true)
                                              {
-                                                 ConsoleDriver.Diagnostics =
-                                                     ConsoleDriver.DiagnosticFlags.FramePadding | ConsoleDriver.DiagnosticFlags.FrameRuler;
+                                                 View.Diagnostics =
+                                                     ViewDiagnosticFlags.Padding | ViewDiagnosticFlags.Ruler;
                                              }
                                              else
                                              {
-                                                 ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.Off;
+                                                 View.Diagnostics = ViewDiagnosticFlags.Off;
                                              }
                                          };
 

+ 4 - 4
UICatalog/Scenarios/AllViewsTester.cs

@@ -64,8 +64,8 @@ public class AllViewsTester : Scenario
                                                 "~F2~ Toggle Frame Ruler",
                                                 () =>
                                                 {
-                                                    ConsoleDriver.Diagnostics ^=
-                                                        ConsoleDriver.DiagnosticFlags.FrameRuler;
+                                                    View.Diagnostics ^=
+                                                        ViewDiagnosticFlags.Ruler;
                                                     Application.Top.SetNeedsDisplay ();
                                                 }
                                                ),
@@ -74,8 +74,8 @@ public class AllViewsTester : Scenario
                                                 "~F3~ Toggle Frame Padding",
                                                 () =>
                                                 {
-                                                    ConsoleDriver.Diagnostics ^=
-                                                        ConsoleDriver.DiagnosticFlags.FramePadding;
+                                                    View.Diagnostics ^=
+                                                        ViewDiagnosticFlags.Padding;
                                                     Application.Top.SetNeedsDisplay ();
                                                 }
                                                )

+ 9 - 9
UICatalog/Scenarios/GraphViewExample.cs

@@ -122,11 +122,11 @@ public class GraphViewExample : Scenario
                                                               () => EnableDiagnostics ()
                                                              )
                                      {
-                                         Checked = ConsoleDriver.Diagnostics
-                                                   == (ConsoleDriver.DiagnosticFlags
-                                                                    .FramePadding
-                                                       | ConsoleDriver.DiagnosticFlags
-                                                                      .FrameRuler),
+                                         Checked = View.Diagnostics
+                                                   == (ViewDiagnosticFlags
+                                                                    .Padding
+                                                       | ViewDiagnosticFlags
+                                                                      .Ruler),
                                          CheckType = MenuItemCheckStyle.Checked
                                      }
                                  }
@@ -186,10 +186,10 @@ public class GraphViewExample : Scenario
     {
         _miDiags.Checked = !_miDiags.Checked;
 
-        ConsoleDriver.Diagnostics = _miDiags.Checked == true
-                                        ? ConsoleDriver.DiagnosticFlags.FramePadding
-                                          | ConsoleDriver.DiagnosticFlags.FrameRuler
-                                        : ConsoleDriver.DiagnosticFlags.Off;
+        View.Diagnostics = _miDiags.Checked == true
+                                        ? ViewDiagnosticFlags.Padding
+                                          | ViewDiagnosticFlags.Ruler
+                                        : ViewDiagnosticFlags.Off;
         Application.Refresh ();
     }
 

+ 1 - 1
UICatalog/Scenarios/LineCanvasExperiment.cs

@@ -31,7 +31,7 @@ public class LineCanvasExperiment : Scenario
         };
         frame1.BorderStyle = LineStyle.Double;
 
-        //ConsoleDriver.Diagnostics ^= ConsoleDriver.DiagnosticFlags.FrameRuler;
+        //View.Diagnostics ^= DiagnosticFlags.FrameRuler;
 
         Application.Top.Add (frame1);
 

+ 89 - 101
UICatalog/UICatalog.cs

@@ -56,7 +56,7 @@ internal class UICatalogApp
     private static string? _cachedTheme = string.Empty;
     private static List<string>? _categories;
     private static readonly FileSystemWatcher _currentDirWatcher = new ();
-    private static ConsoleDriver.DiagnosticFlags _diagnosticFlags;
+    private static ViewDiagnosticFlags _diagnosticFlags;
     private static string _forceDriver = string.Empty;
     private static readonly FileSystemWatcher _homeDirWatcher = new ();
     private static bool _isFirstRunning = true;
@@ -156,7 +156,7 @@ internal class UICatalogApp
         {
             using var process = new Process
             {
-                StartInfo = new ProcessStartInfo
+                StartInfo = new()
                 {
                     FileName = "xdg-open",
                     Arguments = url,
@@ -301,7 +301,7 @@ internal class UICatalogApp
             return;
         }
 
-        _aboutMessage = new StringBuilder ();
+        _aboutMessage = new ();
         _aboutMessage.AppendLine (@"A comprehensive sample library for");
         _aboutMessage.AppendLine (@"");
         _aboutMessage.AppendLine (@"  _______                  _             _   _____       _  ");
@@ -388,68 +388,68 @@ internal class UICatalogApp
         public UICatalogTopLevel ()
         {
             _themeMenuItems = CreateThemeMenuItems ();
-            _themeMenuBarItem = new MenuBarItem ("_Themes", _themeMenuItems);
+            _themeMenuBarItem = new ("_Themes", _themeMenuItems);
 
-            MenuBar = new MenuBar
+            MenuBar = new()
             {
                 Menus =
                 [
-                    new MenuBarItem (
-                                     "_File",
-                                     new MenuItem []
-                                     {
-                                         new (
-                                              "_Quit",
-                                              "Quit UI Catalog",
-                                              RequestStop
-                                             )
-                                     }
-                                    ),
+                    new (
+                         "_File",
+                         new MenuItem []
+                         {
+                             new (
+                                  "_Quit",
+                                  "Quit UI Catalog",
+                                  RequestStop
+                                 )
+                         }
+                        ),
                     _themeMenuBarItem,
-                    new MenuBarItem ("Diag_nostics", CreateDiagnosticMenuItems ()),
-                    new MenuBarItem (
-                                     "_Help",
-                                     new MenuItem []
-                                     {
-                                         new (
-                                              "_Documentation",
-                                              "",
-                                              () => OpenUrl ("https://gui-cs.github.io/Terminal.GuiV2Docs"),
-                                              null,
-                                              null,
-                                              (KeyCode)Key.F1
-                                             ),
-                                         new (
-                                              "_README",
-                                              "",
-                                              () => OpenUrl ("https://github.com/gui-cs/Terminal.Gui"),
-                                              null,
-                                              null,
-                                              (KeyCode)Key.F2
-                                             ),
-                                         new (
-                                              "_About...",
-                                              "About UI Catalog",
-                                              () => MessageBox.Query (
-                                                                      "About UI Catalog",
-                                                                      _aboutMessage!.ToString (),
-                                                                      0,
-                                                                      false,
-                                                                      "_Ok"
-                                                                     ),
-                                              null,
-                                              null,
-                                              (KeyCode)Key.A.WithCtrl
-                                             )
-                                     }
-                                    )
+                    new ("Diag_nostics", CreateDiagnosticMenuItems ()),
+                    new (
+                         "_Help",
+                         new MenuItem []
+                         {
+                             new (
+                                  "_Documentation",
+                                  "",
+                                  () => OpenUrl ("https://gui-cs.github.io/Terminal.GuiV2Docs"),
+                                  null,
+                                  null,
+                                  (KeyCode)Key.F1
+                                 ),
+                             new (
+                                  "_README",
+                                  "",
+                                  () => OpenUrl ("https://github.com/gui-cs/Terminal.Gui"),
+                                  null,
+                                  null,
+                                  (KeyCode)Key.F2
+                                 ),
+                             new (
+                                  "_About...",
+                                  "About UI Catalog",
+                                  () => MessageBox.Query (
+                                                          "About UI Catalog",
+                                                          _aboutMessage!.ToString (),
+                                                          0,
+                                                          false,
+                                                          "_Ok"
+                                                         ),
+                                  null,
+                                  null,
+                                  (KeyCode)Key.A.WithCtrl
+                                 )
+                         }
+                        )
                 ]
             };
 
-            DriverName = new StatusItem (Key.Empty, "Driver:", null);
-            OS = new StatusItem (Key.Empty, "OS:", null);
+            DriverName = new (Key.Empty, "Driver:", null);
+            OS = new (Key.Empty, "OS:", null);
 
-            StatusBar = new StatusBar { Visible = ShowStatusBar };
+            StatusBar = new() { Visible = ShowStatusBar };
 
             StatusBar.Items = new []
             {
@@ -487,7 +487,7 @@ internal class UICatalogApp
             };
 
             // Create the Category list view. This list never changes.
-            CategoryList = new ListView
+            CategoryList = new()
             {
                 X = 0,
                 Y = 1,
@@ -506,7 +506,7 @@ internal class UICatalogApp
             // Create the scenario list. The contents of the scenario list changes whenever the
             // Category list selection changes (to show just the scenarios that belong to the selected
             // category).
-            ScenarioList = new TableView
+            ScenarioList = new()
             {
                 X = Pos.Right (CategoryList) - 1,
                 Y = 1,
@@ -547,9 +547,9 @@ internal class UICatalogApp
 
             ScenarioList.Style.ColumnStyles.Add (
                                                  0,
-                                                 new ColumnStyle { MaxWidth = longestName, MinWidth = longestName, MinAcceptableWidth = longestName }
+                                                 new() { MaxWidth = longestName, MinWidth = longestName, MinAcceptableWidth = longestName }
                                                 );
-            ScenarioList.Style.ColumnStyles.Add (1, new ColumnStyle { MaxWidth = 1 });
+            ScenarioList.Style.ColumnStyles.Add (1, new() { MaxWidth = 1 });
 
             // Enable user to find & select a scenario by typing text
             // TableView does not (currently) have built-in CollectionNavigator support (the ability for the 
@@ -678,8 +678,7 @@ internal class UICatalogApp
 
                                    foreach (MenuItem schemeMenuItem in schemeMenuItems)
                                    {
-                                       schemeMenuItem.Checked =
-                                           (string)schemeMenuItem.Data == _topLevelColorScheme;
+                                       schemeMenuItem.Checked = (string)schemeMenuItem.Data == _topLevelColorScheme;
                                    }
 
                                    ColorScheme = Colors.ColorSchemes [_topLevelColorScheme];
@@ -713,7 +712,7 @@ internal class UICatalogApp
 
             ScenarioList.Table = new EnumerableTableSource<Scenario> (
                                                                       newlist,
-                                                                      new Dictionary<string, Func<Scenario, object>>
+                                                                      new()
                                                                       {
                                                                           { "Name", s => s.GetName () }, { "Description", s => s.GetDescription () }
                                                                       }
@@ -735,9 +734,9 @@ internal class UICatalogApp
 
         private MenuItem [] CreateDiagnosticFlagsMenuItems ()
         {
-            const string OFF = "Diagnostics: _Off";
-            const string FRAME_RULER = "Diagnostics: Frame _Ruler";
-            const string FRAME_PADDING = "Diagnostics: _Frame Padding";
+            const string OFF = "View Diagnostics: _Off";
+            const string RULER = "View Diagnostics: _Ruler";
+            const string PADDING = "View Diagnostics: _Padding";
             var index = 0;
 
             List<MenuItem> menuItems = new ();
@@ -751,13 +750,9 @@ internal class UICatalogApp
                 index++;
                 item.CheckType |= MenuItemCheckStyle.Checked;
 
-                if (GetDiagnosticsTitle (ConsoleDriver.DiagnosticFlags.Off) == item.Title)
+                if (GetDiagnosticsTitle (ViewDiagnosticFlags.Off) == item.Title)
                 {
-                    item.Checked = (_diagnosticFlags
-                                    & (ConsoleDriver.DiagnosticFlags.FramePadding
-                                       | ConsoleDriver.DiagnosticFlags
-                                                      .FrameRuler))
-                                   == 0;
+                    item.Checked = !_diagnosticFlags.HasFlag (ViewDiagnosticFlags.Padding) && !_diagnosticFlags.HasFlag (ViewDiagnosticFlags.Ruler);
                 }
                 else
                 {
@@ -766,16 +761,16 @@ internal class UICatalogApp
 
                 item.Action += () =>
                                {
-                                   string t = GetDiagnosticsTitle (ConsoleDriver.DiagnosticFlags.Off);
+                                   string t = GetDiagnosticsTitle (ViewDiagnosticFlags.Off);
 
                                    if (item.Title == t && item.Checked == false)
                                    {
-                                       _diagnosticFlags &= ~(ConsoleDriver.DiagnosticFlags.FramePadding | ConsoleDriver.DiagnosticFlags.FrameRuler);
+                                       _diagnosticFlags &= ~(ViewDiagnosticFlags.Padding | ViewDiagnosticFlags.Ruler);
                                        item.Checked = true;
                                    }
                                    else if (item.Title == t && item.Checked == true)
                                    {
-                                       _diagnosticFlags |= ConsoleDriver.DiagnosticFlags.FramePadding | ConsoleDriver.DiagnosticFlags.FrameRuler;
+                                       _diagnosticFlags |= ViewDiagnosticFlags.Padding | ViewDiagnosticFlags.Ruler;
                                        item.Checked = false;
                                    }
                                    else
@@ -796,23 +791,16 @@ internal class UICatalogApp
                                    {
                                        if (menuItem.Title == t)
                                        {
-                                           menuItem.Checked =
-                                               !_diagnosticFlags.HasFlag (
-                                                                          ConsoleDriver.DiagnosticFlags
-                                                                                       .FrameRuler
-                                                                         )
-                                               && !_diagnosticFlags.HasFlag (ConsoleDriver.DiagnosticFlags.FramePadding);
+                                           menuItem.Checked = !_diagnosticFlags.HasFlag (ViewDiagnosticFlags.Ruler)
+                                                              && !_diagnosticFlags.HasFlag (ViewDiagnosticFlags.Padding);
                                        }
                                        else if (menuItem.Title != t)
                                        {
-                                           menuItem.Checked =
-                                               _diagnosticFlags.HasFlag (
-                                                                         GetDiagnosticsEnumValue (menuItem.Title)
-                                                                        );
+                                           menuItem.Checked = _diagnosticFlags.HasFlag (GetDiagnosticsEnumValue (menuItem.Title));
                                        }
                                    }
 
-                                   ConsoleDriver.Diagnostics = _diagnosticFlags;
+                                   Diagnostics = _diagnosticFlags;
                                    Application.Top.SetNeedsDisplay ();
                                };
                 menuItems.Add (item);
@@ -825,8 +813,8 @@ internal class UICatalogApp
                 return Enum.GetName (_diagnosticFlags.GetType (), diag) switch
                        {
                            "Off" => OFF,
-                           "FrameRuler" => FRAME_RULER,
-                           "FramePadding" => FRAME_PADDING,
+                           "Ruler" => RULER,
+                           "Padding" => PADDING,
                            _ => ""
                        };
             }
@@ -835,8 +823,8 @@ internal class UICatalogApp
             {
                 return title switch
                        {
-                           FRAME_RULER => ConsoleDriver.DiagnosticFlags.FrameRuler,
-                           FRAME_PADDING => ConsoleDriver.DiagnosticFlags.FramePadding,
+                           RULER => ViewDiagnosticFlags.Ruler,
+                           PADDING => ViewDiagnosticFlags.Padding,
                            _ => null!
                        };
             }
@@ -845,30 +833,30 @@ internal class UICatalogApp
             {
                 switch (diag)
                 {
-                    case ConsoleDriver.DiagnosticFlags.FrameRuler:
+                    case ViewDiagnosticFlags.Ruler:
                         if (add)
                         {
-                            _diagnosticFlags |= ConsoleDriver.DiagnosticFlags.FrameRuler;
+                            _diagnosticFlags |= ViewDiagnosticFlags.Ruler;
                         }
                         else
                         {
-                            _diagnosticFlags &= ~ConsoleDriver.DiagnosticFlags.FrameRuler;
+                            _diagnosticFlags &= ~ViewDiagnosticFlags.Ruler;
                         }
 
                         break;
-                    case ConsoleDriver.DiagnosticFlags.FramePadding:
+                    case ViewDiagnosticFlags.Padding:
                         if (add)
                         {
-                            _diagnosticFlags |= ConsoleDriver.DiagnosticFlags.FramePadding;
+                            _diagnosticFlags |= ViewDiagnosticFlags.Padding;
                         }
                         else
                         {
-                            _diagnosticFlags &= ~ConsoleDriver.DiagnosticFlags.FramePadding;
+                            _diagnosticFlags &= ~ViewDiagnosticFlags.Padding;
                         }
 
                         break;
                     default:
-                        _diagnosticFlags = default (ConsoleDriver.DiagnosticFlags);
+                        _diagnosticFlags = default (ViewDiagnosticFlags);
 
                         break;
                 }
@@ -894,7 +882,7 @@ internal class UICatalogApp
         private MenuItem [] CreateDisabledEnabledMenuBorder ()
         {
             List<MenuItem> menuItems = new ();
-            miIsMenuBorderDisabled = new MenuItem { Title = "Disable Menu _Border" };
+            miIsMenuBorderDisabled = new() { Title = "Disable Menu _Border" };
 
             miIsMenuBorderDisabled.Shortcut =
                 (KeyCode)new Key (miIsMenuBorderDisabled!.Title!.Substring (14, 1) [0]).WithAlt
@@ -917,7 +905,7 @@ internal class UICatalogApp
         private MenuItem [] CreateDisabledEnabledMouseItems ()
         {
             List<MenuItem> menuItems = new ();
-            miIsMouseDisabled = new MenuItem { Title = "_Disable Mouse" };
+            miIsMouseDisabled = new() { Title = "_Disable Mouse" };
 
             miIsMouseDisabled.Shortcut =
                 (KeyCode)new Key (miIsMouseDisabled!.Title!.Substring (1, 1) [0]).WithAlt.WithCtrl;
@@ -937,7 +925,7 @@ internal class UICatalogApp
         private MenuItem [] CreateDisabledEnableUseSubMenusSingleFrame ()
         {
             List<MenuItem> menuItems = new ();
-            miUseSubMenusSingleFrame = new MenuItem { Title = "Enable _Sub-Menus Single Frame" };
+            miUseSubMenusSingleFrame = new() { Title = "Enable _Sub-Menus Single Frame" };
 
             miUseSubMenusSingleFrame.Shortcut = KeyCode.CtrlMask
                                                 | KeyCode.AltMask
@@ -959,7 +947,7 @@ internal class UICatalogApp
         {
             List<MenuItem> menuItems = new ();
 
-            miForce16Colors = new MenuItem
+            miForce16Colors = new()
             {
                 Title = "Force _16 Colors",
                 Shortcut = (KeyCode)Key.F6,

+ 16 - 16
UnitTests/Drawing/ThicknessTests.cs

@@ -61,14 +61,14 @@ public class ThicknessTests
         ((FakeDriver)Application.Driver).SetBufferSize (60, 60);
         var t = new Thickness (0, 0, 0, 0);
         var r = new Rectangle (5, 5, 40, 15);
-        ConsoleDriver.Diagnostics |= ConsoleDriver.DiagnosticFlags.FramePadding;
+        View.Diagnostics |= ViewDiagnosticFlags.Padding;
 
         Application.Driver.FillRect (
                                      new Rectangle (0, 0, Application.Driver.Cols, Application.Driver.Rows),
                                      (Rune)' '
                                     );
         t.Draw (r, "Test");
-        ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.Off;
+        View.Diagnostics = ViewDiagnosticFlags.Off;
 
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
@@ -78,14 +78,14 @@ public class ThicknessTests
 
         t = new Thickness (1, 1, 1, 1);
         r = new Rectangle (5, 5, 40, 15);
-        ConsoleDriver.Diagnostics |= ConsoleDriver.DiagnosticFlags.FramePadding;
+        View.Diagnostics |= ViewDiagnosticFlags.Padding;
 
         Application.Driver.FillRect (
                                      new Rectangle (0, 0, Application.Driver.Cols, Application.Driver.Rows),
                                      (Rune)' '
                                     );
         t.Draw (r, "Test");
-        ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.Off;
+        View.Diagnostics = ViewDiagnosticFlags.Off;
 
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
@@ -109,14 +109,14 @@ public class ThicknessTests
 
         t = new Thickness (1, 2, 3, 4);
         r = new Rectangle (5, 5, 40, 15);
-        ConsoleDriver.Diagnostics |= ConsoleDriver.DiagnosticFlags.FramePadding;
+        View.Diagnostics |= ViewDiagnosticFlags.Padding;
 
         Application.Driver.FillRect (
                                      new Rectangle (0, 0, Application.Driver.Cols, Application.Driver.Rows),
                                      (Rune)' '
                                     );
         t.Draw (r, "Test");
-        ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.Off;
+        View.Diagnostics = ViewDiagnosticFlags.Off;
 
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
@@ -140,14 +140,14 @@ public class ThicknessTests
 
         t = new Thickness (-1, 1, 1, 1);
         r = new Rectangle (5, 5, 40, 15);
-        ConsoleDriver.Diagnostics |= ConsoleDriver.DiagnosticFlags.FramePadding;
+        View.Diagnostics |= ViewDiagnosticFlags.Padding;
 
         Application.Driver.FillRect (
                                      new Rectangle (0, 0, Application.Driver.Cols, Application.Driver.Rows),
                                      (Rune)' '
                                     );
         t.Draw (r, "Test");
-        ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.Off;
+        View.Diagnostics = ViewDiagnosticFlags.Off;
 
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
@@ -184,9 +184,9 @@ public class ThicknessTests
         var t = new Thickness (0, 0, 0, 0);
         var r = new Rectangle (2, 2, 40, 15);
         Application.Refresh ();
-        ConsoleDriver.Diagnostics |= ConsoleDriver.DiagnosticFlags.FrameRuler;
+        View.Diagnostics |= ViewDiagnosticFlags.Ruler;
         t.Draw (r, "Test");
-        ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.Off;
+        View.Diagnostics = ViewDiagnosticFlags.Off;
 
         TestHelpers.AssertDriverContentsAre (
                                              @"
@@ -216,9 +216,9 @@ public class ThicknessTests
         t = new Thickness (1, 1, 1, 1);
         r = new Rectangle (1, 1, 40, 15);
         Application.Refresh ();
-        ConsoleDriver.Diagnostics |= ConsoleDriver.DiagnosticFlags.FrameRuler;
+        View.Diagnostics |= ViewDiagnosticFlags.Ruler;
         t.Draw (r, "Test");
-        ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.Off;
+        View.Diagnostics = ViewDiagnosticFlags.Off;
 
         TestHelpers.AssertDriverContentsAre (
                                              @"
@@ -248,9 +248,9 @@ public class ThicknessTests
         t = new Thickness (1, 2, 3, 4);
         r = new Rectangle (2, 2, 40, 15);
         Application.Refresh ();
-        ConsoleDriver.Diagnostics |= ConsoleDriver.DiagnosticFlags.FrameRuler;
+        View.Diagnostics |= ViewDiagnosticFlags.Ruler;
         t.Draw (r, "Test");
-        ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.Off;
+        View.Diagnostics = ViewDiagnosticFlags.Off;
 
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
@@ -280,9 +280,9 @@ public class ThicknessTests
         t = new Thickness (-1, 1, 1, 1);
         r = new Rectangle (5, 5, 40, 15);
         Application.Refresh ();
-        ConsoleDriver.Diagnostics |= ConsoleDriver.DiagnosticFlags.FrameRuler;
+        View.Diagnostics |= ViewDiagnosticFlags.Ruler;
         t.Draw (r, "Test");
-        ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.Off;
+        View.Diagnostics = ViewDiagnosticFlags.Off;
 
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"

+ 2 - 2
UnitTests/View/Adornment/MarginTests.cs

@@ -30,9 +30,9 @@ public class MarginTests
 
         superView.BeginInit ();
         superView.EndInit ();
-        ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.FramePadding;
+        View.Diagnostics = ViewDiagnosticFlags.Padding;
         view.Draw ();
-        ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.Off;
+        View.Diagnostics = ViewDiagnosticFlags.Off;
 
         TestHelpers.AssertDriverContentsAre (
                                              @"

+ 2 - 2
UnitTests/View/Adornment/PaddingTests.cs

@@ -25,9 +25,9 @@ public class PaddingTests
 
         view.BeginInit ();
         view.EndInit ();
-        ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.FramePadding;
+        View.Diagnostics = ViewDiagnosticFlags.Padding;
         view.Draw ();
-        ConsoleDriver.Diagnostics = ConsoleDriver.DiagnosticFlags.Off;
+        View.Diagnostics = ViewDiagnosticFlags.Off;
 
         TestHelpers.AssertDriverContentsAre (
                                              @"