care when editing 16bit text (dont hardcode String into the edit methods)
authorClaus Gittinger <cg@exept.de>
Fri, 23 Feb 1996 18:06:53 +0100
changeset 385 a373f2dd9c60
parent 384 0f2676690760
child 386 514f73e07c2d
care when editing 16bit text (dont hardcode String into the edit methods)
ETxtView.st
EditTextView.st
--- a/ETxtView.st	Fri Feb 23 17:20:03 1996 +0100
+++ b/ETxtView.st	Fri Feb 23 18:06:53 1996 +0100
@@ -1016,31 +1016,33 @@
 
     drawCharacterOnly := false.
     (colNr == lineSize) ifTrue:[
-	newLine := line copyTo:(lineSize - 1).
-	fontIsFixedWidth ifTrue:[
-	    drawCharacterOnly := true
-	]
+        newLine := line copyTo:(lineSize - 1).
+        fontIsFixedWidth ifTrue:[
+            drawCharacterOnly := true
+        ]
     ] ifFalse:[
-	newLine := String new:(lineSize - 1).
-	newLine replaceFrom:1 to:(colNr - 1)
-		       with:line startingAt:1.
-	newLine replaceFrom:colNr to:(lineSize - 1)
-		       with:line startingAt:(colNr + 1)
+        newLine := line species new:(lineSize - 1).
+        newLine replaceFrom:1 to:(colNr - 1)
+                       with:line startingAt:1.
+        newLine replaceFrom:colNr to:(lineSize - 1)
+                       with:line startingAt:(colNr + 1)
     ].
 
     newLine isBlank ifTrue:[
-	newLine := nil
+        newLine := nil
     ].
     list at:lineNr put:newLine.
     wasLargest ifTrue:[
-	widthOfWidestLine := nil. "/ i.e. unknown
+        widthOfWidestLine := nil. "/ i.e. unknown
     ].
     self textChanged.
     drawCharacterOnly ifTrue:[
-	self redrawLine:lineNr col:colNr
+        self redrawLine:lineNr col:colNr
     ] ifFalse:[
-	self redrawLine:lineNr from:colNr
+        self redrawLine:lineNr from:colNr
     ]
+
+    "Modified: 23.2.1996 / 17:42:23 / cg"
 !
 
 deleteCharBeforeCursor
@@ -1339,52 +1341,54 @@
     self checkModificationsAllowed ifFalse:[ ^ self].
 
     aCharacter == (Character cr) ifTrue:[
-	self splitLine:lineNr before:colNr.
-	^ self
+        self splitLine:lineNr before:colNr.
+        ^ self
     ].
     drawCharacterOnly := false.
     self checkForExistingLine:lineNr.
     line := list at:lineNr.
     lineSize := line size.
     (aCharacter == Character space) ifTrue:[
-	(colNr > lineSize)  ifTrue:[
-	    ^ self
-	]
+        (colNr > lineSize)  ifTrue:[
+            ^ self
+        ]
     ].
     (lineSize == 0) ifTrue: [
-	newLine := String new:colNr.
-	drawCharacterOnly := true
+        newLine := String new:colNr.
+        drawCharacterOnly := true
     ] ifFalse: [
-	(colNr > lineSize) ifTrue: [
-	    newLine := String new:colNr.
-	    newLine replaceFrom:1 to:lineSize
-			   with:line startingAt:1.
-	    drawCharacterOnly := true
-	] ifFalse: [
-	    newLine := String new:(lineSize + 1).
-	    newLine replaceFrom:1 to:(colNr - 1)
-			   with:line startingAt:1.
-	    newLine replaceFrom:(colNr + 1) to:(lineSize + 1)
-			   with:line startingAt:colNr
-	]
+        (colNr > lineSize) ifTrue: [
+            newLine := line species new:colNr.
+            newLine replaceFrom:1 to:lineSize
+                           with:line startingAt:1.
+            drawCharacterOnly := true
+        ] ifFalse: [
+            newLine := line species new:(lineSize + 1).
+            newLine replaceFrom:1 to:(colNr - 1)
+                           with:line startingAt:1.
+            newLine replaceFrom:(colNr + 1) to:(lineSize + 1)
+                           with:line startingAt:colNr
+        ]
     ].
     newLine at:colNr put:aCharacter.
     aCharacter == (Character tab) ifTrue:[
-	newLine := self withTabsExpanded:newLine.
-	drawCharacterOnly := false
+        newLine := self withTabsExpanded:newLine.
+        drawCharacterOnly := false
     ].
     list at:lineNr put:newLine.
     widthOfWidestLine notNil ifTrue:[
-	widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
+        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
     ].
     self textChanged.
     shown ifTrue:[
-	drawCharacterOnly ifTrue:[
-	    self redrawLine:lineNr col:colNr
-	] ifFalse:[
-	    self redrawLine:lineNr from:colNr
-	]
+        drawCharacterOnly ifTrue:[
+            self redrawLine:lineNr col:colNr
+        ] ifFalse:[
+            self redrawLine:lineNr from:colNr
+        ]
     ]
+
+    "Modified: 23.2.1996 / 17:41:49 / cg"
 !
 
 insertCharAtCursor:aCharacter
@@ -1913,41 +1917,43 @@
     self checkForExistingLine:lineNr.
     line := list at:lineNr.
     line notNil ifTrue:[
-	lineSize := line size
+        lineSize := line size
     ] ifFalse:[
-	lineSize := 0
+        lineSize := 0
     ].
     ((colNr == 1) and:[lineSize == 0]) ifTrue: [
-	newLine := aString
+        newLine := aString
     ] ifFalse:[
-	(lineSize == 0) ifTrue: [
-	    newLine := String new:(colNr + strLen - 1)
-	] ifFalse: [
-	    (colNr > lineSize) ifTrue: [
-		newLine := String new:(colNr + strLen - 1).
-		newLine replaceFrom:1 to:lineSize
-			       with:line startingAt:1
-	    ] ifFalse: [
-		newLine := String new:(lineSize + strLen).
-		newLine replaceFrom:1 to:(colNr - 1)
-			       with:line startingAt:1.
-		newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen)
-			       with:line startingAt:colNr
-	    ]
-	].
-	newLine replaceFrom:colNr to:(colNr + strLen - 1)
-		       with:aString startingAt:1
+        (lineSize == 0) ifTrue: [
+            newLine := String new:(colNr + strLen - 1)
+        ] ifFalse: [
+            (colNr > lineSize) ifTrue: [
+                newLine := line species new:(colNr + strLen - 1).
+                newLine replaceFrom:1 to:lineSize
+                               with:line startingAt:1
+            ] ifFalse: [
+                newLine := line species new:(lineSize + strLen).
+                newLine replaceFrom:1 to:(colNr - 1)
+                               with:line startingAt:1.
+                newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen)
+                               with:line startingAt:colNr
+            ]
+        ].
+        newLine replaceFrom:colNr to:(colNr + strLen - 1)
+                       with:aString startingAt:1
     ].
 
     (aString occurrencesOf:(Character tab)) == 0 ifFalse:[
-	newLine := self withTabsExpanded:newLine
+        newLine := self withTabsExpanded:newLine
     ].
 
     list at:lineNr put:newLine.
     widthOfWidestLine notNil ifTrue:[
-	widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
+        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
     ].
     self textChanged.
+
+    "Modified: 23.2.1996 / 17:42:47 / cg"
 ! !
 
 !EditTextView methodsFor:'event processing'!
@@ -3192,5 +3198,5 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Attic/ETxtView.st,v 1.46 1996-02-14 11:19:53 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/ETxtView.st,v 1.47 1996-02-23 17:06:53 cg Exp $'
 ! !
--- a/EditTextView.st	Fri Feb 23 17:20:03 1996 +0100
+++ b/EditTextView.st	Fri Feb 23 18:06:53 1996 +0100
@@ -1016,31 +1016,33 @@
 
     drawCharacterOnly := false.
     (colNr == lineSize) ifTrue:[
-	newLine := line copyTo:(lineSize - 1).
-	fontIsFixedWidth ifTrue:[
-	    drawCharacterOnly := true
-	]
+        newLine := line copyTo:(lineSize - 1).
+        fontIsFixedWidth ifTrue:[
+            drawCharacterOnly := true
+        ]
     ] ifFalse:[
-	newLine := String new:(lineSize - 1).
-	newLine replaceFrom:1 to:(colNr - 1)
-		       with:line startingAt:1.
-	newLine replaceFrom:colNr to:(lineSize - 1)
-		       with:line startingAt:(colNr + 1)
+        newLine := line species new:(lineSize - 1).
+        newLine replaceFrom:1 to:(colNr - 1)
+                       with:line startingAt:1.
+        newLine replaceFrom:colNr to:(lineSize - 1)
+                       with:line startingAt:(colNr + 1)
     ].
 
     newLine isBlank ifTrue:[
-	newLine := nil
+        newLine := nil
     ].
     list at:lineNr put:newLine.
     wasLargest ifTrue:[
-	widthOfWidestLine := nil. "/ i.e. unknown
+        widthOfWidestLine := nil. "/ i.e. unknown
     ].
     self textChanged.
     drawCharacterOnly ifTrue:[
-	self redrawLine:lineNr col:colNr
+        self redrawLine:lineNr col:colNr
     ] ifFalse:[
-	self redrawLine:lineNr from:colNr
+        self redrawLine:lineNr from:colNr
     ]
+
+    "Modified: 23.2.1996 / 17:42:23 / cg"
 !
 
 deleteCharBeforeCursor
