--- a/EditTextView.st Sun May 01 06:37:41 2016 +0200
+++ b/EditTextView.st Mon May 02 06:46:50 2016 +0200
@@ -138,6 +138,14 @@
privateIn:EditTextView
!
+EditTextView::EditAction subclass:#RestoreSelectionAndCursor
+ instanceVariableNames:'cursorLine cursorCol selectionStartLine selectionStartCol
+ selectionEndLine selectionEndCol'
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:EditTextView
+!
+
!EditTextView class methodsFor:'documentation'!
copyright
@@ -5685,19 +5693,23 @@
wasOn := cursorShown.
- NoModificationError handle:[:ex |
- self flashReadOnly.
- (cursorShown not and:[wasOn]) ifTrue:[
- self makeCursorVisibleAndShowCursor:wasOn.
- ].
- ] do:[
- self undoableDo:[
- self doKeyPress:key x:x y:y
- ].
- ].
+ NoModificationError
+ handle:[:ex |
+ self flashReadOnly.
+ (cursorShown not and:[wasOn]) ifTrue:[
+ self makeCursorVisibleAndShowCursor:wasOn.
+ ].
+ ]
+ do:[
+ self undoableDo:[
+ self doKeyPress:key x:x y:y
+ ].
+ ].
+
self repairDamage
"Modified: / 18-04-2011 / 21:35:27 / cg"
+ "Modified (format): / 30-04-2016 / 20:45:52 / cg"
!
mapped
@@ -6258,6 +6270,18 @@
and:t2 label:'Clipboard'
!
+copySelection
+ "copy contents into smalltalk copybuffer.
+ Redefined to move the (currently hidden cursor) to the selection's end"
+
+ self hasSelection ifTrue:[
+ self setCursorLine:selectionEndLine col:selectionEndCol+1
+ ].
+ super copySelection.
+
+ "Created: / 30-04-2016 / 21:07:10 / cg"
+!
+
cut
"cut selection into copybuffer"
@@ -8510,14 +8534,32 @@
!
undoableDo:aBlock info:aString
+ |selectionRestore|
+
self checkModificationsAllowed ifFalse:[
"/ will trigger an error-dialog there (no need for undo-carekeeping)
aBlock value.
] ifTrue:[
- undoSupport undoableDo:aBlock info:aString.
- ].
-
- "Modified: / 28-07-2007 / 13:21:00 / cg"
+ undoSupport isInTransaction ifFalse:[
+ selectionRestore := RestoreSelectionAndCursor new
+ cursorLine:cursorLine cursorCol:cursorCol
+ selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol
+ selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol
+ info:nil.
+ ].
+ undoSupport
+ undoableDo:[
+ aBlock value.
+ selectionRestore notNil ifTrue:[
+ undoSupport transactionNotEmpty ifTrue:[
+ undoSupport addUndoFirst:selectionRestore
+ ].
+ ].
+ ]
+ info:aString.
+ ].
+
+ "Modified: / 30-04-2016 / 21:08:30 / cg"
! !
!EditTextView::EditAction class methodsFor:'instance creation'!
@@ -9073,6 +9115,47 @@
"Modified: / 09-10-2006 / 10:39:16 / cg"
! !
+!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'!
+
+cursorLine:cursorLineArg cursorCol:cursorColArg selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg
+ cursorLine := cursorLineArg.
+ cursorCol := cursorColArg.
+ selectionStartLine := selectionStartLineArg.
+ selectionStartCol := selectionStartColArg.
+ selectionEndLine := selectionEndLineArg.
+ selectionEndCol := selectionEndColArg.
+!
+
+cursorLine:cursorLineArg cursorCol:cursorColArg
+ selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg
+ selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg
+ info:info
+
+ cursorLine := cursorLineArg.
+ cursorCol := cursorColArg.
+ selectionStartLine := selectionStartLineArg.
+ selectionStartCol := selectionStartColArg.
+ selectionEndLine := selectionEndLineArg.
+ selectionEndCol := selectionEndColArg.
+ userFriendlyInfo := info.
+
+ "Created: / 30-04-2016 / 20:21:18 / cg"
+! !
+
+!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'!
+
+executeIn:editor
+ (selectionStartLine notNil and:[selectionEndLine notNil
+ and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[
+ editor setCursorLine:cursorLine col:cursorCol.
+ editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol
+ ] ifFalse:[
+ editor cursorLine:cursorLine col:cursorCol.
+ ].
+
+ "Created: / 30-04-2016 / 20:14:55 / cg"
+! !
+
!EditTextView class methodsFor:'documentation'!
version