File: hppj.trm

package info (click to toggle)
gnuplot 3.5beta6.340-5
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 4,792 kB
  • ctags: 4,205
  • sloc: ansic: 41,878; asm: 539; makefile: 498; objc: 379; csh: 297; sh: 277; pascal: 194; perl: 138; lisp: 88
file content (260 lines) | stat: -rw-r--r-- 7,459 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/*
 * $Id: hppj.trm,v 1.11 1996/12/08 13:11:25 drd Exp $
 *
 */

/* GNUPLOT - hppj.trm */
/*
 * Copyright (C) 1990   
 *
 * Permission to use, copy, and distribute this software and its
 * documentation for any purpose with or without fee is hereby granted, 
 * provided that the above copyright notice appear in all copies and 
 * that both that copyright notice and this permission notice appear 
 * in supporting documentation.
 *
 * Permission to modify the software is granted, but not the right to
 * distribute the modified code.  Modifications are to be distributed 
 * as patches to released version.
 *  
 * This software  is provided "as is" without express or implied warranty.
 * 
 * This file is included by ../term.c.
 *
 * This terminal driver supports:
 *  hppj
 *
 * AUTHORS
 *  Dan Merget (danm@sr.hp.com)
 *
 * This file was based on the hpljii file by:
 *  John Engels
 *  Russell Lang
 *  Maurice Castro
 *
 * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
 * 
 */

/* The following HP laserjet series II driver uses generic bit mapped graphics
 * routines from bitmap.c to build up a bit map in memory.
 */

/*
 * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
 */

#ifndef GOT_DRIVER_H
#include "driver.h"
#endif

#ifdef TERM_REGISTER
register_term(hppj)
#endif

#ifdef TERM_PROTO
TERM_PUBLIC void HPPJoptions __PROTO((void));
TERM_PUBLIC void HPPJinit __PROTO((void));
TERM_PUBLIC void HPPJreset __PROTO((void));
TERM_PUBLIC void HPPJgraphics __PROTO((void));
TERM_PUBLIC void HPPJtext __PROTO((void));
TERM_PUBLIC void HPPJlinetype __PROTO((int linetype));
#define HPPJmove       b_move
#define HPPJvector     b_vector
#define HPPJtext_angle b_text_angle
#define HPPJput_text   b_put_text

/* We define 3 different font sizes: 5x9, 9x17, and 13x25 */

#define HPPJ_DPI 180   /* dots per inch */
#define HPPJ_PLANES 3  /* color planes */
#define HPPJ_COLORS (1 << HPPJ_PLANES)
/* make XMAX and YMAX a multiple of 8 */
#define HPPJ_XMAX (8*(unsigned int)(9.5 * HPPJ_DPI / 8.0 + 0.9))
#define HPPJ_YMAX (8 * HPPJ_DPI)

/* default values for term_tbl */
#define HPPJ_9x17_VCHAR FNT9X17_VCHAR
#define HPPJ_9x17_HCHAR FNT9X17_HCHAR
#define HPPJ_9x17_VTIC (FNT9X17_VCHAR / 2)
#define HPPJ_9x17_HTIC (FNT9X17_HCHAR / 2)
#endif /* TERM_PROTO */

#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY
static int hppj_font = FNT9X17;

TERM_PUBLIC void HPPJoptions()
{
    char opt[10];
#define HPPJERROR "expecting font size FNT5X9, FNT9X17, or FNT13X25"

    term_options[0]='\0'; /* default to empty string and 9x17 font */
    hppj_font = FNT9X17;  /* in case of error or empty options     */

    if ( !END_OF_COMMAND ) {
        if ( token[c_token].length > 8 ) {
            int_error(HPPJERROR, c_token);
       }

        capture(opt, c_token, c_token, 4);
        if ( !strcmp(opt, "FNT5X9") ) {
            hppj_font = FNT5X9;
            strcpy(term_options, "FNT5X9");
	} else if ( !strcmp(opt, "FNT9X17") ) {
   	    hppj_font = FNT9X17;
            strcpy(term_options, "FNT9X17");
	} else if ( !strcmp(opt, "FNT13X25") ) {
   	    hppj_font = FNT13X25;
            strcpy(term_options, "FNT13X25");
	} else {
	    int_error(HPPJERROR, c_token);
	}
	c_token++;
    }
}


TERM_PUBLIC void HPPJinit()
{
}


TERM_PUBLIC void HPPJreset()
{
#ifdef vms
    fflush_binary();
#endif /* vms */
}


