author | Claus Gittinger <cg@exept.de> |
Tue, 25 Jun 2019 14:28:51 +0200 | |
changeset 5050 | 44fa8672d102 |
parent 4539 | 01e34acb71e4 |
child 5145 | 8a1040ff7c87 |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1991 by Claus Gittinger |
84 | 3 |
All Rights Reserved |
0 | 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 |
" |
|
3997 | 12 |
"{ Package: 'stx:libbasic2' }" |
0 | 13 |
|
3997 | 14 |
"{ NameSpace: Smalltalk }" |
1317 | 15 |
|
0 | 16 |
PrinterStream subclass:#EpsonFX1PrinterStream |
259 | 17 |
instanceVariableNames:'' |
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
1651 | 20 |
category:'Interface-Printing' |
0 | 21 |
! |
22 |
||
1317 | 23 |
!EpsonFX1PrinterStream class methodsFor:'documentation'! |
31 | 24 |
|
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
84 | 28 |
All Rights Reserved |
2 | 29 |
|
31 | 30 |
This software is furnished under a license and may be used |
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
0 | 38 |
|
31 | 39 |
documentation |
40 |
" |
|
348 | 41 |
This class defines protocol for simple text printing on an Epson-FX1 |
179
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
42 |
(and compatible) printer. |
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
43 |
It does not support multiple fonts, but knows how to print bold, italic etc. |
31 | 44 |
|
348 | 45 |
Graphics printing is not supported - you need a postscriptprinter for this. |
46 |
||
31 | 47 |
I cannot tell, if this is really an Epson - |
348 | 48 |
all I had to test was a Citizen 120D - its documentation claims it to be |
49 |
FX1 compatible. |
|
50 |
||
51 |
Notice: |
|
52 |
This class only defines some minimum protocol for printing on |
|
53 |
Epsons - you really should use a PostscriptPrinter ... |
|
54 |
... however, if you own an Epson, here is some class to start with. |
|
55 |
It may need to be enhanced at some places (for example: provide more |
|
56 |
fonts/emphasis's; better international character translation etc.) |
|
57 |
||
4197 | 58 |
[Disclaimer:] |
348 | 59 |
This class is not officially supported - take it or leave it. |
259 | 60 |
|
61 |
[author:] |
|
62 |
Claus Gittinger |
|
31 | 63 |
" |
179
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
64 |
! ! |
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
65 |
|
1317 | 66 |
!EpsonFX1PrinterStream class methodsFor:'initialization'! |
441 | 67 |
|
68 |
initialize |
|
69 |
DefaultCommands := #('lpr' |
|
70 |
'lpr -P<your-printer>' |
|
71 |
'cat | rsh <printHost> lpr -h' |
|
72 |
). |
|
73 |
super initialize |
|
74 |
||
75 |
" |
|
76 |
self initialize |
|
77 |
" |
|
78 |
! ! |
|
79 |
||
1317 | 80 |
!EpsonFX1PrinterStream class methodsFor:'queries'! |
179
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
81 |
|
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
82 |
printerTypeName |
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
83 |
"return a descriptive name" |
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
84 |
|
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
85 |
^ 'Epson FX1 compatible printer' |
0 | 86 |
! ! |
87 |
||
4539 | 88 |
!EpsonFX1PrinterStream methodsFor:'access-writing'! |
0 | 89 |
|
348 | 90 |
cr |
91 |
"send a carriage return (newLine). |
|
92 |
We have to output cr-nl here" |
|
93 |
||
94 |
super nextPutUntranslated:(Character value:13). |
|
95 |
super nextPutUntranslated:(Character value:10). |
|
370 | 96 |
self spaces:self class leftMargin |
348 | 97 |
|
370 | 98 |
"Modified: 1.6.1996 / 00:13:39 / cg" |
348 | 99 |
! |
100 |
||
101 |
nextPut:aCharacter |
|
102 |
"send aCharacter to the printer. |
|
103 |
Catch special characters |
|
104 |
- currently only german umlauts are handled - If you own this type |
|
105 |
of printer and depend on it, add more translation here ..." |
|
106 |
||
107 |
|ascii| |
|
108 |
||
3997 | 109 |
ascii := aCharacter codePoint. |
348 | 110 |
(ascii < 128) ifTrue:[ |
1317 | 111 |
^ stream nextPut:aCharacter |
348 | 112 |
]. |
113 |
(ascii == 16rfc) ifTrue:[ "udiaeresis" |
|
114 |
^ self character:$} fromCharacterSet:2 |
|
115 |
]. |
|
116 |
(ascii == 16re4) ifTrue:[ "adiaeresis" |
|
117 |
^ self character:${ fromCharacterSet:2 |
|
118 |
]. |
|
119 |
(ascii == 16rf6) ifTrue:[ "odiaeresis" |
|
120 |
^ self character:$| fromCharacterSet:2 |
|
121 |
]. |
|
122 |
(ascii == 16rdc) ifTrue:[ "Udiaeresis" |
|
123 |
^ self character:$] fromCharacterSet:2 |
|
124 |
]. |
|
125 |
(ascii == 16rc4) ifTrue:[ "Adiaeresis" |
|
126 |
^ self character:$[ fromCharacterSet:2 |
|
127 |
]. |
|
128 |
(ascii == 16rd6) ifTrue:[ "Odiaeresis" |
|
129 |
^ self character:$\ fromCharacterSet:2 |
|
130 |
]. |
|
131 |
(ascii == 16rdf) ifTrue:[ "ssharp" |
|
132 |
^ self character:$~ fromCharacterSet:2 |
|
133 |
] |
|
134 |
||
135 |
"Modified: 18.5.1996 / 09:03:18 / cg" |
|
136 |
! ! |
|
137 |
||
138 |
!EpsonFX1PrinterStream methodsFor:'emphasis change'! |
|
139 |
||
126 | 140 |
bold |
348 | 141 |
"set emphasis to bold" |
126 | 142 |
|
179
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
143 |
"send: <ESC>G " |
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
144 |
|
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
145 |
super escape:$G |
348 | 146 |
|
147 |
"Modified: 18.5.1996 / 09:03:31 / cg" |
|
126 | 148 |
! |
149 |
||
348 | 150 |
italic |
151 |
"set emphasis to italic" |
|
152 |
||
153 |
"send: <ESC>4 will do that" |
|
154 |
||
155 |
super escape:$4 |
|
156 |
||
157 |
"Modified: 18.5.1996 / 09:03:33 / cg" |
|
158 |
! |
|
159 |
||
160 |
normal |
|
161 |
"set emphasis to normal" |
|
162 |
||
163 |
"send: <ESC>H<ESC>5" |
|
164 |
||
165 |
super escape:$H. super escape:$5 |
|
166 |
||
167 |
"Modified: 18.5.1996 / 09:03:35 / cg" |
|
168 |
! ! |
|
169 |
||
170 |
!EpsonFX1PrinterStream methodsFor:'layout'! |
|
171 |
||
172 |
linesPerPage:n |
|
173 |
"change the lines-per-page setting" |
|
174 |
||
175 |
"send: <ESC>C<n>" |
|
176 |
||
177 |
super escape:$C. |
|
178 |
super nextPut:(Character value:n) |
|
179 |
||
180 |
"Modified: 18.5.1996 / 09:03:50 / cg" |
|
181 |
! |
|
182 |
||
183 |
newPage |
|
184 |
"force a newPage" |
|
185 |
||
186 |
super nextPut:(Character value:12) |
|
187 |
||
188 |
"Modified: 18.5.1996 / 09:04:04 / cg" |
|
189 |
! |
|
190 |
||
191 |
noTopMargin |
|
192 |
"turn off topMargin in the printer" |
|
193 |
||
194 |
"send <ESC>0" |
|
195 |
||
196 |
super escape:$O |
|
197 |
||
198 |
"Modified: 18.5.1996 / 09:04:19 / cg" |
|
199 |
! |
|
200 |
||
201 |
pageHeight:inches |
|
202 |
"set the pageHeight in inches" |
|
203 |
||
204 |
"send <ESC>G<0><inch>" |
|
205 |
||
206 |
super escape:$C. |
|
207 |
super nextPut:(Character value:0). |
|
208 |
super nextPut:(Character value:inches) |
|
209 |
||
210 |
"Modified: 18.5.1996 / 09:04:38 / cg" |
|
211 |
! |
|
212 |
||
213 |
proportional:aBoolean |
|
214 |
"turn on/off proportional printing" |
|
215 |
||
216 |
"send <ESC>p0 or <ESC>p1" |
|
217 |
||
218 |
super escape:$p. |
|
219 |
super nextPut:(aBoolean ifTrue:[$1] ifFalse:[$0]) |
|
220 |
||
221 |
"Modified: 18.5.1996 / 09:05:18 / cg" |
|
222 |
! |
|
223 |
||
224 |
reset |
|
225 |
"reset the printer - send <ESC>@" |
|
226 |
||
227 |
super escape:$@ |
|
228 |
||
229 |
"Modified: 18.5.1996 / 09:05:27 / cg" |
|
230 |
! |
|
231 |
||
232 |
topMargin:n |
|
233 |
"set the topMargin" |
|
234 |
||
235 |
"send <ESC>N<n>" |
|
236 |
||
237 |
super escape:$N. |
|
238 |
super nextPut:(Character value:n) |
|
239 |
||
240 |
"Modified: 18.5.1996 / 09:05:43 / cg" |
|
241 |
! ! |
|
242 |
||
243 |
!EpsonFX1PrinterStream methodsFor:'private'! |
|
244 |
||
0 | 245 |
character:char fromCharacterSet:set |
6 | 246 |
"send a character from an alternate character set" |
247 |
||
179
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
248 |
"send: <ESC>R<set><char><ESC>R<0>" |
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
249 |
|
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
250 |
super escape:$R. |
0 | 251 |
super nextPut:(Character value:set). |
252 |
super nextPut:char. |
|
179
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
253 |
super escape:$R. |
0 | 254 |
super nextPut:(Character value:0) |
126 | 255 |
! ! |
259 | 256 |
|
1317 | 257 |
!EpsonFX1PrinterStream class methodsFor:'documentation'! |
259 | 258 |
|
259 |
version |
|
3997 | 260 |
^ '$Header$' |
259 | 261 |
! ! |
1317 | 262 |
|
3997 | 263 |
|
441 | 264 |
EpsonFX1PrinterStream initialize! |