--- a/EditTextView.st Tue May 14 12:31:57 1996 +0200
+++ b/EditTextView.st Tue May 14 13:57:42 1996 +0200
@@ -1409,6 +1409,14 @@
self makeCursorVisibleAndShowCursor:wasOn.
!
+insertLine:aString before:lineNr
+ "insert the line aString before line lineNr"
+
+ ^ self insertLines:(Array with:aString) from:1 to:1 before:lineNr.
+
+ "Modified: 14.5.1996 / 13:42:54 / cg"
+!
+
insertLines:aStringCollection before:lineNr
"insert a bunch before line lineNr"
@@ -1417,6 +1425,50 @@
"Modified: 6.9.1995 / 20:51:03 / claus"
!
+insertLines:lines withCr:withCr
+ "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)
+ ]
+ ]
+ ]
+!
+
insertSelectedStringAtCursor:aString
"insert the argument, aString at cursor position and select it"
@@ -1651,7 +1703,7 @@
!EditTextView methodsFor:'editing - basic'!
deleteCharAtLine:lineNr col:colNr
- "delete single character at colNr in line lineNr"
+ "delete a single character at colNr in line lineNr"
|line lineSize newLine drawCharacterOnly wasLargest|
@@ -1692,7 +1744,7 @@
self redrawLine:lineNr from:colNr
]
- "Modified: 12.5.1996 / 16:33:04 / cg"
+ "Modified: 14.5.1996 / 13:50:37 / cg"
!
deleteCharsAtLine:lineNr fromCol:colNr
@@ -1705,14 +1757,19 @@
line := self listAt:lineNr.
line isNil ifTrue: [^self].
(colNr > line size) ifTrue: [^ self].
+
newLine := line copyTo:(colNr - 1).
newLine isBlank ifTrue:[
- newLine := nil
+ newLine := nil
].
list at:lineNr put:newLine.
widthOfWidestLine := nil. "/ i.e. unknown
self textChanged.
- self redrawLine:lineNr
+
+ self redrawLine:lineNr from:colNr.
+"/ self redrawLine:lineNr
+
+ "Modified: 14.5.1996 / 13:52:19 / cg"
!
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
@@ -1730,27 +1787,32 @@
(endCol < startCol) ifTrue:[^ self].
(startCol == endCol) ifTrue:[
- self deleteCharAtLine:lineNr col:startCol.
- ^ self
+ self deleteCharAtLine:lineNr col:startCol.
+ ^ self
].
(endCol >= lineSize) ifTrue:[
- self deleteCharsAtLine:lineNr fromCol:startCol.
- ^ self
+ self deleteCharsAtLine:lineNr fromCol:startCol.
+ ^ self
].
(startCol <= 1) ifTrue:[
- self deleteCharsAtLine:lineNr toCol:endCol.
- ^ self
+ self deleteCharsAtLine:lineNr toCol:endCol.
+ ^ self
].
+
newLine := (line copyTo:(startCol - 1))
- , (line copyFrom:(endCol + 1) to:lineSize).
+ , (line copyFrom:(endCol + 1) to:lineSize).
newLine isBlank ifTrue:[
- newLine := nil
+ newLine := nil
].
list at:lineNr put:newLine.
widthOfWidestLine := nil. "/ i.e. unknown
self textChanged.
- self redrawLine:lineNr
+
+ self redrawLine:lineNr from:startCol.
+"/ self redrawLine:lineNr
+
+ "Modified: 14.5.1996 / 13:53:53 / cg"
!
deleteCharsAtLine:lineNr toCol:colNr
@@ -1784,36 +1846,37 @@
|line lineSize|
self checkModificationsAllowed ifFalse:[ ^ self].
-
list isNil ifTrue:[^ self].
(startLine == endLine) ifTrue:[
- "delete chars within a line"
+ "/ delete chars within a line
self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol.
^ self
].
((startCol == 1) and:[endCol == 0]) ifTrue:[
- "delete full lines only"
+ "/ delete full lines only
endLine > startLine ifTrue:[
self deleteFromLine:startLine toLine:(endLine - 1)
].
^ self
].
- "delete right rest of 1st line"
+ "/ delete right rest of 1st line
self deleteCharsAtLine:startLine fromCol:startCol.
- "delete the inner lines ..."
+ "/ delete the inner lines ...
endLine > (startLine + 1) ifTrue:[
self deleteFromLine:(startLine + 1) toLine:(endLine - 1)
].
(endCol ~~ 0) ifTrue:[
- "delete the left rest of the last line"
+ "/ delete the left rest of the last line
+
self deleteCharsAtLine:(startLine + 1) toCol:endCol.
- "must add blanks, if startCal lies behond end of startLine"
+ "/ must add blanks, if startCol lies behond end of startLine
+
line := list at:startLine.
lineSize := line size.
(startCol > lineSize) ifTrue:[
@@ -1828,10 +1891,10 @@
]
].
- "merge the left rest of 1st line with right rest of last line into one"
+ "/ merge the left rest of 1st line with right rest of last line into one
self mergeLine:startLine
- "Modified: 23.2.1996 / 19:08:21 / cg"
+ "Modified: 14.5.1996 / 13:55:07 / cg"
!
deleteFromLine:startLineNr toLine:endLineNr
@@ -1960,42 +2023,6 @@
"Modified: 23.2.1996 / 19:09:36 / cg"
!
-insertLine:aString before:lineNr
- "insert the line aString before line lineNr"
-
- |wasOn visLine w
- dstY "{ Class: SmallInteger }" |
-
- wasOn := self hideCursor.
-
- visLine := self listLineToVisibleLine:lineNr.
- (shown not or:[visLine isNil]) ifTrue:[
- self withoutRedrawInsertLine:aString before:lineNr.
- ] ifFalse:[
- w := self widthForScrollBetween:lineNr
- and:(firstLineShown + nLinesShown).
- dstY := topMargin + ((visLine ) * fontHeight).
- "/
- "/ scroll ...
- "/
- self catchExpose.
- self withoutRedrawInsertLine:aString before:lineNr.
- self copyFrom:self x:textStartLeft y:(dstY - fontHeight)
- toX:textStartLeft y:dstY
- width:w
- height:((nLinesShown - visLine "- 1") * fontHeight).
- self redrawVisibleLine:visLine.
- self waitForExpose.
- ].
- widthOfWidestLine notNil ifTrue:[
- widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:aString).
- ].
- self textChanged.
- wasOn ifTrue:[self showCursor].
-
- "Modified: 12.5.1996 / 15:41:24 / cg"
-!
-
insertLines:someText from:start to:end before:lineNr
"insert a bunch of lines before line lineNr"
@@ -2053,50 +2080,6 @@
"Modified: 12.5.1996 / 15:41:36 / cg"
!
-insertLines:lines withCr:withCr
- "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)
- ]
- ]
- ]
-!
-
mergeLine:lineNr
"merge line lineNr with line lineNr+1"
@@ -3311,9 +3294,11 @@
contentsChanged, which is triggered when the size has changed, and
is used to notify scrollers, other views etc.)"
- super contentsChanged.
+ self contentsChanged.
modifiedChannel value:true.
contentsWasSaved := false
+
+ "Modified: 14.5.1996 / 13:45:42 / cg"
! !
!EditTextView methodsFor:'queries'!
@@ -3776,5 +3761,5 @@
!EditTextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.71 1996-05-12 15:18:12 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.72 1996-05-14 11:57:42 cg Exp $'
! !