Annotation of OpenXM_contrib/gnuplot/term/cgi.trm, Revision 1.1
1.1 ! maekawa 1: /*
! 2: * $Id: cgi.trm,v 1.12 1998/04/14 00:17:32 drd Exp $
! 3: *
! 4: */
! 5:
! 6: /* GNUPLOT - cgi.trm */
! 7: /*
! 8: * Copyright (C) 1990 - 1993 Ronald Florence
! 9: *
! 10: * Permission is hereby granted for unlimited non-commercial
! 11: * use of this code, on condition that the copyright
! 12: * notices are left intact and any modifications to the source
! 13: * code are noted as such. No warranty of any kind is implied
! 14: * or granted for this material.
! 15: *
! 16: * This file is included by ../term.h.
! 17: *
! 18: * This terminal driver supports SCO CGI drivers
! 19: *
! 20: * AUTHOR
! 21: * Ronald Florence <ron@mlfarm.com>
! 22: */
! 23:
! 24: /*
! 25: * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
! 26: */
! 27:
! 28: #include "driver.h"
! 29:
! 30: #ifdef TERM_REGISTER
! 31: register_term(cgi)
! 32: register_term(hcgi)
! 33: #endif
! 34:
! 35: #ifdef TERM_PROTO
! 36: TERM_PUBLIC void CGI_init __PROTO((void));
! 37: TERM_PUBLIC void HCGI_init __PROTO((void));
! 38: TERM_PUBLIC void CGI_graphics __PROTO((void));
! 39: TERM_PUBLIC void CGI_text __PROTO((void));
! 40: TERM_PUBLIC void CGI_reset __PROTO((void));
! 41: TERM_PUBLIC void CGI_move __PROTO((unsigned int x, unsigned int y));
! 42: TERM_PUBLIC void CGI_vector __PROTO((unsigned int x, unsigned int y));
! 43: TERM_PUBLIC void CGI_linetype __PROTO((int linetype));
! 44: TERM_PUBLIC void CGI_put_text __PROTO((unsigned int x, unsigned int y, char *str));
! 45: TERM_PUBLIC int CGI_text_angle __PROTO((int ang));
! 46: TERM_PUBLIC int CGI_justify_text __PROTO((enum JUSTIFY mode));
! 47: TERM_PUBLIC void CGI_point __PROTO((unsigned int x, unsigned int y, int num));
! 48: #define CGI_XMAX 32767
! 49: #define CGI_YMAX 32767
! 50: #define CGI_VTIC (CGI_YMAX / 75)
! 51: #define CGI_HTIC term->h_tic
! 52: #define CGI_VCHAR term->v_char
! 53: #define CGI_HCHAR term->h_char
! 54: #endif
! 55:
! 56: #ifndef TERM_PROTO_ONLY
! 57: #ifdef TERM_BODY
! 58:
! 59: #ifdef VGA_MONO
! 60: static short rgb[16][3] =
! 61: {
! 62: 0, 0, 0, /* Black */
! 63: 1000, 1000, 1000, /* White */
! 64: 800, 800, 0, /* Red */
! 65: 0, 600, 0, /* Green */
! 66: 0, 800, 800, /* Blue */
! 67: 1000, 1000, 400, /* Yellow */
! 68: 0, 600, 600, /* Cyan */
! 69: 600, 600, 600, /* Magenta */
! 70: 800, 800, 0, /* Brown */
! 71: 600, 600, 600, /* Lt. Grey */
! 72: 400, 600, 400, /* Dark Grey */
! 73: 400, 600, 1000, /* Lt. Blue */
! 74: 400, 1000, 400, /* Lt Green */
! 75: 400, 1000, 1000, /* Lt Cyan */
! 76: 1000, 600, 400, /* Lt Red */
! 77: 600, 600, 1000 /* Lt Magenta */
! 78: };
! 79: #endif
! 80:
! 81: #define CRT (gout[45] == 0)
! 82: #define CGICOLORS gout[13]
! 83: #define CGILINES gout[6]
! 84: #define CGIROTATES gout[36]
! 85: #define CGITEXTALIGN gout[48]
! 86:
! 87: static short gout[66];
! 88: static short cgidev;
! 89: static short vect[4];
! 90: static short gin[19] =
! 91: {
! 92: 0, /* default aspect ratio */
! 93: 1, /* solid line */
! 94: 1, /* line color */
! 95: 1, /* marker type . */
! 96: 1, /* marker color */
! 97: 1, /* graphics text font */
! 98: 1, /* graphics text color */
! 99: 0, /* fill interior style */
! 100: 0, /* fill style index */
! 101: 1, /* fill color index */
! 102: 1 /* prompt for paper changes */
! 103: };
! 104:
! 105: char *cgidriver, *getenv();
! 106:
! 107:
! 108: TERM_PUBLIC void CGI_init()
! 109: {
! 110: if (getenv(cgidriver = "CGIDISP") == NULL)
! 111: HCGI_init();
! 112: }
! 113:
! 114:
! 115: TERM_PUBLIC void HCGI_init()
! 116: {
! 117: if (getenv(cgidriver = "CGIPRNT") == NULL)
! 118: int_error("no CGI driver", NO_CARET);
! 119: }
! 120:
! 121:
! 122: TERM_PUBLIC void CGI_graphics()
! 123: {
! 124: int i, aspect;
! 125: char *s;
! 126: short font_cap[9];
! 127: char err_str[80];
! 128:
! 129: if ((s = getenv("ASPECT")) != NULL && (aspect = atoi(s)) >= 0 && aspect <= 3)
! 130: gin[0] = aspect;
! 131: for (i = 0; cgidriver[i]; i++)
! 132: gin[11 + i] = cgidriver[i];
! 133: gin[18] = ' ';
! 134:
! 135: if (v_opnwk(gin, &cgidev, gout) < 0) {
! 136: sprintf(err_str, "CGI error %d opening %s", -vq_error(), cgidriver);
! 137: int_error(err_str, NO_CARET);
! 138: }
! 139: vqt_representation(cgidev, 9, font_cap);
! 140: CGI_VCHAR = font_cap[8] * 3 / 2;
! 141: CGI_HCHAR = font_cap[7];
! 142: CGI_HTIC = CGI_VTIC * ((double) gout[1] / (double) gout[4]) /
! 143: ((double) gout[0] / (double) gout[3]);
! 144: #ifdef VGA_MONO
! 145: if (CGICOLORS > 2)
! 146: vsc_table(cgidev, 0, CGICOLORS, rgb);
! 147: #endif
! 148: }
! 149:
! 150:
! 151: TERM_PUBLIC void CGI_text()
! 152: {
! 153: if (CRT) {
! 154: short ptin[2];
! 155: char strin[2];
! 156:
! 157: ptin[0] = 0;
! 158: ptin[1] = 0;
! 159: vrq_string(cgidev, 1, 0, ptin, strin);
! 160: }
! 161: v_clswk(cgidev);
! 162: }
! 163:
! 164:
! 165: TERM_PUBLIC void CGI_reset()
! 166: {
! 167: }
! 168:
! 169:
! 170: TERM_PUBLIC void CGI_move(x, y)
! 171: unsigned int x, y;
! 172: {
! 173: vect[0] = x;
! 174: vect[1] = y;
! 175: }
! 176:
! 177: TERM_PUBLIC void CGI_vector(x, y)
! 178: unsigned int x, y;
! 179: {
! 180: vect[2] = x;
! 181: vect[3] = y;
! 182: v_pline(cgidev, 2, vect);
! 183: vect[0] = x;
! 184: vect[1] = y;
! 185: }
! 186:
! 187:
! 188: TERM_PUBLIC void CGI_linetype(linetype)
! 189: int linetype;
! 190: {
! 191: short lcolor;
! 192:
! 193: if (CGICOLORS > 2) {
! 194: lcolor = (linetype + 2) % CGICOLORS + 1;
! 195: vsl_color(cgidev, lcolor);
! 196: vsm_color(cgidev, lcolor);
! 197: }
! 198: vsl_type(cgidev, (linetype < 1) ? 1 : (linetype % CGILINES) + 1);
! 199: }
! 200:
! 201:
! 202: TERM_PUBLIC void CGI_put_text(x, y, str)
! 203: unsigned int x, y;
! 204: char *str;
! 205: {
! 206: v_gtext(cgidev, (short) x, (short) y, str);
! 207: }
! 208:
! 209:
! 210: TERM_PUBLIC CGI_text_angle(ang)
! 211: int ang;
! 212: {
! 213: if (!CGIROTATES)
! 214: return FALSE;
! 215: /* angles are 1/10 degree ccw */
! 216: vst_rotation(cgidev, (ang) ? 900 : 0);
! 217: return TRUE;
! 218: }
! 219:
! 220:
! 221: TERM_PUBLIC CGI_justify_text(mode)
! 222: enum JUSTIFY mode;
! 223: {
! 224: short hor_in, hor_out, vert_out;
! 225:
! 226: if (!CGITEXTALIGN)
! 227: return FALSE;
! 228:
! 229: switch (mode) {
! 230: case LEFT:
! 231: hor_in = 0;
! 232: break;
! 233: case CENTRE:
! 234: hor_in = 1;
! 235: break;
! 236: case RIGHT:
! 237: hor_in = 2;
! 238: break;
! 239: }
! 240: vst_alignment(cgidev, hor_in, 1, &hor_out, &vert_out);
! 241: return TRUE;
! 242: }
! 243:
! 244:
! 245: #define POINT_TYPES 6
! 246:
! 247: TERM_PUBLIC void CGI_point(x, y, num)
! 248: unsigned int x, y;
! 249: int num;
! 250: {
! 251: short point[2];
! 252: static short cgimarker[POINT_TYPES] = { 1, 2, 6, 4, 5, 3 };
! 253: /* . + <> [] X * */
! 254: if (num < 0) {
! 255: CGI_move(x, y);
! 256: CGI_vector(x, y);
! 257: } else {
! 258: vsm_type(cgidev, cgimarker[num % POINT_TYPES]);
! 259: point[0] = x;
! 260: point[1] = y;
! 261: v_pmarker(cgidev, 1, point);
! 262: }
! 263: }
! 264:
! 265: #endif /* TERM_BODY */
! 266:
! 267: #ifdef TERM_TABLE
! 268:
! 269: TERM_TABLE_START(cgi_driver)
! 270: "cgi", "SCO CGI drivers (requires CGIDISP or CGIPRNT env variable)",
! 271: CGI_XMAX, CGI_YMAX, 0, 0,
! 272: CGI_VTIC, 0, options_null, CGI_init, CGI_reset,
! 273: CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector,
! 274: CGI_linetype, CGI_put_text, CGI_text_angle,
! 275: CGI_justify_text, CGI_point, do_arrow, set_font_null
! 276: TERM_TABLE_END(cgi_driver)
! 277:
! 278: #undef LAST_TERM
! 279: #define LAST_TERM cgi_driver
! 280:
! 281: TERM_TABLE_START(hcgi_driver)
! 282: "hcgi", "SCO CGI drivers (hardcopy, requires CGIPRNT env variable)",
! 283: CGI_XMAX, CGI_YMAX, 0, 0,
! 284: CGI_VTIC, 0, options_null, HCGI_init, CGI_reset,
! 285: CGI_text, null_scale, CGI_graphics, CGI_move, CGI_vector,
! 286: CGI_linetype, CGI_put_text, CGI_text_angle,
! 287: CGI_justify_text, CGI_point, do_arrow, set_font_null
! 288: TERM_TABLE_END(hcgi_driver)
! 289:
! 290: #undef LAST_TERM
! 291: #define LAST_TERM hcgi_driver
! 292:
! 293: #endif /* TERM_TABLE */
! 294: #endif /* TERM_PROTO_ONLY */
! 295:
! 296: #ifdef TERM_HELP
! 297: START_HELP(cgi)
! 298: "1 cgi",
! 299: "?commands set terminal cgi",
! 300: "?set terminal cgi",
! 301: "?set term cgi",
! 302: "?terminal cgi",
! 303: "?term cgi",
! 304: "?cgi",
! 305: "?commands set terminal hcgi",
! 306: "?set terminal hcgi",
! 307: "?set term hcgi",
! 308: "?terminal hcgi",
! 309: "?term hcgi",
! 310: "?hcgi",
! 311: " The `cgi` and `hcgi` terminal drivers support SCO CGI drivers. `hcgi` is for",
! 312: " printers; the environment variable CGIPRNT must be set. `cgi` may be used",
! 313: " for either a display or hardcopy; if the environment variable CGIDISP is set,",
! 314: " then that display is used. Otherwise CGIPRNT is used.",
! 315: "",
! 316: " These terminals have no options."
! 317: END_HELP(cgi)
! 318: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>