📄 ipress.c
字号:
showchar(ch) /* buffer "ch" for use in a "show" command */int ch;{ char *framep; register int hdiff, vdiff; /* set correct position */ vdiff = ver_pos - old_ver; hdiff = hor_pos - old_hor; if (dbg > 4) { printf("old_hor %d, hor_pos %d, hdiff %d; old_ver %d, ver_pos %d, vdiff %d %s\n", old_hor, hor_pos, hdiff, old_ver, ver_pos, vdiff, virgin_line ? "(virgin)" : ""); } /* NOTE: this expression depends on boolean true being 1! */ /* See K&R, Appendix A, section 7.7, page 190 */ switch (((vdiff != 0) << 1) | (hdiff != 0)) { case 0: /* no change */ break; default: flushbuff(); Setxy(xloc(hor_pos), yloc(ver_pos)); break; } /* * Update old_hor and old_ver. Account for character width in old_hor but not in * hor_pos. If the next hInc call is for the width of the character, the * next time showchar gets called, old_hor will equal hor_pos. */ old_ver = ver_pos; old_hor = hor_pos + charw; /* line is no longer virgin */ virgin_line = 0; /* font and point still the same? */ if (ftsz != oldftsz) { flushbuff(); if ((framep = currfonts[font]->frames) == NULL) { /* previously unused -- give it a frame table */ framep = currfonts[font]->frames = malloc((unsigned)(device.num_sizes * sizeof(char))); bzero(framep, device.num_sizes * sizeof(char)); } if (framep[size] == 0) { /* make a new font */ ip_select(outputfile); SetupFont(currfonts[font]->uname, floor(pointsizeTab[size-1] * 35.28 + .5), frameindex); ip_select(pagebodyfile); framep[size] = frameindex++; } /* switch to new font/size combo */ Setfont(framep[size]); oldftsz = ftsz; } /* adjust for character codes > 0377 */ if (ch > 0377) { if (dbg > 4) { printf("processing large code: 0%o (%d)\n", ch, ch); } if (showcnt + 5 > Showbuff_size) { flushbuff(); } *showp++ = '\377'; *showp++ = (ch & 0177400) >> 8; *showp++ = ch & 255; *showp++ = '\377'; *showp++ = '\0'; showcnt += 5; } else { *showp++ = ch; if (++showcnt > Showbuff_size) { flushbuff(); } }}/* * getexcode(findex) - get the extended code for the character "findex" */getexcode(findex)int findex;{ register int extfd; register int i; register unsigned short *tab; char temp[132]; if (dbg > 4) { printf("getexcode(%d)\n", findex); } if ((tab = currfonts[font]->extab) == NULL) { /* load in the extended code table */ (void) sprintf(temp, "%s/dev%s/%s.out.ext", fontdirectory, devicename, currfonts[font]->name); if (dbg > 4) { printf("opening and reading %s\n", temp); } if ((extfd = open(temp, O_RDONLY,0)) == -1) { reportError(CONTINUE, "can't open %s (%s)", temp, sys_errlist[errno]); return(0); } currfonts[font]->extab = tab = (unsigned short *) malloc( (unsigned)(i = (device.spec_char_num + 128-32) * sizeof(short)) ); (void) read(extfd, (char *)tab, i); /* should test result! */ (void) close(extfd); } if (dbg > 4) { printf("getexcode returning %.7o\n", tab[findex]); } return(tab[findex]);}flushbuff() /* flush and reset "showbuff" */{ if (showcnt == 0) return; if (!in_correct) { startcorrect(); } /* we must do the append_Sequence explicitly, */ /* because showbuff might have nulls in it. */ append_Sequence(sequenceString, showcnt, (unsigned char *)showbuff); AppendOp(OP_show); showp = showbuff; showcnt = 0;}int hstart;startcorrect(){#ifdef CORRECT_BLOCKS AppendOp(OP_correct); AppendOp(OP_beginBody);#endif in_correct = 1; hstart = hor_pos;}endcorrect(){ /* append a Setcorrectmeasure operation */ /* "hor_pos" or "old_hor"??? Make it "old_hor" for now */#ifdef CORRECT_BLOCKS Setcorrectmeasure(xloc(old_hor), 0.0); AppendOp(OP_endBody);#endif in_correct = 0;}/* * IPprint(filename) - send the file "filename" to the interpress printer. * This routine is *very* dependent on local * environments. */IPprint(filename)char *filename;{ if (dbg) { printf("interpress file saved in %s.\n", filename); return; } if (vfork() == 0) { /* is child */ execl("/usr/local/bin/qip", "qip", "-nc", "-nk", filename, 0); exit(1); }}/* bitmap graphics object sizing functions */g_sizearc(x1, y1, xc, yc, x2, y2)int x1, y1, xc, yc, x2, y2;{ int minx; int miny; int maxx; int maxy; int quad1; int quad2; int radius; int axc; int ayc; int i; /* the center and the second point are offsets from the first */ /* calculate actual center and radius */ axc = x1 + xc; ayc = y1 + yc; radius = (int)(hypot((double)xc, (double)yc) + .5); if (dbg > 1) { printf("g_sizearc(%d, %d, %d, %d, %d, %d): radius is %d\n", x1, y1, xc, yc, x2, y2, radius); } /* preset the minmal and maximal points -- this is our first guess */ if ((minx = x1 + xc + x2) > x1) { maxx = minx; minx = x1; } else { maxx = x1; } if ((miny = y1 + yc + y2) > y1) { maxy = miny; miny = y1; } else { maxy = y1; } /* calculate the offset from the center to the first point */ x1 = -xc; y1 = -yc; /* now all three arguments are offsets */ /* calculate the quadrant of each endpoint */ quad1 = quadrant(x1, y1); quad2 = quadrant(x2, y2); if (dbg > 1) { printf("(%d, %d) in quadrant %d ... ", x1, y1, quad1); printf("(%d, %d) in quadrant %d\n", x2, y2, quad2); } /* insure that quad1 < quad2 */ if (quad2 < quad1) { quad2 += 4; } /* compensate for arc at each quadrant boundary */ for (i = quad1 + 1; i <= quad2; i++) { switch (i & 3) { case 0: /* 1st quadrant */ maxx = axc + radius; break; case 1: /* 2nd quadrant */ miny = ayc - radius; break; case 2: /* 3rd quadrant */ minx = axc - radius; break; case 3: /* 4th quadrant */ maxy = ayc + radius; break; } } /* now set the extremes */ if (dbg > 1) { printf("extremes are %d, %d, %d, %d\n", minx, miny, maxx, maxy); } gobj_size(minx, miny, maxx, maxy);}quadrant(dx, dy)int dx,dy;{ register int yplus; yplus = dy > 0; if (dx > 0) { return(yplus ? 3 : 0); } else { return(yplus ? 2 : 1); }}g_sizeWigglyLine(str)char *str;{ int minx; int miny; int maxx; int maxy; int currx; int curry; int incx; int incy; currx = minx = maxx = hor_pos; curry = miny = maxy = ver_pos; while(white(*str)) str++; /* trim leading white space */ while (*str) { (void) readNumber(&str,&incx); (void) readNumber(&str,&incy); currx += incx; curry += incy; if (currx > maxx) maxx = currx; else if (currx < minx) minx = currx; if (curry > maxy) maxy = curry; else if (curry < miny) miny = curry; } gobj_size(minx, miny, maxx, maxy);}/* * Request the insertion of an Interpress master */doSequenceInsertIP(fileName)char *fileName; { AppendOp(OP_dosavesimplebody); AppendOp(OP_beginBody); /* set the IP position at the current troff position */ Setxy(xloc(hor_pos), yloc(ver_pos)); /* undo the Troff scaling */ AppendRational(spotsPerInch*10000L, 254L); AppendOp(OP_scale); AppendOp(OP_concatt); AppendOp(OP_trans); AppendInsertFile(fileName); AppendOp(OP_endBody);}#define SAME 0/* * define frame variables for the RES image */#define IMAGE_EDIT 47L#define IMAGE_COLOR_OP 46L#define IMAGE_COLOR 45L#define IMAGE_MASK 44L#define IMAGE_Y 43L#define IMAGE_X 42L#define IMAGE_SCALE 41L/* * Request the insertion of an RES file */doSequenceInsertRES(anchor, resolutionString, fileName) char *anchor, *resolutionString, *fileName; { int resolution; resolution = atoi(resolutionString); AppendOp(OP_dosavesimplebody); AppendOp(OP_beginBody); /* set the IP position at the current troff position */ Setxy(xloc(hor_pos), yloc(ver_pos)); AppendInsertFile(fileName); /* pop and store */ AppendOp(OP_pop); /* for now, don't check the signature */ AppendInteger(IMAGE_EDIT); AppendOp(OP_fset); AppendInteger(IMAGE_COLOR_OP); AppendOp(OP_fset); AppendInteger(IMAGE_COLOR); AppendOp(OP_fset); AppendOp(OP_pop); /* discard mask image */ AppendInteger(IMAGE_Y); AppendOp(OP_fset); AppendInteger(IMAGE_X); AppendOp(OP_fset); AppendInteger(IMAGE_SCALE); AppendOp(OP_fset); /* undo the Troff scaling */ AppendRational(spotsPerInch*10000L, 254L); AppendOp(OP_scale); /* set the resolution */ if( resolution != 0 ) { /* display the RES file at the specified resolution */ AppendRational(254L, resolution*10000L); AppendOp(OP_scale); } else /* get the default scale from the RES file */ /* can the device do a "get" operator? */ if( IPDeviceType == Xerox8044_Services8 || IPDeviceType == Xerox8044_Services9 || IPDeviceType == Xerox8044_Services10 ) reportError(CONTINUE, "requested device can't read resolution from an RES file"); else { /* Yes! Use the imageScale suggested by the image */ Fget(IMAGE_SCALE); Get(1L); Fget(IMAGE_SCALE); Get(2L); AppendOp(OP_scale2); } AppendOp(OP_concat); /* concat undo-scale with image scale */ if( strcmp(anchor, "bl") == SAME ) /* bottom left */ ; else if( strcmp(anchor, "tl") == SAME ) { /* top left */ AppendInteger(-1L); /* invert scale */ AppendOp(OP_scale); AppendOp(OP_concat); AppendOp(OP_concatt); FGet(IMAGE_Y); AppendOp(OP_setyrel); AppendInteger(-1L); AppendOp(OP_scale); } else if( strcmp(anchor, "c") == SAME ) { /* center */ AppendRational(-1L, 2L); AppendOp(OP_scale); AppendOp(OP_concat); AppendOp(OP_concatt); /* half normal scale for centering */ FGet(IMAGE_X); FGet(IMAGE_Y); AppendOp(OP_setxyrel); AppendRational(-2L, 1L); AppendOp(OP_scale); } else if( strcmp(anchor, "br") == SAME ) { /* bottom right */ AppendInteger(-1L); /* invert scale */ AppendOp(OP_scale); AppendOp(OP_concat); AppendOp(OP_concatt); FGet(IMAGE_X); AppendOp(OP_setxrel); AppendInteger(-1L); /* invert scale */ AppendOp(OP_scale); } else if( strcmp(anchor, "tr") == SAME ) { /* top right */ AppendInteger(-1L); /* invert scale */ AppendOp(OP_scale); AppendOp(OP_concat); AppendOp(OP_concatt); FGet(IMAGE_X); FGet(IMAGE_Y); AppendOp(OP_setxyrel); AppendInteger(-1L); /* invert scale */ AppendOp(OP_scale); } else reportError(CONTINUE, "unknown position in RES command: %s", anchor ); AppendOp(OP_concatt); AppendOp(OP_trans); FGet(IMAGE_COLOR); AppendOp(OP_maskpixel); AppendOp(OP_endBody);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -