home *** CD-ROM | disk | FTP | other *** search
- /* $RCSfile: asterisk.c,v $ $Revision: 2.0 $ */
-
- #include <stdio.h>
- #include "gdefs.h"
- #include "externals.h"
- #include "protos.h"
-
- extern FILE *ifile,*ofile;
-
- static int fill_area = 0; /* Start with set to black fill (default) */
-
- static char *compress[] = {
- "Unencoded",
- "Run-Length Encoded",
- "Tagged Image File Format (TIFF)",
- };
-
- static char *font_ctl[] = {
- "Delete all soft fonts",
- "Delete all temporary soft fonts",
- "Delete soft font (last ID specified)",
- "Delete character code (last ID and character code)",
- "Make soft font temporary (last font ID specified)",
- "Make soft font permanent (last font ID specified)",
- "Copy/Assign current invoked font as temporary",
- };
-
- static char *fill_patterns[] = {
- "???",
- "Horizontal Lines",
- "Vertical Lines",
- "Diagonal Lines ///",
- "Diagonal Lines \\\\\\",
- "Square Grid",
- "Diagonal Grid",
- };
-
- static char *fill_types[] = {
- "Solid area (black)",
- "White",
- "Shaded",
- "HP defined pattern",
- };
-
- static char *fill_pct[] = {
- "0",
- "1-2",
- "2-10",
- "10-20",
- "20-35",
- "35-55",
- "55-80",
- "80-99",
- "100",
- };
-
- static char *graphics_mode[] = {
- "Image in orientation of logical page (rotate image)",
- "???",
- "???",
- "Image along width of physical page (landscape compatible)",
- };
-
- static char *graphics_quality[] = {
- "Default (high)",
- "Draft",
- "High",
- };
-
- void decode_asterisk(void) /* <Esc>* */
- {
- int start_pos;
- int stop_pos;
- int i;
- int done;
- char c1,c2,c3;
-
- c1 = esc_string[1];
- c2 = esc_string[2];
- c3 = esc_string[3];
- if (c2 == 'b') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- if (raster_mode == NO_RASTER) {
- print_sub_string(2, start_pos, stop_pos);
- }
- switch (c3) {
- case 'm':
- case 'M':
- fprintf(ofile,"Compression mode = ");
- if ((num >= 0) && (num <= 2)) {
- fprintf(ofile,"%s\n",compress[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'V': /* Can't have 'v' */
- case 'W': /* Can't have 'w' */
- if (raster_mode != NO_RASTER) {
- /* Count number of "extra" (other than first)
- like lines */
- raster_count++;
- }
- else {
- if (c3 == 'V') {
- raster_mode = V_RASTER;
- fprintf(ofile,
- "Next %d bytes form one plane ",num);
- fprintf(ofile,
- "of raster graphics data (PaintJet).\n");
- }
- else {
- raster_mode = W_RASTER;
- fprintf(ofile,
- "Next %d bytes form (final) plane ",num);
- fprintf(ofile,
- "of raster graphics data.\n");
- }
- for (i=0; i<=stop_pos; i++) {
- raster_header[i] = esc_string[i];
- }
- raster_header[i] = 0;
- raster_count = 0;
- }
- for (i=0; i<num; i++) {
- c1 = getc(ifile);
- }
- done = TRUE;
- break;
- case 'x':
- case 'X':
- fprintf(ofile,"Horizontal offset = ");
- if ((num >= 0) && (num <= 32767)) {
- fprintf(ofile,"%d pixels\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- case 'y':
- case 'Y':
- fprintf(ofile,"Vertical offset = ");
- if ((num >= -5) && (num <= 32767)) {
- fprintf(ofile,"%d pixels\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else if (c2 == 'c') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 'a':
- case 'A':
- fprintf(ofile,"Horizontal rectangle size = ");
- if ((num >= 0)) {
- fprintf(ofile,"%d dots (300 dpi)\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- case 'b':
- case 'B':
- fprintf(ofile,"Vertical rectangle size = ");
- if ((num >= 0)) {
- fprintf(ofile,"%d dots (300 dpi)\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- case 'd':
- case 'D':
- fprintf(ofile,"Specify Font ID to be ");
- if ((num >= 0) && (num <= 32767)) {
- fprintf(ofile,"%d\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- case 'e':
- case 'E':
- fprintf(ofile,"Specify the character code to be ");
- if ((num >= 0) && (num <= 255)) {
- fprintf(ofile,"%d\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- case 'f':
- case 'F':
- fprintf(ofile,"Font/character control =\n");
- indent(5);
- if ((num >= 0) && (num <= 6)) {
- fprintf(ofile,"%s\n",font_ctl[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'g':
- case 'G':
- fprintf(ofile,"Area fill ID = ");
- switch (fill_area) {
- case 0:
- fprintf(ofile,
- "Not appropriate for solid fill\n");
- break;
- case 1:
- fprintf(ofile,
- "Not appropriate for white fill\n");
- break;
- case 2:
- if ((num >= 0) && (num <= 100)) {
- i = 0;
- if (num < 1) num = 0;
- else if (num <= 2) i = 1;
- else if (num <= 10) i = 2;
- else if (num <= 20) i = 3;
- else if (num <= 35) i = 4;
- else if (num <= 55) i = 5;
- else if (num <= 80) i = 6;
- else if (num <= 99) i = 7;
- else i = 8;
- fprintf(ofile,"%s %s\n",fill_pct[i],"%");
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 3:
- if ((num >= 0) && (num <= 6)) {
- fprintf(ofile,"%s\n",fill_patterns[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- default: /* Shouldn't happen */
- fprintf(ofile,"%s",bad_esc);
- break;
- } /* end switch */
- break;
- case 'h':
- case 'H':
- fprintf(ofile,"Horizontal rectangle size = ");
- if ((num >= 0)) {
- fprintf(ofile,"%d/720 inch\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- case 'p':
- case 'P':
- fprintf(ofile,"Fill rectangular area = ");
- if ((num >= 0) && (num <= 3)) {
- fill_area = num;
- fprintf(ofile,"%s fill\n",fill_types[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'v':
- case 'V':
- fprintf(ofile,"Vertical rectangle size = ");
- if ((num >= 0)) {
- fprintf(ofile,"%d/720 inch\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else if (c2 == 'p') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 'x':
- case 'X':
- if (plus) {
- fprintf(ofile,
- "Move cursor right %d dots (300 dpi)\n",num);
- }
- else if (minus) {
- fprintf(ofile,
- "Move cursor left %d dots (300 dpi)\n",-num);
- }
- else {
- fprintf(ofile,
- "Move cursor to %d/300 inch ",num);
- fprintf(ofile,
- "from left boundary of page.\n");
- }
- break;
- case 'y':
- case 'Y':
- if (plus) {
- fprintf(ofile,
- "Move cursor down %d dots (300 dpi)\n",num);
- }
- else if (minus) {
- fprintf(ofile,
- "Move cursor up %d dots (300 dpi)\n",-num);
- }
- else {
- fprintf(ofile,
- "Move cursor to %d/300 inch ",num);
- fprintf(ofile, "down from top margin.\n");
- }
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else if (c2 == 'r') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 'a':
- case 'A':
- fprintf(ofile,"Start raster graphics.\n");
- indent(5);
- if (num == 0) {
- fprintf(ofile,
- "Graphics start at left-most printable region.\n");
- }
- else if (num == 1) {
- fprintf(ofile,
- "Set starting position and left graphics margin\n");
- indent(5);
- fprintf(ofile,"to current position.\n");
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'b':
- case 'B':
- fprintf(ofile,"End raster graphics.\n");
- if (num != 0) {
- fprintf(ofile,questions);
- }
- break;
- case 'f':
- case 'F':
- fprintf(ofile,"Raster graphics mode =\n");
- indent(5);
- if ((num >= 0) && (num <= 3)) {
- fprintf(ofile,"%s\n",graphics_mode[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 'k':
- case 'K':
- fprintf(ofile,"Return Model number\n");
- if (num != 0) {
- fprintf(ofile,questions);
- }
- break;
- case 'q':
- case 'Q':
- fprintf(ofile,"Graphics quality = ");
- if ((num >= 0) && (num <= 2)) {
- fprintf(ofile,"%s\n",graphics_quality[num]);
- }
- else {
- fprintf(ofile,questions);
- }
- break;
- case 's':
- case 'S':
- fprintf(ofile,"Image width (pixels/row) = ");
- if ((num >= 0) && (num <= 32767)) {
- fprintf(ofile,"%d\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- case 'u':
- case 'U':
- fprintf(ofile,"Number of color planes per row = ");
- if ((num >= 1) && (num <= 4)) {
- fprintf(ofile,"%d\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else if (c2 == 't') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 'r':
- case 'R':
- fprintf(ofile,"Resolution (dots per inch) = ");
- switch (num) {
- case 75:
- case 100:
- case 150:
- case 300:
- case 90:
- case 180:
- fprintf(ofile,"%d\n",num);
- break;
- default:
- fprintf(ofile,"%d ???\n",num);
- break;
- }
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- else if (c2 == 'v') {
- start_pos = stop_pos = 3;
- done = FALSE;
- while (done == FALSE) {
- get_num(&stop_pos,0);
- c3 = esc_string[stop_pos];
- print_sub_string(2, start_pos, stop_pos);
- switch (c3) {
- case 'a':
- case 'A':
- fprintf(ofile,"Red component = ");
- if ((num >= 4) && (num <= 90)) {
- fprintf(ofile,"%d\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- case 'b':
- case 'B':
- fprintf(ofile,"Green component = ");
- if ((num >= 4) && (num <= 88)) {
- fprintf(ofile,"%d\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- case 'c':
- case 'C':
- fprintf(ofile,"Blue component = ");
- if ((num >= 6) && (num <= 85)) {
- fprintf(ofile,"%d\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- case 'i':
- case 'I':
- fprintf(ofile,"Put color into palette at index ");
- if ((num >= 0) && (num <= 15)) {
- fprintf(ofile,"%d\n",num);
- }
- else {
- fprintf(ofile,out_of_range,num);
- }
- break;
- default:
- fprintf(ofile,"%s",bad_esc);
- break;
- }
- stop_pos++;
- start_pos = stop_pos;
- if (esc_string[start_pos] == 0) {
- done = TRUE;
- }
- }
- }
- }
-