Răsfoiți Sursa

Fixes #3431. TextView and TextField are showing the cursor beyond their limits.

BDisp 1 an în urmă
părinte
comite
2f17584ac8

+ 1 - 1
Terminal.Gui/Application.cs

@@ -882,7 +882,7 @@ public static partial class Application
         }
         }
         else
         else
         {
         {
-            //Driver.UpdateCursor ();
+            Driver.UpdateCursor ();
         }
         }
 
 
         if (state.Toplevel != Top && !state.Toplevel.Modal && (Top.NeedsDisplay || Top.SubViewNeedsDisplay || Top.LayoutNeeded))
         if (state.Toplevel != Top && !state.Toplevel.Modal && (Top.NeedsDisplay || Top.SubViewNeedsDisplay || Top.LayoutNeeded))

+ 4 - 5
Terminal.Gui/Views/TextField.cs

@@ -1196,13 +1196,12 @@ public class TextField : View
 
 
         int pos = _cursorPosition - ScrollOffset + Math.Min (Frame.X, 0);
         int pos = _cursorPosition - ScrollOffset + Math.Min (Frame.X, 0);
         int offB = OffSetBackground ();
         int offB = OffSetBackground ();
-        Rectangle containerFrame = SuperView?.ViewportToScreen (SuperView.Viewport) ?? default (Rectangle);
-        Rectangle thisFrame = ViewportToScreen (Viewport);
+        var thisOffset = ViewportToScreen (new (new (col, Viewport.Y), new (Viewport.Width - col, Viewport.Height - Viewport.Y)));
+        var view = Application.Current is { } ? FindDeepestView (Application.Current, thisOffset.X, thisOffset.Y) : this;
 
 
-        if (pos > -1
+        if (view == this && pos > -1
             && col >= pos
             && col >= pos
-            && pos < Frame.Width + offB
-            && containerFrame.IntersectsWith (thisFrame))
+            && pos < Frame.Width + offB)
         {
         {
             RestoreCursorVisibility ();
             RestoreCursorVisibility ();
             Move (col, 0);
             Move (col, 0);

+ 11 - 1
Terminal.Gui/Views/TextView.cs

@@ -3879,8 +3879,10 @@ public class TextView : View
 
 
         int posX = CurrentColumn - _leftColumn;
         int posX = CurrentColumn - _leftColumn;
         int posY = CurrentRow - _topRow;
         int posY = CurrentRow - _topRow;
+        var thisOffset = ViewportToScreen (new (new (col, posY), new (Viewport.Width - col, Viewport.Height - posY)));
+        var view = Application.Current is { } ? FindDeepestView (Application.Current, thisOffset.X, thisOffset.Y)  : this;
 
 
-        if (posX > -1 && col >= posX && posX < Frame.Width - RightOffset && _topRow <= CurrentRow && posY < Frame.Height - BottomOffset)
+        if (view == this && posX > -1 && col >= posX && posX < Frame.Width - RightOffset && _topRow <= CurrentRow && posY < Frame.Height - BottomOffset)
         {
         {
             ResetCursorVisibility ();
             ResetCursorVisibility ();
             Move (col, CurrentRow - _topRow);
             Move (col, CurrentRow - _topRow);
@@ -6250,6 +6252,14 @@ public class TextView : View
             DesiredCursorVisibility = _savedCursorVisibility;
             DesiredCursorVisibility = _savedCursorVisibility;
             _savedCursorVisibility = 0;
             _savedCursorVisibility = 0;
         }
         }
+        else if (Application.Driver is { })
+        {
+            Application.Driver.GetCursorVisibility (out CursorVisibility cursorVisibility);
+            if (cursorVisibility == CursorVisibility.Invisible)
+            {
+                DesiredCursorVisibility = CursorVisibility.Default;
+            }
+        }
     }
     }
 
 
     private void ResetPosition ()
     private void ResetPosition ()