--- a/EditTextView.st Tue Feb 10 18:05:35 2004 +0100
+++ b/EditTextView.st Tue Feb 10 18:06:01 2004 +0100
@@ -4589,36 +4589,38 @@
paste:someText
"paste someText at cursor"
- |s nLines startLine startCol l1 l2 c1 c2|
+ |s nLines startLine startCol l1 l2 c1 c2 codingErrorReported|
self checkModificationsAllowed ifFalse:[^ self].
someText isNil ifTrue:[^ self].
s := someText.
- s isString ifTrue:[
- s encoding ~~ characterEncoding ifTrue:[
- s := CharacterEncoder encode:s as:characterEncoding.
+ codingErrorReported := false.
+ CharacterEncoderError handle:[:ex |
+ codingErrorReported ifFalse:[
+ Dialog warn:('Cannot represent pasted string in this Views encoding (',characterEncoding,').').
+ codingErrorReported := true.
].
-
- s := s asStringCollection.
- (someText endsWith:Character cr) ifTrue:[
- s := s copyWith:nil "/ an empty line at the end
- ]
- ] ifFalse:[
- (s isStringCollection) ifFalse:[
- self warn:'selection (' , s class name , ') is not convertable to Text'.
- ^ self
+ ex proceedWith:($? asciiValue)
+ ] do:[
+ s isString ifTrue:[
+ s encoding ~~ characterEncoding ifTrue:[
+ s := s encodeFrom:(s encoding) into:characterEncoding.
+ ].
+
+ s := s asStringCollection.
+ (someText endsWith:Character cr) ifTrue:[
+ s := s copyWith:nil "/ an empty line at the end
+ ]
+ ] ifFalse:[
+ (s isStringCollection) ifFalse:[
+ self warn:'selection (' , s class name , ') is not convertable to Text'.
+ ^ self
+ ].
+ s := s encodeFrom:(s encoding) into:characterEncoding.
].
- s := s collect:
- [:eachLine |
- (eachLine notNil
- and:[eachLine encoding ~~ characterEncoding]) ifTrue:[
- CharacterEncoder encode:eachLine as:characterEncoding.
- ] ifFalse:[
- eachLine
- ].
- ].
- ].
+ ].
+
(nLines := s size) == 0 ifTrue:[^ self].
(nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self].
@@ -5559,5 +5561,5 @@
!EditTextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.323 2004-02-10 09:33:12 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.324 2004-02-10 17:06:01 cg Exp $'
! !
--- a/TextView.st Tue Feb 10 18:05:35 2004 +0100
+++ b/TextView.st Tue Feb 10 18:06:01 2004 +0100
@@ -636,6 +636,17 @@
!TextView methodsFor:'accessing'!
+characterEncoding:encodingSymOrNil
+ "define how the contents is encoded internally.
+ For now, this should be the same encoding as my fonts encoding (otherwise, mappings would
+ occur when drawing).
+ This is (currently) only passed down from the fileBrowser,
+ and required when japanese/chinese/korean text is edited.
+ (encoding is something like #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc)"
+
+ characterEncoding := encodingSymOrNil
+!
+
characterPositionOfSelection
"return the character index of the first character in the selection.
Returns 0 if there is no selection."
@@ -686,8 +697,8 @@
"define how the contents should be encoded when saved
via the 'save / save as' dialog.
This is (currently) only passed down from the fileBrowser,
- and required when japanese/chines/korean text is edited.
- (encoding is one of #euc, #sjis, #jis7, #gb, #big5 or #ksc)"
+ and required when japanese/chinese/korean text is edited.
+ (encoding is something like #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc)"
externalEncoding := encodingSymOrNil
!
@@ -3621,8 +3632,14 @@
If the selection ends in a full line, the last entry in the returned
collection will be an empty string."
+ |sel|
+
selectionStartLine isNil ifTrue:[^ nil].
- ^ self textFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol
+ sel := self textFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol.
+ characterEncoding ~~ #'iso8859-1' ifTrue:[
+ sel := sel encodeFrom:characterEncoding into:#'unicode'
+ ].
+ ^ sel
"Modified: / 22.2.2000 / 23:54:54 / cg"
!
@@ -3714,7 +3731,7 @@
!TextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.224 2004-02-10 09:32:45 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.225 2004-02-10 17:05:01 cg Exp $'
! !
TextView initialize!