--- a/ETxtView.st Sat Jan 17 14:49:07 1998 +0100
+++ b/ETxtView.st Sat Jan 17 14:49:55 1998 +0100
@@ -333,21 +333,55 @@
!EditTextView class methodsFor:'defaults'!
+st80Mode
+ "return true, if the st80 editing mode is turned on.
+ This setting affects the behavior of the cursor, when positioned
+ behond the end of a line or the end of the text.
+ The default is initialized from the viewStyle."
+
+ ^ ST80Mode
+
+ "
+ EditTextView st80Mode:true
+ EditTextView st80Mode:false
+ "
+
+ "Modified: / 16.1.1998 / 22:54:57 / cg"
+!
+
+st80Mode:aBoolean
+ "turns on/off st80 behavior, where the cursor cannot be positioned
+ behond the end of a line or the last line"
+
+ ST80Mode := aBoolean.
+
+ "
+ EditTextView st80Mode:true
+ EditTextView st80Mode:false
+ "
+
+ "Modified: / 16.1.1998 / 22:55:19 / cg"
+!
+
updateStyleCache
"extract values from the styleSheet and cache them in class variables"
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor'
#'textCursor.noFocusForegroundColor'
- #'textCursor.type' )>
+ #'textCursor.type'
+ #'editText.st80Mode')>
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'.
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'.
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'.
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block.
-
- ST80Mode := false.
-
- "Modified: / 31.10.1997 / 13:13:51 / cg"
+ ST80Mode := StyleSheet at:'editText.st80Mode' default:false.
+
+ "
+ self updateStyleCache
+ "
+
+ "Modified: / 16.1.1998 / 21:56:12 / cg"
! !
!EditTextView methodsFor:'ST-80 compatibility editing'!
@@ -778,13 +812,15 @@
(cursorCol ~~ 1) ifTrue:[
self cursorCol:(cursorCol - 1)
] ifFalse:[
- ST80Mode == true ifTrue:[
- self cursorUp.
- self cursorToEndOfLine.
+ cursorLine ~~ 1 ifTrue:[
+ ST80Mode == true ifTrue:[
+ self cursorUp.
+ self cursorToEndOfLine.
+ ]
]
]
- "Modified: 12.8.1997 / 13:57:14 / cg"
+ "Modified: / 16.1.1998 / 22:26:46 / cg"
!
cursorLine:line col:col
@@ -794,16 +830,22 @@
wasOn := self hideCursor.
cursorLine := self validateCursorLine:line.
- cursorVisibleLine := self listLineToVisibleLine:line.
+ cursorVisibleLine := self listLineToVisibleLine:cursorLine.
(col < 1) ifTrue:[
newCol := 1
] ifFalse:[
newCol := col.
].
+ ST80Mode ifTrue:[
+ (cursorLine == list size
+ and:[cursorLine ~~ line]) ifTrue:[
+ newCol := (self listAt:(list size)) size + 1.
+ ]
+ ].
cursorCol := self validateCursorCol:newCol inLine:cursorLine.
self makeCursorVisibleAndShowCursor:wasOn.
- "Modified: 24.5.1996 / 14:16:14 / cg"
+ "Modified: / 16.1.1998 / 22:46:18 / cg"
!
cursorReturn
@@ -835,13 +877,15 @@
ST80Mode == true ifTrue:[
l := (self listAt:cursorLine).
cursorCol >= (l size + 1) ifTrue:[
- self cursorReturn.
+ cursorLine < list size ifTrue:[
+ self cursorReturn.
+ ].
^ self
]
].
self cursorCol:(cursorCol + 1)
- "Modified: 13.8.1997 / 15:33:48 / cg"
+ "Modified: / 16.1.1998 / 22:37:23 / cg"
!
cursorTab
@@ -1364,6 +1408,10 @@
|l max|
+ "/ in ST80 mode,
+ "/ the cursor may not be positioned behond the
+ "/ end of a line or behond the last line of the text
+ "/
ST80Mode == true ifTrue:[
l := (self listAt:line).
max := l size + 1.
@@ -1373,8 +1421,8 @@
].
^ col
- "Created: 22.5.1996 / 14:25:30 / cg"
- "Modified: 13.8.1997 / 15:34:13 / cg"
+ "Created: / 22.5.1996 / 14:25:30 / cg"
+ "Modified: / 16.1.1998 / 22:44:23 / cg"
!
validateCursorLine:line
@@ -1384,10 +1432,17 @@
behind the end of the text (vi/st-80 behavior), or want to
skip reserved regions"
+ "/
+ "/ in st80Mode, the cursor may not be positioned
+ "/ behond the last line
+ "/
+ ST80Mode == true ifTrue:[
+ ^ (line min:(list size)) max:1
+ ].
^ line
- "Created: 22.5.1996 / 18:22:23 / cg"
- "Modified: 22.5.1996 / 18:30:05 / cg"
+ "Created: / 22.5.1996 / 18:22:23 / cg"
+ "Modified: / 16.1.1998 / 22:59:26 / cg"
!
withCursorOffDo:aBlock
@@ -1429,8 +1484,6 @@
"delete a single character at colNr in line lineNr"
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr
-
-
!
deleteCharBeforeCursor
@@ -1456,13 +1509,13 @@
soCol := 1
].
- (cursorCol == soCol) ifFalse:[
+ (cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[
"
somewhere in the middle of a line
"
self cursorLeft.
self deleteCharAtLine:cursorLine col:cursorCol.
- ] ifTrue:[
+ ] ifFalse:[
"
at begin of line - merge with previous line;
except for the very first line.
@@ -1476,7 +1529,7 @@
].
wasOn ifTrue:[ self showCursor ]
- "Modified: 9.9.1997 / 09:29:14 / cg"
+ "Modified: / 16.1.1998 / 22:33:04 / cg"
!
deleteCharsAtLine:lineNr fromCol:colNr
@@ -1696,11 +1749,6 @@
"insert the argument, aString at cursor position
handle cr's correctly. A nil argument is interpreted as an empty line."
- |start " { Class: SmallInteger }"
- stop " { Class: SmallInteger }"
- end " { Class: SmallInteger }"
- subString|
-
aString isNil ifTrue:[
"new:"
self insertCharAtCursor:(Character cr).
@@ -1712,34 +1760,6 @@
self insertLines:aString asStringCollection withCR:false.
-"/ start := 1.
-"/ end := aString size.
-"/ "insert the 1st line"
-"/ (cursorCol ~~ 1) ifTrue:[
-"/ stop := aString indexOf:(Character cr) startingAt:start.
-"/ stop == 0 ifTrue:[
-"/ stop := end + 1
-"/ ].
-"/ subString := aString copyFrom:start to:(stop - 1).
-"/ self insertStringWithoutCRsAtCursor:subString.
-"/ self insertCharAtCursor:(Character cr).
-"/ start := stop + 1
-"/ ].
-"/ "insert the block of full lines"
-"/
-"/ [start <= end] whileTrue:[
-"/ stop := aString indexOf:(Character cr) startingAt:start.
-"/ stop == 0 ifTrue:[
-"/ stop := end + 1
-"/ ].
-"/ subString := aString copyFrom:start to:(stop - 1).
-"/ self insertStringWithoutCRsAtCursor:subString.
-"/ (stop < end) ifTrue:[
-"/ self insertCharAtCursor:(Character cr)
-"/ ].
-"/ start := stop + 1
-"/ ]
-
"Modified: 18.5.1996 / 15:33:14 / cg"
!
@@ -2222,7 +2242,7 @@
replace:aCharacter atLine:lineNr col:colNr
"replace a single character at lineNr/colNr"
- |line lineSize newLine drawCharacterOnly|
+ |line lineSize newLine|
self checkModificationsAllowed ifFalse:[ ^ self].
@@ -3137,7 +3157,7 @@
tabMeansNextField := false.
autoIndent := false.
insertMode := true.
- trimBlankLines := true.
+ trimBlankLines := ST80Mode not. "true."
"Modified: 14.2.1997 / 16:52:05 / cg"
!
@@ -4108,5 +4128,5 @@
!EditTextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/Attic/ETxtView.st,v 1.141 1998-01-16 15:29:23 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/Attic/ETxtView.st,v 1.142 1998-01-17 13:49:55 cg Exp $'
! !
--- a/EditTextView.st Sat Jan 17 14:49:07 1998 +0100
+++ b/EditTextView.st Sat Jan 17 14:49:55 1998 +0100
@@ -333,21 +333,55 @@
!EditTextView class methodsFor:'defaults'!
+st80Mode
+ "return true, if the st80 editing mode is turned on.
+ This setting affects the behavior of the cursor, when positioned
+ behond the end of a line or the end of the text.
+ The default is initialized from the viewStyle."
+
+ ^ ST80Mode
+
+ "
+ EditTextView st80Mode:true
+ EditTextView st80Mode:false
+ "
+
+ "Modified: / 16.1.1998 / 22:54:57 / cg"
+!
+
+st80Mode:aBoolean
+ "turns on/off st80 behavior, where the cursor cannot be positioned
+ behond the end of a line or the last line"
+
+ ST80Mode := aBoolean.
+
+ "
+ EditTextView st80Mode:true
+ EditTextView st80Mode:false
+ "
+
+ "Modified: / 16.1.1998 / 22:55:19 / cg"
+!
+
updateStyleCache
"extract values from the styleSheet and cache them in class variables"
<resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor'
#'textCursor.noFocusForegroundColor'
- #'textCursor.type' )>
+ #'textCursor.type'
+ #'editText.st80Mode')>
DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'.
DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'.
DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'.
DefaultCursorType := StyleSheet at:'textCursor.type' default:#block.
-
- ST80Mode := false.
-
- "Modified: / 31.10.1997 / 13:13:51 / cg"
+ ST80Mode := StyleSheet at:'editText.st80Mode' default:false.
+
+ "
+ self updateStyleCache
+ "
+
+ "Modified: / 16.1.1998 / 21:56:12 / cg"
! !
!EditTextView methodsFor:'ST-80 compatibility editing'!
@@ -778,13 +812,15 @@
(cursorCol ~~ 1) ifTrue:[
self cursorCol:(cursorCol - 1)
] ifFalse:[
- ST80Mode == true ifTrue:[
- self cursorUp.
- self cursorToEndOfLine.
+ cursorLine ~~ 1 ifTrue:[
+ ST80Mode == true ifTrue:[
+ self cursorUp.
+ self cursorToEndOfLine.
+ ]
]
]
- "Modified: 12.8.1997 / 13:57:14 / cg"
+ "Modified: / 16.1.1998 / 22:26:46 / cg"
!
cursorLine:line col:col
@@ -794,16 +830,22 @@
wasOn := self hideCursor.
cursorLine := self validateCursorLine:line.
- cursorVisibleLine := self listLineToVisibleLine:line.
+ cursorVisibleLine := self listLineToVisibleLine:cursorLine.
(col < 1) ifTrue:[
newCol := 1
] ifFalse:[
newCol := col.
].
+ ST80Mode ifTrue:[
+ (cursorLine == list size
+ and:[cursorLine ~~ line]) ifTrue:[
+ newCol := (self listAt:(list size)) size + 1.
+ ]
+ ].
cursorCol := self validateCursorCol:newCol inLine:cursorLine.
self makeCursorVisibleAndShowCursor:wasOn.
- "Modified: 24.5.1996 / 14:16:14 / cg"
+ "Modified: / 16.1.1998 / 22:46:18 / cg"
!
cursorReturn
@@ -835,13 +877,15 @@
ST80Mode == true ifTrue:[
l := (self listAt:cursorLine).
cursorCol >= (l size + 1) ifTrue:[
- self cursorReturn.
+ cursorLine < list size ifTrue:[
+ self cursorReturn.
+ ].
^ self
]
].
self cursorCol:(cursorCol + 1)
- "Modified: 13.8.1997 / 15:33:48 / cg"
+ "Modified: / 16.1.1998 / 22:37:23 / cg"
!
cursorTab
@@ -1364,6 +1408,10 @@
|l max|
+ "/ in ST80 mode,
+ "/ the cursor may not be positioned behond the
+ "/ end of a line or behond the last line of the text
+ "/
ST80Mode == true ifTrue:[
l := (self listAt:line).
max := l size + 1.
@@ -1373,8 +1421,8 @@
].
^ col
- "Created: 22.5.1996 / 14:25:30 / cg"
- "Modified: 13.8.1997 / 15:34:13 / cg"
+ "Created: / 22.5.1996 / 14:25:30 / cg"
+ "Modified: / 16.1.1998 / 22:44:23 / cg"
!
validateCursorLine:line
@@ -1384,10 +1432,17 @@
behind the end of the text (vi/st-80 behavior), or want to
skip reserved regions"
+ "/
+ "/ in st80Mode, the cursor may not be positioned
+ "/ behond the last line
+ "/
+ ST80Mode == true ifTrue:[
+ ^ (line min:(list size)) max:1
+ ].
^ line
- "Created: 22.5.1996 / 18:22:23 / cg"
- "Modified: 22.5.1996 / 18:30:05 / cg"
+ "Created: / 22.5.1996 / 18:22:23 / cg"
+ "Modified: / 16.1.1998 / 22:59:26 / cg"
!
withCursorOffDo:aBlock
@@ -1429,8 +1484,6 @@
"delete a single character at colNr in line lineNr"
self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr
-
-
!
deleteCharBeforeCursor
@@ -1456,13 +1509,13 @@
soCol := 1
].
- (cursorCol == soCol) ifFalse:[
+ (cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[
"
somewhere in the middle of a line
"
self cursorLeft.
self deleteCharAtLine:cursorLine col:cursorCol.
- ] ifTrue:[
+ ] ifFalse:[
"
at begin of line - merge with previous line;
except for the very first line.
@@ -1476,7 +1529,7 @@
].
wasOn ifTrue:[ self showCursor ]
- "Modified: 9.9.1997 / 09:29:14 / cg"
+ "Modified: / 16.1.1998 / 22:33:04 / cg"
!
deleteCharsAtLine:lineNr fromCol:colNr
@@ -1696,11 +1749,6 @@
"insert the argument, aString at cursor position
handle cr's correctly. A nil argument is interpreted as an empty line."
- |start " { Class: SmallInteger }"
- stop " { Class: SmallInteger }"
- end " { Class: SmallInteger }"
- subString|
-
aString isNil ifTrue:[
"new:"
self insertCharAtCursor:(Character cr).
@@ -1712,34 +1760,6 @@
self insertLines:aString asStringCollection withCR:false.
-"/ start := 1.
-"/ end := aString size.
-"/ "insert the 1st line"
-"/ (cursorCol ~~ 1) ifTrue:[
-"/ stop := aString indexOf:(Character cr) startingAt:start.
-"/ stop == 0 ifTrue:[
-"/ stop := end + 1
-"/ ].
-"/ subString := aString copyFrom:start to:(stop - 1).
-"/ self insertStringWithoutCRsAtCursor:subString.
-"/ self insertCharAtCursor:(Character cr).
-"/ start := stop + 1
-"/ ].
-"/ "insert the block of full lines"
-"/
-"/ [start <= end] whileTrue:[
-"/ stop := aString indexOf:(Character cr) startingAt:start.
-"/ stop == 0 ifTrue:[
-"/ stop := end + 1
-"/ ].
-"/ subString := aString copyFrom:start to:(stop - 1).
-"/ self insertStringWithoutCRsAtCursor:subString.
-"/ (stop < end) ifTrue:[
-"/ self insertCharAtCursor:(Character cr)
-"/ ].
-"/ start := stop + 1
-"/ ]
-
"Modified: 18.5.1996 / 15:33:14 / cg"
!
@@ -2222,7 +2242,7 @@
replace:aCharacter atLine:lineNr col:colNr
"replace a single character at lineNr/colNr"
- |line lineSize newLine drawCharacterOnly|
+ |line lineSize newLine|
self checkModificationsAllowed ifFalse:[ ^ self].
@@ -3137,7 +3157,7 @@
tabMeansNextField := false.
autoIndent := false.
insertMode := true.
- trimBlankLines := true.
+ trimBlankLines := ST80Mode not. "true."
"Modified: 14.2.1997 / 16:52:05 / cg"
!
@@ -4108,5 +4128,5 @@
!EditTextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.141 1998-01-16 15:29:23 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.142 1998-01-17 13:49:55 cg Exp $'
! !