--- a/EditTextView.st Fri Feb 25 12:58:08 2005 +0100
+++ b/EditTextView.st Fri Feb 25 12:58:25 2005 +0100
@@ -66,6 +66,13 @@
privateIn:EditTextView
!
+EditTextView::EditAction subclass:#ReplaceLine
+ instanceVariableNames:'line text'
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:EditTextView
+!
+
!EditTextView class methodsFor:'documentation'!
copyright
@@ -3490,6 +3497,17 @@
self addUndo:(ReplaceCharacter line:lineNr col:colNr character:originalChar info:'replace').
!
+replaceLine:lineNr with:newText
+ "replace a line at lineNr"
+
+ |originalLine|
+
+ originalLine := self listAt:lineNr.
+ self list at:lineNr put:newText.
+ self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace').
+ self invalidateLine:lineNr.
+!
+
replaceString:aString atLine:lineNr col:colNr
"replace multiple characters starting at lineNr/colNr.
This is not prepared to encounter special chars (except TAB)
@@ -3548,6 +3566,16 @@
self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split').
!
+withoutRedrawAt:lineNr put:aString
+ "replace a line at lineNr"
+
+ |originalLine|
+
+ originalLine := self listAt:lineNr.
+ self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace').
+ super withoutRedrawAt:lineNr put:aString.
+!
+
withoutRedrawInsertLine:aString before:lineNr
"insert the argument, aString before line lineNr; the string
becomes line lineNr; everything else is moved down; the view
@@ -3788,7 +3816,10 @@
cmdMacro := UserPreferences current functionKeySequences at:key ifAbsent:nil.
cmdMacro notNil ifTrue:[
- self executeKeyboardMacro:cmdMacro.
+ self
+ undoableDo:
+ [ self executeKeyboardMacro:cmdMacro ]
+ info: key.
^ self
].
@@ -4268,7 +4299,11 @@
end := end - 1
].
self unselect.
- self indentFromLine:start toLine:end
+ self
+ undoableDo:[
+ self indentFromLine:start toLine:end
+ ]
+ info:'indent'
!
indentFromLine:start toLine:end
@@ -4939,74 +4974,76 @@
self checkModificationsAllowed ifFalse:[^ self].
- selected := self selection.
- selected isNil ifTrue:[
- ^ self paste:someText
- ].
-
- self deleteSelection.
-
- "take care, if we replace a selection without space by a word selected
- with one - in this case we usually do not want the space.
- But, if we replace a word-selected selection by something without a
- space, we DO want the space added."
-
- selected size == 1 ifTrue:[
- selectedString := selected at:1.
- ].
-
- someText size == 1 ifTrue:[
- |cutOffSpace addSpace replacement replacementString|
-
- cutOffSpace := false.
- addSpace := false.
- replacement := someText copyFrom:1.
-
- selectedString notNil ifTrue:[
- ((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[
- "selection has no space"
-
- ((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[
- cutOffSpace := true
- ]
- ] ifTrue:[
- addSpace := true
- ]
+ self undoableDo:[
+ selected := self selection.
+ selected isNil ifTrue:[
+ ^ self paste:someText
+ ].
+
+ self deleteSelection.
+
+ "take care, if we replace a selection without space by a word selected
+ with one - in this case we usually do not want the space.
+ But, if we replace a word-selected selection by something without a
+ space, we DO want the space added."
+
+ selected size == 1 ifTrue:[
+ selectedString := selected at:1.
].
- replacementString := replacement at:1.
- cutOffSpace ifTrue:[
- (replacementString startsWith:' ') ifTrue:[
- replacementString := replacementString withoutSpaces
- ].
- ] ifFalse:[
- selectStyle == #wordLeft ifTrue:[
- "want a space at left"
- (replacementString startsWith:' ') ifFalse:[
- replacementString := replacementString withoutSpaces.
- replacementString := ' ' , replacementString
+
+ someText size == 1 ifTrue:[
+ |cutOffSpace addSpace replacement replacementString|
+
+ cutOffSpace := false.
+ addSpace := false.
+ replacement := someText copyFrom:1.
+
+ selectedString notNil ifTrue:[
+ ((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[
+ "selection has no space"
+
+ ((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[
+ cutOffSpace := true
+ ]
+ ] ifTrue:[
+ addSpace := true
]
].
- selectStyle == #wordRight ifTrue:[
- "want a space at right"
-
- (replacementString endsWith:' ') ifFalse:[
- replacementString := replacementString withoutSpaces.
- replacementString := replacementString , ' '
- ]
+ replacementString := replacement at:1.
+ cutOffSpace ifTrue:[
+ (replacementString startsWith:' ') ifTrue:[
+ replacementString := replacementString withoutSpaces
+ ].
+ ] ifFalse:[
+ selectStyle == #wordLeft ifTrue:[
+ "want a space at left"
+ (replacementString startsWith:' ') ifFalse:[
+ replacementString := replacementString withoutSpaces.
+ replacementString := ' ' , replacementString
+ ]
+ ].
+ selectStyle == #wordRight ifTrue:[
+ "want a space at right"
+
+ (replacementString endsWith:' ') ifFalse:[
+ replacementString := replacementString withoutSpaces.
+ replacementString := replacementString , ' '
+ ]
+ ].
].
+ replacement at:1 put: replacementString.
+ self paste:replacement.
+ ] ifFalse:[
+ self paste:someText
].
- replacement at:1 put: replacementString.
- self paste:replacement.
- ] ifFalse:[
- self paste:someText
- ].
- lastString := selectedString.
- lastReplacement := someText.
-
- selStartLine := selectionStartLine.
- selStartCol := self selectionStartCol.
- selEndLine := selectionEndLine.
- selEndCol := self selectionEndCol.
+ lastString := selectedString.
+ lastReplacement := someText.
+
+ selStartLine := selectionStartLine.
+ selStartCol := self selectionStartCol.
+ selEndLine := selectionEndLine.
+ selEndCol := self selectionEndCol.
+ ]
"Modified: / 14.2.1996 / 10:37:02 / stefan"
"Modified: / 5.4.1998 / 16:55:28 / cg"
@@ -5828,6 +5865,14 @@
] ifFalse:[
undoSupport undoableDo:aBlock.
].
+!
+
+undoableDo:aBlock info:aString
+ self checkModificationsAllowed not ifTrue:[
+ aBlock value.
+ ] ifFalse:[
+ undoSupport undoableDo:aBlock info:aString.
+ ].
! !
!EditTextView::EditAction class methodsFor:'instance creation'!
@@ -5854,6 +5899,10 @@
line:arg1 col:arg2 string:arg3 info:info
^ (self new line:arg1 col:arg2 string:arg3) info:info
+!
+
+line:arg1 string:arg3 info:info
+ ^ (self new line:arg1 string:arg3) info:info
! !
!EditTextView::EditAction methodsFor:'accessing'!
@@ -5950,8 +5999,6 @@
!EditTextView::ReplaceCharacter methodsFor:'accessing'!
line:lineArg col:colArg character:characterArg
- "set instance variables (automatically generated)"
-
line := lineArg.
col := colArg.
character := characterArg.
@@ -5967,8 +6014,22 @@
editor cursorLine:line col:col.
! !
+!EditTextView::ReplaceLine methodsFor:'accessing'!
+
+line:lineArg string:stringArg
+ line := lineArg.
+ text := stringArg.
+! !
+
+!EditTextView::ReplaceLine methodsFor:'execution'!
+
+executeIn:editor
+ editor list at:line put:text.
+ editor invalidateLine:line
+! !
+
!EditTextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.367 2005-02-25 10:56:35 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.368 2005-02-25 11:58:25 cg Exp $'
! !