--- 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
--- a/ListView.st Sun May 01 06:37:41 2016 +0200
+++ b/ListView.st Mon May 02 06:46:50 2016 +0200
@@ -3394,19 +3394,26 @@
1 to:(lineNr - 1) do:[:lnr |
lineString := self at:lnr.
lineString notNil ifTrue:[
- charPos := charPos + (lineString string "withoutTrailingSeparators") size
+ charPos := charPos + (lineString string) size
].
charPos := charPos + lineEndCharSize "the return-character"
].
- "/ if beyond end of line, be careful to not advance into next line.
+ "/ NEW: expand that line, so that characterAtCharacterPosition returns the correct character
+"/ wrong: will modify!!
+"/ (lineString := self at:lineNr) size < colArg ifTrue:[
+"/ "/ expand this line
+"/ self at:lineNr put:((lineString ? ''),(String new:colArg-lineString size)).
+"/ ].
+
+ "/ OLD: if beyond end of line, be careful to not advance into next line.
"/ otherwise, syntaxHighlighter (and others) walk into trouble,
"/ if clicked on a space beyond a line's end.
col := colArg min:((self at:lineNr) size + 1).
^ charPos + col - 1
"Modified: / 04-07-2006 / 19:14:25 / fm"
- "Modified: / 21-08-2011 / 11:03:19 / cg"
+ "Modified: / 01-05-2016 / 15:48:24 / cg"
!
colOfCharacterPosition:charPos
--- a/Workspace.st Sun May 01 06:37:41 2016 +0200
+++ b/Workspace.st Mon May 02 06:46:50 2016 +0200
@@ -188,8 +188,8 @@
'ien' 'isEmptyOrNil '
'nen' 'notEmptyOrNil '
- '[it' '[] ifTrue:[!!'
- '[if' '[] ifFalse:[!!'
+ '[it' '[nil] ifTrue:[!!'
+ '[if' '[nil] ifFalse:[!!'
'it' 'ifTrue:[!!'
'if' 'ifFalse:[!!'
'itf' 'ifTrue:[!!] ifFalse:[].'
@@ -318,7 +318,7 @@
at:abbrev put:text "/ ifPresent:[ self error:'duplicate abbreviation key' ]
].
- "Modified: / 30-04-2016 / 19:40:42 / cg"
+ "Modified: / 30-04-2016 / 19:43:35 / cg"
!
updateStyleCache