/usr/bin/gnuplot symlinks packageing problems were fixed gor gnuplot-x11
[gnuplot] / term / fg.trm
1 /* Hello, Emacs, this is -*-C-*-
2  * $Id: fg.trm,v 1.13 2006/07/21 02:35:46 sfeam Exp $
3  */
4
5 /* GNUPLOT - fg.trm */
6
7 /*[
8  * Copyright 1990 - 1993, 1998, 2004
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
37 /*
38  * This file is included by ../term.c.
39  *
40  * This terminal driver supports:
41  *      Under Zortech C
42  *      egalib, vgalib, vgamono, svga, mcga, cga, hercules, att
43  *
44  * AUTHORS
45  *                Gnuplot for DOS 386/flash graphics
46  *                                Clifton T. Liu
47  *
48  */
49
50 /* The modifications to allow Gnuplot to compile with Zortech C/C++   */
51 /* 3.1 /Flash Graphics  were made by Clifton T. Liu               */
52 /* (cliu@merlin.appmath.columbia.edu)            20 Feb 1993      */
53
54 /*
55  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
56  */
57
58 #include "driver.h"
59
60 #ifdef TERM_REGISTER
61 register_term(hercules)
62 register_term(egamono)
63 register_term(egalib)
64 register_term(vgalib)
65 register_term(vgamono)
66 register_term(svgalib)
67 register_term(ssvgalib)
68 #endif
69
70 #ifdef TERM_PROTO
71 TERM_PUBLIC void PC_text __PROTO((void));
72 TERM_PUBLIC void PC_reset __PROTO((void));
73 TERM_PUBLIC int VGA_text_angle __PROTO((int ang));
74 TERM_PUBLIC int VGA_justify_text __PROTO((enum JUSTIFY mode));
75 TERM_PUBLIC void VGA_init __PROTO((void));
76 TERM_PUBLIC void HERC_graphics __PROTO((void));
77 TERM_PUBLIC void EGAMONO_graphics __PROTO((void));
78 TERM_PUBLIC void EGA_graphics __PROTO((void));
79 TERM_PUBLIC void VGA_graphics __PROTO((void));
80 TERM_PUBLIC void VGAMONO_graphics __PROTO((void));
81 TERM_PUBLIC void SVGA_graphics __PROTO((void));
82 TERM_PUBLIC void SSVGA_graphics __PROTO((void));
83 TERM_PUBLIC void VGA_linetype __PROTO((int linetype));
84 TERM_PUBLIC void VGA_put_text __PROTO((unsigned int x, unsigned int y, const char *str));
85 TERM_PUBLIC void VGA_move __PROTO((int x, int y));
86 TERM_PUBLIC void VGA_vector __PROTO((int x, int y));
87 TERM_PUBLIC void VGA_text __PROTO((void));
88 TERM_PUBLIC void VGA_reset __PROTO((void));
89 #define HERC_XMAX 720
90 #define HERC_YMAX 348
91
92 #define HERC_XLAST (HERC_XMAX - 1)
93 #define HERC_YLAST (HERC_YMAX - 1)
94
95 #define HERC_VCHAR 10
96 #define HERC_HCHAR 8
97 #define HERC_VTIC 5
98 #define HERC_HTIC 5
99
100
101
102 #define EGA_XMAX 640
103 #define EGA_YMAX 350
104
105 #define EGA_XLAST (EGA_XMAX - 1)
106 #define EGA_YLAST (EGA_YMAX - 1)
107
108 #define EGA_VCHAR 18
109 #define EGA_HCHAR 8
110 #define EGA_VTIC 5
111 #define EGA_HTIC 5
112
113
114 #define VGA_XMAX 640
115 #define VGA_YMAX 480
116
117 #define VGA_XLAST (VGA_XMAX - 1)
118 #define VGA_YLAST (VGA_YMAX - 1)
119
120 #define VGA_VCHAR 24
121 #define VGA_HCHAR 8
122 #define VGA_VTIC 5
123 #define VGA_HTIC 5
124
125
126 #define SVGA_XMAX 800
127 #define SVGA_YMAX 600
128
129 #define SVGA_XLAST (SVGA_XMAX - 1)
130 #define SVGA_YLAST (SVGA_YMAX - 1)
131
132 #define SVGA_VCHAR 24
133 #define SVGA_HCHAR 8
134 #define SVGA_VTIC 5
135 #define SVGA_HTIC 5
136
137 #define SSVGA_XMAX 1024
138 #define SSVGA_YMAX 768
139
140 #define SSVGA_XLAST (SSVGA_XMAX - 1)
141 #define SSVGA_YLAST (SSVGA_YMAX - 1)
142
143 #define SSVGA_VCHAR 24
144 #define SSVGA_HCHAR 8
145 #define SSVGA_VTIC 5
146 #define SSVGA_HTIC 5
147
148 #endif /* TERM_PROTO */
149
150 #ifndef TERM_PROTO_ONLY
151 #ifdef TERM_BODY
152
153 void pause __PROTO((void));
154
155 #include <fg.h>
156
157 static int pattern[] ={ 0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f };
158
159 static int graphics_on = FALSE;
160 int startx, starty;
161 /*
162 int pc_angle;
163 #define PC_VCHAR FNT5X9_VCHAR
164 #define PC_HCHAR FNT5X9_HCHAR
165 */
166 void
167 pause()
168 {                               /* press any key to continue... */
169     (void) getch();
170 }
171
172
173 TERM_PUBLIC void
174 PC_text()
175 {
176     if (graphics_on) {
177         graphics_on = FALSE;
178         pause();
179     }
180     fg_term();
181 }
182
183 TERM_PUBLIC void
184 PC_reset()
185 {
186 }
187
188
189
190 /* all of the FlashGraphics C routines for the different graphics devices
191  * go here */
192
193
194
195 static int vga256color[] ={ 7, 8, 2, 3, 4, 5, 9, 14, 12, 15, 13, 10, 11, 1, 6 };
196 static int *vgacolor = vga256color;
197 static fg_color_t vga_color;
198 static int text_angle;
199 static fg_line_t line_to_draw;
200
201 TERM_PUBLIC int
202 VGA_text_angle(int ang)
203 {
204     text_angle = (ang ? 1 : 0);
205     return TRUE;
206 }
207
208 TERM_PUBLIC int
209 VGA_justify_text(enum JUSTIFY mode)
210 {
211     return FALSE;
212 }
213
214 TERM_PUBLIC void
215 VGA_init()
216 {
217     if (fg_init() == FG_NULL) {
218         fputs("Graphics card not detected.\n", stderr);
219         exit(EXIT_FAILURE);
220     }
221 }
222
223 TERM_PUBLIC void
224 HERC_graphics()
225 {
226     fg_init_herc();
227     graphics_on = TRUE;
228 }
229
230 TERM_PUBLIC void
231 EGAMONO_graphics()
232 {
233     fg_init_egamono();
234     graphics_on = TRUE;
235 }
236
237 TERM_PUBLIC void
238 EGA_graphics()
239 {
240     fg_init_egaecd();
241     graphics_on = TRUE;
242 }
243
244 TERM_PUBLIC void
245 VGA_graphics()
246 {
247     fg_init_vga12();
248     graphics_on = TRUE;
249 }
250
251 TERM_PUBLIC void
252 VGAMONO_graphics()
253 {
254     fg_init_vga11();
255     graphics_on = TRUE;
256 }
257
258 TERM_PUBLIC void
259 SVGA_graphics()
260 {
261     fg_init_vesa6a();
262     graphics_on = TRUE;
263 }
264
265 TERM_PUBLIC void
266 SSVGA_graphics()
267 {
268     fg_init_vesa5();
269     graphics_on = TRUE;
270 }
271
272 TERM_PUBLIC void
273 VGA_linetype(int linetype)
274 {
275     if (linetype >= 13)
276         linetype %= 13;
277     if (linetype < -2)
278         linetype = LT_BLACK;
279     vga_color = fg.color[vgacolor[linetype + 2]];
280 }
281
282 TERM_PUBLIC void
283 VGA_put_text(unsigned int x, unsigned int y, const char *str)
284 {
285     fg_puts(vga_color, FG_MODE_SET, ~0, text_angle, x, y, str, fg.displaybox);
286 }
287
288 TERM_PUBLIC void
289 VGA_move(unsigned int x, unsigned int y)
290 {
291     line_to_draw[FG_X1] = x;
292     line_to_draw[FG_Y1] = y;
293 }
294
295
296 TERM_PUBLIC void
297 VGA_vector(unsigned int x, unsigned int y);
298 {
299     line_to_draw[FG_X2] = x;
300     line_to_draw[FG_Y2] = y;
301     fg_drawline(vga_color, FG_MODE_SET, ~0, FG_LINE_SOLID, line_to_draw);
302     line_to_draw[FG_X1] = x;
303     line_to_draw[FG_Y1] = y;
304 }
305
306 TERM_PUBLIC void
307 VGA_text()
308 {
309     if (graphics_on) {
310         graphics_on = FALSE;
311         fg_flush();
312         pause();
313     }
314     fg_term();
315 }
316
317 TERM_PUBLIC void
318 VGA_reset()
319 {
320     fg_term();
321 }
322
323 #endif /* TERM_BODY */
324
325 #ifdef TERM_TABLE
326
327 TERM_TABLE_START(hercules_driver)
328     "hercules", "IBM PC/Clone with Hercules graphics board",
329     HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
330     HERC_VTIC, HERC_HTIC, options_null, VGA_init, VGA_reset,
331     VGA_text, null_scale, HERC_graphics, VGA_move, VGA_vector,
332     VGA_linetype, VGA_put_text, VGA_text_angle,
333     VGA_justify_text, do_point, do_arrow, set_font_null
334 TERM_TABLE_END(hercules_driver)
335
336 #undef LAST_TERM
337 #define LAST_TERM hercules_driver
338
339 TERM_TABLE_START(egamono_driver)
340     "egamono", "IBM PC/Clone with monochrome EGA graphics board",
341     EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
342     EGA_VTIC, EGA_HTIC, options_null, VGA_init, VGA_reset,
343     VGA_text, null_scale, EGAMONO_graphics, VGA_move, VGA_vector,
344     VGA_linetype, VGA_put_text, VGA_text_angle,
345     VGA_justify_text, do_point, do_arrow, set_font_null
346 TERM_TABLE_END(egamono_driver)
347
348 #undef LAST_TERM
349 #define LAST_TERM egamono_driver
350
351 TERM_TABLE_START(egalib_driver)
352     "egalib", "IBM PC/Clone with color EGA graphics board",
353     EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
354     EGA_VTIC, EGA_HTIC, options_null, VGA_init, VGA_reset,
355     VGA_text, null_scale, EGA_graphics, VGA_move, VGA_vector,
356     VGA_linetype, VGA_put_text, VGA_text_angle,
357     VGA_justify_text, do_point, do_arrow, set_font_null
358 TERM_TABLE_END(egalib_driver)
359
360 #undef LAST_TERM
361 #define LAST_TERM egalib_driver
362
363 TERM_TABLE_START(vgalib_driver)
364     "vgalib", "IBM PC/Clone with VGA graphics board",
365     VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
366     VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
367     VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
368     VGA_linetype, VGA_put_text, VGA_text_angle,
369     VGA_justify_text, do_point, do_arrow, set_font_null
370 TERM_TABLE_END(vgalib_driver)
371
372 #undef LAST_TERM
373 #define LAST_TERM vgalib_driver
374
375 TERM_TABLE_START(vgamono_driver)
376     "vgamono", "IBM PC/Clone with monochrome VGA graphics board",
377     VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
378     VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
379     VGA_text, null_scale, VGAMONO_graphics, VGA_move, VGA_vector,
380     VGA_linetype, VGA_put_text, VGA_text_angle,
381     VGA_justify_text, do_point, do_arrow, set_font_null
382 TERM_TABLE_END(vgamono_driver)
383
384 #undef LAST_TERM
385 #define LAST_TERM vgamono_driver
386
387 TERM_TABLE_START(svgalib_driver)
388     "svgalib", "IBM PC/Clone with VESA Super VGA graphics board",
389     SVGA_XMAX, SVGA_YMAX, SVGA_VCHAR, SVGA_HCHAR,
390     SVGA_VTIC, SVGA_HTIC, options_null, VGA_init, VGA_reset,
391     VGA_text, null_scale, SVGA_graphics, VGA_move, VGA_vector,
392     VGA_linetype, VGA_put_text, VGA_text_angle,
393     VGA_justify_text, do_point, do_arrow, set_font_null
394 TERM_TABLE_END(svgalib_driver)
395
396 #undef LAST_TERM
397 #define LAST_TERM svgalib_driver
398
399 TERM_TABLE_START(ssvgalib_driver)
400     "ssvgalib", "IBM PC/Clone with VESA 256 color 1024 by 768 super VGA",
401     SSVGA_XMAX, SSVGA_YMAX, SSVGA_VCHAR, SSVGA_HCHAR,
402     SSVGA_VTIC, SSVGA_HTIC, options_null, VGA_init, VGA_reset,
403     VGA_text, null_scale, SSVGA_graphics, VGA_move, VGA_vector,
404     VGA_linetype, VGA_put_text, VGA_text_angle,
405     VGA_justify_text, do_point, do_arrow, set_font_null
406 TERM_TABLE_END(ssvgalib_driver)
407
408 #undef LAST_TERM
409 #define LAST_TERM ssvgalib_driver
410
411 #endif /* TERM_TABLE */
412 #endif /* TERM_PROTO_ONLY */
413
414
415 #ifdef TERM_HELP
416 START_HELP(hercules)
417 "1 hercules",
418 "?commands set terminal hercules",
419 "?set terminal hercules",
420 "?set term hercules",
421 "?terminal hercules",
422 "?term hercules",
423 "?hercules",
424 "?commands set terminal egalib",
425 "?set terminal egalib",
426 "?set term egalib",
427 "?terminal egalib",
428 "?term egalib",
429 "?egalib",
430 "?commands set terminal egamono",
431 "?set terminal egamono",
432 "?set term egamono",
433 "?terminal egamono",
434 "?term egamono",
435 "?egamono",
436 "?commands set terminal vgalib",
437 "?set terminal vgalib",
438 "?set term vgalib",
439 "?terminal vgalib",
440 "?term vgalib",
441 "?vgalib",
442 "?commands set terminal vgamono",
443 "?set terminal vgamono",
444 "?set term vgamono",
445 "?terminal vgamono",
446 "?term vgamono",
447 "?vgamono",
448 "?commands set terminal svgalib",
449 "?set terminal svgalib",
450 "?set term svgalib",
451 "?terminal svgalib",
452 "?term svgalib",
453 "?svgalib",
454 "?commands set terminal ssvgalib",
455 "?set terminal ssvgalib",
456 "?set term ssvgalib",
457 "?terminal ssvgalib",
458 "?term ssvgalib",
459 "?ssvgalib",
460 " These drivers supports PC monitors with autodetected graphics boards.  They",
461 " can be used only when compiled with Zortech C/C++.  None have options."
462 END_HELP(hercules)
463 #endif /* TERM_HELP */