characterEncoding stuff
authorClaus Gittinger <cg@exept.de>
Sat, 28 Feb 2004 13:57:56 +0100
changeset 2916 7f1e089959a3
parent 2915 8db67a5d1ccb
child 2917 cbca85d08c88
characterEncoding stuff
EditTextView.st
FontPanel.st
TextView.st
--- a/EditTextView.st	Fri Feb 27 12:41:14 2004 +0100
+++ b/EditTextView.st	Sat Feb 28 13:57:56 2004 +0100
@@ -3650,8 +3650,8 @@
     selEndCol := self selectionEndCol.
     sel := self selection.
 
-    (characterEncoding ? #'unicode') ~= 'unicode' ifTrue:[
-        key := CharacterEncoder encode:key from:'unicode' into:characterEncoding.
+    (characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[
+        key := CharacterEncoder encode:key from:#'iso10646-1' into:characterEncoding.
     ].
 
     "replace selection by what is typed in -
@@ -5649,5 +5649,5 @@
 !EditTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.337 2004-02-27 11:41:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.338 2004-02-28 12:57:53 cg Exp $'
 ! !
--- a/FontPanel.st	Fri Feb 27 12:41:14 2004 +0100
+++ b/FontPanel.st	Sat Feb 28 13:57:56 2004 +0100
@@ -730,7 +730,7 @@
         font notNil ifTrue:[
             deviceFont := font onDevice:device.
             enc := deviceFont encoding.
-            enc isNil ifTrue:[enc := 'fontspecific'].
+            enc isNil ifTrue:[enc := #'fontspecific'].
 
             previewField font:deviceFont.
             previewField characterEncoding:enc.
@@ -988,5 +988,5 @@
 !FontPanel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.72 2004-02-22 15:40:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/FontPanel.st,v 1.73 2004-02-28 12:57:39 cg Exp $'
 ! !
--- 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!