--- a/TextView.st Fri Feb 27 12:41:14 2004 +0100
+++ b/TextView.st Sat Feb 28 13:57:56 2004 +0100
@@ -646,15 +646,27 @@
^ characterEncoding
!
-characterEncoding:encodingSymOrNil
+characterEncoding:encodingArg
"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
+ This should normally never be required, as ST/X now assumes
+ unicode (of which iso8859-1 is a subset) encoding.
+ The possibility to change the characterEncoding is provided as
+ a backward compatibility hook for programs which want to use
+ another encoding internally."
+
+ |encodingSymOrNil|
+
+ encodingSymOrNil := encodingArg isNil ifTrue:[#'iso10646-1'] ifFalse:[encodingArg asSymbol].
+
+ characterEncoding ~~ encodingSymOrNil ifTrue:[
+ "/ TODO: reencode contents if required.
+ (list size ~~ 0
+ and:[ list contains:[:line | line size > 0]]) ifTrue:[
+ (self confirm:'Your text may need to be re-coded - this is not yet supported.\\Proceed ?')
+ ifFalse:[^ self].
+ ].
+ characterEncoding := encodingSymOrNil.
+ ].
!
characterPositionOfSelection
@@ -706,9 +718,10 @@
externalEncoding:encodingSymOrNil
"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/chinese/korean text is edited.
- (encoding is something like #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc)"
+ This is (currently only) passed down from the fileBrowser,
+ and required when utf8/japanese/chinese/korean text is edited.
+ (encoding is something like #utf8 #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc).
+ Notice: this only affects the external representation of the text."
externalEncoding := encodingSymOrNil
!
@@ -1019,7 +1032,7 @@
]
].
- msg := 'switch to a %1 encoded font ?'.
+ msg := 'Switch to a %1 encoded font ?'.
(ask not or:[self confirm:(resources string:msg with:pref) withCRs])
ifTrue:[
self withWaitCursorDo:[
@@ -1031,7 +1044,6 @@
f notNil ifTrue:[
self font:f.
- self characterEncoding:f encoding.
]
]
]
@@ -1657,7 +1669,6 @@
newFont := FontPanel fontFromUserInitial:font.
newFont notNil ifTrue:[
self font:newFont.
- characterEncoding := newFont encoding.
]
"Modified: 27.2.1996 / 00:53:51 / cg"
@@ -2002,6 +2013,7 @@
|startNr nLines string encoder|
encoder := CharacterEncoder encoderToEncodeFrom:characterEncoding into:encodingSymOrNil.
+
aStream isFileStream ifTrue:[
"on some systems, writing linewise is very slow (via NFS)
therefore we convert to a string and write it in big chunks.
@@ -3810,7 +3822,7 @@
!TextView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.239 2004-02-26 12:18:10 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/TextView.st,v 1.240 2004-02-28 12:57:56 cg Exp $'
! !
TextView initialize!