Andreas Raab uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-ar.154.mcz ==================== Summary ==================== Name: System-ar.154 Author: ar Time: 13 October 2009, 8:08:56 am UUID: fae6d434-549e-2349-905b-ec333d76f2e4 Ancestors: System-dtl.153 Move class Clipboard from System-Support to ST80. =============== Diff against System-dtl.153 =============== Item was added: + ----- Method: Clipboard class>>clipboardText (in category 'accessing') ----- + clipboardText "Clipboard clipboardText" + ^self default clipboardText.! Item was added: + ----- Method: Clipboard>>primitiveClipboardText: (in category 'primitives') ----- + primitiveClipboardText: aString + "Set the current clipboard text to the given string." + + <primitive: 141> + "don't fail if the primitive is not implemented"! Item was added: + ----- Method: Clipboard>>chooseRecentClipping (in category 'accessing') ----- + chooseRecentClipping "Clipboard chooseRecentClipping" + "Choose by menu from among the recent clippings" + + recent ifNil: [^ nil]. + ^ UIManager default + chooseFrom: (recent collect: [:txt | ((txt asString contractTo: 50) + copyReplaceAll: Character cr asString with: '\') + copyReplaceAll: Character tab asString with: '|']) + values: recent! Item was added: + ----- Method: Clipboard>>primitiveClipboardText (in category 'primitives') ----- + primitiveClipboardText + "Get the current clipboard text. Return the empty string if the primitive fails." + <primitive: 141> + ^ ''! Item was added: + ----- Method: Clipboard>>clipboardText: (in category 'accessing') ----- + clipboardText: text + + | string | + string := text asString. + self noteRecentClipping: text asText. + contents := text asText. + string := self interpreter toSystemClipboard: string. + self primitiveClipboardText: string. + ! Item was added: + ----- Method: Clipboard class>>clearInterpreters (in category 'class initialization') ----- + clearInterpreters + + self allInstances do: [:each | each clearInterpreter]. + ! Item was added: + ----- Method: Clipboard class>>clipboardText: (in category 'accessing') ----- + clipboardText: aText + ^self default clipboardText: aText! Item was added: + Object subclass: #Clipboard + instanceVariableNames: 'contents recent interpreter' + classVariableNames: 'Default' + poolDictionaries: '' + category: 'System-Support'! + + !Clipboard commentStamp: '<historical>' prior: 0! + The Clipboard class implements a basic buffering scheme for text. The currently selected text is also exported to the OS so that text can be copied from and to other applications. Commonly only a single instance is used (the default clipboard) but applications are free to use other than the default clipboard if necessary.! Item was added: + ----- Method: Clipboard class>>default: (in category 'accessing') ----- + default: aClipboard + "So that clients can switch between different default clipboards" + Default := aClipboard.! Item was added: + ----- Method: Clipboard>>setInterpreter (in category 'accessing') ----- + setInterpreter + + interpreter := LanguageEnvironment defaultClipboardInterpreter. + interpreter ifNil: [ + "Should never be reached, but just in case." + interpreter := NoConversionClipboardInterpreter new]. + ! Item was added: + ----- Method: Clipboard class>>default (in category 'accessing') ----- + default + ^Default ifNil:[Default := self new].! Item was added: + ----- Method: Clipboard>>interpreter (in category 'accessing') ----- + interpreter + + interpreter ifNil: [self setInterpreter]. + ^ interpreter. + ! Item was added: + ----- Method: Clipboard>>noteRecentClipping: (in category 'private') ----- + noteRecentClipping: text + "Keep most recent clippings in a queue for pasteRecent (paste... command)" + text isEmpty ifTrue: [^ self]. + text size > 50000 ifTrue: [^ self]. + (recent includes: text) ifTrue: [^ self]. + recent addFirst: text. + [recent size > 5] whileTrue: [recent removeLast]. + ! Item was added: + ----- Method: Clipboard class>>startUp (in category 'class initialization') ----- + startUp + + self clearInterpreters. + ! Item was added: + ----- Method: Clipboard class>>chooseRecentClipping (in category 'accessing') ----- + chooseRecentClipping "Clipboard chooseRecentClipping" + "Choose by menu from among the recent clippings" + ^self default chooseRecentClipping! Item was added: + ----- Method: Clipboard>>initialize (in category 'initialize') ----- + initialize + contents := '' asText. + recent := OrderedCollection new.! Item was added: + ----- Method: Clipboard>>clearInterpreter (in category 'accessing') ----- + clearInterpreter + + interpreter := nil. + ! Item was added: + ----- Method: Clipboard>>clipboardText (in category 'accessing') ----- + 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." + + | string decodedString | + string := self primitiveClipboardText withSqueakLineEndings. + (string isEmpty + or: [string = contents asString]) + ifTrue: [^ contents]. + decodedString := self interpreter fromSystemClipboard: string. + ^ decodedString = contents asString + ifTrue: [contents] + ifFalse: [decodedString asText]. + ! |
Free forum by Nabble | Edit this page |