PrinterStream.st
changeset 348 e4790af5d077
parent 341 1e28fd1604ba
child 349 e2806ca1c634
--- a/PrinterStream.st	Fri May 17 16:46:19 1996 +0200
+++ b/PrinterStream.st	Sat May 18 09:14:51 1996 +0200
@@ -36,8 +36,9 @@
 documentation
 "
     a stream for printing; this (concrete or abstract) class can handle only
-    very dumb printers. No attributes (italic, bold etc) and no multiple fonts
-    are supported - just plain single font text printing.
+    very dumb printers. 
+    No attributes (italic, bold etc) and no multiple fonts are supported 
+    - just plain single font text printing.
 
     More intelligence is added by subclasses (see PostscriptPrinterStream among others.)
 
@@ -45,6 +46,9 @@
     text; although some limited font functionality (such as bold or italic printing)
     may be supported by some subclasses.
 
+
+    [usage:]
+
     The concrete printer class is bound to the global variable Printer,
     which is either set to PrinterStream (for dumb printers) or to one of
     the subclasses (PostscriptPrinterStream etc.).
@@ -62,6 +66,14 @@
 
     See users of the Printer global variable for more examples.
 
+    [class variables:]
+        PrintCommand    <String>        the operatingSystem command for printing.
+                                        Usually something like 'lp' or 'lpr'
+
+        LeftMargin      <Integer>       optional default left margin.
+                                        Defaults to 0.
+
+
     [author:]
         Claus Gittinger
 "
@@ -131,13 +143,15 @@
 !
 
 printCommand
-    "return command used for printing (usually lp or lpr)"
+    "return the command used for printing (usually 'lp' or 'lpr')"
 
     ^ PrintCommand
+
+    "Modified: 18.5.1996 / 09:12:35 / cg"
 !
 
 printCommand:aString
-    "set the command for printing (usually lp or lpr)"
+    "set the command for printing (usually 'lp' or 'lpr')"
 
     PrintCommand := aString
 
@@ -147,6 +161,8 @@
      PrinterStream printCommand:'rsh ibm lpr -h'
      PrinterStream printCommand:'gs -sDEVICE=djet500 -sOutputFile=/tmp/stx.ps -sPAPERSIZE=a4 -q -; cat /tmp/stx.ps | rsh ibm lpr -h'
     "
+
+    "Modified: 18.5.1996 / 09:12:48 / cg"
 ! !
 
 !PrinterStream class methodsFor:'queries'!
@@ -167,81 +183,6 @@
     "Created: 10.2.1996 / 16:23:07 / cg"
 ! !
 
-!PrinterStream methodsFor:'access font change'!
-
-bold
-    "set font to bold
-     - ignore here, since this class does not know anything about the printer"
-
-    ^ self
-!
-
-boldItalic
-    "set font to boldItalic
-     - ignore here, since this class does not know anything about the printer"
-
-    ^ self
-
-    "Created: 14.5.1996 / 18:53:43 / cg"
-!
-
-courier
-    "set font to courier 
-     - ignore here, since this class does not know anything about the printer"
-
-    ^ self
-!
-
-emphasis:anEmphasis
-    "change the emphasis"
-
-    anEmphasis isNil ifTrue:[
-        ^ self normal
-    ].
-    anEmphasis == #bold ifTrue:[
-        ^ self bold
-    ].
-    anEmphasis == #italic ifTrue:[
-        ^ self italic
-    ].
-    anEmphasis == #underline ifTrue:[
-        ^ self underline
-    ].
-    anEmphasis == #strikeout ifTrue:[
-        ^ self strikeout
-    ].
-
-    "Created: 14.5.1996 / 18:53:54 / cg"
-!
-
-helvetica
-    "set font to helvetic
-     - ignore here, since this class does not know anything about the printer"
-
-    ^ self
-!
-
-italic
-    "set font to italic
-     - ignore here, since this class does not know anything about the printer"
-
-    ^ self
-!
-
-normal
-    "set font to normal (non-bold, non-italic)
-     - ignore here, since this class does not know anything about the printer"
-
-    ^ self
-!
-
-times
-    "set font to times 
-     - ignore here, since this class does not know anything about the printer"
-
-    ^ self
-! !
-
 !PrinterStream methodsFor:'access writing'!
 
 cr
