From fca6048bfa245e1bd3b156b8c1ec9674553e57ea Mon Sep 17 00:00:00 2001 From: Tig Date: Fri, 21 Nov 2025 16:54:36 -0700 Subject: [PATCH] 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 --- .../TextInput/TextView/TextView.Utilities.cs | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/Terminal.Gui/Views/TextInput/TextView/TextView.Utilities.cs b/Terminal.Gui/Views/TextInput/TextView/TextView.Utilities.cs index 3cd27a393..73f15699d 100644 --- a/Terminal.Gui/Views/TextInput/TextView/TextView.Utilities.cs +++ b/Terminal.Gui/Views/TextInput/TextView/TextView.Utilities.cs @@ -3,6 +3,11 @@ namespace Terminal.Gui.Views; /// Utility and helper methods for TextView public partial class TextView { + /// + /// 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. + /// private void Adjust () { (int width, int height) offB = OffSetBackground (); @@ -80,6 +85,11 @@ public partial class TextView OnUnwrappedCursorPosition (); } + /// + /// INTERNAL: Determines if a redraw is needed based on selection state, word wrap needs, and Used flag. + /// If a redraw is needed, calls ; otherwise positions the cursor and updates + /// the unwrapped cursor position. + /// private void DoNeededAction () { if (!NeedsDraw && (IsSelecting || _wrapNeeded || !Used)) @@ -98,6 +108,12 @@ public partial class TextView } } + /// + /// 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. + /// + /// A tuple containing the width and height offsets. private (int width, int height) OffSetBackground () { var w = 0; @@ -117,7 +133,10 @@ public partial class TextView } /// - /// 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. /// private void UpdateContentSize () { @@ -142,21 +161,21 @@ public partial class TextView SetContentSize (new Size (contentWidth, contentHeight)); } + /// + /// INTERNAL: Resets the cursor position and scroll offsets to the beginning of the document (0,0) + /// and stops any active text selection. + /// 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; - } - + /// + /// 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. + /// 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; - } }