[prev in list] [next in list] [prev in thread] [next in thread]
List: squeak-dev
Subject: [squeak-dev] The Trunk: System-mt.1405.mcz
From: commits () source ! squeak ! org
Date: 2023-03-29 11:56:32
Message-ID: 20230329115638.512CA14D50A () mail ! squeak ! org
[Download RAW message or body]
Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1405.mcz
==================== Summary ====================
Name: System-mt.1405
Author: mt
Time: 29 March 2023, 1:56:30.174927 pm
UUID: 0ff6d772-c400-ec4b-98db-219158b3a7dd
Ancestors: System-mt.1404
Try to use the extended clipboard for both set/get contents. Gracefully fallback to \
the old primitive. Retain in-image buffer (and text attributes) when string contents \
are unchanged.
Note that there is no #getClipboardData: but only #readClipboardData:.
=============== Diff against System-mt.1404 ===============
Item was changed:
----- Method: Clipboard>>clipboardText (in category 'accessing') -----
clipboardText
+ "Answer the text currently in the (system) clipboard. To preserve image-specifc \
formatting, simply answer the text from an in-image buffer UNLESS that buffer differs \
from what is in the system clipboard. Also use that buffer if the sytem clipboard got \
cleared by some other application."
- "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."
+ | systemContents needsDecoding stringOrText |
+ needsDecoding := false.
+ systemContents := ExtendedClipboardInterface current readTextClipboardData
+ ifNil: [needsDecoding := true.
+ self primitiveClipboardText "old primitive"].
+ stringOrText := systemContents withSqueakLineEndings.
+ (stringOrText isEmpty or: [stringOrText asString = contents asString])
- | string decodedString |
- string := self primitiveClipboardText withSqueakLineEndings.
- (string isEmpty
- or: [string = contents asString])
ifTrue: [^ contents].
+ ^ needsDecoding
+ ifFalse: [stringOrText asText]
+ ifTrue: [ | decodedString | "from old primitive"
+ decodedString := self interpreter fromSystemClipboard: stringOrText asString.
+ decodedString = contents asString
+ ifTrue: [contents]
+ ifFalse: [decodedString asText]].!
- decodedString := self interpreter fromSystemClipboard: string.
- ^ decodedString = contents asString
- ifTrue: [contents]
- ifFalse: [decodedString asText].
- !
Item was changed:
----- Method: Clipboard>>clipboardText: (in category 'accessing') -----
clipboardText: text
+
+ self clipboardText: text notifyWith: nil!
- (ExtendedClipboardInterface current clipboardText: text) ifFalse:
- [self clipboardText: text notifyWith: nil]!
Item was changed:
----- Method: Clipboard>>clipboardText:notifyWith: (in category 'accessing') -----
+ clipboardText: stringOrText notifyWith: anObject
+ "Set the contents of the (system) clipboard. anObject can be used as a marker for \
the source of the clipboard change, the default value is nil. Try to use the extended \
interface so that, e.g., rich text can be encoded and transported to other \
applications."
- clipboardText: text notifyWith: anObject
- "Set the contents of the clipboard to text. anObject can be used as a marker for \
the source of the clipboard change, the default value is nil."
+ | newContents |
+ newContents := stringOrText asText.
+ self noteRecentClipping: newContents.
+ contents := newContents. "Preserve in-image attributes. See #clipboardText."
+
+ (ExtendedClipboardInterface current clipboardText: newContents)
+ ifFalse: [ | string |
+ "Extended interface failed. Use old primitive and plain text with \
system-specific encoding." + string := newContents asString.
+ string := self interpreter toSystemClipboard: string.
+ self primitiveClipboardText: string].
+
+ self triggerEvent: #contentChanged withArguments: { newContents. anObject }.!
- | string |
- string := text asString.
- self noteRecentClipping: text asText.
- contents := text asText.
- string := self interpreter toSystemClipboard: string.
- self primitiveClipboardText: string.
- self triggerEvent: #contentChanged withArguments: { text. anObject }!
Item was added:
+ ----- Method: ExtendedClipboardInterface>>clipboardText (in category \
'general-api-read') ----- + clipboardText
+
+ ^ self readTextClipboardData ifNil: ['' asText]!
Item was changed:
----- Method: ExtendedClipboardInterface>>readStringClipboardData (in category \
'general-api-read') ----- readStringClipboardData
+
+ ^ self readWideStringClipboardData
+ ifNil: [self readByteStringClipboardData]!
- ^ self subclassResponsibility!
Item was changed:
----- Method: ExtendedClipboardInterface>>readTextClipboardData (in category \
'general-api-read') ----- readTextClipboardData
+ ^ self readStringClipboardData ifNotNil: [:string | string asText]!
- ^ nil!
Item was changed:
----- Method: ExtendedClipboardWinInterface>>readByteStringClipboardData (in \
category 'general-api-read') ----- readByteStringClipboardData
+ ^ (self hasClipboardData: CF_TEXT)
+ ifTrue: [(self readClipboardData: CF_TEXT) asString]!
- (self hasClipboardData: 1) "CF_TEXT"
- ifFalse: [^ nil].
-
- ^ (self readClipboardData: 1) "CF_TEXT" asString!
Item was changed:
----- Method: ExtendedClipboardWinInterface>>readWideStringClipboardData (in \
category 'general-api-read') ----- readWideStringClipboardData
+ ^ (self hasClipboardData: CF_UNICODETEXT)
+ ifTrue: [((self readClipboardData: CF_UTF8TEXT) changeClassTo: ByteString) \
utf8ToSqueak]!
- (self hasClipboardData: 13) "CF_UNICODETEXT"
- ifFalse: [^ nil].
-
- ^((self getClipboardData: CF_UTF8TEXT) changeClassTo: ByteString) utf8ToSqueak!
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic