File: debug.trm

package info (click to toggle)
gnuplot5 5.0.0~rc%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,548 kB
  • ctags: 8,104
  • sloc: ansic: 77,108; cpp: 6,848; makefile: 1,932; sh: 1,343; lisp: 657; perl: 302; awk: 235; pascal: 194; tcl: 88; python: 46
file content (388 lines) | stat: -rw-r--r-- 10,356 bytes parent folder | download | duplicates (5)
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
/* Hello, Emacs, this is -*-C-*-
 * $Id: debug.trm,v 1.18 2012/10/30 04:13:32 sfeam Exp $
 *
 */

/* GNUPLOT - debug.trm */

/*[
 * Copyright 1990 - 1993, 1998, 2004   Thomas Williams, Colin Kelley
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the complete modified source code.  Modifications are to
 * be distributed as patches to the released version.  Permission to
 * distribute binaries produced by compiling modified sources is granted,
 * provided you
 *   1. distribute the corresponding source modifications from the
 *    released version in the form of a patch file along with the binaries,
 *   2. add special version identification to distinguish your version
 *    in addition to the base release version number,
 *   3. provide your name and address as the primary contact for the
 *    support of your modified version, and
 *   4. retain our contact information in regard to use of the base
 *    software.
 * Permission to distribute the released version of the source code along
 * with corresponding source modifications in the form of a patch file is
 * granted with same provisions 2 through 4 for binary distributions.
 *
 * This software is provided "as is" without express or implied warranty
 * to the extent permitted by applicable law.
]*/

/*
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  DEBUG
 *
 * AUTHORS
 *    luecken@udel.edu
 *
 * send your comments or suggestions to (luecken@udel.edu).
 *
 */

/*
 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
 * generalised to have *all* defined capabilities by HBB (June 1997)
 */


#include "driver.h"

#ifdef TERM_REGISTER
register_term(debug)
#endif

#ifdef TERM_PROTO
TERM_PUBLIC void DEBUG_init __PROTO((void));
TERM_PUBLIC void DEBUG_graphics __PROTO((void));
TERM_PUBLIC void DEBUG_text __PROTO((void));
TERM_PUBLIC void DEBUG_linetype __PROTO((int linetype));
TERM_PUBLIC void DEBUG_move __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void DEBUG_vector __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void DEBUG_put_text __PROTO((unsigned int x, unsigned int y, const char *str));
TERM_PUBLIC void DEBUG_reset __PROTO((void));
TERM_PUBLIC int DEBUG_justify_text __PROTO((enum JUSTIFY mode));
TERM_PUBLIC int DEBUG_text_angle __PROTO((int ang));
TERM_PUBLIC void DEBUG_point __PROTO((unsigned int x, unsigned int y, int pointstyle));
TERM_PUBLIC void DEBUG_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, int head));
TERM_PUBLIC int DEBUG_set_font __PROTO((const char *font));
TERM_PUBLIC void DEBUG_pointsize __PROTO((double pointsize));
TERM_PUBLIC void DEBUG_suspend __PROTO((void));
TERM_PUBLIC void DEBUG_resume __PROTO((void));
TERM_PUBLIC void DEBUG_fillbox __PROTO((int style, unsigned int x1, unsigned int y1, unsigned int width, unsigned int height));
TERM_PUBLIC void DEBUG_linewidth __PROTO((double linewidth));
TERM_PUBLIC void DEBUG_filled_polygon __PROTO((int, gpiPoint *));
TERM_PUBLIC void DEBUG_set_color __PROTO((t_colorspec *));
TERM_PUBLIC void DEBUG_layer __PROTO((t_termlayer syncpoint));
TERM_PUBLIC void DEBUG_path __PROTO((int p));
TERM_PUBLIC void DEBUG_image __PROTO((unsigned m, unsigned n, coordval *image, gpiPoint *corner, t_imagecolor color_mode));


#define DEBUG_XMAX 512
#define DEBUG_YMAX 390

#define DEBUG_XLAST (DEBUG_XMAX - 1)
#define DEBUG_YLAST (DEBUG_XMAX - 1)

/* Assume a character size of 1, or a 7 x 10 grid. */
#define DEBUG_VCHAR	10
#define DEBUG_HCHAR	7
#define DEBUG_VTIC	(DEBUG_YMAX/70)
#define DEBUG_HTIC	(DEBUG_XMAX/75)
#endif /* TERM_PROTO */

#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY

int DEBUG_linetype_last;
int DEBUG_xlast;
int DEBUG_ylast;