TERM_PUBLIC void HPPJgraphics()
{
    switch ( hppj_font ) {
      case FNT5X9 :
	term->v_char = FNT5X9_VCHAR;
	term->h_char = FNT5X9_HCHAR;
	term->v_tic = FNT5X9_VCHAR / 2;
	term->h_tic = FNT5X9_HCHAR / 2;
	break;
      case FNT9X17 :
	term->v_char = FNT9X17_VCHAR;
	term->h_char = FNT9X17_HCHAR;
	term->v_tic = FNT9X17_VCHAR / 2;
	term->h_tic = FNT9X17_HCHAR / 2;
	break;
      case FNT13X25 :
	term->v_char = FNT13X25_VCHAR;
	term->h_char = FNT13X25_HCHAR;
	term->v_tic = FNT13X25_VCHAR / 2;
	term->h_tic = FNT13X25_HCHAR / 2;
	break;
    }
    b_charsize(hppj_font);

    b_makebitmap(HPPJ_XMAX, HPPJ_YMAX, HPPJ_PLANES);
}


TERM_PUBLIC void HPPJtext()
{
    int x, plane, y;	/* loop indexes */
    int minRow, maxRow;	/* loop bounds */
    int numBytes;	/* Number of run-length coded bytes to output */
    int numReps;	/* Number of times the current byte is repeated */

    fprintf(outfile, "\033E\033*t%dR\033*r%dS", HPPJ_DPI, HPPJ_YMAX);
    fprintf(outfile, "\033*b0X\033*b0Y\033*r%dU", HPPJ_PLANES);
    fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI", 90, 88, 85, 0);
    fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI", 53,  8, 14, 1);
    fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI",  3, 26, 22, 2);
    fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI",  4,  4, 29, 3);
    fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI", 53,  5, 25, 4);
    fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI",  2, 22, 64, 5);
    fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI", 89, 83, 13, 6);
    fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI",  4,  4,  6, 7);
    fprintf(outfile, "\033*b1M\033*r1A");

    /* dump bitmap in raster mode using run-length encoding */
    for ( x = HPPJ_XMAX - 1 ; x >= 0 ; --x ) {
        for ( plane = 0 ; plane < HPPJ_PLANES ; plane++ ) {
            minRow = b_psize * plane;
            maxRow = b_psize * plane + b_psize - 1;

            /* Print column header */
            numBytes = 0;
            for ( y = maxRow ; y >= minRow ; --y ) {
                if ( y == minRow || *((*b_p)[y]+x) != *((*b_p)[y-1]+x) ) {
                    numBytes += 2;
                }
            }
            fprintf(outfile, "\033*b%d", numBytes);
            (void) fputc((char)(plane < HPPJ_PLANES - 1 ? 'V' : 'W'), outfile);

            /* Print remainder of column */
            numReps = 0;
            for ( y = maxRow ; y >= minRow ; --y ) {
                if ( y == minRow || *((*b_p)[y]+x) != *((*b_p)[y-1]+x) ) {
                    (void) fputc( (char)(numReps), outfile );
                    (void) fputc( (char)(*((*b_p)[y]+x)), outfile );
                    numReps = 0;
                } else {
                    numReps++;
                }
            }
        }
    }
    fprintf(outfile, "\033*r1B\033E");

    b_freebitmap();
}


TERM_PUBLIC void HPPJlinetype(linetype)
    int linetype;
{
    if ( linetype >= 0 ) {
        b_setlinetype(0);
        b_setvalue((linetype % (HPPJ_COLORS-1)) + 1);
    } else {
        b_setlinetype(linetype + 2);
        b_setvalue(HPPJ_COLORS - 1);
    }
}

#endif /* TERM_BODY */

#ifdef TERM_TABLE

TERM_TABLE_START(hppj_driver)
    "hppj", "HP PaintJet and HP3630 [FNT5X9 FNT9X17 FNT13X25]",
       HPPJ_XMAX, HPPJ_YMAX,
       HPPJ_9x17_VCHAR, HPPJ_9x17_HCHAR, HPPJ_9x17_VTIC, HPPJ_9x17_HTIC,
       HPPJoptions, HPPJinit, HPPJreset, HPPJtext, null_scale, HPPJgraphics,
       HPPJmove, HPPJvector, HPPJlinetype, HPPJput_text, HPPJtext_angle,
       null_justify_text, do_point, do_arrow, set_font_null, 0, TERM_BINARY
TERM_TABLE_END(hppj_driver)

#undef LAST_TERM
#define LAST_TERM hppj_driver

#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */

#ifdef TERM_HELP
START_HELP(hppj)
"1 hppj",
"?set terminal hppj",
"?set term hppj",
"?terminal hppj",
"?term hppj",
"?hppj",
" The `hppj` terminal driver supports the HP PaintJet and HP3630 printers.  The",
" only option is the choice of font.",
"",
" Syntax:",
"       set terminal hppj {FNT5X9 | FNT9X17 | FNT13X25}",
"",
" with the middle-sized font (FNT9X17) being the default."
END_HELP(hppj)
#endif