'From Cuis 2.6 of 10 August 2010 [latest update: #540] on 11 August 2010 at 1:50:48 pm'!

!Clipboard methodsFor: 'accessing' stamp: 'jmv 8/11/2010 13:49'!
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.
	Note:
		Smalltalk clipboard can hold a String or a Text.
		OS clipboard currently supports ony a String"

	| latin1Format |
	"Windows uses UTF-8 for clipboard. Other platforms use MacRoman"
	latin1Format _ Smalltalk platformName = 'Win32'
		ifTrue: [ self primitiveClipboardText utf8ToLatin1 ]
		ifFalse: [ self primitiveClipboardText macRomanToLatin1 ].
	^(latin1Format isEmpty or: [latin1Format = contents asString])
		ifTrue: [ contents ]
		ifFalse: [ latin1Format ]! !

!Clipboard methodsFor: 'accessing' stamp: 'jmv 8/11/2010 13:47'!
clipboardText: textOrString
	"Set text currently on the clipboard.  Also export to OS"
	| primitiveFormat |
	contents _ textOrString.
	self noteRecentClipping: textOrString.
	"Windows uses UTF-8 for clipboard. Other platforms use MacRoman"
	primitiveFormat _ Smalltalk platformName = 'Win32'
		ifTrue: [ textOrString asString latin1ToUtf8 ]
		ifFalse: [ textOrString asString latin1ToMacRoman ].
	self primitiveClipboardText: primitiveFormat! !

