class: EditTextView
comment/format in: #insertLines:from:to:before:
changed:
#basicWithoutRedrawInsertLine:before:
fixed a bug in:
#insertLines:withCR: (send #<= instead of #<)
--- a/EditTextView.st Mon Jul 08 15:39:42 2013 +0200
+++ b/EditTextView.st Mon Jul 08 15:43:20 2013 +0200
@@ -3047,38 +3047,38 @@
|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.
- self setCursorLine:(cursorLine + (end - start + 1)).
- 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.
+ self setCursorLine:(cursorLine + (end - start + 1)).
+ wasOn ifTrue:[self showCursor].
+ ]
+ ].
+ withCr ifFalse:[
+ "last line without cr"
+ self insertStringAtCursor:(lines at:nLines)
+ ]
+ ]
]
"Created: / 18.5.1996 / 15:32:06 / cg"
@@ -4215,7 +4215,7 @@
].
"
list replaceFrom:(lineNr + 1) to:(list size) with:list startingAt:lineNr.
- list at:lineNr put:(line ifNil:[nil] ifNotNil:[line asSingleByteStringIfPossible]).
+ list at:lineNr put:(line isNil ifTrue:[nil] ifFalse:[line asSingleByteStringIfPossible]).
self contentsChanged
"Modified: / 10.6.1998 / 19:00:56 / cg"
@@ -4343,74 +4343,75 @@
!
insertLines:someText from:start to:end before:lineNr
- "insert a bunch of lines before line lineNr"
+ "insert a bunch of lines before line lineNr.
+ The cursor position is left unchanged."
|text indent visLine w nLines "{ Class: SmallInteger }"
srcY "{ Class: SmallInteger }"
dstY "{ Class: SmallInteger }" |
autoIndent ifTrue:[
- indent := self leftIndentForLine:lineNr.
-
- text := someText collect:[:ln||line|
- ln notNil ifTrue:[
- line := ln withoutLeadingSeparators.
- (line isEmpty or:[indent == 0]) ifFalse:[
- line := (String new:indent), line
- ].
- line
- ] ifFalse:[
- nil
- ]
- ].
+ indent := self leftIndentForLine:lineNr.
+
+ text := someText collect:[:ln||line|
+ ln notNil ifTrue:[
+ line := ln withoutLeadingSeparators.
+ (line isEmpty or:[indent == 0]) ifFalse:[
+ line := (String new:indent), line
+ ].
+ line
+ ] ifFalse:[
+ nil
+ ]
+ ].
] ifFalse:[
- text := someText
+ text := someText
].
visLine := self listLineToVisibleLine:lineNr.
(shown not or:[visLine isNil]) ifTrue:[
- self withoutRedrawInsertLines:text
- from:start to:end
- before:lineNr.
+ self withoutRedrawInsertLines:text
+ from:start to:end
+ before:lineNr.
] ifFalse:[
- nLines := end - start + 1.
- ((visLine + nLines) >= nLinesShown) ifTrue:[
- self withoutRedrawInsertLines:text
- from:start to:end
- before:lineNr.
- self redrawFromVisibleLine:visLine to:nLinesShown
- ] ifFalse:[
- w := self widthForScrollBetween:(lineNr + nLines)
- and:(firstLineShown + nLines + nLinesShown).
- srcY := topMargin + ((visLine - 1) * fontHeight).
- dstY := srcY + (nLines * fontHeight).
-
- "/
- "/ scroll ...
- "/
- "
- stupid: must catchExpose before inserting new
- stuff - since catchExpose may perform redraws
- "
- self catchExpose.
- self withoutRedrawInsertLines:text
- from:start to:end
- before:lineNr.
- self
- copyFrom:self
- x:textStartLeft y:srcY
- toX:textStartLeft y:dstY
- width:w
- height:(height - dstY)
- async:true.
- self redrawFromVisibleLine:visLine to:(visLine + nLines - 1).
- self waitForExpose
- ].
+ nLines := end - start + 1.
+ ((visLine + nLines) >= nLinesShown) ifTrue:[
+ self withoutRedrawInsertLines:text
+ from:start to:end
+ before:lineNr.
+ self redrawFromVisibleLine:visLine to:nLinesShown
+ ] ifFalse:[
+ w := self widthForScrollBetween:(lineNr + nLines)
+ and:(firstLineShown + nLines + nLinesShown).
+ srcY := topMargin + ((visLine - 1) * fontHeight).
+ dstY := srcY + (nLines * fontHeight).
+
+ "/
+ "/ scroll ...
+ "/
+ "
+ stupid: must catchExpose before inserting new
+ stuff - since catchExpose may perform redraws
+ "
+ self catchExpose.
+ self withoutRedrawInsertLines:text
+ from:start to:end
+ before:lineNr.
+ self
+ copyFrom:self
+ x:textStartLeft y:srcY
+ toX:textStartLeft y:dstY
+ width:w
+ height:(height - dstY)
+ async:true.
+ self redrawFromVisibleLine:visLine to:(visLine + nLines - 1).
+ self waitForExpose
+ ].
].
widthOfWidestLine notNil ifTrue:[
- text do:[:line |
- widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
- ]
+ text do:[:line |
+ widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
+ ]
].
self textChanged.
@@ -8194,10 +8195,10 @@
!EditTextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.556 2013-06-27 14:00:30 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.557 2013-07-08 13:43:20 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.556 2013-06-27 14:00:30 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.557 2013-07-08 13:43:20 cg Exp $'
! !