EditTextView.st
changeset 3023 9a6809da7351
parent 3020 68a2dfad4e5e
child 3024 e2d7e40e6481
--- a/EditTextView.st	Tue Sep 14 12:18:01 2004 +0200
+++ b/EditTextView.st	Tue Sep 14 12:39:31 2004 +0200
@@ -394,8 +394,7 @@
 st80Mode
     "return true, if the st80 editing mode is turned on.
      This setting affects the behavior of the cursor, when positioned
-     beyond the end of a line or the end of the text.
-     The default is initialized from the viewStyle."
+     beyond the end of a line or the end of the text."
 
     ^ UserPreferences current st80EditMode
 
@@ -1192,13 +1191,12 @@
     (cursorCol ~~ 1) ifTrue:[
         self cursorCol:(cursorCol - 1)
     ] ifFalse:[
-"/ no, do not wrap back to previous line
-"/        cursorLine ~~ 1 ifTrue:[
-"/            self st80Mode == true ifTrue:[
-"/                self cursorUp.
-"/                self cursorToEndOfLine.
-"/           ]
-"/        ]
+        cursorLine ~~ 1 ifTrue:[
+            self st80EditMode ifTrue:[
+                self cursorUp.
+                self cursorToEndOfLine.
+           ]
+        ]
     ]
 
     "Modified: / 23.1.1998 / 12:37:13 / cg"
@@ -1267,13 +1265,12 @@
 
     |l|
 
