Unicode handling:
authorStefan Vogel <sv@exept.de>
Thu, 06 Nov 2008 11:59:07 +0100
changeset 2050 bf12f977da5f
parent 2049 310eea860aa2
child 2051 d55c088e8bfd
Unicode handling: implement #printOn: via dispatching to #nextPutAllUnicode: resp. #nextPutAllText:
PrinterStream.st
--- a/PrinterStream.st	Wed Nov 05 17:37:43 2008 +0100
+++ b/PrinterStream.st	Thu Nov 06 11:59:07 2008 +0100
@@ -607,29 +607,16 @@
     "send some characters to the printer - translate as needed.
      The argument, aCollection can be a Text (i.e. include emphasis)"
 
-    |lastE|
-
-    native == true ifTrue:[
+    native ifTrue:[
         stream nextPutAll:aCollection.
         ^ self.
     ].
 
     aCollection hasChangeOfEmphasis ifTrue:[
-        aCollection keysAndValuesDo:[:idx :aChar |
-            |e|
-
-            e := aCollection emphasisAt:idx.
-            (idx == 1
-            or:[lastE ~~ e]) ifTrue:[
-                self emphasis:e.
-                lastE := e.
-            ].
-            self nextPut:aChar.
-        ].
-        self emphasis:nil.
+        self nextPutAllText:aCollection.
     ] ifFalse:[
-        aCollection do:[:aChar |
-            self nextPut:aChar
+        aCollection do:[:eachChar |
+            self nextPut:eachChar
         ]
     ]
 
@@ -647,6 +634,34 @@
     ^ aCollection
 !
 
+nextPutAllText:aText
+    "send some characters to the printer - translate as needed.
+     The argument is a String or Text (i.e. includes emphasis)"
+
+    |lastE|
+
+    native ifTrue:[
+        stream nextPutAllText:aText.
+        ^ self.
+    ].
+
+    lastE := 42.    "initialize to something that is not a valid emphasis"
+
+    aText keysAndValuesDo:[:idx :aChar |
+        |e|
+
+        e := aText emphasisAt:idx.
+        lastE ~~ e ifTrue:[
+            self emphasis:e.
+            lastE := e.
+        ].
+        self nextPut:aChar.
+    ].
+    self emphasis:nil.
+
+    "Modified: 3.6.1996 / 17:12:31 / cg"
+!
+
 nextPutAllUntranslated:aCollection
     "send some raw characters to the printer - even if not in native mode"
 
@@ -834,6 +849,7 @@
 !PrinterStream methodsFor:'initialization'!
 
 initialize
+    native := false.
     pageFormat := DefaultPageFormat.
 
     "Created: 31.5.1996 / 20:14:36 / cg"
@@ -993,7 +1009,7 @@
 !PrinterStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.68 2008-05-13 12:34:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.69 2008-11-06 10:59:07 stefan Exp $'
 ! !
 
 PrinterStream initialize!