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

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

1.1       maekawa     1: /*
1.1.1.3 ! ohara       2:  * $Id: regis.trm,v 1.6.2.1 2002/01/26 19:05:34 lhecking Exp $
1.1       maekawa     3:  */
                      4:
                      5: /* GNUPLOT - regis.trm */
                      6:
                      7: /*[
                      8:  * Copyright 1990 - 1993, 1998
                      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:  *  REGIS devices
                     42:  *
                     43:  * AUTHORS
                     44:  *  Colin Kelley, Thomas Williams
                     45:  *
                     46:  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
                     47:  *
                     48:  */
                     49:
                     50: #include "driver.h"
                     51:
                     52: #ifdef TERM_REGISTER
                     53: register_term(regis)
                     54: #endif
                     55:
                     56:
                     57: #ifdef TERM_PROTO
1.1.1.3 ! ohara      58: TERM_PUBLIC void REGIS_init __PROTO((void));
        !            59: TERM_PUBLIC void REGIS_graphics __PROTO((void));
        !            60: TERM_PUBLIC void REGIS_init __PROTO((void));
        !            61: TERM_PUBLIC void REGIS_graphics __PROTO((void));
        !            62: TERM_PUBLIC void REGIS_text __PROTO((void));
        !            63: TERM_PUBLIC void REGIS_linetype __PROTO((int linetype));
        !            64: TERM_PUBLIC void REGIS_move __PROTO((unsigned int x, unsigned int y));
        !            65: TERM_PUBLIC void REGIS_vector __PROTO((unsigned int x, unsigned int y));
        !            66: TERM_PUBLIC void REGIS_put_text __PROTO((unsigned int x, unsigned int y, char *str));
        !            67: TERM_PUBLIC int REGIS_text_angle __PROTO((int ang));
        !            68: TERM_PUBLIC void REGIS_reset __PROTO((void));
        !            69: TERM_PUBLIC void REGIS_options __PROTO((void));
1.1       maekawa    70:
                     71: #define REGISXMAX 800
                     72: #define REGISYMAX 440
                     73:
                     74: #define REGISXLAST (REGISXMAX - 1)
                     75: #define REGISYLAST (REGISYMAX - 1)
                     76:
                     77: #define REGISVCHAR             20
                     78: #define REGISHCHAR             9
                     79: #define REGISVTIC              8
                     80: #define REGISHTIC              6
                     81:
                     82: /* is defined in plot.h
                     83: #define TRUE 1
                     84: #define FALSE 0
                     85: */
                     86: #endif
                     87:
                     88:
                     89:
                     90: #ifndef TERM_PROTO_ONLY
                     91: #ifdef TERM_BODY
                     92:
                     93: static int REGIS16color = FALSE;
                     94:
                     95: static int REGISang = 0;
                     96:
1.1.1.3 ! ohara      97: TERM_PUBLIC void
        !            98: REGIS_init()
1.1       maekawa    99: {
                    100:     fputs("\033[r\033[24;1H", gpoutfile);
                    101:     /*     1     2
                    102:      * 1. reset scrolling region
                    103:      * 2. locate cursor on bottom line
                    104:      */
                    105: }
                    106:
                    107:
                    108: /* thanks to calmasd!dko (Dan O'Neill) for adding S(E) for vt125s */
1.1.1.3 ! ohara     109: TERM_PUBLIC void
        !           110: REGIS_graphics()
1.1       maekawa   111: {
                    112:     fputs("\033[2J\033P1pS(C0)S(E)T(A0)\n", gpoutfile);
                    113:     /*     1      2      3    4   5
                    114:      * 1. clear screen
                    115:      * 2. enter ReGIS graphics
                    116:      * 3. turn off graphics diamond cursor
                    117:      * 4. clear graphics screen
                    118:      * 5. character set option.
                    119:      */
1.1.1.3 ! ohara     120:     (void) REGIS_text_angle(0);        /* select text size and angle */
1.1       maekawa   121: }
                    122:
                    123:
1.1.1.3 ! ohara     124: TERM_PUBLIC void
        !           125: REGIS_text()
1.1       maekawa   126: {
                    127:     fputs("\033\\\033[24;1H", gpoutfile);
                    128:     /*     1    2
                    129:      * 1. Leave ReGIS graphics mode
                    130:      * 2. locate cursor on last line of screen
                    131:      */
                    132: }
                    133:
                    134:
1.1.1.3 ! ohara     135: TERM_PUBLIC void
        !           136: REGIS_linetype(linetype)