-    self st80EditMode == true ifTrue:[
+    self st80EditMode ifTrue:[
         l := (self listAt:cursorLine).
         cursorCol >= (l size + 1) ifTrue:[
-"/ no, do not wrap to next line
-"/            cursorLine < list size ifTrue:[
-"/                self cursorReturn.
-"/            ].
+            cursorLine < list size ifTrue:[
+                self cursorReturn.
+            ].
             ^ self    
         ]
     ].    
@@ -1953,8 +1950,8 @@
     "/ in ST80 mode,
     "/ the cursor may not be positioned beyond the
     "/ end of a line or beyond the last line of the text
-    "/
-    self st80EditMode == true ifTrue:[
+    
+    self st80EditMode ifTrue:[
         l := (self listAt:line).
         max := l size + 1.
         col > max ifTrue:[
@@ -1978,7 +1975,7 @@
     "/ in st80Mode, the cursor may not be positioned
     "/ beyond the last line
     "/
-    self st80EditMode == true ifTrue:[
+    self st80EditMode ifTrue:[
         ^ (line min:(list size)) max:1
     ].
     ^ line
@@ -2091,6 +2088,19 @@
 deleteCharAtLine:lineNr col:colNr
     "delete a single character at colNr in line lineNr"
 
+    self st80EditMode ifTrue:[
+        (self listAt:cursorLine) size + 1 = colNr ifTrue:[
+            | wasOn |
+            wasOn := self hideCursor.
+            self 
+                cursorReturn;
+                cursorCol:1;
+                deleteCharBeforeCursor.        
+            wasOn ifTrue:[ self showCursor].
+            ^ self.
+        ].
+    ].
+
     self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr
 !
 
@@ -2933,7 +2943,7 @@
     line := list at:lineNr.
     lineSize := line size.
 
-    self st80EditMode ~~ true ifTrue:[
+    self st80EditMode ifFalse:[
         (trimBlankLines 
         and:[colNr > lineSize
         and:[aCharacter == Character space]]) ifTrue:[
@@ -3768,10 +3778,11 @@
                           #LearnKeyboardMacro #ExecuteKeyboardMacro
                           #'F*' #'f*')>
 
-    |fKeyMacros shifted i event cmdMacro|
+    |fKeyMacros shiftPressed ctrlPressed i event cmdMacro|
 
     event := WindowGroup lastEventQuerySignal query.
-    shifted := event hasShift.
+    shiftPressed := event hasShift.
+    ctrlPressed := event hasCtrl.
 
     cmdMacro := UserPreferences current functionKeySequences at:key ifAbsent:nil.
     cmdMacro notNil ifTrue:[
@@ -3791,7 +3802,7 @@
         ].
 
         self makeCursorVisible.
-        shifted ifTrue:[
+        shiftPressed ifTrue:[
             self deleteWordBeforeCursor.
         ] ifFalse:[
             self deleteCharBeforeCursor. 
@@ -3828,7 +3839,7 @@
     (key at:1) asLowercase == $f ifTrue:[
         (('[fF][0-9]' match:key)
         or:['[fF][0-9][0-9]' match:key]) ifTrue:[
-            shifted ifFalse:[
+            shiftPressed ifFalse:[
                 fKeyMacros := UserPreferences current functionKeySequences.
                 fKeyMacros notNil ifTrue:[
                     (fKeyMacros includesKey:key) ifTrue:[
@@ -3882,20 +3893,36 @@
 "
 
     (key == #BeginOfLine) ifTrue:[
-        self unselect.
-        shifted ifTrue:[
-            self cursorHome
-        ] ifFalse:[
-            self cursorToBeginOfLine. 
+        shiftPressed ifTrue: [       
+            "/ "Original St/X code - now use Ctrl modifier"
+            "/ self unselect.
+            "/ self cursorHome.
+            "Jan's modification"        
+            self addToSelectionAfter:[ self cursorToBeginOfLine ].
+        ] ifFalse: [
+            self unselect.
+            ctrlPressed ifTrue:[
+                self cursorHome.
+            ] ifFalse:[
+                self cursorToBeginOfLine.
+            ]
         ].
         ^ self
     ].
     (key == #EndOfLine) ifTrue:[
-        self unselect.
-        shifted ifTrue:[
-            self cursorToBottom
+        shiftPressed ifTrue:[
+            "/ "Original St/X code - now use Ctrl modifier"
+            "/ self unselect.
+            "/ self cursorToBottom
+            "Jan's modification"        
+            self addToSelectionAfter:[ self cursorToEndOfLine ] .
         ] ifFalse:[
-            self cursorToEndOfLine. 
+            self unselect.
+            ctrlPressed ifTrue:[
+                self cursorToBottom
+            ] ifFalse:[
+                self cursorToEndOfLine. 
+            ]
         ].
         ^ self
     ].
@@ -3907,12 +3934,12 @@
     or:[key == #CursorDown
     or:[key == #CursorLeft
     or:[key == #CursorUp]]]) ifTrue:[
-        self cursorKeyPress:key shifted:shifted.
+        self cursorKeyPress:key shifted:shiftPressed.
         ^ self.
     ].
 
     (key == #Return)    ifTrue:[
-        shifted ifTrue:[
+        shiftPressed ifTrue:[
             self unselect. self cursorReturn. 
             ^ self
         ].
@@ -3969,7 +3996,7 @@
 
     "/ key == #DeleteSpaces ifTrue:[
     (key == #Delete) ifTrue:[
-        shifted ifTrue:[
+        shiftPressed ifTrue:[
             [(cursorCol <= (self listAt:cursorLine) size)
              and:[self characterUnderCursor isSeparator]] whileTrue:[
                 self makeCursorVisible.
@@ -5506,6 +5533,39 @@
 
 !EditTextView methodsFor:'selections'!
 
+addToSelectionAfter:aBlock
+    "Pokud existuje selekce, upravi ji
+     podle aktualni pozice kurzoru a pozice
+     po provedeni blocku.
+     Urceno k implementaci Shift-Home a Shift-End
+     Nejak nevim, jak to presneji popsat :-)"
+
+    |startLine startCol endLine endCol |
+
+    self hasSelection ifTrue: [
+        startLine := selectionStartLine .
+        startCol := selectionStartCol .
+        endLine := selectionEndLine .
+        endCol := selectionEndCol .
+    ] ifFalse: [
+        startLine := endLine :=  cursorLine .
+        startCol := endCol := cursorCol .
+    ].
+
+    "deselectim a provedu presun kurzoru..."
+    self unselect .
+    aBlock value .
+
+    "funguje dost mizerne, jen na jednom radku..."
+    (startCol - cursorCol) abs <= (endCol - cursorCol) abs
+        ifTrue: [
+            startCol := cursorCol.
+        ] ifFalse: [
+            endCol := cursorCol - 1.
+        ].
+    self selectFromLine:startLine col:startCol toLine: endLine col:endCol .
+!
+
 autoMoveCursorToEndOfSelection
     "return true, if the cursor should be automatically moved to the
      end of a selection.
@@ -5868,5 +5928,5 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.356 2004-09-14 09:55:41 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.357 2004-09-14 10:39:31 cg Exp $'
 ! !