'From etoys4.0 of 9 October 2008 [latest update: #2322] on 29 September 2009 at 2:12:39 pm'! "Change Set: pasteFix-bf Date: 29 September 2009 Author: Bert Freudenberg Move ExtendedClipboard text handling to Clipboard class, to retain text formatting when copied from Etoys."! !Clipboard methodsFor: 'accessing' stamp: 'bf 9/29/2009 14:06'! clipboardText "Return the text currently in the clipboard. If the system clipboard is empty, or if it differs from the Smalltalk clipboard text, use the Smalltalk clipboard. This is done since (a) the Mac clipboard gives up on very large chunks of text and (b) since not all platforms support the notion of a clipboard." | text string decodedString ind | text := ExtendedClipboardInterface current readTextClipboardData. text isEmptyOrNil ifFalse: [ ^text asString = contents asString ifTrue: [contents] ifFalse: [text]]. string := self primitiveClipboardText. (string size > 0 and: [(ind := string indexOf: (Character value: 0)) > 0]) ifTrue: [ string := string copyFrom: 1 to: ind - 1]. (string isEmpty or: [string = contents asString]) ifTrue: [^ contents]. decodedString := self interpreter fromSystemClipboard: string. ^ decodedString = contents asString ifTrue: [contents] ifFalse: [decodedString asText]. ! ! !HandMorph methodsFor: 'paste buffer' stamp: 'bf 9/29/2009 13:55'! pasteMorph "The user requested 'paste'; depending on the type of data on the clipboard, launch an appropropriate morph that embodies the clipboard content, and open it on the screen." | aPastee form text | aPastee := nil. form := ExtendedClipboardInterface current readFormClipboardData. form ifNotNil: [aPastee := SketchMorph withForm: form]. aPastee ifNil: [text := Clipboard clipboardText. text isEmpty ifFalse: [aPastee := TextMorph nonwrappingPrototype. aPastee contents: text. text embeddedMorphs ifNotNilDo: [:morphs | morphs do: [:m | m forkDownloadWhenFinished: [aPastee composeToBounds]]. aPastee composeToBounds]. aPastee width > ActiveWorld width ifTrue: [aPastee wrapFlag: true. aPastee width: ((2 * ActiveWorld width) // 3). aPastee refreshParagraph]]]. aPastee ifNil: [aPastee := self objectToPaste]. aPastee ifNil: [^ self]. self attachMorph: aPastee. aPastee align: aPastee center with: self position. aPastee player ifNotNil: [aPastee player startRunning]! ! !ParagraphEditor methodsFor: 'menu messages' stamp: 'bf 9/29/2009 13:55'! clipboardText ^ Clipboard clipboardText! !