--- a/EditTextView.st Thu Mar 09 11:01:37 2017 +0100
+++ b/EditTextView.st Tue Mar 14 20:29:07 2017 +0100
@@ -6706,6 +6706,8 @@
('AutoIndent \c' autoIndent: ToggleAutoIndent )
('InsertMode \c' insertMode: ToggleInsertMode )
('-' )
+ ('Copy Box' copySelectionBox CopyBox )
+ ('Paste Box' pasteOrReplaceBox PasteBox )
('Paste Previous...' pasteOrReplaceFromHistory PasteFromHistory )
('Join Lines' joinLines Join )
('Wrap Lines...' wrapLines Wrap )
@@ -6816,14 +6818,22 @@
('Undo' undo Undo )
('Again' again Again )
('-' )
- ('Cut' cut Cut )
+ ('Cut' cut Cut )).
+ self sensor metaDown ifTrue:[
+ mainItems := mainItems , #(
+ ('Copy Box' copySelectionBox CopyBox )
+ ('Paste Box' pasteOrReplaceBox PasteBox ))
+ ] ifFalse:[
+ mainItems := mainItems , #(
('Copy' copySelection Copy )
- ('Paste' pasteOrReplace Paste )
+ ('Paste' pasteOrReplace Paste ))
+ ].
+ mainItems := mainItems , #(
('-' )
('Accept' accept Accept )
('=' )
- ('More' others Ctrl )
- ).
+ ('More' others Ctrl )).
+
main := PopUpMenu itemList:mainItems resources:resources.
main subMenuAt:#others put:sub.
@@ -6854,7 +6864,7 @@
self isReadOnly ifTrue:[
m disableAll:#(accept undo again multipleAgain redo
- paste pasteOrReplace pasteOrReplaceFromHistory
+ paste pasteOrReplace pasteOrReplaceBox pasteOrReplaceFromHistory
cut indent autoIndent: insertMode:
insertFile insertFileAsStringLiteral insertURL
babelFishTranslate googleSpellingSuggestion sort
@@ -6864,6 +6874,7 @@
].
self hasSelectionForCopy ifFalse:[
m disable:#copySelection.
+ m disable:#copySelectionBox.
].
self hasSelection ifFalse:[
m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt
@@ -6902,7 +6913,7 @@
].
^ m.
- "Modified: / 01-03-2012 / 19:56:58 / cg"
+ "Modified: / 14-03-2017 / 16:30:44 / cg"
!
getTextSelectionFromHistory
@@ -7308,6 +7319,67 @@
info:'Paste as String Literal'
!
+pasteBox
+ "paste the copybuffer as a box;
+ if there is a selection, unselect first.
+ Then paste at cursor position."
+
+ self checkModificationsAllowed ifTrue:[
+ self withSelfAndTextForPasteDo:[:me :text |
+ me unselect.
+ me undoablePasteBox:text
+ ]
+ ]
+
+ "Created: / 14-03-2017 / 16:34:16 / cg"
+!
+
+pasteBox:someText
+ "paste someText at cursor"
+
+ self pasteBox:someText withCR:false
+
+ "Created: / 14-03-2017 / 16:35:08 / cg"
+!
+
+pasteBox:someText withCR:withCR
+ "paste someText at cursor"
+
+ |lines nLines startLine startCol l1 l2 c1 c2|
+
+ self checkModificationsAllowed ifFalse:[^ self].
+
+ lines := someText asStringCollection.
+
+ (nLines := lines size) == 0 ifTrue:[^ self].
+ (nLines == 1 and:[(lines at:1) size == 0]) ifTrue:[^ self].
+
+ typeOfSelection := #paste.
+
+ startLine := l1 := cursorLine.
+ startCol := c1 := cursorCol.
+
+ "do not autoindent here.
+ It does make things very ugly, in the inspector
+ (try inspecting a multiline string)..."
+ self withAutoIndent:false do:[
+ "do not expand tabs into spaces here -
+ they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
+ Some Subviews want to paste with unexpanded tabs!!"
+
+ lines do:[:eachLine |
+ self insertString:eachLine atLine:l1 col:startCol.
+ l1 := l1 + 1.
+ ].
+ ].
+ l2 := cursorLine.
+ c2 := (cursorCol - 1).
+ self selectFromLine:l1 col:c1 toLine:l2 col:c2.
+ typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine:
+
+ "Created: / 14-03-2017 / 16:39:11 / cg"
+!
+
pasteOrReplace
"paste the copybuffer; if there is a selection, replace it.
otherwise paste at cursor position.
@@ -7336,6 +7408,16 @@
"Modified: / 30.1.2000 / 02:33:00 / cg"
!
+pasteOrReplaceBox
+ "paste the copybuffer as a box;
+ if there is a selection, unselect first.
+ Then paste at cursor position."
+
+ self pasteBox
+
+ "Created: / 14-03-2017 / 16:40:08 / cg"
+!
+
pasteOrReplaceByKeyPress
"paste a previous item from the copybuffer history.
(i.e. repaste some previously deleted or copied text)"
@@ -7754,6 +7836,22 @@
"Created: / 28-07-2007 / 13:25:30 / cg"
!
+undoablePasteBox:someText
+ self undoablePasteBox:someText info:nil.
+
+ "Created: / 14-03-2017 / 16:34:31 / cg"
+!
+
+undoablePasteBox:someText info:infoOrNil
+ self
+ undoableDo:[
+ self pasteBox:someText.
+ ]
+ info:infoOrNil
+
+ "Created: / 14-03-2017 / 16:34:55 / cg"
+!
+
undoablePasteOrReplace:someText info:infoOrNil
self
undoableDo:[