fixed Shift-Cursor selection & show another cursor when matching parents
authorClaus Gittinger <cg@exept.de>
Wed, 06 Mar 1996 15:02:08 +0100
changeset 479 fae6d1251888
parent 478 180275291838
child 480 dd6263c5f9ee
fixed Shift-Cursor selection & show another cursor when matching parents
ETxtView.st
EditTextView.st
--- a/ETxtView.st	Wed Mar 06 15:00:25 1996 +0100
+++ b/ETxtView.st	Wed Mar 06 15:02:08 1996 +0100
@@ -917,26 +917,27 @@
     |line col|
 
     cursorLine notNil ifTrue:[
-	line := cursorLine.
-	col := cursorCol.
-	"
-	 if there is a selection, its better to
-	 have its start being visible, instead of the end
-	"
-	(selectionStartLine notNil 
-	and:[selectionEndLine notNil]) ifTrue:[
-
-"/ that was wrong
-"/      ((line == selectionEndLine)
-"/      and:[selectionEndCol notNil
-"/      and:[col == (selectionEndCol+1)]]) ifTrue:[
-
-	    line := selectionStartLine.
-	    col := selectionStartCol.
-	].
-	self makeLineVisible:line.
-	self makeColVisible:col inLine:line 
+        line := cursorLine.
+        col := cursorCol.
+        "
+         if there is a selection, its better to
+         have its start being visible, instead of the end
+        "
+        (selectionStartLine notNil 
+        and:[selectionEndLine notNil]) ifTrue:[
+            expandingTop ~~ false ifTrue:[
+                line := selectionStartLine.
+                col := selectionStartCol.
+            ] ifFalse:[
+                line := selectionEndLine.
+                col := selectionEndCol
+            ]
+        ].
+        self makeLineVisible:line.
+        self makeColVisible:col inLine:line 
     ]
+
+    "Modified: 6.3.1996 / 13:46:46 / cg"
 !
 
 makeCursorVisibleAndShowCursor:flag
@@ -2150,12 +2151,14 @@
                                    ifFound:[:line :col |
                                                 |savLine savCol|
 
-                                                savLine := cursorLine.
-                                                savCol := cursorCol.
-                                                self cursorLine:line col:col.
-                                                device flush.
-                                                Processor activeProcess millisecondDelay:200.
-                                                self cursorLine:savLine col:savCol
+                                                self withCursor:Cursor eye do:[
+                                                    savLine := cursorLine.
+                                                    savCol := cursorCol.
+                                                    self cursorLine:line col:col.
+                                                    device flush.
+                                                    Processor activeProcess millisecondDelay:200.
+                                                    self cursorLine:savLine col:savCol
+                                                ]
                                            ]
                                 ifNotFound:[self showNotFound]
                                    onError:[device beep]
@@ -2219,8 +2222,9 @@
 
     (key == #CursorRight) ifTrue:[
         (shifted and:[selectionStartLine isNil]) ifTrue:[
-            selectionStartLine := selectionEndLine := cursorLine.
-            selectionStartCol := selectionEndCol := cursorCol.
+            selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
+            selectionStartCol := selectionEndCol := clickStartCol := cursorCol.
+            expandingTop := false.
             ^ self redrawLine:selectionStartLine. 
         ].
 
@@ -2245,9 +2249,10 @@
     ].
     (key == #CursorDown) ifTrue:[
         (shifted and:[selectionStartLine isNil]) ifTrue:[
-            selectionStartLine := cursorLine. selectionEndLine := cursorLine + 1.
-            selectionStartCol := selectionEndCol := cursorCol.
+            selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1.
+            selectionStartCol := clickStartCol := selectionEndCol := cursorCol.
             self redrawLine:selectionStartLine. 
+            expandingTop := false.
             ^ self redrawLine:selectionEndLine. 
         ].
 
@@ -2281,6 +2286,25 @@
         ^ self
     ].
     (key == #CursorLeft or:[key == #CursorUp]) ifTrue:[
+        (shifted and:[selectionStartLine isNil]) ifTrue:[
+            expandingTop := true.
+            key == #CursorLeft ifTrue:[
+                cursorCol > 1 ifTrue:[
+                    selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
+                    selectionEndCol := clickStartCol := cursorCol.
+                    selectionStartCol := cursorCol.
+                    ^ self redrawLine:selectionStartLine. 
+                ]
+            ] ifFalse:[
+                cursorLine > 1 ifTrue:[
+                    selectionEndLine := clickStartLine := cursorLine.
+                    selectionEndCol := selectionStartCol := clickStartCol := cursorCol.
+                    selectionStartLine := cursorLine - 1.
+                    ^ self redrawFromLine:selectionStartLine to:cursorLine. 
+                ]
+            ]
+        ].
+
         selectionStartLine notNil ifTrue:[
             "/
             "/ treat the whole selection as cursor
@@ -2438,7 +2462,7 @@
     ].
     super keyPress:key x:x y:y
 
-    "Modified: 6.3.1996 / 12:38:39 / cg"
+    "Modified: 6.3.1996 / 14:56:07 / cg"
 !
 
 mapped
