wdvi

network DVI viewer
Log | Files | Refs

commit 6d08c77f9f52decec0544d54ee5143099488f877
parent 693046573312346b52a28184387ac0bde446acae
Author: Kyle Milz <krwmilz@gmail.com>
Date:   Tue, 14 Sep 2021 16:20:47 +0000

delete the rest of postscript special support

Diffstat:
Mdvi-draw.c | 4----
Mspecial.c | 350+------------------------------------------------------------------------------
Mspecial.h | 1-
Mxdvi.h | 5-----
4 files changed, 1 insertion(+), 359 deletions(-)

diff --git a/dvi-draw.c b/dvi-draw.c @@ -1101,7 +1101,6 @@ draw_page() currinf.pos = currinf.end = dvi_buffer; currinf.virtual = NULL; dvi_pointer_frame = &currinf; - psfig_begun = False; drawing_mag = (currwin.win == alt.win); draw_part(current_frame = &frame0, dimconv); @@ -1412,9 +1411,6 @@ geom_scan_part(g_info, minframe, current_dimconv) if (a > 0) { char *str = read_special(a); - /* process the bounding box */ - geom_do_special(g_info, str, current_dimconv); - /* process the specials we're looking for */ g_info->geom_special(g_info, str); } diff --git a/special.c b/special.c @@ -466,73 +466,6 @@ blacken_last() } -/* - * Code for PostScript<tm> specials begins here. - */ - - -static Boolean bbox_valid; -static unsigned int bbox_width; -static unsigned int bbox_height; -static int bbox_angle; -static int bbox_voffset; - -void -draw_bbox() -{ - int xcorner, ycorner; - - if (bbox_valid) { - - if (fg_active != fg_current) do_color_change(); - - xcorner = PXL_H - currwin.base_x; - ycorner = PXL_V - currwin.base_y; - - if (bbox_angle == 0) { - ycorner -= bbox_voffset; - XDrawLine(DISP, currwin.win, ruleGC, - xcorner, ycorner, - xcorner + bbox_width, ycorner); - XDrawLine(DISP, currwin.win, ruleGC, - xcorner + bbox_width, ycorner, - xcorner + bbox_width, ycorner + bbox_height); - XDrawLine(DISP, currwin.win, ruleGC, - xcorner + bbox_width, ycorner + bbox_height, - xcorner, ycorner + bbox_height); - XDrawLine(DISP, currwin.win, ruleGC, - xcorner, ycorner + bbox_height, - xcorner, ycorner); - } - else { - float sin_a = sin(bbox_angle * (TWOPI / 360)); - float cos_a = cos(bbox_angle * (TWOPI / 360)); - float a, b, c, d; - - a = cos_a * bbox_width; - b = -sin_a * bbox_width; - c = -sin_a * bbox_height; - d = -cos_a * bbox_height; - - XDrawLine(DISP, currwin.win, ruleGC, - xcorner, ycorner, - xcorner + (int) rint(a), ycorner + (int) rint(b)); - XDrawLine(DISP, currwin.win, ruleGC, - xcorner + (int) rint(a), ycorner + (int) rint(b), - xcorner + (int) rint(a + c), ycorner + (int) rint(b + d)); - XDrawLine(DISP, currwin.win, ruleGC, - xcorner + (int) rint(a + c), ycorner + (int) rint(b + d), - xcorner + (int) rint(c), ycorner + (int) rint(d)); - XDrawLine(DISP, currwin.win, ruleGC, - xcorner + (int) rint(c), ycorner + (int) rint(d), - xcorner, ycorner); - } - bbox_valid = False; - } -} - - - void init_prescan() { @@ -543,170 +476,6 @@ init_prescan() } -static void -psfig_special(cp) - char *cp; -{ - char *filename; - int raww, rawh; - - if (strncmp(cp, ":[begin]", 8) == 0) { - cp += 8; - bbox_valid = False; - bbox_angle = 0; - if (sscanf(cp, "%d %d\n", &raww, &rawh) >= 2) { - bbox_valid = True; - bbox_width = pixel_conv(spell_conv(raww)); - bbox_height = pixel_conv(spell_conv(rawh)); - bbox_voffset = 0; - } - if (currwin.win == mane.win) - draw_bbox(); - psfig_begun = True; - } else if (strncmp(cp, " plotfile ", 10) == 0) { - cp += 10; - while (isspace(*cp)) cp++; - for (filename = cp; !isspace(*cp); ++cp); - *cp = '\0'; - } else if (strncmp(cp, ":[end]", 6) == 0) { - cp += 6; - bbox_valid = False; - psfig_begun = False; - } else if (*cp == ':') { - /* I am going to send some raw postscript stuff */ - ++cp; /* skip the colon */ - } else { - /* also raw PostScript, but no extra colon to skip */ - } -} - - -/* Keys for epsf specials */ - -static const char *keytab[] = {"clip", - "llx", - "lly", - "urx", - "ury", - "rwi", - "rhi", - "hsize", - "vsize", - "hoffset", - "voffset", - "hscale", - "vscale", - "angle"}; - -#define KEY_LLX keyval[0] -#define KEY_LLY keyval[1] -#define KEY_URX keyval[2] -#define KEY_URY keyval[3] -#define KEY_RWI keyval[4] -#define KEY_RHI keyval[5] - -#define NKEYS (sizeof(keytab)/sizeof(*keytab)) -#define N_ARGLESS_KEYS 1 - -static void -epsf_special(cp) - char *cp; -{ - char *filename; - static char *buffer; - static unsigned int buflen = 0; - unsigned int len; - char *q; - int flags = 0; - double keyval[6]; - - filename = cp; - if (*cp == '\'' || *cp == '"') { - do ++cp; - while (*cp != '\0' && *cp != *filename); - ++filename; - } - else - while (*cp != '\0' && !isspace(*cp)) ++cp; - if (*cp != '\0') *cp++ = '\0'; - while (isspace(*cp)) ++cp; - len = strlen(cp) + NKEYS + 30; - if (buflen < len) { - if (buflen != 0) free(buffer); - buflen = len; - buffer = xmalloc(buflen); - } - strcpy(buffer, "@beginspecial"); - q = buffer + strlen(buffer); - while (*cp != '\0') { - char *p1 = cp; - int keyno; - - while (*p1 != '=' && !isspace(*p1) && *p1 != '\0') ++p1; - for (keyno = 0;; ++keyno) { - if (keyno >= NKEYS) { - if (warn_spec_now) - warnx("unknown keyword '%.*s' in \\special will be ignored", - (int) (p1 - cp), cp); - break; - } - if (memcmp(cp, keytab[keyno], p1 - cp) == 0) { - if (keyno >= N_ARGLESS_KEYS) { - while (isspace(*p1)) ++p1; - if (*p1 == '=') { - ++p1; - while (isspace(*p1)) ++p1; - } - if (keyno < N_ARGLESS_KEYS + 6) { - keyval[keyno - N_ARGLESS_KEYS] = atof(p1); - flags |= (1 << (keyno - N_ARGLESS_KEYS)); - } - *q++ = ' '; - while (!isspace(*p1) && *p1 != '\0') *q++ = *p1++; - } - *q++ = ' '; - *q++ = '@'; - strcpy(q, keytab[keyno]); - q += strlen(q); - break; - } - } - cp = p1; - while (!isspace(*cp) && *cp != '\0') ++cp; - while (isspace(*cp)) ++cp; - } - strcpy(q, " @setspecial\n"); - - bbox_valid = False; - if ((flags & 0x30) == 0x30 || ((flags & 0x30) && (flags & 0xf) == 0xf)){ - bbox_valid = True; - bbox_width = 0.1 * ((flags & 0x10) ? KEY_RWI - : KEY_RHI * (KEY_URX - KEY_LLX) / (KEY_URY - KEY_LLY)) - * dimconv / shrink_factor + 0.5; - bbox_voffset = bbox_height = 0.1 * ((flags & 0x20) ? KEY_RHI - : KEY_RWI * (KEY_URY - KEY_LLY) / (KEY_URX - KEY_LLX)) - * dimconv / shrink_factor + 0.5; - } - - if (currwin.win == mane.win) { - draw_bbox(); - } - bbox_valid = False; -} - - -static void -quote_special(cp) - char *cp; -{ - bbox_valid = False; - - - /* nothing else to do--there's no bbox here */ -} - - - /* * Table of dvips color names. Produced by passing the table in * dvipsk/color.lpro through the following perl script, and then @@ -1290,11 +1059,8 @@ endofcommand(cp) #define CMD(x, y) ((x) << 8 | (y)) void -applicationDoSpecial(cp) - char *cp; +applicationDoSpecial(char *cp) { - char *p; - if (debug & DBG_DVI) printf(" `%s'\n", cp); @@ -1307,21 +1073,6 @@ applicationDoSpecial(cp) while (isspace(*cp)) ++cp; } - /* PostScript specials */ - - if (*cp == '"') { - quote_special(cp); - return; - } - if (memicmp(cp, "ps:", 3) == 0) { - psfig_special(cp + 3); - return; - } - if (memicmp(cp, "psfile", 6) == 0 - && (p = endofcommand(cp + 6)) != NULL) { - epsf_special(p); - return; - } if (memicmp(cp, "color ", 6) == 0) { color_special(cp + 6); return; @@ -1419,102 +1170,3 @@ scan_special(cp) return; } } - - -#define xspell_conv(n) spell_conv0(n, current_dimconv) -#define xpixel_conv(x) ((int) ((x) >> 16)) -#define G_PXL_H xpixel_conv(currinf.data.dvi_h) - -/* ARGSUSED */ -void -geom_do_special(g_info, cp, current_dimconv) - struct geom_info *g_info; - /* cp is not const, because of endofcommand(). */ - char *cp; - double current_dimconv; -{ - const char *p; - - /* Skip white space */ - while (isspace(*cp)) ++cp; - - /* Ignore initial "xdvi:" */ - if (memcmp(cp, "xdvi:", 5) == 0) { - cp += 5; - while (isspace(*cp)) ++cp; - } - - if (memicmp(cp, "psfile", 6) == 0 - && (p = endofcommand(cp + 6)) != NULL) { - /* compute epsf bounding box */ - char c; - int flags = 0; - double keyval[6]; - - c = *p; - if (c == '\'' || c == '"') { - do ++p; - while (*p != '\0' && *p != c); - } - else - while (*p != '\0' && !isspace(*p)) ++p; - while (isspace(*p)) ++p; - while (*p != '\0') { - const char *p1 = p; - int keyno; - - while (*p1 != '=' && !isspace(*p1) && *p1 != '\0') ++p1; - for (keyno = 0; keyno < NKEYS; ++keyno) { - if (memcmp(p, keytab[keyno], p1 - p) == 0) { - if (keyno >= N_ARGLESS_KEYS) { - while (isspace(*p1)) ++p1; - if (*p1 == '=') { - ++p1; - while (isspace(*p1)) ++p1; - } - if (keyno < N_ARGLESS_KEYS + 6) { - keyval[keyno - N_ARGLESS_KEYS] = atof(p1); - flags |= (1 << (keyno - N_ARGLESS_KEYS)); - } - while (!isspace(*p1) && *p1 != '\0') ++p1; - } - break; - } - } - p = p1; - while (!isspace(*p) && *p != '\0') ++p; - while (isspace(*p)) ++p; - } - - if ((flags & 0x30) == 0x30 - || ((flags & 0x30) && (flags & 0xf) == 0xf)){ - long x = G_PXL_H; - long y = PXL_V; - long bbox_w; - long bbox_h; - - bbox_w = 0.1 * ((flags & 0x10) ? KEY_RWI - : KEY_RHI * (KEY_URX - KEY_LLX) / (KEY_URY - KEY_LLY)) - * dimconv + 0.5; - bbox_h = 0.1 * ((flags & 0x20) ? KEY_RHI - : KEY_RWI * (KEY_URY - KEY_LLY) / (KEY_URX - KEY_LLX)) - * dimconv + 0.5; - - g_info->geom_box(g_info, x, y - bbox_h, x + bbox_w, y); - } - } - else if (memicmp(cp, "ps::[begin]", 11) == 0) { - /* compute psfig bounding box */ - long bbox_w, bbox_h; - - if (sscanf(cp + 11, "%ld %ld\n", &bbox_w, &bbox_h) >= 2) { - long x = G_PXL_H; - long y = PXL_V; - - bbox_w = xpixel_conv(spell_conv(bbox_w)); - bbox_h = xpixel_conv(spell_conv(bbox_h)); - - g_info->geom_box(g_info, x, y, x + bbox_w, y + bbox_h); - } - } -} diff --git a/special.h b/special.h @@ -48,7 +48,6 @@ int scanned_page_reset; /* number to reset the above to */ void applicationDoSpecial(char *); -void geom_do_special(struct geom_info *, char *, double); void init_prescan(void); void scan_color_eop(void); void scan_special(char *); diff --git a/xdvi.h b/xdvi.h @@ -80,11 +80,6 @@ unsigned int page_w, page_h; Boolean warn_spec_now; /* - * If we're in the middle of a PSFIG special. - */ -Boolean psfig_begun = False; - -/* * Used for window manager delete protocol (toolkit only). */ Atom atoms[2];