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

Annotation of OpenXM_contrib/gnuplot/term/hppj.trm, Revision 1.1

1.1     ! maekawa     1: /*
        !             2:  * $Id: hppj.trm,v 1.13 1998/04/14 00:17:51 drd Exp $
        !             3:  *
        !             4:  */
        !             5:
        !             6: /* GNUPLOT - hppj.trm */
        !             7:
        !             8: /*[
        !             9:  * Copyright 1990 - 1993, 1998
        !            10:  *
        !            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.
        !            33:  *
        !            34:  * This software is provided "as is" without express or implied warranty
        !            35:  * to the extent permitted by applicable law.
        !            36: ]*/
        !            37:
        !            38: /*
        !            39:  * This file is included by ../term.c.
        !            40:  *
        !            41:  * This terminal driver supports:
        !            42:  *  hppj
        !            43:  *
        !            44:  * AUTHORS
        !            45:  *  Dan Merget (danm@sr.hp.com)
        !            46:  *
        !            47:  * This file was based on the hpljii file by:
        !            48:  *  John Engels
        !            49:  *  Russell Lang
        !            50:  *  Maurice Castro
        !            51:  *
        !            52:  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
        !            53:  *
        !            54:  */
        !            55:
        !            56: /* The following HP laserjet series II driver uses generic bit mapped graphics
        !            57:  * routines from bitmap.c to build up a bit map in memory.
        !            58:  */
        !            59:
        !            60: /*
        !            61:  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
        !            62:  */
        !            63:
        !            64: #include "driver.h"
        !            65:
        !            66: #ifdef TERM_REGISTER
        !            67: register_term(hppj)
        !            68: #endif
        !            69:
        !            70: #ifdef TERM_PROTO
        !            71: TERM_PUBLIC void HPPJoptions __PROTO((void));
        !            72: TERM_PUBLIC void HPPJinit __PROTO((void));
        !            73: TERM_PUBLIC void HPPJreset __PROTO((void));
        !            74: TERM_PUBLIC void HPPJgraphics __PROTO((void));
        !            75: TERM_PUBLIC void HPPJtext __PROTO((void));
        !            76: TERM_PUBLIC void HPPJlinetype __PROTO((int linetype));
        !            77: #define HPPJmove       b_move
        !            78: #define HPPJvector     b_vector
        !            79: #define HPPJtext_angle b_text_angle
        !            80: #define HPPJput_text   b_put_text
        !            81:
        !            82: /* We define 3 different font sizes: 5x9, 9x17, and 13x25 */
        !            83:
        !            84: #define HPPJ_DPI 180           /* dots per inch */
        !            85: #define HPPJ_PLANES 3          /* color planes */
        !            86: #define HPPJ_COLORS (1 << HPPJ_PLANES)
        !            87: /* make XMAX and YMAX a multiple of 8 */
        !            88: #define HPPJ_XMAX (8*(unsigned int)(9.5 * HPPJ_DPI / 8.0 + 0.9))
        !            89: #define HPPJ_YMAX (8 * HPPJ_DPI)
        !            90:
        !            91: /* default values for term_tbl */
        !            92: #define HPPJ_9x17_VCHAR FNT9X17_VCHAR
        !            93: #define HPPJ_9x17_HCHAR FNT9X17_HCHAR
        !            94: #define HPPJ_9x17_VTIC (FNT9X17_VCHAR / 2)
        !            95: #define HPPJ_9x17_HTIC (FNT9X17_HCHAR / 2)
        !            96: #endif /* TERM_PROTO */
        !            97:
        !            98: #ifndef TERM_PROTO_ONLY
        !            99: #ifdef TERM_BODY
        !           100: static int hppj_font = FNT9X17;
        !           101:
        !           102: TERM_PUBLIC void HPPJoptions()
        !           103: {
        !           104:     char opt[10];
        !           105: #define HPPJERROR "expecting font size FNT5X9, FNT9X17, or FNT13X25"
        !           106:
        !           107:     term_options[0] = NUL;     /* default to empty string and 9x17 font */
        !           108:     hppj_font = FNT9X17;       /* in case of error or empty options     */
        !           109:
        !           110:     if (!END_OF_COMMAND) {
        !           111:        if (token[c_token].length > 8) {
        !           112:            int_error(HPPJERROR, c_token);
        !           113:        }
        !           114:        capture(opt, c_token, c_token, /*4 */ 9);       /* HBB 980226 */
        !           115:        if (!strcmp(opt, "FNT5X9")) {
        !           116:            hppj_font = FNT5X9;
        !           117:            strcpy(term_options, "FNT5X9");
        !           118:        } else if (!strcmp(opt, "FNT9X17")) {
        !           119:            hppj_font = FNT9X17;
        !           120:            strcpy(term_options, "FNT9X17");
        !           121:        } else if (!strcmp(opt, "FNT13X25")) {
        !           122:            hppj_font = FNT13X25;
        !           123:            strcpy(term_options, "FNT13X25");
        !           124:        } else {
        !           125:            int_error(HPPJERROR, c_token);
        !           126:        }
        !           127:        c_token++;
        !           128:     }
        !           129: }
        !           130:
        !           131:
        !           132: TERM_PUBLIC void HPPJinit()
        !           133: {
        !           134:     /* HBB 980226: moved this here, from graphics(): only init() may
        !           135:      * change fields of *term ! */
        !           136:     switch (hppj_font) {
        !           137:     case FNT5X9:
        !           138:        term->v_char = FNT5X9_VCHAR;
        !           139:        term->h_char = FNT5X9_HCHAR;
        !           140:        term->v_tic = FNT5X9_VCHAR / 2;
        !           141:        term->h_tic = FNT5X9_HCHAR / 2;
        !           142:        break;
        !           143:     case FNT9X17:
        !           144:        term->v_char = FNT9X17_VCHAR;
        !           145:        term->h_char = FNT9X17_HCHAR;
        !           146:        term->v_tic = FNT9X17_VCHAR / 2;
        !           147:        term->h_tic = FNT9X17_HCHAR / 2;
        !           148:        break;
        !           149:     case FNT13X25:
        !           150:        term->v_char = FNT13X25_VCHAR;
        !           151:        term->h_char = FNT13X25_HCHAR;
        !           152:        term->v_tic = FNT13X25_VCHAR / 2;
        !           153:        term->h_tic = FNT13X25_HCHAR / 2;
        !           154:        break;
        !           155:     }
        !           156: }
        !           157:
        !           158:
        !           159: TERM_PUBLIC void HPPJreset()
        !           160: {
        !           161: #ifdef VMS
        !           162:     fflush_binary();
        !           163: #endif /* VMS */
        !           164: }
        !           165:
        !           166:
        !           167: TERM_PUBLIC void HPPJgraphics()
        !           168: {
        !           169:     /* HBB 980226: move a block of code from here to init() */
        !           170:     b_charsize(hppj_font);
        !           171:
        !           172:     b_makebitmap(HPPJ_XMAX, HPPJ_YMAX, HPPJ_PLANES);
        !           173: }
        !           174:
        !           175:
        !           176: TERM_PUBLIC void HPPJtext()
        !           177: {
        !           178:     int x, plane, y;           /* loop indexes */
        !           179:     int minRow, maxRow;                /* loop bounds */
        !           180:     int numBytes;              /* Number of run-length coded bytes to output */
        !           181:     int numReps;               /* Number of times the current byte is repeated */
        !           182:
        !           183:     fprintf(gpoutfile, "\
        !           184: \033E\033*t%dR\033*r%dS\
        !           185: \033*b0X\033*b0Y\033*r%dU\
        !           186: \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
        !           187: \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
        !           188: \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
        !           189: \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
        !           190: \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
        !           191: \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
        !           192: \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
        !           193: \033*v%dA\033*v%dB\033*v%dC\033*v%dI\
        !           194: \033*b1M\033*r1A",
        !           195:            HPPJ_DPI, HPPJ_YMAX,
        !           196:            HPPJ_PLANES,
        !           197:            90, 88, 85, 0,
        !           198:            53, 8, 14, 1,
        !           199:            3, 26, 22, 2,
        !           200:            4, 4, 29, 3,
        !           201:            53, 5, 25, 4,
        !           202:            2, 22, 64, 5,
        !           203:            89, 83, 13, 6,
        !           204:            4, 4, 6, 7);
        !           205:
        !           206:     /* dump bitmap in raster mode using run-length encoding */
        !           207:     for (x = HPPJ_XMAX - 1; x >= 0; --x) {
        !           208:        for (plane = 0; plane < HPPJ_PLANES; plane++) {
        !           209:            minRow = b_psize * plane;
        !           210:            maxRow = b_psize * plane + b_psize - 1;
        !           211:
        !           212:            /* Print column header */
        !           213:            numBytes = 0;
        !           214:            for (y = maxRow; y >= minRow; --y) {
        !           215:                if (y == minRow || *((*b_p)[y] + x) != *((*b_p)[y - 1] + x)) {
        !           216:                    numBytes += 2;
        !           217:                }
        !           218:            }
        !           219:            fprintf(gpoutfile, "\033*b%d", numBytes);
        !           220:            (void) fputc((char) (plane < HPPJ_PLANES - 1 ? 'V' : 'W'), gpoutfile);
        !           221:
        !           222:            /* Print remainder of column */
        !           223:            numReps = 0;
        !           224:            for (y = maxRow; y >= minRow; --y) {
        !           225:                if (y == minRow || *((*b_p)[y] + x) != *((*b_p)[y - 1] + x)) {
        !           226:                    (void) fputc((char) (numReps), gpoutfile);
        !           227:                    (void) fputc((char) (*((*b_p)[y] + x)), gpoutfile);
        !           228:                    numReps = 0;
        !           229:                } else {
        !           230:                    numReps++;
        !           231:                }
        !           232:            }
        !           233:        }
        !           234:     }
        !           235:     fputs("\033*r1B\033E", gpoutfile);
        !           236:
        !           237:     b_freebitmap();
        !           238: }
        !           239:
        !           240:
        !           241: TERM_PUBLIC void HPPJlinetype(linetype)
        !           242: int linetype;
        !           243: {
        !           244:     if (linetype >= 0) {
        !           245:        b_setlinetype(0);
        !           246:        b_setvalue((linetype % (HPPJ_COLORS - 1)) + 1);
        !           247:     } else {
        !           248:        b_setlinetype(linetype + 2);
        !           249:        b_setvalue(HPPJ_COLORS - 1);
        !           250:     }
        !           251: }
        !           252:
        !           253: #endif /* TERM_BODY */
        !           254:
        !           255: #ifdef TERM_TABLE
        !           256:
        !           257: TERM_TABLE_START(hppj_driver)
        !           258:     "hppj", "HP PaintJet and HP3630 [FNT5X9 FNT9X17 FNT13X25]",
        !           259:     HPPJ_XMAX, HPPJ_YMAX,
        !           260:     HPPJ_9x17_VCHAR, HPPJ_9x17_HCHAR, HPPJ_9x17_VTIC, HPPJ_9x17_HTIC,
        !           261:     HPPJoptions, HPPJinit, HPPJreset, HPPJtext, null_scale, HPPJgraphics,
        !           262:     HPPJmove, HPPJvector, HPPJlinetype, HPPJput_text, HPPJtext_angle,
        !           263:     null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY
        !           264: TERM_TABLE_END(hppj_driver)
        !           265:
        !           266: #undef LAST_TERM
        !           267: #define LAST_TERM hppj_driver
        !           268:
        !           269: #endif /* TERM_TABLE */
        !           270: #endif /* TERM_PROTO_ONLY */
        !           271:
        !           272: #ifdef TERM_HELP
        !           273: START_HELP(hppj)
        !           274: "1 hppj",
        !           275: "?commands set terminal hppj",
        !           276: "?set terminal hppj",
        !           277: "?set term hppj",
        !           278: "?terminal hppj",
        !           279: "?term hppj",
        !           280: "?hppj",
        !           281: " The `hppj` terminal driver supports the HP PaintJet and HP3630 printers.  The",
        !           282: " only option is the choice of font.",
        !           283: "",
        !           284: " Syntax:",
        !           285: "       set terminal hppj {FNT5X9 | FNT9X17 | FNT13X25}",
        !           286: "",
        !           287: " with the middle-sized font (FNT9X17) being the default."
        !           288: END_HELP(hppj)
        !           289: #endif

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