Initial release of Maemo 5 port of gnuplot
[gnuplot] / term / excl.trm
1 /* Hello, Emacs, this is -*-C-*-
2  * $Id: excl.trm,v 1.16 2006/07/21 02:35:46 sfeam Exp $
3  *
4  */
5
6 /* GNUPLOT - excl.trm */
7
8 /* Copyright 1992, 1998, 2004 by P. Klosowski at NIST.  All Rights Reserved
9  *
10  * Permission to use, copy, and distribute this software and its
11  * documentation for any purpose with or without fee is hereby granted,
12  * provided that the above copyright notice appear in all copies and
13  * that both that copyright notice and this permission notice appear
14  * in supporting documentation.
15  *
16  * Permission to modify the software is granted, but not the right to
17  * distribute the complete modified source code.  Modifications are to
18  * be distributed as patches to the released version.  Permission to
19  * distribute binaries produced by compiling modified sources is granted,
20  * provided you
21  *   1. distribute the corresponding source modifications from the
22  *    released version in the form of a patch file along with the binaries,
23  *   2. add special version identification to distinguish your version
24  *    in addition to the base release version number,
25  *   3. provide your name and address as the primary contact for the
26  *    support of your modified version, and
27  *   4. retain our contact information in regard to use of the base
28  *    software.
29  * Permission to distribute the released version of the source code along
30  * with corresponding source modifications in the form of a patch file is
31  * granted with same provisions 2 through 4 for binary distributions.
32  *
33  * This software is provided "as is" without express or implied warranty
34  * to the extent permitted by applicable law.
35  *
36  * This file is included by ../term.c.
37  *
38  *
39  * send your comments or suggestions to (gnuplot-info@lists.sourceforge.net).
40  *
41  */
42
43 /***
44   NAME
45      quic
46    PURPOSE
47      QUIC driver for GNUPLOT
48    NOTES
49
50    HISTORY
51      przemek - Aug 16, 1992: Created.
52      lars - Nov 30, 1998: Updated to new gnuplot copyright by
53                           permission from Przemek
54 ***/
55 /*
56 c               *****************************************
57 c               *****************************************
58 c               ******                              *****
59 c               ******   EXCL command definitions   *****
60 c               ******                              *****
61 c               *****************************************
62 c               *****************************************
63 */
64
65 /*
66  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
67  */
68
69 #include "driver.h"
70
71 #ifdef TERM_REGISTER
72 register_term(excl)
73 #endif
74
75 #ifdef TERM_PROTO
76 TERM_PUBLIC void EXCL_init __PROTO((void));
77 TERM_PUBLIC void EXCL_graphics __PROTO((void));
78 TERM_PUBLIC void EXCL_text __PROTO((void));
79 TERM_PUBLIC void EXCL_linetype __PROTO((int linetype));
80 TERM_PUBLIC void EXCL_move __PROTO((unsigned int x, unsigned int y));
81 TERM_PUBLIC void EXCL_vector __PROTO((unsigned int x2, unsigned int y2));
82 TERM_PUBLIC void EXCL_put_text __PROTO((unsigned int x, unsigned int y, const char str[]));
83 TERM_PUBLIC void EXCL_reset __PROTO((void));
84
85 #define EXCL_XMAX 9000
86 #define EXCL_YMAX 6500
87
88 #define EXCL_XLAST (EXCL_XMAX - 1)
89 #define EXCL_YLAST (EXCL_YMAX - 1)
90
91 #define EXCL_VCHAR              120
92 #define EXCL_HCHAR              70
93 #define EXCL_VTIC               70
94 #define EXCL_HTIC               70
95 #endif /* TERM_PROTO */
96
97
98 #ifndef TERM_PROTO_ONLY
99 #ifdef TERM_BODY
100
101 /*  Define ansi command headers, NUL character */
102 #define ESC "\033"
103 #define GS  "\035"
104 #define CSI "\033["
105 #define DCS "\033P"
106 #define ST  "\033\\"
107
108 /*
109 page numbers are given per "Talaris EXCL programmer's reference manual" M292 rev.2
110 NOTE: EXCL coordinate system places (0,0) at upper left corner of the page
111
112 c EXCL commands for initialization
113
114 c     TALAMS: set ANSI                                        (p. 162)
115 c     TALMOD: set emulation *** EXCL                          (p. 164)
116 c     TALPGO: set page orient *** landscape                   (p.  81)
117 c     TALFCTL: set paper format *** 8.5x11                    (p.  85)
118 c     TALTBM: set top/bot margins  ** in land mode to full pg (p.  73)
119 c     TALLRM: set left/right margins                          (p.  75)
120 c     PUM:    set units ** units of measure set by TALPRM     (p.  67)
121 c     TALASF: Absorb cr/ff/lf/vt   ** ON                      (p. 182)
122 c     TALPOP: pop controller params                           (p. 168)
123 c     TALPSH: push controller params                          (p. 167)
124 c     TALPRM: set units of measure ** to 1/1000 inch          (p.  64)
125 c     TALGLT: set line type ** solid                          (p. 211)
126 c     TALORG: set page absolute origin ** (0,0) UL corner     (p.  78)
127 c     TALPCW: set page clip window *** for landsc/full page   (p.  84)
128 c     TALGLP: line: **pen7x7mil*draw*smear*glyph112*font5279* (p. 208)
129 c     TALGLPE: ending for TALGLP command, forcing DRAW mode
130 c     TALGBB: bounding box; used only by qdrive               (p. 207)
131 c     TALFPO: Force page out  ** clear bitmap                 (p.  95)
132 c     TALGDW: graphical draw to hor,vert ** abs  coords       (p. 212)
133 c     TALGMV: graphical move to hor,vert ** abs  coords       (p. 213)
134 */
135 #define TALAMS  "\033[0*s"
136 #define TALMOD  "\033[1;0r"
137 #define TALPGO  "\033[1;0p"
138 #define TALFCTL "\033[0;3x"
139 #define TALTBM  "\033[0;8500 v"
140 #define TALLRM  "\033[0;11000v"
141 #define PUM     "\033[11h"
142 #define TALASF  "\033[1 z"
143 #define TALPOP  "\033[*]"
144 #define TALPSH  "\033[*["
145 #define TALPRM  "\033[3y"
146 #define TALGLT  "\033[%s*t"
147 #define TALORG  "\033[0;0o"
148 #define TALCCNT "\033[1;0u"
149 #define TALPCW  "\033[0;8500;11000;0*c"
150 #define TALGLP_init  "\033[7;7;8;1;112;5279*w"
151 #define TALGLP  "\033[%d;%d;8*w"
152 #define TALFPO  "\033[0*F"
153 #define TALGDW "\033[0;%d;%d*d"
154 #define TALGMV "\033[0;%d;%d*m"
155
156 /*  TALPYL: polyline                                        (p. 222)
157 **        5;0} list of 16-bit signed integers, encoded, mostly relative
158 **        5,1} list of ASCII  absolute coords (if w/o +- signs)(e.g. 315:1222;)
159 */
160
161 #define TALPYL  "\033P5;1}"
162
163 TERM_PUBLIC void
164 EXCL_init()
165 {
166     fprintf(gpoutfile, "%s%s%s%s%s%s",
167             TALPSH, TALAMS, TALMOD, TALCCNT, TALFCTL, TALASF);
168 /*                ^save state   ^setEXCL       ^PaperSize8.5x11       */
169 /*                       ^setANSI      ^copyCount1     ^absorbCtlChar */
170     fprintf(gpoutfile, "%s%s%s%s%s%s",
171             PUM, TALPRM, TALPGO, TALPCW, TALORG, TALGLP_init);
172     fprintf(gpoutfile, TALGLT, "");
173 /*                ^setUnits  ^landscape    ^OriginZero        ^SolidLine   */
174 /*                    ^Units1/1000" ^pageClip     ^SetLine            */
175 }
176
177 TERM_PUBLIC void
178 EXCL_graphics()
179 {
180 }
181
182 TERM_PUBLIC void
183 EXCL_text()
184 {
185     fputs(TALFPO, gpoutfile);
186     /*    ^pageout  */
187 }
188
189
190 TERM_PUBLIC void
191 EXCL_linetype(int linetype)
192 {
193 /* excl line widths in mils: 4 is mimimum, but too thin; then
194    7,10,14,17,20,24,27...
195    exclpen=MOD(NPEN,8)*7
196    CSI  exclpen; exclpen; TALGLPE
197 */
198     static char *type[2 + 9] =
199     {
200         "", "40;40", "", "42;42", "14;21",
201     /*   ....   ----  -- -- --   . . .   */
202         "", "49;30", "14;21", "", "49;30", "14;21"
203     /*  same pattern, but thicker..  and thicker       */
204     };
205     static int width[2+9] = { 14, 7, 7, 7, 7, 10, 10, 10, 17, 17, 17 };
206
207     if (linetype >= 9)
208         linetype %= 9;
209
210     if (linetype < -2)
211         linetype = LT_BLACK;
212
213     fprintf(gpoutfile, TALGLP, width[linetype + 2], width[linetype + 2]);
214     /*                 ^width in dots */
215     fprintf(gpoutfile, TALGLT, type[linetype + 2]);
216     /*                 ^line type     */
217 }
218
219
220 TERM_PUBLIC void
221 EXCL_move(unsigned int x, unsigned int y)
222 {
223     fprintf(gpoutfile, TALGMV, 1000 + x, EXCL_YLAST + 1000 - y);
224     /*                 ^pen up vector */
225 }
226
227
228 TERM_PUBLIC void
229 EXCL_vector(unsigned int x2, unsigned int y2)
230 {
231     fprintf(gpoutfile, TALGDW, 1000 + x2, EXCL_YLAST + 1000 - y2);
232     /*                 ^pen down vector */
233 }
234
235
236 TERM_PUBLIC void
237 EXCL_put_text(unsigned int x, unsigned int y, const char str[])
238 {
239     char ch;
240     EXCL_move(x, y - EXCL_VCHAR / 3);
241     ch = *str++;
242     while (ch != NUL) {
243         putc(ch, gpoutfile);
244         ch = *str++;
245     }
246 }
247
248 TERM_PUBLIC void
249 EXCL_reset()
250 {
251     fprintf(gpoutfile, "%s%s", TALFPO, TALPOP);
252     /*                         ^pageout ^pop  */
253 }
254
255
256 #endif /* TERM_BODY */
257
258 #ifdef TERM_TABLE
259
260 TERM_TABLE_START(excl_driver)
261     "excl", "Talaris EXCL Laser printer (also Talaris 1590 and others)",
262     EXCL_XMAX, EXCL_YMAX, EXCL_VCHAR, EXCL_HCHAR,
263     EXCL_VTIC, EXCL_HTIC, options_null, EXCL_init, EXCL_reset,
264     EXCL_text, null_scale, EXCL_graphics, EXCL_move, EXCL_vector,
265     EXCL_linetype, EXCL_put_text, null_text_angle,
266     null_justify_text, line_and_point, do_arrow, set_font_null
267 TERM_TABLE_END(excl_driver)
268 #undef LAST_TERM
269 #define LAST_TERM excl_driver
270
271 #endif /* TERM_TABLE */
272 #endif /* TERM_PROTO_ONLY */
273
274 #ifdef TERM_HELP
275 START_HELP(excl)
276 "1 excl",
277 "?commands set terminal excl",
278 "?set terminal excl",
279 "?set term excl",
280 "?terminal excl",
281 "?term excl",
282 "?excl",
283 " The `excl` terminal driver supports Talaris printers such as the EXCL Laser",
284 " printer and the 1590.  It has no options."
285 END_HELP(excl)
286 #endif