[BACK]Return to cgi.trm CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot / term

Annotation of OpenXM_contrib/gnuplot/term/cgi.trm, Revision 1.1.1.3

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>