Browse Source

Add XML documentation to TextView.Utilities.cs methods

All private utility methods now have XML docs with 'INTERNAL:' prefix:

- Adjust: Scroll position and cursor visibility management

- DoNeededAction: Redraw determination and cursor positioning

- OffSetBackground: Viewport offset calculation

- UpdateContentSize: Content size management for scrolling

- ResetPosition: Document position reset

- ResetColumnTrack: Column tracking state reset

Build successful, all 163 tests pass
Tig 3 weeks ago
parent
commit
fca6048bfa
1 changed files with 29 additions and 18 deletions
  1. 29 18
      Terminal.Gui/Views/TextInput/TextView/TextView.Utilities.cs

+ 29 - 18
Terminal.Gui/Views/TextInput/TextView/TextView.Utilities.cs

@@ -3,6 +3,11 @@ namespace Terminal.Gui.Views;
 /// <summary>Utility and helper methods for TextView</summary>
 public partial class TextView
 {
+    /// <summary>
+    ///     INTERNAL: Adjusts the scroll position and cursor to ensure the cursor is visible in the viewport.
+    ///     This method handles both horizontal and vertical scrolling, word wrap considerations, and syncs
+    ///     the internal scroll fields with the Viewport property.
+    /// </summary>
     private void Adjust ()
     {
         (int width, int height) offB = OffSetBackground ();
@@ -80,6 +85,11 @@ public partial class TextView
         OnUnwrappedCursorPosition ();
     }
 
+    /// <summary>
+    ///     INTERNAL: Determines if a redraw is needed based on selection state, word wrap needs, and Used flag.
+    ///     If a redraw is needed, calls <see cref="Adjust"/>; otherwise positions the cursor and updates
+    ///     the unwrapped cursor position.
+    /// </summary>
     private void DoNeededAction ()
     {
         if (!NeedsDraw && (IsSelecting || _wrapNeeded || !Used))
@@ -98,6 +108,12 @@ public partial class TextView
         }
     }
 
+    /// <summary>
+    ///     INTERNAL: Calculates the offset from the viewport edges caused by the background extending
+    ///     beyond the SuperView's boundaries. Returns negative width and height offsets if the viewport
+    ///     extends beyond the SuperView.
+    /// </summary>
+    /// <returns>A tuple containing the width and height offsets.</returns>
     private (int width, int height) OffSetBackground ()
     {
         var w = 0;
@@ -117,7 +133,10 @@ public partial class TextView
     }
 
     /// <summary>
-    ///     Updates the content size based on the text model dimensions.
+    ///     INTERNAL: Updates the content size based on the text model dimensions.
+    ///     When word wrap is enabled, content width equals viewport width.
+    ///     Otherwise, calculates the maximum line width from the entire text model.
+    ///     Content height is always the number of lines in the model.
     /// </summary>
     private void UpdateContentSize ()
     {
@@ -142,21 +161,21 @@ public partial class TextView
         SetContentSize (new Size (contentWidth, contentHeight));
     }
 
+    /// <summary>
+    ///     INTERNAL: Resets the cursor position and scroll offsets to the beginning of the document (0,0)
+    ///     and stops any active text selection.
+    /// </summary>
     private void ResetPosition ()
     {
         _topRow = _leftColumn = CurrentRow = CurrentColumn = 0;
         StopSelecting ();
     }
 
-    private void ResetAllTrack ()
-    {
-        // Handle some state here - whether the last command was a kill
-        // operation and the column tracking (up/down)
-        _lastWasKill = false;
-        _columnTrack = -1;
-        _continuousFind = false;
-    }
-
+    /// <summary>
+    ///     INTERNAL: Resets the column tracking state and last kill operation flag.
+    ///     Column tracking is used to maintain the desired cursor column position when moving up/down
+    ///     through lines of different lengths.
+    /// </summary>
     private void ResetColumnTrack ()
     {
         // Handle some state here - whether the last command was a kill
@@ -164,12 +183,4 @@ public partial class TextView
         _lastWasKill = false;
         _columnTrack = -1;
     }
-
-    private void ToggleSelecting ()
-    {
-        ResetColumnTrack ();
-        IsSelecting = !IsSelecting;
-        _selectionStartColumn = CurrentColumn;
-        _selectionStartRow = CurrentRow;
-    }
 }