TERM_PUBLIC void
DEBUG_init()
{
    fputs("init\n", gpoutfile);
    DEBUG_linetype_last = LT_NODRAW;
}


TERM_PUBLIC void
DEBUG_graphics()
{
    DEBUG_xlast = DEBUG_ylast = 0;
    fputs("graphics\n", gpoutfile);
}


TERM_PUBLIC void
DEBUG_text()
{
    fputs("text\n", gpoutfile);
}


TERM_PUBLIC void
DEBUG_linetype(int linetype)
{
    /*
       if (linetype != DEBUG_linetype_last){
       fprintf(gpoutfile,"l%d",linetype);
       DEBUG_linetype_last = linetype;
       }
     */
    fprintf(gpoutfile, "line %d\n", linetype);
}


TERM_PUBLIC void
DEBUG_move(unsigned int x, unsigned int y)
{
    /*
       if (x != DEBUG_xlast || y != DEBUG_ylast){
       fprintf(gpoutfile,"mm");
       DEBUG_xlast = x;
       DEBUG_ylast = y;
       }
     */
    fprintf(gpoutfile, "move %d, %d\t(%d, %d)\n", x, y, x - DEBUG_xlast, y - DEBUG_ylast);
    DEBUG_xlast = x;
    DEBUG_ylast = y;
}


TERM_PUBLIC void
DEBUG_vector(unsigned int x, unsigned int y)
{
    /*
       if (x != DEBUG_xlast || y != DEBUG_ylast){
       fprintf(gpoutfile,"vv");
       DEBUG_xlast = x;
       DEBUG_ylast = y;
       }
     */
    fprintf(gpoutfile, "vect %d, %d\t(%d, %d)\n", x, y, x - DEBUG_xlast, y - DEBUG_ylast);
    DEBUG_xlast = x;
    DEBUG_ylast = y;
}


TERM_PUBLIC void
DEBUG_put_text(unsigned int x, unsigned int y, const char *str)
{
    /*
       DEBUG_move(x,y);
       fprintf(gpoutfile,"tx%s\r",str);
     */
    fputs("put_text calls:", gpoutfile);
    DEBUG_move(x, y);
    fprintf(gpoutfile, "put_text '%s'\n", str);
}



TERM_PUBLIC void
DEBUG_reset()
{
    fputs("reset", gpoutfile);
}

TERM_PUBLIC int
DEBUG_justify_text(enum JUSTIFY mode)
{
    fputs("justify ", gpoutfile);
    switch (mode) {
    case (CENTRE):
	fputs("centre", gpoutfile);
	break;
    case (RIGHT):
	fputs("right", gpoutfile);
	break;
    default:
    case (LEFT):
	fputs("left", gpoutfile);
	break;
    }
    fputs("\n", gpoutfile);
    return (TRUE);
}

TERM_PUBLIC int
DEBUG_text_angle(int ang)
{
    fprintf(gpoutfile, "text_angle %d:", ang);
    switch (ang) {
    case 0:
	fputs(": horizontal\n", gpoutfile);
	break;
    case 1:
	fputs(": upwards\n", gpoutfile);
	break;
    default:
	fputs(": \a*undefined*\n", gpoutfile);
	break;
    }
    return TRUE;
}

TERM_PUBLIC void
DEBUG_point(unsigned int x, unsigned int y, int pointstyle)
{
    fprintf(gpoutfile, "point at (%ud,%ud), pointstyle %d\n", x, y, pointstyle);
}

TERM_PUBLIC void
DEBUG_arrow(
    unsigned int sx, unsigned int sy,
    unsigned int ex, unsigned int ey,
    int head)
{
    fprintf(gpoutfile, "arrow from (%ud,%ud) to (%ud,%ud), %s head\n",
	    sx, sy, ex, ey, head ? "with" : "without");
}

TERM_PUBLIC int
DEBUG_set_font(const char *font)
{
    fprintf(gpoutfile, "set font to \"%s\"\n",
	    font ? (*font ? font : "\aempty string!") : "\aNULL string!");
    return TRUE;
}

TERM_PUBLIC void
DEBUG_pointsize(double pointsize)
{
    fprintf(gpoutfile, "set pointsize to %lf\n", pointsize);
}

TERM_PUBLIC void
DEBUG_suspend()
{
    fputs("suspended terminal driver\n", gpoutfile);
}

TERM_PUBLIC void
DEBUG_resume()
{
    fputs("resumed terminal driver\n", gpoutfile);
}

