[go: up one dir, main page]

Menu

[b88bd8]: / printerx.pas  Maximize  Restore  History

Download this file

274 lines (223 with data), 6.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
{ $Id$
OpenXP printer unit
Copyright (C) 1991-2001 Peter Mandrella
Copyright (C) 2000-2002 OpenXP team (www.openxp.de)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
}
UNIT printerx;
{$I xpdefine.inc }
{ ================== Interface-Teil =================== }
interface
uses
xpglobal,
keys,typeform,inout,xp0,debug;
const drlength = 20;
dnlength = 30;
maxdd = 75; { Aenderung bei Driver 1.0 nicht moeglich }
type perrfunc = function:boolean;
drstring = string[drlength];
dnstring = string[dnlength];
druck_par = record
case integer of
0 : (zahl : integer);
1 : (name : dnstring;
randtyp : shortint;
dd : array[0..maxdd] of drstring;
xlatger : boolean);
end;
{ dd:
0 : reset xlatger : Uebersetzung Umlaute -> Epson
1 : Rand randtyp : 0 = n Zeichen
2 :
3 : FF
4 : step
5 : NLQ/LQ an
6 : NLQ/LQ aus
7 : Zeilenabstand 1/6 "
8 : Zeilenabstand 1/8 "
9 : breit an
10 : breit aus
11 : Elite an (96 cpl)
12 : Elite aus
13 : Schmal an (136 cpl)
14 : Schmal aus
15 : Schmal/Elite an (168 cpi)
16 : Boldface an
17 : Boldface aus
18 : Emphasized an
19 : Emphasized aus
20 : Italics an
21 : Italics aus
22 : Superscript an
23 : Superscript aus
24 : Subscript an
25 : Subscript aus
26 : Unterstreichung an
27 : Unterstreichung aus
}
var checklst,xlatger : boolean;
lst : text;
{$IFDEF Unix }
procedure OpenLst(Port: String);
{$ELSE }
procedure OpenLst(Port: Integer);
{$ENDIF }
procedure CloseLst;
function PrintString(const s:string):string;
implementation
uses
SysUtils,
{$IFDEF NCRT }
xpcurses,
{$ENDIF }
{$IFDEF Unix }
{$IFNDEF Kylix}
printer,
{$ELSE}
xp1,
libc,
{$ENDIF}
{$ENDIF }
winxp,maus2;
{$IFDEF unix }
{$IFDEF Kylix}
var LstFile:String;
{$ENDIF}
{$ENDIF}
{$IFDEF Unix }
procedure OpenLst(Port: String);
begin
if DruckProg = '' then DruckProg := '|/usr/bin/lpr -P';
{$IFNDEF Kylix}
AssignLst(lst, '|'+DruckProg+' ' + Port);
Debug.Debuglog('printerx','lst-Assignment: |'+DruckProg+', Port: '+Port,dlDebug);
{$ELSE}
LstFile:=TempS(10000);
Assign(lst, LstFile);
{$ENDIF}
ReWrite(lst);
if IOResult = 0 then ;
end;
{$ELSE }
procedure OpenLst(Port: Integer);
begin
if DruckProg = '' then DruckProg := 'lpt';
Assign(lst, DruckProg + IntToStr(Port));
ReWrite(lst);
if IOResult = 0 then ;
end;
{$ENDIF }
procedure CloseLst;
begin
Close(lst);
{$IFDEF unix }
{$IFDEF Kylix}
libc.system(PChar(DruckProg+' -m '+LstFile));
SafeDeleteFile(LstFile);
{$ENDIF}
{$ENDIF}
end;
{ ^X in Steuerzeichen umsetzen; ^0 -> ^ }
function PrintString(const s:string):string;
var i,j,p : byte;
r: string;
begin
i:=1;
j:=0;
while i<=length(s) do begin
inc(j);
SetLength(r, j);
if s[i]='^' then begin
inc(i);
if s[i]='0' then
r[j]:='^'
else if s[i]='#' then
r[j]:='#'
else
r[j]:=chr(ord(s[i])-64);
end
else if s[i]='#' then begin
p:=i;
while (i<length(s)) and (s[i+1]>='0') and (s[i+1]<='9') do
inc(i);
if i=p then r[j]:='#'
else r[j]:=chr(minmax(ival(copy(s,p+1,i-p)),0,255));
end
else
r[j]:=s[i];
inc(i);
end;
SetLength(r, j);
PrintString:= r;
end;
{
$Log: printerx.pas,v $
Revision 1.28 2003/09/05 18:22:49 mk
- fixed for printing support under linux
Revision 1.27 2003/09/01 16:17:12 mk
- added printing support for linux
Revision 1.26 2003/01/01 16:19:44 mk
- changes to made FreeBSD-Version compilable
Revision 1.25 2002/12/04 16:57:00 dodi
- updated uses, comments and todos
Revision 1.24 2002/07/25 20:43:52 ma
- updated copyright notices
Revision 1.23 2001/12/30 19:56:48 cl
- Kylix 2 compile fixes
Revision 1.22 2001/12/26 21:33:52 mk
- fixed printing with linux
Revision 1.21 2001/10/15 08:31:39 mk
- allow printing on unix platforms
Revision 1.20 2001/09/10 15:58:01 ml
- Kylix-compatibility (xpdefines written small)
- removed div. hints and warnings
Revision 1.19 2001/09/06 19:31:19 mk
- removed some hints und warnings
Revision 1.18 2001/07/28 12:04:09 mk
- removed crt unit as much as possible
Revision 1.17 2001/03/13 19:24:56 ma
- added GPL headers, PLEASE CHECK!
- removed unnecessary comments
Revision 1.16 2000/12/03 22:23:08 mk
- Improved Printing Support
Revision 1.15 2000/11/19 18:22:52 hd
- Replaced initlization by InitxxxUnit to get control over init processes
Revision 1.14 2000/11/18 16:55:36 hd
- Unit DOS entfernt
Revision 1.13 2000/08/19 09:41:36 mk
- Code aufgeraeumt
Revision 1.12 2000/07/05 09:09:28 hd
- Anpassungen AnsiString
- Neue Definition: hasHugeString. Ist zur Zeit bei einigen Records
erforderlich, sollte aber nach vollstaendiger Umstellung entfernt werden
Revision 1.11 2000/06/24 14:10:26 mk
- 32 Bit Teile entfernt
Revision 1.10 2000/05/13 09:32:56 mk
- Crashing Bug unter Win9x und Win32-Version mit FPC behoben
Revision 1.9 2000/05/02 19:13:58 hd
xpcurses statt crt in den Units
Revision 1.8 2000/04/24 11:28:54 mk
- 32 Bit: Drucken funktioniert jetzt
Revision 1.7 2000/03/14 15:15:36 mk
- Aufraeumen des Codes abgeschlossen (unbenoetigte Variablen usw.)
- Alle 16 Bit ASM-Routinen in 32 Bit umgeschrieben
- TPZCRC.PAS ist nicht mehr noetig, Routinen befinden sich in CRC16.PAS
- XP_DES.ASM in XP_DES integriert
- 32 Bit Windows Portierung (misc)
- lauffaehig jetzt unter FPC sowohl als DOS/32 und Win/32
Revision 1.6 2000/03/07 23:41:07 mk
Komplett neue 32 Bit Windows Screenroutinen und Bugfixes
Revision 1.5 2000/02/19 11:40:07 mk
Code aufgeraeumt und z.T. portiert
}
end.