-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvtgraph.c
More file actions
417 lines (363 loc) · 8.74 KB
/
Copy pathvtgraph.c
File metadata and controls
417 lines (363 loc) · 8.74 KB
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
/* vtgraph.c
*
* Started off being generic VT320 soft-font definition code; went on to
* to become optimised for GIFView 2.0; and then became all the box-drawing,
* line-drawing, bells'n'whistles code for GIF320.
*
* $Id: vtgraph.c,v 1.4 1992/11/24 16:00:35 jmason Exp $
*
* $Log: vtgraph.c,v $
* Revision 1.4 1992/11/24 16:00:35 jmason
* fixed an embarrassing speeling erorr.
*
* Revision 1.3 1992/11/24 15:57:16 jmason
* added latest sugggestion from Kelly Dean.
*
* Revision 1.2 1992/10/30 16:29:56 jmason
* Added VMS support; fixed bad raster errors.
*
* Revision 1.1 1992/10/30 11:09:43 jmason
* Placed under CVS control.
*
* Revision 3.0 1992/07/04 01:27:16 sboyle
* Initial RCS-aided revision
*
*/
#ifndef DONT_USE_SIGNAL
# include <signal.h>
void reset_bits_on(), reset_bits_off();
# ifdef ON_VAX
/*
* this is a fix provided by Kelly Dean
* <dean%sol.dnet@sirius.cira.colostate.edu>, to get around two signals
* missing from the VAX/VMS signal.h header file.
*/
# define SIGSTOP 17 /* sendable stop signal not from tty */
# define SIGTSTP 18 /* stop signal from tty */
# endif
#endif
#include "vtgraph.h"
#include "gif320.h"
unsigned char display [scrwidth][scrheight][groups][charwidth];
void trap_ignore(), trap_on(), trap_off(), linedraw(), standout(),
def_soft(), softfont();
/* set terminal up for soft-font programming. */
void setup_vt(out)
FILE *out;
{
fprintf(out, "%s%s", ES_init, ES_clear_soft_font);
def_soft(out,FALSE);
softfont(out,FALSE);
standout(out,FALSE);
linedraw(out,FALSE);
fflush(out);
}
/* Clear out full bitmap image. */
void clear_image()
{
int row, col, group, slice;
for (row = 0; row < scrheight; row++) {
for (col = 0; col < scrwidth; col++) {
for (group = 0; group < groups; group++) {
for (slice = 0; slice < charwidth; slice++) {
display[col][row][group][slice] = 0;
}
}
}
}
}
/* Define and draw bitmap. */
void show_image(outF, charsX, charsY, curr_char, doublesize)
FILE *outF;
int charsX, charsY;
unsigned char curr_char;
bool doublesize;
{
int row, col, group, slice, ypos, xpos, i;
extern unsigned char scrmap[scrwidth][scrheight];
extern int dispindx[cells], dispindy[cells];
/* Define full cell 96 character font */
def_soft(outF,TRUE);
putc('\n', outF);
for (i = 0; i < curr_char; i++) {
row = dispindy[i];
col = dispindx[i];
for (group = 0; group < groups; group++) {
for (slice = 0; slice < charwidth; slice++) {
putc((int) (display[col][row][group][slice] + 0x3f), outF);
}
if (!group)
putc('/', outF);
}
fprintf(outF, ";\n");
fflush(outF); /* buffering troubles */
}
def_soft(outF,FALSE);
softfont(outF,TRUE);
standout(outF,TRUE);
putc('\n', outF);
/* Draw characters in softset font */
if (doublesize) {
for (ypos = 0; ypos < charsY; ypos++) {
for (i = 0; i < 2; i++) {
if (!i)
fprintf(outF, ES_doublesize_top);
else
fprintf(outF, ES_doublesize_bot);
fmvcur(outF, 2 + ypos * 2 + i, ((scrwidth / 2) - charsX) / 2);
for (xpos = 0; xpos < charsX; xpos++)
putc((int) (' ' + scrmap[xpos][ypos]), outF);
putc('\n', outF);
}
}
} else {
for (ypos = 0; ypos < charsY; ypos++) {
fmvcur(outF, 2 + ypos, (scrwidth - charsX) / 2);
for (xpos = 0; xpos < charsX; xpos++)
putc((int) (' ' + scrmap[xpos][ypos]), outF);
putc('\n', outF);
}
}
softfont(outF,FALSE);
standout(outF,FALSE);
fprintf(outF, "%s%s", ES_soft_font_off, ES_standout_off);
fflush(outF);
}
/* Plot a single point into the graphics window at (xpos, ypos). */
void plot(xpos, ypos)
int xpos, ypos;
{
register int row, col, group, slice, sixel, tmp;
static char pmask[sixels_group] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20 };
if ((xpos < 0) || (ypos < 0) || (xpos > scrwidth * charwidth)
|| (ypos > scrheight * charheight))
return;
col = xpos / charwidth;
slice = xpos % charwidth;
row = ypos / charheight;
tmp = ypos % charheight;
group = tmp / sixels_group;
sixel = tmp % sixels_group;
display[col][row][group][slice] |= (pmask[sixel]);
}
void dump_char(col, row)
int col, row;
{
int group, slice, ypos, xpos, sixel;
char map[charwidth][charheight];
static char pmask[sixels_group] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20 };
for (group = 0; group < groups; group++) {
for (slice = 0; slice < charwidth; slice++) {
for (sixel = 0; sixel < 6; sixel++) {
if (display[col][row][group][slice] & pmask[sixel])
map[slice][group * 6 + sixel] = '@';
else
map[slice][group * 6 + sixel] = '.';
}
}
}
mvcur(1,1);
for (ypos = 0; ypos < charheight; ypos++) {
printf(" [");
for (xpos = 0; xpos < charwidth; xpos++)
putchar(map[xpos][ypos]);
printf("] \n");
}
}
int handleMeter(old, new, ypos)
int old, new, ypos;
{
register int i;
if (new > old) {
mvcur(ypos + 1, 13 + old);
for (i = old; i < new; i++)
putchar('a');
}
return (new);
}
void drawLines(ypos)
int ypos;
{
extern bool verbose;
#define DO_LINE(text) printf("%-11s%s%s%s\n", (text), \
ES_line_drawing_chars_on, \
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", \
ES_line_drawing_chars_off);
if (verbose) {
mvcur(ypos + 1, 2);
DO_LINE("Progress:");
mvcur(ypos + 2, 2);
DO_LINE("Cells:");
fflush(stdout);
}
}
void setupReadMeter(ypos)
int ypos;
{
extern bool verbose;
if (verbose) {
mvcur(ypos + 1, 2);
DO_LINE("Reading:");
fflush(stdout);
}
}
void drawMeters(ypos, done, used)
int ypos, done, used;
{
static int oldDone, oldUsed;
extern bool verbose;
if (verbose) {
oldDone = handleMeter(oldDone, done, ypos);
oldUsed = handleMeter(oldUsed, used, ypos + 1);
fflush(stdout);
}
}
void drawReadMeter(ypos, done)
int ypos, done;
{
static int oldDone;
extern bool verbose;
if (verbose) {
oldDone = handleMeter(oldDone, done, ypos);
fflush(stdout);
}
}
void drawBox(t, l, b, r)
int t, l, b, r;
{
extern bool verbose;
register int i;
if (verbose) {
linedraw(stdout,TRUE);
mvcur(t, l);
putchar('l');
for (i = (r - l) - 1; i; i--)
putchar('q');
putchar('k');
for (i = t + 1; i < b; i++) {
mvcur(i, l);
putchar('x');
mvcurright((r - l) - 1);
putchar('x');
}
mvcur(b, l);
putchar('m');
for (i = (r - l) - 1; i; i--)
putchar('q');
putchar('j');
linedraw(stdout,FALSE);
}
}
optBoxes(X, Y, dX, dY, clear)
float X, Y, dX, dY;
bool clear;
{
extern bool verbose;
static int aX, aY, bX, bY;
register int i;
if (verbose) {
if (clear) {
printf(ES_home_cursor);
for (i = bY + 1; i; i--)
printf("%s\n", ES_clear_to_eol);
}
aX = (int)X;
bX = (int)(X + 2 * dX);
aY = (int)Y;
bY = (int)(Y + 2 * dY);
drawBox(2, (scrwidth - aX) / 2, aY + 1, (scrwidth + aX) / 2 - 1);
drawBox(2, (scrwidth - bX) / 2, bY + 1, (scrwidth + bX) / 2 - 1);
}
}
bool softfont_mode, linedraw_mode, standout_mode;
#ifndef DONT_USE_SIGNAL
void reset_bits_off() {
if (softfont_mode)
printf(ES_soft_font_off);
if (linedraw_mode)
printf(ES_line_drawing_chars_off);
if (standout_mode)
printf(ES_standout_off);
}
void reset_bits_on() {
extern bool RedrawHeader;
redraw_screen();
if (softfont_mode)
printf(ES_soft_font_on);
if (linedraw_mode)
printf(ES_line_drawing_chars_on);
if (standout_mode)
printf(ES_standout_on);
}
sig_type reset_and_intr() {
reset_bits_off();
exit(128 + 2); /* exit code for SIGINT ;-P */
}
sig_type reset_and_stop() {
reset_bits_off();
kill(getpid(), SIGSTOP);
reset_bits_on();
}
#endif
void trap_ignore() {
#ifndef DONT_USE_SIGNAL
signal(SIGINT, SIG_IGN);
signal(SIGTSTP, SIG_IGN);
#endif
}
void trap_on() {
#ifndef DONT_USE_SIGNAL
signal(SIGINT, reset_and_intr);
signal(SIGTSTP, reset_and_stop);
#endif
}
void trap_off() {
#ifndef DONT_USE_SIGNAL
signal(SIGINT, SIG_DFL);
signal(SIGTSTP, SIG_DFL);
#endif
}
void linedraw(file,state)
FILE *file;
bool state; {
if (state) {
linedraw_mode = TRUE;
fprintf(file, ES_line_drawing_chars_on);
} else {
linedraw_mode = FALSE;
fprintf(file, ES_line_drawing_chars_off);
}
}
void standout(file,state)
FILE *file;
bool state; {
if (state) {
standout_mode = TRUE;
fprintf(file, ES_standout_on);
} else {
standout_mode = FALSE;
fprintf(file, ES_standout_off);
}
}
void softfont(file,state)
FILE *file;
bool state; {
if (state) {
softfont_mode = TRUE;
fprintf(file, ES_soft_font_on);
} else {
softfont_mode = FALSE;
fprintf(file, ES_soft_font_off);
}
}
void def_soft(file,state)
FILE *file;
bool state; {
if (state) {
trap_ignore();
fprintf(file, ES_define_soft_font);
} else {
trap_on();
fprintf(file, ES_end_soft_font_defn);
}
}