--- a/EditTextView.st Thu Jun 11 10:54:51 1998 +0200
+++ b/EditTextView.st Fri Jun 12 22:02:44 1998 +0200
@@ -1701,18 +1701,25 @@
!
insertCharAtCursor:aCharacter
- "insert a single character at cursor-position - advance cursor"
+ "insert a single character at cursor-position - advance cursor."
|wasOn|
wasOn := self hideCursor.
- self insert:aCharacter atLine:cursorLine col:cursorCol.
- aCharacter == (Character cr) ifTrue:[
- self cursorReturn
+ aCharacter == Character tab ifTrue:[
+ "/ needs special care to advance cursor correctly
+ self insertTabAtCursor
] ifFalse:[
- self cursorRight.
+ self insert:aCharacter atLine:cursorLine col:cursorCol.
+ aCharacter == (Character cr) ifTrue:[
+ self cursorReturn
+ ] ifFalse:[
+ self cursorRight.
+ ].
].
self makeCursorVisibleAndShowCursor:wasOn.
+
+ "Modified: / 12.6.1998 / 21:50:20 / cg"
!
insertLine:aString before:lineNr
@@ -1732,49 +1739,50 @@
!
insertLines:lines withCR:withCr
- "insert a bunch of lines at cursor position. Cursor
- is moved behind insertion.
+ "insert a bunch of lines at cursor position.
+ Cursor is moved behind insertion.
If withCr is true, append cr after last line"
|start end nLines wasOn|
lines notNil ifTrue:[
- nLines := lines size.
- (nLines == 1) ifTrue:[
- self insertStringAtCursor:(lines at:1).
- withCr ifTrue:[
- self insertCharAtCursor:(Character cr)
- ]
- ] ifFalse:[
- (cursorCol ~~ 1) ifTrue:[
- self insertStringAtCursor:(lines at:1).
- self insertCharAtCursor:(Character cr).
- start := 2
- ] ifFalse:[
- start := 1
- ].
- withCr ifTrue:[
- end := nLines
- ] ifFalse:[
- end := nLines - 1
- ].
- (start < nLines) ifTrue:[
- (end >= start) ifTrue:[
- wasOn := self hideCursor.
- self insertLines:lines from:start to:end before:cursorLine.
- cursorLine := cursorLine + (end - start + 1).
- cursorVisibleLine := self absoluteLineToVisibleLine:cursorLine.
- wasOn ifTrue:[self showCursor].
- ]
- ].
- withCr ifFalse:[
- "last line without cr"
- self insertStringAtCursor:(lines at:nLines)
- ]
- ]
+ nLines := lines size.
+ (nLines == 1) ifTrue:[
+ self insertStringAtCursor:(lines at:1).
+ withCr ifTrue:[
+ self insertCharAtCursor:(Character cr)
+ ]
+ ] ifFalse:[
+ (cursorCol ~~ 1) ifTrue:[
+ self insertStringAtCursor:(lines at:1).
+ self insertCharAtCursor:(Character cr).
+ start := 2
+ ] ifFalse:[
+ start := 1
+ ].
+ withCr ifTrue:[
+ end := nLines
+ ] ifFalse:[
+ end := nLines - 1
+ ].
+ (start < nLines) ifTrue:[
+ (end >= start) ifTrue:[
+ wasOn := self hideCursor.
+ self insertLines:lines from:start to:end before:cursorLine.
+ cursorLine := cursorLine + (end - start + 1).
+ cursorVisibleLine := self absoluteLineToVisibleLine:cursorLine.
+ wasOn ifTrue:[self showCursor].
+ ]
+ ].
+ withCr ifFalse:[
+ "last line without cr"
+ self insertStringAtCursor:(lines at:nLines)
+ ]
+ ]
]
- "Created: 18.5.1996 / 15:32:06 / cg"
+ "Created: / 18.5.1996 / 15:32:06 / cg"
+ "Modified: / 12.6.1998 / 21:51:16 / cg"
!
insertLines:lines withCr:withCr
@@ -2031,15 +2039,45 @@
replaceStringAtCursor:aString
"replace multiple characters at cursor-position - advance cursor"
- |wasOn|
+ |wasOn i1 i2|
wasOn := self hideCursor.
- self replaceString:aString atLine:cursorLine col:cursorCol.
- self cursorCol:(cursorCol + aString size).
+ (aString includes:Character tab) ifTrue:[
+ "/ need special care for TAB (to move cursor correctly)
+ i1 := 1.
+ [i1 ~~ 0] whileTrue:[
+ i2 := aString indexOf:Character tab startingAt:i1.
+ i2 ~~ 0 ifTrue:[
+ self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol.
+ self cursorCol:(cursorCol + (i2 - i1)).
+ self replaceTABAtCursor.
+ i2 := i2 + 1.
+ ] ifFalse:[
+ self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol.
+ ].
+ i1 := i2.
+ ]
+ ] ifFalse:[
+ self replaceString:aString atLine:cursorLine col:cursorCol.
+ self cursorCol:(cursorCol + aString size).
+ ].
self makeCursorVisibleAndShowCursor:wasOn.
"Created: / 9.6.1998 / 20:33:20 / cg"
- "Modified: / 11.6.1998 / 10:38:19 / cg"
+ "Modified: / 12.6.1998 / 21:58:25 / cg"
+!
+
+replaceTABAtCursor
+ "replace a single character at cursor-position by a TAB character"
+
+ |wasOn nextTab|
+
+ wasOn := self hideCursor.
+ nextTab := self nextTabAfter:cursorCol.
+ self replaceStringAtCursor:(String new:(nextTab - cursorCol)).
+ self makeCursorVisibleAndShowCursor:wasOn.
+
+ "Created: / 12.6.1998 / 21:53:23 / cg"
! !
!EditTextView methodsFor:'editing - basic'!
@@ -4290,5 +4328,5 @@
!EditTextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.165 1998-06-11 08:43:14 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.166 1998-06-12 20:02:44 cg Exp $'
! !