Initial release of Maemo 5 port of gnuplot
[gnuplot] / term / qms.trm
1 /* Hello, Emacs, this is -*-C-*-
2  * $Id: qms.trm,v 1.12 2006/07/21 02:35:48 sfeam Exp $
3  *
4  */
5
6 /* GNUPLOT - qms.trm */
7
8 /*[
9  * Copyright 1990 - 1993, 1998, 2004
10  *
11  * Permission to use, copy, and distribute this software and its
12  * documentation for any purpose with or without fee is hereby granted,
13  * provided that the above copyright notice appear in all copies and
14  * that both that copyright notice and this permission notice appear
15  * in supporting documentation.
16  *
17  * Permission to modify the software is granted, but not the right to
18  * distribute the complete modified source code.  Modifications are to
19  * be distributed as patches to the released version.  Permission to
20  * distribute binaries produced by compiling modified sources is granted,
21  * provided you
22  *   1. distribute the corresponding source modifications from the
23  *    released version in the form of a patch file along with the binaries,
24  *   2. add special version identification to distinguish your version
25  *    in addition to the base release version number,
26  *   3. provide your name and address as the primary contact for the
27  *    support of your modified version, and
28  *   4. retain our contact information in regard to use of the base
29  *    software.
30  * Permission to distribute the released version of the source code along
31  * with corresponding source modifications in the form of a patch file is
32  * granted with same provisions 2 through 4 for binary distributions.
33  *
34  * This software is provided "as is" without express or implied warranty
35  * to the extent permitted by applicable law.
36 ]*/
37
38 /*
39  * This file is included by ../term.c.
40  *
41  * This terminal driver supports:
42  *  QMS laser printers
43  *
44  * AUTHORS
45  *  Colin Kelley, Thomas Williams, Russell Lang
46  *
47  * send your comments or suggestions to (gnuplot-info@lists.sourceforge.net).
48  *
49  */
50
51 /*
52  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
53  */
54
55 #include "driver.h"
56
57 #ifdef TERM_REGISTER
58 register_term(qms)
59 #endif
60
61 #ifdef TERM_PROTO
62 TERM_PUBLIC void QMS_init __PROTO((void));
63 TERM_PUBLIC void QMS_graphics __PROTO((void));
64 TERM_PUBLIC void QMS_text __PROTO((void));
65 TERM_PUBLIC void QMS_linetype __PROTO((int linetype));
66 TERM_PUBLIC void QMS_move __PROTO((unsigned int x, unsigned int y));
67 TERM_PUBLIC void QMS_vector __PROTO((unsigned int x2, unsigned int y2));
68 TERM_PUBLIC void QMS_put_text __PROTO((unsigned int x, unsigned int y, const char str[]));
69 TERM_PUBLIC void QMS_reset __PROTO((void));
70
71 #define QMS_XMAX 9000
72 #define QMS_YMAX 6000
73
74 #define QMS_XLAST (QMS_XMAX - 1)
75 #define QMS_YLAST (QMS_YMAX - 1)
76
77 #define QMS_VCHAR               120
78 #define QMS_HCHAR               70
79 #define QMS_VTIC                70
80 #define QMS_HTIC                70
81 #endif /* TERM_PROTO */
82
83 #ifndef TERM_PROTO_ONLY
84 #ifdef TERM_BODY
85 static int qms_line = 0;        /* to remember current line type */
86
87 TERM_PUBLIC void
88 QMS_init()
89 {
90     /* This was just ^IOL, but at Rutgers at least we need some more stuff */
91     fputs("^PY^-\n^IOL\n^ISYNTAX00000^F^IB11000^IJ00000^IT00000\n", gpoutfile);
92     /*     ^ QUIC on    ^set defaults  ^ set botttom,top,left margins
93      *            ^landscape         ^free format
94      */
95
96 /* set defaults are: implicit decimal point, units in inches,
97  * numbers left justified, units in 1/1000 inch, do not ignore spaces
98  * margins are in 1/1000 inch units
99  */
100 }
101
102
103 TERM_PUBLIC void
104 QMS_graphics()
105 {
106     fputs("^IGV\n", gpoutfile);
107     /*     ^enter graphics vector mode */
108 }
109
110
111
112 TERM_PUBLIC void
113 QMS_text()
114 {
115 /* added ^-, because ^, after an ^I command doesn't actually print a page */
116 /* Did anybody try this code out?  [uhh...-cdk] */
117     fputs("^IGE\n^-^,", gpoutfile);
118     /*     ^exit graphics vector mode
119      *           ^pass terminator
120      *             ^print page
121      */
122 }
123
124
125 TERM_PUBLIC void
126 QMS_linetype(int linetype)
127 {
128     static int width[2 + 9] = { 7, 3, 3, 3, 3, 5, 5, 5, 7, 7, 7 };
129     static int type[2 + 9] = { 0, 1, 0, 2, 3, 0, 2, 3, 0, 2, 3 };
130 /*
131  * I don't know about Villanova, but on our printer, using ^V without
132  * previously setting up a pattern crashes the microcode.
133  * [nope, doesn't crash here. -cdk]
134  * [it generates a controller error here on dotted lines. - rjl]
135  */
136 /* Code to define patterns added by rjl
137  * According to the manual it should work - but it doesn't
138  */
139     qms_line = linetype;
140     if (linetype >= 9)
141         linetype %= 9;
142
143     fprintf(gpoutfile, "^PW%02d\n", width[linetype + 2]);
144 /*                       ^width in dots */
145
146     switch (type[linetype + 2]) {
147     case 1:                     /* short dash */
148         fputs("^PV102025^G\n^V1\n", gpoutfile);
149         /* ^PV = define pattern vector, 1 = pattern number,
150          * 02 = number of pen downs and ups, 025 = .025" length of ups/downs
151          */
152         break;
153     case 2:                     /* medium dash */
154         fputs("^PV202050^G\n^V2\n", gpoutfile);
155         break;
156     case 3:                     /* long dash */
157         fputs("^PV302100^G\n^V3\n", gpoutfile);
158         break;
159     default:
160     case 0:
161         fputs("^V0\n", gpoutfile);
162         break;
163     }
164 }
165
166
167 TERM_PUBLIC void
168 QMS_move(unsigned int x, unsigned int y)
169 {
170     fprintf(gpoutfile, "^U%05d:%05d\n", 1000 + x, QMS_YLAST + 1000 - y);
171     /*                   ^pen up vector*/
172 }
173
174
175 TERM_PUBLIC void
176 QMS_vector(unsigned int x2, unsigned int y2)
177 {
178     fprintf(gpoutfile, "^D%05d:%05d\n", 1000 + x2, QMS_YLAST + 1000 - y2);
179     /*                  ^pen down vector*/
180 }
181
182
183 TERM_PUBLIC void
184 QMS_put_text(unsigned int x, unsigned int y, const char str[])
185 {
186     char ch;
187     QMS_move(x, y + QMS_VCHAR / 3);
188     fputs("^IGE\n", gpoutfile);
189     ch = *str++;
190     while (ch != NUL) {
191         if (ch == '^')
192             putc('^', gpoutfile);
193         putc(ch, gpoutfile);
194         ch = *str++;
195     }
196     fputs("\n^IGV\n", gpoutfile);
197     QMS_linetype(qms_line);     /* restore line type */
198 }
199
200
201 TERM_PUBLIC void
202 QMS_reset()
203 {
204     fputs("^PN^-\n", gpoutfile);
205     /*     ^QUIC off */
206 }
207
208 #endif /* TERM_BODY */
209
210 #ifdef TERM_TABLE
211 TERM_TABLE_START(qms_driver)
212     "qms", "QMS/QUIC Laser printer (also Talaris 1200 and others)",
213     QMS_XMAX, QMS_YMAX, QMS_VCHAR, QMS_HCHAR,
214     QMS_VTIC, QMS_HTIC, options_null, QMS_init, QMS_reset,
215     QMS_text, null_scale, QMS_graphics, QMS_move, QMS_vector,
216     QMS_linetype, QMS_put_text, null_text_angle,
217     null_justify_text, line_and_point, do_arrow, set_font_null
218 TERM_TABLE_END(qms_driver)
219
220 #undef LAST_TERM
221 #define LAST_TERM qms_driver
222
223 #endif /* TERM_TABLE */
224 #endif /* TERM_PROTO_ONLY */
225
226 #ifdef TERM_HELP
227 START_HELP(qms)
228 "1 qms",
229 "?commands set terminal qms",
230 "?set terminal qms",
231 "?set term qms",
232 "?terminal qms",
233 "?term qms",
234 "?qms",
235 " The `qms` terminal driver supports the QMS/QUIC Laser printer, the Talaris",
236 " 1200 and others.  It has no options."
237 END_HELP(qms)
238 #endif