Browse Source

Added some TODOs

Tig 1 year ago
parent
commit
2fe4e9206f

+ 4 - 2
Terminal.Gui/ConsoleDrivers/ConsoleDriver.cs

@@ -337,8 +337,8 @@ public abstract class ConsoleDriver
         {
         {
             for (int c = rect.X; c < rect.X + rect.Width; c++)
             for (int c = rect.X; c < rect.X + rect.Width; c++)
             {
             {
-                Application.Driver.Move (c, r);
-                Application.Driver.AddRune (rune == default (Rune) ? new Rune (' ') : rune);
+                Move (c, r);
+                AddRune (rune == default (Rune) ? new Rune (' ') : rune);
             }
             }
         }
         }
     }
     }
@@ -437,6 +437,7 @@ public abstract class ConsoleDriver
     /// <summary>Gets whether the <see cref="ConsoleDriver"/> supports TrueColor output.</summary>
     /// <summary>Gets whether the <see cref="ConsoleDriver"/> supports TrueColor output.</summary>
     public virtual bool SupportsTrueColor => true;
     public virtual bool SupportsTrueColor => true;
 
 
+    // TODO: This makes ConsoleDriver dependent on Application, which is not ideal. This should be moved to Application.
     /// <summary>
     /// <summary>
     ///     Gets or sets whether the <see cref="ConsoleDriver"/> should use 16 colors instead of the default TrueColors.
     ///     Gets or sets whether the <see cref="ConsoleDriver"/> should use 16 colors instead of the default TrueColors.
     ///     See <see cref="Application.Force16Colors"/> to change this setting via <see cref="ConfigurationManager"/>.
     ///     See <see cref="Application.Force16Colors"/> to change this setting via <see cref="ConfigurationManager"/>.
@@ -466,6 +467,7 @@ public abstract class ConsoleDriver
         get => _currentAttribute;
         get => _currentAttribute;
         set
         set
         {
         {
+            // TODO: This makes ConsoleDriver dependent on Application, which is not ideal. Once Attribute.PlatformColor is removed, this can be fixed.
             if (Application.Driver is { })
             if (Application.Driver is { })
             {
             {
                 _currentAttribute = new Attribute (value.Foreground, value.Background);
                 _currentAttribute = new Attribute (value.Foreground, value.Background);

+ 4 - 0
Terminal.Gui/ConsoleDrivers/WindowsDriver.cs

@@ -1715,6 +1715,7 @@ internal class WindowsDriver : ConsoleDriver
                 Flags = mouseFlag
                 Flags = mouseFlag
             };
             };
 
 
+            // TODO: This makes ConsoleDriver dependent on Application, which is not ideal. This should be moved to Application.
             View view = Application.WantContinuousButtonPressedView;
             View view = Application.WantContinuousButtonPressedView;
 
 
             if (view is null)
             if (view is null)
@@ -1724,6 +1725,7 @@ internal class WindowsDriver : ConsoleDriver
 
 
             if (_isButtonPressed && (mouseFlag & MouseFlags.ReportMousePosition) == 0)
             if (_isButtonPressed && (mouseFlag & MouseFlags.ReportMousePosition) == 0)
             {
             {
+                // TODO: This makes ConsoleDriver dependent on Application, which is not ideal. This should be moved to Application.
                 Application.Invoke (() => OnMouseEvent (new MouseEventEventArgs (me)));
                 Application.Invoke (() => OnMouseEvent (new MouseEventEventArgs (me)));
             }
             }
         }
         }
@@ -1779,6 +1781,7 @@ internal class WindowsDriver : ConsoleDriver
 
 
         if (_isButtonDoubleClicked || _isOneFingerDoubleClicked)
         if (_isButtonDoubleClicked || _isOneFingerDoubleClicked)
         {
         {
+            // TODO: This makes ConsoleDriver dependent on Application, which is not ideal. This should be moved to Application.
             Application.MainLoop.AddIdle (
             Application.MainLoop.AddIdle (
                                           () =>
                                           () =>
                                           {
                                           {
@@ -1850,6 +1853,7 @@ internal class WindowsDriver : ConsoleDriver
 
 
             if ((mouseFlag & MouseFlags.ReportMousePosition) == 0)
             if ((mouseFlag & MouseFlags.ReportMousePosition) == 0)
             {
             {
+                // TODO: This makes ConsoleDriver dependent on Application, which is not ideal. This should be moved to Application.
                 Application.MainLoop.AddIdle (
                 Application.MainLoop.AddIdle (
                                               () =>
                                               () =>
                                               {
                                               {

+ 3 - 3
Terminal.Gui/View/ViewDrawing.cs

@@ -101,8 +101,8 @@ public partial class View
 
 
         // If toClear does not fill the Viewport, we need to clear the area outside toClear with DarkGray.
         // If toClear does not fill the Viewport, we need to clear the area outside toClear with DarkGray.
         // TODO: Need a configurable color for this
         // TODO: Need a configurable color for this
+        // PERF: Put an if around this if toClear is not smaller than Viewport
         Attribute prev = Driver.SetAttribute (new Attribute (ColorName.DarkGray, ColorName.DarkGray));
         Attribute prev = Driver.SetAttribute (new Attribute (ColorName.DarkGray, ColorName.DarkGray));
-
         Rectangle viewport = new (Point.Empty, Viewport.Size);
         Rectangle viewport = new (Point.Empty, Viewport.Size);
         Driver.FillRect (ViewportToScreen (viewport));
         Driver.FillRect (ViewportToScreen (viewport));
         Driver.SetAttribute (prev);
         Driver.SetAttribute (prev);
@@ -120,10 +120,10 @@ public partial class View
             return;
             return;
         }
         }
 
 
-        Attribute prev = Driver.SetAttribute (GetNormalColor ());
-
         // Clamp the region to the bounds of the view
         // Clamp the region to the bounds of the view
         viewport = Rectangle.Intersect (viewport, new (Point.Empty, Viewport.Size));
         viewport = Rectangle.Intersect (viewport, new (Point.Empty, Viewport.Size));
+
+        Attribute prev = Driver.SetAttribute (GetNormalColor ());
         Driver.FillRect (ViewportToScreen (viewport));
         Driver.FillRect (ViewportToScreen (viewport));
         Driver.SetAttribute (prev);
         Driver.SetAttribute (prev);
     }
     }