@@ -3404,5 +3428,5 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Attic/ETxtView.st,v 1.55 1996-03-06 11:41:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/ETxtView.st,v 1.56 1996-03-06 14:02:08 cg Exp $'
 ! !
--- a/EditTextView.st	Wed Mar 06 15:00:25 1996 +0100
+++ b/EditTextView.st	Wed Mar 06 15:02:08 1996 +0100
@@ -917,26 +917,27 @@
     |line col|
 
     cursorLine notNil ifTrue:[
-	line := cursorLine.
-	col := cursorCol.
-	"
-	 if there is a selection, its better to
-	 have its start being visible, instead of the end
-	"
-	(selectionStartLine notNil 
-	and:[selectionEndLine notNil]) ifTrue:[
-
-"/ that was wrong
-"/      ((line == selectionEndLine)
-"/      and:[selectionEndCol notNil
-"/      and:[col == (selectionEndCol+1)]]) ifTrue:[
-
-	    line := selectionStartLine.
-	    col := selectionStartCol.
-	].
-	self makeLineVisible:line.
-	self makeColVisible:col inLine:line 
+        line := cursorLine.
+        col := cursorCol.
+        "
+         if there is a selection, its better to
+         have its start being visible, instead of the end
+        "
+        (selectionStartLine notNil 
+        and:[selectionEndLine notNil]) ifTrue:[
+            expandingTop ~~ false ifTrue:[
+                line := selectionStartLine.
+                col := selectionStartCol.
+            ] ifFalse:[
+                line := selectionEndLine.
+                col := selectionEndCol
+            ]
+        ].
+        self makeLineVisible:line.
+        self makeColVisible:col inLine:line 
     ]
+
+    "Modified: 6.3.1996 / 13:46:46 / cg"
 !
 
 makeCursorVisibleAndShowCursor:flag
@@ -2150,12 +2151,14 @@
                                    ifFound:[:line :col |
                                                 |savLine savCol|
 
-                                                savLine := cursorLine.
-                                                savCol := cursorCol.
-                                                self cursorLine:line col:col.
-                                                device flush.
-                                                Processor activeProcess millisecondDelay:200.
-                                                self cursorLine:savLine col:savCol
+                                                self withCursor:Cursor eye do:[
+                                                    savLine := cursorLine.
+                                                    savCol := cursorCol.
+                                                    self cursorLine:line col:col.
+                                                    device flush.
+                                                    Processor activeProcess millisecondDelay:200.
+                                                    self cursorLine:savLine col:savCol
+                                                ]
                                            ]
                                 ifNotFound:[self showNotFound]
                                    onError:[device beep]
@@ -2219,8 +2222,9 @@
 
     (key == #CursorRight) ifTrue:[
         (shifted and:[selectionStartLine isNil]) ifTrue:[
-            selectionStartLine := selectionEndLine := cursorLine.
-            selectionStartCol := selectionEndCol := cursorCol.
+            selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
+            selectionStartCol := selectionEndCol := clickStartCol := cursorCol.
+            expandingTop := false.
             ^ self redrawLine:selectionStartLine. 
         ].
 
@@ -2245,9 +2249,10 @@
     ].
     (key == #CursorDown) ifTrue:[
         (shifted and:[selectionStartLine isNil]) ifTrue:[
-            selectionStartLine := cursorLine. selectionEndLine := cursorLine + 1.
-            selectionStartCol := selectionEndCol := cursorCol.
+            selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1.
+            selectionStartCol := clickStartCol := selectionEndCol := cursorCol.
             self redrawLine:selectionStartLine. 
+            expandingTop := false.
             ^ self redrawLine:selectionEndLine. 
         ].
 
@@ -2281,6 +2286,25 @@
         ^ self
     ].
     (key == #CursorLeft or:[key == #CursorUp]) ifTrue:[
+        (shifted and:[selectionStartLine isNil]) ifTrue:[
+            expandingTop := true.
+            key == #CursorLeft ifTrue:[
+                cursorCol > 1 ifTrue:[
+                    selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
+                    selectionEndCol := clickStartCol := cursorCol.
+                    selectionStartCol := cursorCol.
+                    ^ self redrawLine:selectionStartLine. 
+                ]
+            ] ifFalse:[
+                cursorLine > 1 ifTrue:[
+                    selectionEndLine := clickStartLine := cursorLine.
+                    selectionEndCol := selectionStartCol := clickStartCol := cursorCol.
+                    selectionStartLine := cursorLine - 1.
+                    ^ self redrawFromLine:selectionStartLine to:cursorLine. 
+                ]
+            ]
+        ].
+
         selectionStartLine notNil ifTrue:[
             "/
             "/ treat the whole selection as cursor
@@ -2438,7 +2462,7 @@
     ].
     super keyPress:key x:x y:y
 
-    "Modified: 6.3.1996 / 12:38:39 / cg"
+    "Modified: 6.3.1996 / 14:56:07 / cg"
 !
 
 mapped
@@ -3404,5 +3428,5 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.55 1996-03-06 11:41:29 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.56 1996-03-06 14:02:08 cg Exp $'
 ! !