瀏覽代碼

Code cleanup

Tig 1 年之前
父節點
當前提交
6982a85a70
共有 3 個文件被更改,包括 49 次插入49 次删除
  1. 7 7
      Terminal.Gui/Input/Mouse.cs
  2. 1 1
      Terminal.Gui/Views/TableView/TableView.cs
  3. 41 41
      UnitTests/View/Layout/Pos.Tests.cs

+ 7 - 7
Terminal.Gui/Input/Mouse.cs

@@ -119,18 +119,12 @@ public class MouseEvent
     /// <summary>The position of the mouse in <see cref="Gui.View.Viewport"/>-relative coordinates.</summary>
     public Point Position { get; set; }
 
-    /// <summary>
-    ///     Indicates if the current mouse event has been processed. Set this value to <see langword="true"/> to indicate the mouse
-    ///     event was handled.
-    /// </summary>
-    public bool Handled { get; set; }
-
     /// <summary>
     ///     The screen-relative mouse position.
     /// </summary>
     /// <remarks>
     ///     <para>
-    ///         The <see cref="X"/> and <see cref="Y"/> properties are always <see cref="Gui.View.Viewport"/>-relative. When the mouse is grabbed by a view,
+    ///         <see cref="Position"/> is <see cref="Gui.View.Viewport"/>-relative. When the mouse is grabbed by a view,
     ///         <see cref="ScreenPosition"/> provides the mouse position screen-relative coordinates, enabling the grabbed view to know how much the
     ///         mouse has moved.
     ///     </para>
@@ -140,6 +134,12 @@ public class MouseEvent
     /// </remarks>
     public Point ScreenPosition { get; set; }
 
+    /// <summary>
+    ///     Indicates if the current mouse event has been processed. Set this value to <see langword="true"/> to indicate the mouse
+    ///     event was handled.
+    /// </summary>
+    public bool Handled { get; set; }
+
     /// <summary>Returns a <see cref="T:System.String"/> that represents the current <see cref="MouseEvent"/>.</summary>
     /// <returns>A <see cref="T:System.String"/> that represents the current <see cref="MouseEvent"/>.</returns>
     public override string ToString () { return $"({Position}):{Flags}"; }

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

@@ -1050,7 +1050,7 @@ public class TableView : View
     ///     bounds.
     /// </summary>
     /// <param name="client">offset from the top left of the control.</param>
-    /// <retur
+    /// <returns>The position.</returns>
     public Point? ScreenToCell (Point client) { return ScreenToCell (client, out _, out _); }
 
     /// <summary>

+ 41 - 41
UnitTests/View/Layout/Pos.Tests.cs

@@ -254,82 +254,82 @@ public class PosTests (ITestOutputHelper output)
     [TestRespondersDisposed]
     public void LeftTopBottomRight_Win_ShouldNotThrow ()
     {
-        // Setup Fake driver
-        (Toplevel top, Window win, Button button) setup ()
-        {
-            Application.Init (new FakeDriver ());
-            Application.Iteration += (s, a) => { Application.RequestStop (); };
-            var win = new Window { X = 0, Y = 0, Width = Dim.Fill (), Height = Dim.Fill () };
-            var top = new Toplevel ();
-            top.Add (win);
-
-            var button = new Button { X = Pos.Center (), Text = "button" };
-            win.Add (button);
-
-            return (top, win, button);
-        }
-
-        RunState rs;
-
-        void cleanup (RunState rs)
-        {
-            // Cleanup
-            Application.End (rs);
-
-            Application.Top.Dispose ();
-
-            // Shutdown must be called to safely clean up Application if Init has been called
-            Application.Shutdown ();
-        }
-
         // Test cases:
-        (Toplevel top, Window win, Button button) app = setup ();
+        (Toplevel top, Window win, Button button) app = Setup ();
         app.button.Y = Pos.Left (app.win);
-        rs = Application.Begin (app.top);
+        RunState rs = Application.Begin (app.top);
 
         // If Application.RunState is used then we must use Application.RunLoop with the rs parameter
         Application.RunLoop (rs);
-        cleanup (rs);
+        Cleanup (rs);
 
-        app = setup ();
+        app = Setup ();
         app.button.Y = Pos.X (app.win);
         rs = Application.Begin (app.top);
 
         // If Application.RunState is used then we must use Application.RunLoop with the rs parameter
         Application.RunLoop (rs);
-        cleanup (rs);
+        Cleanup (rs);
 
-        app = setup ();
+        app = Setup ();
         app.button.Y = Pos.Top (app.win);
         rs = Application.Begin (app.top);
 
         // If Application.RunState is used then we must use Application.RunLoop with the rs parameter
         Application.RunLoop (rs);
-        cleanup (rs);
+        Cleanup (rs);
 
-        app = setup ();
+        app = Setup ();
         app.button.Y = Pos.Y (app.win);
         rs = Application.Begin (app.top);
 
         // If Application.RunState is used then we must use Application.RunLoop with the rs parameter
         Application.RunLoop (rs);
-        cleanup (rs);
+        Cleanup (rs);
 
-        app = setup ();
+        app = Setup ();
         app.button.Y = Pos.Bottom (app.win);
         rs = Application.Begin (app.top);
 
         // If Application.RunState is used then we must use Application.RunLoop with the rs parameter
         Application.RunLoop (rs);
-        cleanup (rs);
+        Cleanup (rs);
 
-        app = setup ();
+        app = Setup ();
         app.button.Y = Pos.Right (app.win);
         rs = Application.Begin (app.top);
 
         // If Application.RunState is used then we must use Application.RunLoop with the rs parameter
         Application.RunLoop (rs);
-        cleanup (rs);
+        Cleanup (rs);
+
+        return;
+
+        void Cleanup (RunState rs)
+        {
+            // Cleanup
+            Application.End (rs);
+
+            Application.Top.Dispose ();
+
+            // Shutdown must be called to safely clean up Application if Init has been called
+            Application.Shutdown ();
+        }
+
+        // Setup Fake driver
+        (Toplevel top, Window win, Button button) Setup ()
+        {
+            Application.Init (new FakeDriver ());
+            Application.Iteration += (s, a) => { Application.RequestStop (); };
+            var win = new Window { X = 0, Y = 0, Width = Dim.Fill (), Height = Dim.Fill () };
+            var top = new Toplevel ();
+            top.Add (win);
+
+            var button = new Button { X = Pos.Center (), Text = "button" };
+            win.Add (button);
+
+            return (top, win, button);
+        }
     }
 
     [Fact]