Bugfix for cursor position after non-shifter cursor key press while having selection. text-view-selection-refactoring
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 27 Mar 2014 22:51:09 +0000
branchtext-view-selection-refactoring
changeset 4975 bee454945bf7
parent 4974 def8e296a561
child 4976 83f3df06495f
Bugfix for cursor position after non-shifter cursor key press while having selection.
EditTextView.st
--- a/EditTextView.st	Thu Mar 27 12:57:01 2014 +0000
+++ b/EditTextView.st	Thu Mar 27 22:51:09 2014 +0000
@@ -4695,6 +4695,15 @@
                     cursorLine := selectionEndLine.
                     cursorCol := selectionEndCol + 1.
                 ].
+
+                "/ If there's selection, unselect and move cursor
+                "/ to the end of selection.
+                self hasSelection ifTrue:[ 
+                    self setCursorLine: selectionEndLine.
+                    self setCursorCol: selectionEndCol + 1.
+                    self unselect; makeCursorVisible.
+                    ^ self.
+                ].
                 self unselect; makeCursorVisible.
                 self cursorRight.
             ].
@@ -4746,6 +4755,12 @@
             shifted ifTrue:[
                 self addToSelectionAfter:[ self cursorDown:n ]
             ] ifFalse:[
+                "/ If there's selection, unselect and move cursor
+                "/ to the end of selection.   
+                self hasSelection ifTrue:[ 
+                    self setCursorLine: selectionEndLine.
+                    self setCursorCol: selectionEndCol + 1.    
+                ].    
                 self unselect; makeCursorVisible.
                 self cursorDown:n.
             ].  
@@ -4795,8 +4810,8 @@
                 "/
 "/                self setCursorLine:selectionStartLine.
 "/                self setCursorCol:selectionStartCol.
-                self makeCursorVisible.
-
+"/                self makeCursorVisible.
+"/
 "/                shifted ifFalse:[
 "/                    self unselect.
 "/                ]
@@ -4806,6 +4821,14 @@
             shifted ifTrue:[
                 self addToSelectionAfter:[self cursorLeft].
             ] ifFalse:[
+                "/ If there's selection, unselect and move cursor
+                "/ to the end of selection.   
+                self hasSelection ifTrue:[ 
+                    self setCursorLine:selectionStartLine.
+                    self setCursorCol:selectionStartCol.
+                    self unselect; makeCursorVisible.                    
+                    ^ self.
+                ].
                 self unselect; makeCursorVisible.
                 self cursorLeft. 
             ].
@@ -4816,6 +4839,12 @@
             shifted ifTrue:[
                 self addToSelectionAfter: [ self cursorUp:n ]
             ] ifFalse:[
+                "/ If there's selection, unselect and move cursor
+                "/ to the beggining of selection.   
+                self hasSelection ifTrue:[ 
+                    self setCursorLine:selectionStartLine.
+                    self setCursorCol:selectionStartCol.
+                ].    
                 self unselect; makeCursorVisible.
                 self cursorUp:n.
             ].
@@ -4827,7 +4856,7 @@
         ].
     ].
 
-    "Modified: / 25-03-2014 / 17:24:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 27-03-2014 / 22:47:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 doKeyPress:key x:x y:y