1.1       maekawa   137: int linetype;
                    138: {
                    139:     /* This will change color in order G,R,B,G-dot,R-dot,B-dot */
                    140:
                    141:     static int in_16_map[15 + 2] = { 7, 7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
                    142:     static int lt_16_map[15 + 2] = { 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
                    143:     static int in_map[9 + 2] = { 2, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1 };
                    144:     static int lt_map[9 + 2] = { 1, 4, 1, 1, 1, 4, 4, 4, 6, 6, 6 };
                    145:
                    146:     if (!REGIS16color) {
                    147:        if (linetype >= 9)
                    148:            linetype %= 9;
                    149:        fprintf(gpoutfile, "W(I%d)\n", in_map[linetype + 2]);
                    150:        fprintf(gpoutfile, "W(P%d)\n", lt_map[linetype + 2]);
                    151:     } else {
                    152:        if (linetype >= 15)
                    153:            linetype %= 15;
                    154:        fprintf(gpoutfile, "W(I%d)\n", in_16_map[linetype + 2]);
                    155:        fprintf(gpoutfile, "W(P%d)\n", lt_16_map[linetype + 2]);
                    156:     }
                    157: }
                    158:
                    159:
                    160:
                    161: /*
                    162: ** The \n was added in the functions below (and above) in order to not cause
                    163: ** a buffer overflow in devices that can't deal with long line lengths.
                    164: ** The DEC vt-340 doesn't need this, but Reflection 4, a vt-340 emulator
                    165: ** for PC's under MS-DOS and Microsoft Windows does need it.
                    166: ** Also needed for DECterm, a vt-340 emulator for use with Motif 1.0
                    167: ** on Open/VMS.
                    168: ** NGB 9/13/93
                    169: */
                    170:
1.1.1.3 ! ohara     171: TERM_PUBLIC void
        !           172: REGIS_move(x, y)
1.1       maekawa   173: unsigned int x, y;
                    174: {
                    175:     fprintf(gpoutfile, "P[%d,%d]\n", x, REGISYLAST - y);
                    176: }
                    177:
                    178:
1.1.1.3 ! ohara     179: TERM_PUBLIC void
        !           180: REGIS_vector(x, y)
1.1       maekawa   181: unsigned int x, y;
                    182: {
                    183:     fprintf(gpoutfile, "v[]v[%d,%d]\n", x, REGISYLAST - y);
                    184:     /* the initial v[] is needed to get the first pixel plotted */
                    185: }
                    186:
                    187:
                    188: /* put_text and text_angle by rjl */
1.1.1.3 ! ohara     189: TERM_PUBLIC void
        !           190: REGIS_put_text(x, y, str)
1.1       maekawa   191: unsigned int x, y;
                    192: char *str;
                    193: {
                    194:     if (REGISang == 1)
1.1.1.3 ! ohara     195:        REGIS_move(x - REGISVCHAR / 2 - 1, y);
1.1       maekawa   196:     else
1.1.1.3 ! ohara     197:        REGIS_move(x, y + REGISVCHAR / 2 - 1);
1.1       maekawa   198:     (void) putc('T', gpoutfile);
                    199:     (void) putc('\'', gpoutfile);
                    200:     while (*str) {
                    201:        (void) putc(*str, gpoutfile);
                    202:        if (*str == '\'')
                    203:            (void) putc('\'', gpoutfile);       /* send out another one */
                    204:        str++;
                    205:     }
                    206:     (void) putc('\'', gpoutfile);
                    207:     (void) putc('\n', gpoutfile);
                    208: }
                    209:
                    210:
1.1.1.3 ! ohara     211: TERM_PUBLIC int
        !           212: REGIS_text_angle(ang)
1.1       maekawa   213: int ang;
                    214: {
                    215:     REGISang = ang;
                    216:     if (ang == 1)
                    217:        fputs("T(D90,S1)\n", gpoutfile);
                    218:     else
                    219:        fputs("T(D0,S1)\n", gpoutfile);
                    220:     return TRUE;
                    221: }
                    222:
                    223:
1.1.1.3 ! ohara     224: TERM_PUBLIC void
        !           225: REGIS_reset()
1.1       maekawa   226: {
                    227:     fputs("\033[2J\033[24;1H", gpoutfile);
                    228: }
                    229:
1.1.1.3 ! ohara     230: TERM_PUBLIC void
        !           231: REGIS_options()
1.1       maekawa   232: {
                    233:     int i = 0;
                    234:     struct value a;
                    235:
                    236:     if (!END_OF_COMMAND) {
                    237:        i = (int) real(const_express(&a));
                    238:     }
                    239:     REGIS16color = (i == 16);
                    240:     sprintf(term_options, "%s", REGIS16color ? "16" : "4");
                    241: }
                    242:
                    243: #endif
                    244:
                    245:
                    246: #ifdef TERM_TABLE
                    247: TERM_TABLE_START(regis_driver)
                    248:     "regis", "REGIS graphics language",
                    249:     REGISXMAX, REGISYMAX, REGISVCHAR, REGISHCHAR,
1.1.1.3 ! ohara     250:     REGISVTIC, REGISHTIC, REGIS_options, REGIS_init, REGIS_reset,
        !           251:     REGIS_text, null_scale, REGIS_graphics, REGIS_move, REGIS_vector,
        !           252:     REGIS_linetype, REGIS_put_text, REGIS_text_angle,
1.1       maekawa   253:     null_justify_text, line_and_point, do_arrow, set_font_null
                    254: TERM_TABLE_END(regis_driver)
                    255:
                    256: #undef LAST_TERM
                    257: #define LAST_TERM regis_driver
                    258: #endif
                    259: #endif /* TERM_PROTO_ONLY */
                    260:
                    261: #ifdef TERM_HELP
                    262: START_HELP(regis)
                    263: "1 regis",
                    264: "?commands set terminal regis",
                    265: "?set terminal regis",
                    266: "?set term regis",
                    267: "?terminal regis",
                    268: "?term regis",
                    269: "?regis",
                    270: " The `regis` terminal device generates output in the REGIS graphics language.",
                    271: " It has the option of using 4 (the default) or 16 colors.",
                    272: "",
                    273: " Syntax:",
                    274: "       set terminal regis {4 | 16}"
                    275: END_HELP(regis)
                    276: #endif

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