@@ -1339,52 +1341,54 @@
     self checkModificationsAllowed ifFalse:[ ^ self].
 
     aCharacter == (Character cr) ifTrue:[
-	self splitLine:lineNr before:colNr.
-	^ self
+        self splitLine:lineNr before:colNr.
+        ^ self
     ].
     drawCharacterOnly := false.
     self checkForExistingLine:lineNr.
     line := list at:lineNr.
     lineSize := line size.
     (aCharacter == Character space) ifTrue:[
-	(colNr > lineSize)  ifTrue:[
-	    ^ self
-	]
+        (colNr > lineSize)  ifTrue:[
+            ^ self
+        ]
     ].
     (lineSize == 0) ifTrue: [
-	newLine := String new:colNr.
-	drawCharacterOnly := true
+        newLine := String new:colNr.
+        drawCharacterOnly := true
     ] ifFalse: [
-	(colNr > lineSize) ifTrue: [
-	    newLine := String new:colNr.
-	    newLine replaceFrom:1 to:lineSize
-			   with:line startingAt:1.
-	    drawCharacterOnly := true
-	] ifFalse: [
-	    newLine := String new:(lineSize + 1).
-	    newLine replaceFrom:1 to:(colNr - 1)
-			   with:line startingAt:1.
-	    newLine replaceFrom:(colNr + 1) to:(lineSize + 1)
-			   with:line startingAt:colNr
-	]
+        (colNr > lineSize) ifTrue: [
+            newLine := line species new:colNr.
+            newLine replaceFrom:1 to:lineSize
+                           with:line startingAt:1.
+            drawCharacterOnly := true
+        ] ifFalse: [
+            newLine := line species new:(lineSize + 1).
+            newLine replaceFrom:1 to:(colNr - 1)
+                           with:line startingAt:1.
+            newLine replaceFrom:(colNr + 1) to:(lineSize + 1)
+                           with:line startingAt:colNr
+        ]
     ].
     newLine at:colNr put:aCharacter.
     aCharacter == (Character tab) ifTrue:[
-	newLine := self withTabsExpanded:newLine.
-	drawCharacterOnly := false
+        newLine := self withTabsExpanded:newLine.
+        drawCharacterOnly := false
     ].
     list at:lineNr put:newLine.
     widthOfWidestLine notNil ifTrue:[
-	widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
+        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
     ].
     self textChanged.
     shown ifTrue:[
-	drawCharacterOnly ifTrue:[
-	    self redrawLine:lineNr col:colNr
-	] ifFalse:[
-	    self redrawLine:lineNr from:colNr
-	]
+        drawCharacterOnly ifTrue:[
+            self redrawLine:lineNr col:colNr
+        ] ifFalse:[
+            self redrawLine:lineNr from:colNr
+        ]
     ]
+
+    "Modified: 23.2.1996 / 17:41:49 / cg"
 !
 
 insertCharAtCursor:aCharacter
@@ -1913,41 +1917,43 @@
     self checkForExistingLine:lineNr.
     line := list at:lineNr.
     line notNil ifTrue:[
-	lineSize := line size
+        lineSize := line size
     ] ifFalse:[
-	lineSize := 0
+        lineSize := 0
     ].
     ((colNr == 1) and:[lineSize == 0]) ifTrue: [
-	newLine := aString
+        newLine := aString
     ] ifFalse:[
-	(lineSize == 0) ifTrue: [
-	    newLine := String new:(colNr + strLen - 1)
-	] ifFalse: [
-	    (colNr > lineSize) ifTrue: [
-		newLine := String new:(colNr + strLen - 1).
-		newLine replaceFrom:1 to:lineSize
-			       with:line startingAt:1
-	    ] ifFalse: [
-		newLine := String new:(lineSize + strLen).
-		newLine replaceFrom:1 to:(colNr - 1)
-			       with:line startingAt:1.
-		newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen)
-			       with:line startingAt:colNr
-	    ]
-	].
-	newLine replaceFrom:colNr to:(colNr + strLen - 1)
-		       with:aString startingAt:1
+        (lineSize == 0) ifTrue: [
+            newLine := String new:(colNr + strLen - 1)
+        ] ifFalse: [
+            (colNr > lineSize) ifTrue: [
+                newLine := line species new:(colNr + strLen - 1).
+                newLine replaceFrom:1 to:lineSize
+                               with:line startingAt:1
+            ] ifFalse: [
+                newLine := line species new:(lineSize + strLen).
+                newLine replaceFrom:1 to:(colNr - 1)
+                               with:line startingAt:1.
+                newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen)
+                               with:line startingAt:colNr
+            ]
+        ].
+        newLine replaceFrom:colNr to:(colNr + strLen - 1)
+                       with:aString startingAt:1
     ].
 
     (aString occurrencesOf:(Character tab)) == 0 ifFalse:[
-	newLine := self withTabsExpanded:newLine
+        newLine := self withTabsExpanded:newLine
     ].
 
     list at:lineNr put:newLine.
     widthOfWidestLine notNil ifTrue:[
-	widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
+        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
     ].
     self textChanged.
+
+    "Modified: 23.2.1996 / 17:42:47 / cg"
 ! !
 
 !EditTextView methodsFor:'event processing'!
@@ -3192,5 +3198,5 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.46 1996-02-14 11:19:53 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.47 1996-02-23 17:06:53 cg Exp $'
 ! !