1 /* Hello, Emacs, this is -*-C-*-
2 * $Id: cgi.trm,v 1.14 2006/07/21 02:35:45 sfeam Exp $
6 /* GNUPLOT - cgi.trm */
9 * Copyright (C) 1990 - 1993 Ronald Florence
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.
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,
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
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.
34 * This software is provided "as is" without express or implied warranty
35 * to the extent permitted by applicable law.
39 * This file is included by ../term.h.
41 * This terminal driver supports SCO CGI drivers
44 * Ronald Florence <ron@18james.com>
48 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
59 TERM_PUBLIC void CGI_init __PROTO((void));
60 TERM_PUBLIC void HCGI_init __PROTO((void));
61 TERM_PUBLIC void CGI_graphics __PROTO((void));
62 TERM_PUBLIC void CGI_text __PROTO((void));
63 TERM_PUBLIC void CGI_reset __PROTO((void));
64 TERM_PUBLIC void CGI_move __PROTO((unsigned int x, unsigned int y));
65 TERM_PUBLIC void CGI_vector __PROTO((unsigned int x, unsigned int y));
66 TERM_PUBLIC void CGI_linetype __PROTO((int linetype));
67 TERM_PUBLIC void CGI_put_text __PROTO((unsigned int x, unsigned int y, const char *str));
68 TERM_PUBLIC int CGI_text_angle __PROTO((int ang));
69 TERM_PUBLIC int CGI_justify_text __PROTO((enum JUSTIFY mode));
70 TERM_PUBLIC void CGI_point __PROTO((unsigned int x, unsigned int y, int num));
71 #define CGI_XMAX 32767
72 #define CGI_YMAX 32767
73 #define CGI_VTIC (CGI_YMAX / 75)
74 #define CGI_HTIC term->h_tic
75 #define CGI_VCHAR term->v_char
76 #define CGI_HCHAR term->h_char
79 #ifndef TERM_PROTO_ONLY
83 static short rgb[16][3] =
86 1000, 1000, 1000, /* White */
87 800, 800, 0, /* Red */
88 0, 600, 0, /* Green */
89 0, 800, 800, /* Blue */
90 1000, 1000, 400, /* Yellow */
91 0, 600, 600, /* Cyan */
92 600, 600, 600, /* Magenta */
93 800, 800, 0, /* Brown */
94 600, 600, 600, /* Lt. Grey */
95 400, 600, 400, /* Dark Grey */
96 400, 600, 1000, /* Lt. Blue */
97 400, 1000, 400, /* Lt Green */
98 400, 1000, 1000, /* Lt Cyan */
99 1000, 600, 400, /* Lt Red */
100 600, 600, 1000 /* Lt Magenta */
104 #define CRT (gout[45] == 0)
105 #define CGICOLORS gout[13]
106 #define CGILINES gout[6]
107 #define CGIROTATES gout[36]
108 #define CGITEXTALIGN gout[48]
110 static short gout[66];
112 static short vect[4];
113 static short gin[19] =
115 0, /* default aspect ratio */
118 1, /* marker type . */
119 1, /* marker color */
120 1, /* graphics text font */
121 1, /* graphics text color */
122 0, /* fill interior style */
123 0, /* fill style index */
124 1, /* fill color index */
125 1 /* prompt for paper changes */
128 char *cgidriver, *getenv();
134 if (getenv(cgidriver = "CGIDISP") == NULL)
142 if (getenv(cgidriver = "CGIPRNT") == NULL)
143 int_error(NO_CARET, "no CGI driver");
154 if ((s = getenv("ASPECT")) != NULL && (aspect = atoi(s)) >= 0 && aspect <= 3)
156 for (i = 0; cgidriver[i]; i++)
157 gin[11 + i] = cgidriver[i];
160 if (v_opnwk(gin, &cgidev, gout) < 0) {
161 int_error(NO_CARET, "CGI error %d opening %s", -vq_error(), cgidriver);
163 vqt_representation(cgidev, 9, font_cap);
164 CGI_VCHAR = font_cap[8] * 3 / 2;
165 CGI_HCHAR = font_cap[7];
166 CGI_HTIC = CGI_VTIC * ((double) gout[1] / (double) gout[4]) /
167 ((double) gout[0] / (double) gout[3]);
170 vsc_table(cgidev, 0, CGICOLORS, rgb);
184 vrq_string(cgidev, 1, 0, ptin, strin);
197 CGI_move(unsigned int x, unsigned int y)
204 CGI_vector(unsigned int x, unsigned int y)
208 v_pline(cgidev, 2, vect);
215 CGI_linetype(int linetype)
220 lcolor = (linetype + 2) % CGICOLORS + 1;
221 vsl_color(cgidev, lcolor);
222 vsm_color(cgidev, lcolor);
224 vsl_type(cgidev, (linetype < 1) ? 1 : (linetype % CGILINES) + 1);
229 CGI_put_text(unsigned int x, unsigned int y, const char *str)
231 v_gtext(cgidev, (short) x, (short) y, str);
236 CGI_text_angle(int ang)
240 /* angles are 1/10 degree ccw */
241 vst_rotation(cgidev, (ang) ? 900 : 0);
247 CGI_justify_text(enum JUSTIFY mode)
249 short hor_in, hor_out, vert_out;
265 vst_alignment(cgidev, hor_in, 1, &hor_out, &vert_out);
270 #define POINT_TYPES 6
273 CGI_point(unsigned int x, unsigned y, int num)
276 static short cgimarker[POINT_TYPES] = { 1, 2, 6, 4, 5, 3 };
282 vsm_type(cgidev, cgimarker[num % POINT_TYPES]);
285 v_pmarker(cgidev, 1, point);
289 #endif /* TERM_BODY */
293 TERM_TABLE_START(cgi_driver)
294 "cgi", "SCO CGI drivers (requires CGIDISP or CGIPRNT env variable)",
295 CGI_XMAX, CGI_YMAX, 0, 0,
296 CGI_VTIC, 0, options_null, CGI_init, CGI_reset,
297 CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector,
298 CGI_linetype, CGI_put_text, CGI_text_angle,
299 CGI_justify_text, CGI_point, do_arrow, set_font_null
300 TERM_TABLE_END(cgi_driver)
303 #define LAST_TERM cgi_driver
305 TERM_TABLE_START(hcgi_driver)
306 "hcgi", "SCO CGI drivers (hardcopy, requires CGIPRNT env variable)",
307 CGI_XMAX, CGI_YMAX, 0, 0,
308 CGI_VTIC, 0, options_null, HCGI_init, CGI_reset,
309 CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector,
310 CGI_linetype, CGI_put_text, CGI_text_angle,
311 CGI_justify_text, CGI_point, do_arrow, set_font_null
312 TERM_TABLE_END(hcgi_driver)
315 #define LAST_TERM hcgi_driver
317 #endif /* TERM_TABLE */
318 #endif /* TERM_PROTO_ONLY */
323 "?commands set terminal cgi",
329 "?commands set terminal hcgi",
330 "?set terminal hcgi",
335 " The `cgi` and `hcgi` terminal drivers support SCO CGI drivers. `hcgi` is for",
336 " printers; the environment variable CGIPRNT must be set. `cgi` may be used",
337 " for either a display or hardcopy; if the environment variable CGIDISP is set,",
338 " then that display is used. Otherwise CGIPRNT is used.",
340 " These terminals have no options."