TERM_PUBLIC void
DEBUG_fillbox(
    int style,
    unsigned int x1, unsigned int y1,
    unsigned int width, unsigned int height)
{
    fprintf(gpoutfile, "fillbox/clear at (%ud,%ud), area (%ud,%ud), style %d)\n",
	    x1, y1, width, height, style);
}

TERM_PUBLIC void
DEBUG_linewidth(double linewidth)
{
    fprintf(gpoutfile, "set linewidth %lf\n", linewidth);
}

TERM_PUBLIC void
DEBUG_filled_polygon(int points, gpiPoint *corners)
{
    fprintf(gpoutfile, "polygon with %d vertices\n",points);
}

TERM_PUBLIC void
DEBUG_set_color (t_colorspec *colorspec)
{
    extern void save_pm3dcolor();
    fprintf(gpoutfile,"set_color:  ");
    save_pm3dcolor(gpoutfile, colorspec);
    fprintf(gpoutfile, "\n");
}

TERM_PUBLIC void
DEBUG_layer (t_termlayer syncpoint)
{
    char *l = "";
    switch (syncpoint) {
    case TERM_LAYER_RESET:		l = "reset"; break;
    case TERM_LAYER_BACKTEXT:		l = "backtext"; break;
    case TERM_LAYER_FRONTTEXT:		l = "fronttext"; break;
    case TERM_LAYER_BEGIN_GRID:		l = "begin grid"; break;
    case TERM_LAYER_END_GRID:		l = "end grid"; break;
    case TERM_LAYER_END_TEXT:		l = "end text"; break;
    case TERM_LAYER_BEFORE_PLOT:	l = "before plot"; break;
    case TERM_LAYER_AFTER_PLOT:		l = "after plot"; break;
    case TERM_LAYER_BEGIN_KEYSAMPLE:	l = "begin keysample"; break;
    case TERM_LAYER_END_KEYSAMPLE:	l = "end keysample"; break;
    case TERM_LAYER_RESET_PLOTNO:	l = "reset plotno"; break;
    case TERM_LAYER_BEFORE_ZOOM:	l = "before zoom"; break;
    case TERM_LAYER_BEGIN_PM3D_MAP:	l = "begin pm3d map"; break;
    case TERM_LAYER_END_PM3D_MAP:	l = "end pm3d map"; break;
    default:				l = "unknown"; break;
    }

    fprintf(gpoutfile, "layer %s\n", l);
}

TERM_PUBLIC void
DEBUG_path (int p)
{
    fprintf(gpoutfile, "path %d\n", p);
}

TERM_PUBLIC void 
DEBUG_image (unsigned m, unsigned n, coordval *image, gpiPoint *corner, t_imagecolor color_mode)
{
    fprintf(gpoutfile, "image size = %d x %d\n", m, n);
}
#endif /* TERM_BODY */

#ifdef TERM_TABLE

TERM_TABLE_START(debug_driver)
    "debug", "debugging driver",
    DEBUG_XMAX, DEBUG_YMAX, DEBUG_VCHAR, DEBUG_HCHAR,
    DEBUG_VTIC, DEBUG_HTIC, options_null, DEBUG_init, DEBUG_reset,
    DEBUG_text, null_scale, DEBUG_graphics, DEBUG_move, DEBUG_vector,
    DEBUG_linetype, DEBUG_put_text, DEBUG_text_angle,
    DEBUG_justify_text, DEBUG_point, DEBUG_arrow, DEBUG_set_font,
    DEBUG_pointsize,
    TERM_CAN_MULTIPLOT,
    DEBUG_suspend, DEBUG_resume, DEBUG_fillbox, DEBUG_linewidth,
#ifdef USE_MOUSE
    0, 0, 0, 0, 0, /* no mouse support */
#endif
    0, 0, /* no palette */
    DEBUG_set_color,
    DEBUG_filled_polygon,
    DEBUG_image,
    0, 0, 0, /* no enhanced text */
    DEBUG_layer, DEBUG_path

TERM_TABLE_END(debug_driver)

#undef LAST_TERM
#define LAST_TERM debug_driver

#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */

#ifdef TERM_HELP
START_HELP(debug)
"1 debug",
"?commands set terminal debug",
"?set terminal debug",
"?set term debug",
"?terminal debug",
"?term debug",
"?debug",
" This terminal is provided to allow for the debugging of `gnuplot`.  It is",
" likely to be of use only for users who are modifying the source code."
END_HELP(debug)
#endif