diff -r c7b0b569926d -r 0af3d976211f TextView.st --- a/TextView.st Mon Mar 12 15:42:00 2018 +0100 +++ b/TextView.st Thu Mar 15 12:33:43 2018 +0100 @@ -916,9 +916,10 @@ "return the character index of the first character in the selection. Returns 0 if there is no selection." - selectionStartLine isNil ifTrue:[^ 0]. - ^ self characterPositionOfLine:selectionStartLine - col:selectionStartCol + |startLine| + + (startLine := self selectionStartLine) isNil ifTrue:[^ 0]. + ^ self characterPositionOfLine:startLine col:(self selectionStartCol) "Modified: 14.8.1997 / 16:35:37 / cg" ! @@ -927,9 +928,8 @@ "return the character index of the last character in the selection. Returns 0 if there is no selection." - selectionStartLine isNil ifTrue:[^ 0]. - ^ self characterPositionOfLine:selectionEndLine - col:selectionEndCol + self selectionStartLine isNil ifTrue:[^ 0]. "/ no selection + ^ self characterPositionOfLine:self selectionEndLine col:self selectionEndCol "Created: 14.8.1997 / 16:35:24 / cg" "Modified: 14.8.1997 / 16:35:45 / cg" @@ -1076,15 +1076,16 @@ ! setContents:something - "set the contents (either a string or a Collection of strings) - don't change the position (i.e. do not scroll) or the selection." + "set the contents (either a string or a collection of strings). + Does not change the position (i.e. does not scroll) + and (tries to) keep the selection." |selStartLine selStartCol selEndLine selEndCol selStyle| - selStartLine := selectionStartLine. - selStartCol := selectionStartCol. - selEndLine := selectionEndLine. - selEndCol := selectionEndCol. + selStartLine := self selectionStartLine. + selStartCol := self selectionStartCol. + selEndLine := self selectionEndLine. + selEndCol := self selectionEndCol. selStyle := selectStyle. super setContents:something. @@ -2213,7 +2214,7 @@ defaultForGotoLine "return a default value to show in the gotoLine box" - ^ selectionStartLine + ^ self selectionStartLine "Modified: 1.3.1996 / 18:44:36 / cg" ! @@ -3117,11 +3118,14 @@ ! scrollSelectDown - "auto scroll action; scroll and reinstall timed-block" + "auto scroll downwards while selecting + (i.e. when the mouse is down, and moved out of the window to the bottom) + scroll and reinstall timed-block. + Adjust the selectionStartLine" |prevEndLine| - "just to make certain ..." + "just to make certain, that we actually have a selection..." selectionEndLine isNil ifTrue:[^ self]. self scrollDown. @@ -3138,11 +3142,14 @@ ! scrollSelectLeft - "auto scroll action; scroll and reinstall timed-block" + "auto scroll to the left while selecting + (i.e. when the mouse is down, and moved out of the window to the left) + scroll and reinstall timed-block. + Adjust the selectionStartColumn." |prevStartLine| - "just to make certain ..." + "just to make certain, that we actually have a selection..." selectionStartLine isNil ifTrue:[^ self]. selectionStartCol isNil ifTrue:[^ self]. @@ -3156,11 +3163,14 @@ ! scrollSelectRight - "auto scroll action; scroll and reinstall timed-block" + "auto scroll to the right while selecting + (i.e. when the mouse is down, and moved out of the window to the right) + scroll and reinstall timed-block. + Adjust the selectionEndColumn." |prevEndCol firstVisibleCol endLine| - "just to make certain ..." + "just to make certain, that we actually have a selection..." selectionEndCol isNil ifTrue:[^ self]. selectionEndLine isNil ifTrue:[^ self]. @@ -3186,11 +3196,14 @@ ! scrollSelectUp - "auto scroll action; scroll and reinstall timed-block" + "auto scroll upwards while selecting + (i.e. when the mouse is down, and moved out of the window to the top) + scroll and reinstall timed-block. + Adjust the selectionStartLine" |prevStartLine| - "just to make certain ..." + "just to make certain, that we actually have a selection..." selectionStartLine isNil ifTrue:[^ self]. self scrollUp.