Merged 7ca486a26aa1 and 0eb26aed1456 text-view-selection-refactoring
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 22 Apr 2014 22:50:08 +0200
branchtext-view-selection-refactoring
changeset 5000 f2296f711f51
parent 4999 7ca486a26aa1 (current diff)
parent 4978 0eb26aed1456 (diff)
child 5013 9810ac669227
Merged 7ca486a26aa1 and 0eb26aed1456
--- a/EditTextView.st	Thu Apr 10 10:57:12 2014 +0200
+++ b/EditTextView.st	Tue Apr 22 22:50:08 2014 +0200
@@ -138,69 +138,6 @@
 
 !EditTextView class methodsFor:'documentation'!
 
-selection_and_cursor_movement
-"
-Changes done to implement 'standard' behaviour (that's how vast majority of widgets used in todays desktops behaves)
-as opposed to 'traditional' which is what how it was in St/X 'ever since'
-
-* Numerous off-by-one bugs
-
-* Extending selection by dragging:
-  Scenario:
-    1. Select & drag to expand beggining of the selection (i.e., drag from 'end' to 'beggining'
-    2. Stop dragging
-    3. Press Shift-Left / Shift-Right (to refine selection)
-
-    Traditional ST/X: end of selection is moved
-    Standard:  beginning of selection is moved
-      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
-
-* Extending selection by Shift-Home / Shift-End
-  Scenario:
-    1. Position cursor in the middle of the line
-    2. Press Shift-Home (line for beginning should be selected)
-    3. Press Shift-Right (to refine selection)
-
-    Traditional ST/X: end of selection is moved
-    Standard:  beginning of selection is moved
-      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
-
-* Selection flip by Shift-Home / Shift-End
-  Scenario A:
-    1. Position cursor in the middle of the line to column C
-    2. Press Shift-Home (line from beginning should be selected)
-    2. Press Shift-End
-
-    Traditional ST/X: end of selection is moved so whole line is selected
-    Standard: Selection 'flips' so part of line from column C to the end is selected
-      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
-
-  Scenario B:
-    1. Position cursor in the middle of the line to column C
-    2. Press Shift-End (column C to the end of line should be selected)
-    2. Press Shift-Home
-
-    Traditional ST/X: beginning of selection is moved so whole line is selected
-    Standard: Selection 'flips' so part of line from the beginning to column C is selected
-      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
-
-  NOTE: This could be controlled by 
-    UserPreferences current selectionExtensionMode
-
-
-* Extending selection with Ctrl-Shift-Left / Ctrl-Shift-Right
-  Scenario A:
-    1. Position cursor in the middle of the line to column C
-    2. Select word
-    3. Press Ctrl-Shift-Right, Ctrl-Shift-Right
-
-    Traditional ST/X: nothing happens at all
-    Standard: Selection is extended to include a space (first press) and a word right to previously selected one
-      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
-
-"
-!
-
 copyright
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
@@ -526,6 +463,69 @@
         top2 open.
                                                                         [exEnd]
 "
+!
+
+selection_and_cursor_movement
+"
+Changes done to implement 'standard' behaviour (that's how vast majority of widgets used in todays desktops behaves)
+as opposed to 'traditional' which is what how it was in St/X 'ever since'
+
+* Numerous off-by-one bugs
+
+* Extending selection by dragging:
+  Scenario:
+    1. Select & drag to expand beggining of the selection (i.e., drag from 'end' to 'beggining'
+    2. Stop dragging
+    3. Press Shift-Left / Shift-Right (to refine selection)
+
+    Traditional ST/X: end of selection is moved
+    Standard:  beginning of selection is moved
+      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
+
+* Extending selection by Shift-Home / Shift-End
+  Scenario:
+    1. Position cursor in the middle of the line
+    2. Press Shift-Home (line for beginning should be selected)
+    3. Press Shift-Right (to refine selection)
+
+    Traditional ST/X: end of selection is moved
+    Standard:  beginning of selection is moved
+      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
+
+* Selection flip by Shift-Home / Shift-End
+  Scenario A:
+    1. Position cursor in the middle of the line to column C
+    2. Press Shift-Home (line from beginning should be selected)
+    2. Press Shift-End
+
+    Traditional ST/X: end of selection is moved so whole line is selected
+    Standard: Selection 'flips' so part of line from column C to the end is selected
+      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
+
+  Scenario B:
+    1. Position cursor in the middle of the line to column C
+    2. Press Shift-End (column C to the end of line should be selected)
+    2. Press Shift-Home
+
+    Traditional ST/X: beginning of selection is moved so whole line is selected
+    Standard: Selection 'flips' so part of line from the beginning to column C is selected
+      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
+
+  NOTE: This could be controlled by 
+    UserPreferences current selectionExtensionMode
+
+
+* Extending selection with Ctrl-Shift-Left / Ctrl-Shift-Right
+  Scenario A:
+    1. Position cursor in the middle of the line to column C
+    2. Select word
+    3. Press Ctrl-Shift-Right, Ctrl-Shift-Right
+
+    Traditional ST/X: nothing happens at all
+    Standard: Selection is extended to include a space (first press) and a word right to previously selected one
+      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
+
+"
 ! !
 
 !EditTextView class methodsFor:'defaults'!
@@ -5166,9 +5166,27 @@
         ].
         ^ self
     ].
-    (key == #NextWord) ifTrue:[self cursorToNextWord. ^self].
+    (key == #NextWord) ifTrue:[
+        shiftPressed ifTrue:[
+            self addToSelectionAfter:[  
+                self cursorToNextWord. 
+            ]
+        ] ifFalse:[ 
+            self cursorToNextWord
+        ].
+        ^self
+    ].
     (key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self].
-    (key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self].
+    (key == #PreviousWord) ifTrue:[
+        shiftPressed ifTrue:[
+            self addToSelectionAfter:[      
+                self cursorToPreviousWord. 
+            ]
+        ] ifFalse:[ 
+            self cursorToPreviousWord.                                
+        ].
+        ^self
+    ].
     (key == #GotoLine) ifTrue:[self gotoLine. ^self].
 
     (key == #CursorRight
@@ -5363,7 +5381,7 @@
 
     "Modified: / 06-02-1998 / 11:59:59 / stefan"
     "Modified: / 14-07-2011 / 12:08:28 / cg"
-    "Modified: / 26-09-2013 / 17:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 31-03-2014 / 16:27:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 executeKeyboardMacro:cmdMacro