@@ -275,11 +216,21 @@
 !
 
 nextPutAll:aCollection
-    "send some characters to the printer - translate as needed"
+    "send some characters to the printer - translate as needed.
+     The argument, aCollection can be a Text (i.e. include emphasis)"
 
-    aCollection do:[:aChar |
-	self nextPut:aChar
+    aCollection hasChangeOfEmphasis ifTrue:[
+        aCollection keysAndValuesDo:[:idx :aChar |
+            self emphasis:(aCollection emphasisAt:idx).
+            self nextPut:aChar.
+        ]
+    ] ifFalse:[
+        aCollection do:[:aChar |
+            self nextPut:aChar
+        ]
     ]
+
+    "Modified: 18.5.1996 / 09:01:00 / cg"
 !
 
 nextPutAllUntranslated:aCollection
@@ -298,6 +249,110 @@
     "Modified: 10.4.1996 / 13:08:28 / cg"
 ! !
 
+!PrinterStream methodsFor:'emphasis change'!
+
+bold
+    "set emphasis to bold
+     - ignore here, since this class does not know anything about the printer"
+
+    ^ self
+
+    "Modified: 18.5.1996 / 08:55:10 / cg"
+!
+
+boldItalic
+    "set emphasis to boldItalic
+     - ignore here, since this class does not know anything about the printer"
+
+    ^ self
+
+    "Created: 14.5.1996 / 18:53:43 / cg"
+    "Modified: 18.5.1996 / 08:55:14 / cg"
+!
+
+emphasis:anEmphasis
+    "change the emphasis"
+
+    anEmphasis isNil ifTrue:[
+        ^ self normal
+    ].
+    anEmphasis == #bold ifTrue:[
+        ^ self bold
+    ].
+    anEmphasis == #italic ifTrue:[
+        ^ self italic
+    ].
+    anEmphasis == #underline ifTrue:[
+        ^ self underline
+    ].
+    anEmphasis == #strikeout ifTrue:[
+        ^ self strikeout
+    ].
+
+    "Created: 14.5.1996 / 18:53:54 / cg"
+!
+
+italic
+    "set emphasis to italic
+     - ignore here, since this class does not know anything about the printer"
+
+    ^ self
+
+    "Modified: 18.5.1996 / 08:55:18 / cg"
+!
+
+normal
+    "set emphasis to normal (non-bold, non-italic)
+     - ignore here, since this class does not know anything about the printer"
+
+    ^ self
+
+    "Modified: 18.5.1996 / 08:55:21 / cg"
+!
+
+strikeout
+    "set emphasis to strikeout
+     - ignore here, since this class does not know anything about the printer"
+
+    ^ self
+
+    "Modified: 18.5.1996 / 08:55:10 / cg"
+    "Created: 18.5.1996 / 08:56:13 / cg"
+!
+
+underline
+    "set emphasis to underline
+     - ignore here, since this class does not know anything about the printer"
+
+    ^ self
+
+    "Modified: 18.5.1996 / 08:55:10 / cg"
+    "Created: 18.5.1996 / 08:56:24 / cg"
+! !
+
+!PrinterStream methodsFor:'font change'!
+
+courier
+    "set font to courier 
+     - ignore here, since this class does not know anything about the printer"
+
+    ^ self
+!
+
+helvetica
+    "set font to helvetic
+     - ignore here, since this class does not know anything about the printer"
+
+    ^ self
+!
+
+times
+    "set font to times 
+     - ignore here, since this class does not know anything about the printer"
+
+    ^ self
+! !
+
 !PrinterStream methodsFor:'helpers writing'!
 
 escape:aCharacter
@@ -349,6 +404,6 @@
 !PrinterStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.22 1996-05-14 16:54:02 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.23 1996-05-18 07:14:51 cg Exp $'
 ! !
 PrinterStream initialize!