Initial release of Maemo 5 port of gnuplot
[gnuplot] / term / debug.trm
1 /* Hello, Emacs, this is -*-C-*-
2  * $Id: debug.trm,v 1.17 2006/07/21 02:35:45 sfeam Exp $
3  *
4  */
5
6 /* GNUPLOT - debug.trm */
7
8 /*[
9  * Copyright 1990 - 1993, 1998, 2004   Thomas Williams, Colin Kelley
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  *  DEBUG
43  *
44  * AUTHORS
45  *    luecken@udel.edu
46  *
47  * send your comments or suggestions to (luecken@udel.edu).
48  *
49  */
50
51 /*
52  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
53  * generalised to have *all* defined capabilities by HBB (June 1997)
54  */
55
56
57 #include "driver.h"
58
59 #ifdef TERM_REGISTER
60 register_term(debug)
61 #endif
62
63 #ifdef TERM_PROTO
64 TERM_PUBLIC void DEBUG_init __PROTO((void));
65 TERM_PUBLIC void DEBUG_graphics __PROTO((void));
66 TERM_PUBLIC void DEBUG_text __PROTO((void));
67 TERM_PUBLIC void DEBUG_linetype __PROTO((int linetype));
68 TERM_PUBLIC void DEBUG_move __PROTO((unsigned int x, unsigned int y));
69 TERM_PUBLIC void DEBUG_vector __PROTO((unsigned int x, unsigned int y));
70 TERM_PUBLIC void DEBUG_put_text __PROTO((unsigned int x, unsigned int y, const char *str));
71 TERM_PUBLIC void DEBUG_reset __PROTO((void));
72 TERM_PUBLIC int DEBUG_justify_text __PROTO((enum JUSTIFY mode));
73 TERM_PUBLIC int DEBUG_text_angle __PROTO((int ang));
74 TERM_PUBLIC void DEBUG_point __PROTO((unsigned int x, unsigned int y, int pointstyle));
75 TERM_PUBLIC void DEBUG_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, int head));
76 TERM_PUBLIC int DEBUG_set_font __PROTO((const char *font));
77 TERM_PUBLIC void DEBUG_pointsize __PROTO((double pointsize));
78 TERM_PUBLIC void DEBUG_suspend __PROTO((void));
79 TERM_PUBLIC void DEBUG_resume __PROTO((void));
80 TERM_PUBLIC void DEBUG_fillbox __PROTO((int style, unsigned int x1, unsigned int y1, unsigned int width, unsigned int height));
81 TERM_PUBLIC void DEBUG_linewidth __PROTO((double linewidth));
82
83 #define DEBUG_XMAX 512
84 #define DEBUG_YMAX 390
85
86 #define DEBUG_XLAST (DEBUG_XMAX - 1)
87 #define DEBUG_YLAST (DEBUG_XMAX - 1)
88
89 /* Assume a character size of 1, or a 7 x 10 grid. */
90 #define DEBUG_VCHAR     10
91 #define DEBUG_HCHAR     7
92 #define DEBUG_VTIC      (DEBUG_YMAX/70)
93 #define DEBUG_HTIC      (DEBUG_XMAX/75)
94 #endif /* TERM_PROTO */
95
96 #ifndef TERM_PROTO_ONLY
97 #ifdef TERM_BODY
98
99 int DEBUG_linetype_last;
100 int DEBUG_xlast;
101 int DEBUG_ylast;
102
103 TERM_PUBLIC void
104 DEBUG_init()
105 {
106     fputs("init\n", gpoutfile);
107     DEBUG_linetype_last = LT_NODRAW;
108 }
109
110
111 TERM_PUBLIC void
112 DEBUG_graphics()
113 {
114     DEBUG_xlast = DEBUG_ylast = 0;
115     fputs("graphics\n", gpoutfile);
116 }
117
118
119 TERM_PUBLIC void
120 DEBUG_text()
121 {
122     fputs("text\n", gpoutfile);
123 }
124
125
126 TERM_PUBLIC void
127 DEBUG_linetype(int linetype)
128 {
129     /*
130        if (linetype != DEBUG_linetype_last){
131        fprintf(gpoutfile,"l%d",linetype);
132        DEBUG_linetype_last = linetype;
133        }
134      */
135     fprintf(gpoutfile, "line %d\n", linetype);
136 }
137
138
139 TERM_PUBLIC void
140 DEBUG_move(unsigned int x, unsigned int y)
141 {
142     /*
143        if (x != DEBUG_xlast || y != DEBUG_ylast){
144        fprintf(gpoutfile,"mm");
145        DEBUG_xlast = x;
146        DEBUG_ylast = y;
147        }
148      */
149     fprintf(gpoutfile, "move %d, %d\t(%d, %d)\n", x, y, x - DEBUG_xlast, y - DEBUG_ylast);
150     DEBUG_xlast = x;
151     DEBUG_ylast = y;
152 }
153
154
155 TERM_PUBLIC void
156 DEBUG_vector(unsigned int x, unsigned int y)
157 {
158     /*
159        if (x != DEBUG_xlast || y != DEBUG_ylast){
160        fprintf(gpoutfile,"vv");
161        DEBUG_xlast = x;
162        DEBUG_ylast = y;
163        }
164      */
165     fprintf(gpoutfile, "vect %d, %d\t(%d, %d)\n", x, y, x - DEBUG_xlast, y - DEBUG_ylast);
166     DEBUG_xlast = x;
167     DEBUG_ylast = y;
168 }
169
170
171 TERM_PUBLIC void
172 DEBUG_put_text(unsigned int x, unsigned int y, const char *str)
173 {
174     /*
175        DEBUG_move(x,y);
176        fprintf(gpoutfile,"tx%s\r",str);
177      */
178     fputs("put_text calls:", gpoutfile);
179     DEBUG_move(x, y);
180     fprintf(gpoutfile, "put_text '%s'\n", str);
181 }
182
183
184
185 TERM_PUBLIC void
186 DEBUG_reset()
187 {
188     fputs("reset", gpoutfile);
189 }
190
191 TERM_PUBLIC int
192 DEBUG_justify_text(enum JUSTIFY mode)
193 {
194     fputs("justify ", gpoutfile);
195     switch (mode) {
196     case (CENTRE):
197         fputs("centre", gpoutfile);
198         break;
199     case (RIGHT):
200         fputs("right", gpoutfile);
201         break;
202     default:
203     case (LEFT):
204         fputs("left", gpoutfile);
205         break;
206     }
207     fputs("\n", gpoutfile);
208     return (TRUE);
209 }
210
211 TERM_PUBLIC int
212 DEBUG_text_angle(int ang)
213 {
214     fprintf(gpoutfile, "text_angle %d:", ang);
215     switch (ang) {
216     case 0:
217         fputs(": horizontal\n", gpoutfile);
218         break;
219     case 1:
220         fputs(": upwards\n", gpoutfile);
221         break;
222     default:
223         fputs(": \a*undefined*\n", gpoutfile);
224         break;
225     }
226     return TRUE;
227 }
228
229 TERM_PUBLIC void
230 DEBUG_point(unsigned int x, unsigned int y, int pointstyle)
231 {
232     fprintf(gpoutfile, "point at (%ud,%ud), pointstyle %d\n", x, y, pointstyle);
233 }
234
235 TERM_PUBLIC void
236 DEBUG_arrow(
237     unsigned int sx, unsigned int sy,
238     unsigned int ex, unsigned int ey,
239     int head)
240 {
241     fprintf(gpoutfile, "arrow from (%ud,%ud) to (%ud,%ud), %s head\n",
242             sx, sy, ex, ey, head ? "with" : "without");
243 }
244
245 TERM_PUBLIC int
246 DEBUG_set_font(const char *font)
247 {
248     fprintf(gpoutfile, "set font to \"%s\"\n",
249             font ? (*font ? font : "\aempty string!") : "\aNULL string!");
250     return TRUE;
251 }
252
253 TERM_PUBLIC void
254 DEBUG_pointsize(double pointsize)
255 {
256     fprintf(gpoutfile, "set pointsize to %lf\n", pointsize);
257 }
258
259 TERM_PUBLIC void
260 DEBUG_suspend()
261 {
262     fputs("suspended terminal driver\n", gpoutfile);
263 }
264
265 TERM_PUBLIC void
266 DEBUG_resume()
267 {
268     fputs("resumed terminal driver\n", gpoutfile);
269 }
270
271 TERM_PUBLIC void
272 DEBUG_fillbox(
273     int style,
274     unsigned int x1, unsigned int y1,
275     unsigned int width, unsigned int height)
276 {
277     fprintf(gpoutfile, "fillbox/clear at (%ud,%ud), area (%ud,%ud), style %d)\n",
278             x1, y1, width, height, style);
279 }
280
281 TERM_PUBLIC void
282 DEBUG_linewidth(double linewidth)
283 {
284     fprintf(gpoutfile, "set linewidth %lf\n", linewidth);
285 }
286
287
288 #endif /* TERM_BODY */
289
290 #ifdef TERM_TABLE
291
292 TERM_TABLE_START(debug_driver)
293     "debug", "debugging driver",
294     DEBUG_XMAX, DEBUG_YMAX, DEBUG_VCHAR, DEBUG_HCHAR,
295     DEBUG_VTIC, DEBUG_HTIC, options_null, DEBUG_init, DEBUG_reset,
296     DEBUG_text, null_scale, DEBUG_graphics, DEBUG_move, DEBUG_vector,
297     DEBUG_linetype, DEBUG_put_text, DEBUG_text_angle,
298     DEBUG_justify_text, DEBUG_point, DEBUG_arrow, DEBUG_set_font,
299     DEBUG_pointsize,
300     TERM_CAN_MULTIPLOT,
301     DEBUG_suspend, DEBUG_resume, DEBUG_fillbox, DEBUG_linewidth
302 TERM_TABLE_END(debug_driver)
303
304 #undef LAST_TERM
305 #define LAST_TERM debug_driver
306
307 #endif /* TERM_TABLE */
308 #endif /* TERM_PROTO_ONLY */
309
310 #ifdef TERM_HELP
311 START_HELP(debug)
312 "1 debug",
313 "?commands set terminal debug",
314 "?set terminal debug",
315 "?set term debug",
316 "?terminal debug",
317 "?term debug",
318 "?debug",
319 " This terminal is provided to allow for the debugging of `gnuplot`.  It is",
320 " likely to be of use only for users who are modifying the source code."
321 END_HELP(debug)
322 #endif