"
COPYRIGHT (c) 1990 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
PipeStream subclass:#PrinterStream
instanceVariableNames:''
classVariableNames:'PrintCommand LeftMargin'
poolDictionaries:''
category:'Streams-External'
!
!PrinterStream class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1990 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
documentation
"
a stream for printing; this (concrete or abstract) class can handle only
very dumb printers. More intelligence is added by subclasses (see
PostscriptPrinterStream among others.)
"
!
version
^ '$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.13 1995-11-27 22:09:29 cg Exp $'
! !
!PrinterStream class methodsFor:'initialization'!
initialize
"this is usually redefined by the startup-file"
PrintCommand isNil ifTrue:[
OperatingSystem isBSDlike ifTrue:[
PrintCommand := 'lpr'
] ifFalse:[
PrintCommand := 'lp'
]
].
LeftMargin isNil ifTrue:[
LeftMargin := 0
]
! !
!PrinterStream class methodsFor:'instance creation'!
new
"return a new stream for printing"
^ self basicNew startPrint
! !
!PrinterStream class methodsFor:'accessing'!
leftMargin:aNumber
"set the number of blanks for the left margin"
LeftMargin := aNumber
!
printCommand:aString
"set the command for printing (usually lp or lpr)"
PrintCommand := aString
"
PrinterStream printCommand:'lpr'
PrinterStream printCommand:'lpr -h'
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'
"
!
printCommand
"return command used for printing (usually lp or lpr)"
^ PrintCommand
! !
!PrinterStream methodsFor:'access writing'!
bold
"set font to bold
- ignore here, since this class does not know anything about the printer"
^ self
!
courier
"set font to courier
- ignore here, since this class does not know anything about the printer"
^ self
!
cr
"send a carriage-return to the printer"
super nextPut:(Character cr).
self spaces:LeftMargin
!
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
!
lineLength
"the printer pages width (in characters)"
^ 80
!
nextPut:aCharacter
"send some characters to the printer - translate as needed"
(aCharacter == Character cr) ifTrue:[
super nextPut:(Character cr).
self spaces:LeftMargin
] ifFalse:[
super nextPut:aCharacter
]
!
nextPutAll:aCollection
"send some characters to the printer - translate as needed"
aCollection do:[:aChar |
self nextPut:aChar
]
!
nextPutAllUntranslated:aCollection
"send some raw characters to the printer"
super nextPutAll:aCollection
!
nextPutUntranslated:aCharacter
"send a raw character to the printer"
super nextPut:aCharacter
!
normal
"set font to normal (non-bold, non-italic)
- ignore here, since this class does not know anything about the printer"
^ self
!
spaces:aNumber
"send some spaces to the printer"
aNumber timesRepeat:[
super nextPut:(Character space)
]
!
times
"set font to times
- ignore here, since this class does not know anything about the printer"
^ self
! !
!PrinterStream methodsFor:'open/close'!
close
self endPrint.
super close
!
endPrint
^ self
!
startPrint
super writingTo:PrintCommand.
self spaces:LeftMargin
! !
PrinterStream initialize!