0
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1990-92 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
PipeStream subclass:#PrinterStream
|
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:'printCommand leftMargin'
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Streams-External'
|
|
18 |
!
|
|
19 |
|
|
20 |
PrinterStream comment:'
|
|
21 |
|
|
22 |
COPYRIGHT (c) 1990-92 by Claus Gittinger
|
|
23 |
All Rights Reserved
|
|
24 |
|
|
25 |
a stream for printing; this (abstract) class can handle only
|
|
26 |
very dumb printers
|
|
27 |
|
2
|
28 |
$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.3 1993-10-13 00:17:02 claus Exp $
|
0
|
29 |
'!
|
|
30 |
|
|
31 |
!PrinterStream class methodsFor:'initialization'!
|
|
32 |
|
|
33 |
initialize
|
|
34 |
"this is usually redefined by the startup-file"
|
|
35 |
|
|
36 |
printCommand isNil ifTrue:[
|
|
37 |
OperatingSystem isBSDlike ifTrue:[
|
|
38 |
printCommand := 'lpr'
|
|
39 |
] ifFalse:[
|
|
40 |
printCommand := 'lp'
|
|
41 |
]
|
|
42 |
].
|
|
43 |
leftMargin isNil ifTrue:[
|
|
44 |
leftMargin := 0
|
|
45 |
]
|
2
|
46 |
! !
|
|
47 |
|
|
48 |
!PrinterStream class methodsFor:'accessing'!
|
0
|
49 |
|
|
50 |
leftMargin:aNumber
|
|
51 |
"set the number of blanks for the left margin"
|
|
52 |
|
|
53 |
leftMargin := aNumber
|
|
54 |
!
|
|
55 |
|
|
56 |
printCommand:aString
|
|
57 |
"set the command for printing (usually lp or lpr)"
|
|
58 |
|
|
59 |
printCommand := aString
|
2
|
60 |
!
|
|
61 |
|
|
62 |
printCommand
|
|
63 |
"return the command for printing (usually lp or lpr)"
|
|
64 |
|
|
65 |
^ printCommand
|
0
|
66 |
! !
|
|
67 |
|
|
68 |
!PrinterStream class methodsFor:'instance creation'!
|
|
69 |
|
|
70 |
new
|
|
71 |
"return a new stream for printing"
|
|
72 |
|
|
73 |
^ self basicNew startPrint
|
|
74 |
! !
|
|
75 |
|
|
76 |
!PrinterStream methodsFor:'open/close'!
|
|
77 |
|
|
78 |
startPrint
|
|
79 |
super writingTo:printCommand.
|
|
80 |
self spaces:leftMargin
|
|
81 |
!
|
|
82 |
|
|
83 |
endPrint
|
|
84 |
^ self
|
|
85 |
!
|
|
86 |
|
|
87 |
close
|
|
88 |
self endPrint.
|
|
89 |
super close
|
|
90 |
! !
|
|
91 |
|
|
92 |
!PrinterStream methodsFor:'access writing'!
|
|
93 |
|
|
94 |
nextPutUntranslated:aCharacter
|
|
95 |
super nextPut:aCharacter
|
|
96 |
!
|
|
97 |
|
|
98 |
nextPutAllUntranslated:aCollection
|
|
99 |
super nextPutAll:aCollection
|
|
100 |
!
|
|
101 |
|
|
102 |
nextPutAll:aCollection
|
|
103 |
aCollection do:[:aChar |
|
|
104 |
self nextPut:aChar
|
|
105 |
]
|
|
106 |
!
|
|
107 |
|
|
108 |
nextPut:aCharacter
|
|
109 |
(aCharacter == Character cr) ifTrue:[
|
|
110 |
super nextPut:(Character cr).
|
|
111 |
self spaces:leftMargin
|
|
112 |
] ifFalse:[
|
|
113 |
super nextPut:aCharacter
|
|
114 |
]
|
|
115 |
!
|
|
116 |
|
|
117 |
cr
|
|
118 |
super nextPut:(Character cr).
|
|
119 |
self spaces:leftMargin
|
|
120 |
!
|
|
121 |
|
|
122 |
spaces:aNumber
|
|
123 |
aNumber timesRepeat:[
|
|
124 |
super nextPut:(Character space)
|
|
125 |
]
|
|
126 |
!
|
|
127 |
|
|
128 |
lineLength
|
|
129 |
^ 80
|
|
130 |
!
|
|
131 |
|
|
132 |
courier
|
|
133 |
^ self
|
|
134 |
!
|
|
135 |
|
|
136 |
times
|
|
137 |
^ self
|
|
138 |
!
|
|
139 |
|
|
140 |
helvetica
|
|
141 |
^ self
|
|
142 |
!
|
|
143 |
|
|
144 |
italic
|
|
145 |
^ self
|
|
146 |
!
|
|
147 |
|
|
148 |
bold
|
|
149 |
^ self
|
|
150 |
!
|
|
151 |
|
|
152 |
normal
|
|
153 |
^ self
|
|
154 |
! !
|