EditTextView.st
branchtext-view-selection-refactoring
changeset 4843 7cd827899263
parent 4841 4fca96a61d42
child 4844 269a12794578
--- a/EditTextView.st	Wed Aug 28 10:49:58 2013 +0100
+++ b/EditTextView.st	Wed Aug 28 17:23:49 2013 +0100
@@ -5115,6 +5115,53 @@
     ].
 !
 
+extendSelectionToX:x y:y
+    "mouse-move while button was pressed - handle selection changes"
+
+    " Overwritten here to move cursor position to start/end of the
+      selection, whichever changes"
+
+    | oldClickLine oldClickCol newCursorLine newCursorCol |
+
+    oldClickLine := clickStartLine.
+    oldClickCol := clickStartCol.
+
+    super extendSelectionToX:x y:y.
+
+    self hasSelection ifFalse: [ ^ self ].
+
+    clickLine < oldClickLine ifTrue:[
+        newCursorCol := selectionStartCol.
+        newCursorLine := selectionStartLine.
+    ] ifFalse:[
+        clickLine == oldClickLine ifTrue:[
+            clickCol < oldClickCol ifTrue:[
+                newCursorLine := selectionStartLine.
+                newCursorCol := selectionStartCol.
+            ] ifFalse:[
+                clickCol == oldClickCol ifTrue:[
+                    newCursorLine := selectionStartLine.
+                    newCursorCol := selectionStartCol.
+                ] ifFalse:[
+                    newCursorLine := selectionEndLine.
+                    newCursorCol := selectionEndCol + 1
+                ]
+            ]
+        ] ifFalse:[
+            newCursorLine := selectionEndLine.
+            newCursorCol := selectionEndCol + 1.       
+        ]
+
+    ].
+
+
+    self setCursorCol: newCursorCol. 
+    self setCursorLine: newCursorLine.
+
+    "Created: / 28-08-2013 / 15:28:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 28-08-2013 / 17:18:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 getCompletionSuggestions
     UserInformation ignoreIn:[
         DoWhatIMeanSupport 
@@ -8299,5 +8346,10 @@
 
 version_CVS
     ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.562 2013-08-25 10:58:10 cg Exp $'
+!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
 ! !