v10i010: xdvi, Patch10, Part02/02
Paul Vojta
vojta at math.Berkeley.EDU
Fri Oct 19 08:36:23 AEST 1990
Submitted-by: vojta at math.berkeley.edu (Paul A Vojta)
Posting-number: Volume 10, Issue 10
Archive-name: xdvi/patch10.2
Patch-To: xdvi: Volume 3, Issues 37-39
Patch-To: xdvi: Volume 4, Issue 44 (xdvi, Patch4)
Patch-To: xdvi: Volume 4, Issue 96 (xdvi, dvi previewer, Patch5)
Patch-To: xdvi: Volume 5, Issue 35 (xdvi, dvi previewer, patch 6, part 1/2)
Patch-To: xdvi: Volume 5, Issue 36 (xdvi, dvi previewer, patch 6, part 2/2)
Patch-To: xdvi: Volume 6, Issue 5 (xdvi, Patch7)
Patch-To: xdvi: Volume 6, Issue 49 (xdvi, dvi previewer, patch 8)
Patch-To: xdvi: Volume 7, Issue 52 (xdvi, dvi previewer, patch 9, part 1/2)
Patch-To: xdvi: Volume 7, Issue 53 (xdvi, dvi previewer, patch 9, part 2/2)
diff -cr xdvi_old/pxl_open.c xdvi_new/pxl_open.c
*** xdvi_old/pxl_open.c Mon Sep 17 17:35:58 1990
--- xdvi_new/pxl_open.c Wed Oct 10 12:00:50 1990
***************
*** 1,5 ****
/*
! * pxl_open.c(font, font_ret, mag, mag_ret, factor, name, read_font_index)
* Find and open gf, pk, or pxl files in the given path, having the given
* name and magnification. It tries gf files first, followed by pk and pxl
* files. The path variable should be of the form path1:path2:...:pathn,
--- 1,5 ----
/*
! * pxl_open.c(font, font_ret, mag, mag_ret, factor, name)
* Find and open gf, pk, or pxl files in the given path, having the given
* name and magnification. It tries gf files first, followed by pk and pxl
* files. The path variable should be of the form path1:path2:...:pathn,
***************
*** 19,26 ****
* *factor the ratio of the point sizes of the requested font
* and the font actually found (or 1.0 if altfont is used).
* *name a pointer to a string containing the file name
- * *read_font_index a pointer to the read_index procedure to be
- * used for the given font format.
*
* If the file is not found, then the return value is NULL.
*
--- 19,24 ----
***************
*** 33,53 ****
*/
#include <stdio.h>
-
- #ifndef X10
- #include <X11/Xos.h> /* same as below */
- #else /* X10 */
- #ifdef SYSV
- #include <string.h>
- #define index strchr
- #define rindex strrchr
- #else /* SYSV */
- #include <strings.h>
- #endif /* SYSV */
- #endif /* X10 */
-
#include <errno.h>
! extern int errno;
/*
* If you think you have to change DEFAULT_TAIL, then you haven't read the
--- 31,39 ----
*/
#include <stdio.h>
#include <errno.h>
! int errno;
! #include "xdvi.h"
/*
* If you think you have to change DEFAULT_TAIL, then you haven't read the
***************
*** 57,91 ****
#define PATH_SEP ':'
#define DEFAULT_TAIL "/%f.%d%p"
#else /* VMS */
- #include <string.h>
- #define index strchr
- #define rindex strrchr
#define PATH_SEP '/'
#define DEFAULT_TAIL ":%f.%d%p"
#endif /* VMS */
- #ifndef OPEN_MODE
- #ifndef VMS
- #define OPEN_MODE "r"
- #else
- #define OPEN_MODE "r", "ctx=stm"
- #endif
- #endif /* OPEN_MODE */
-
- extern int n_fonts_left;
- extern char *alt_font;
-
static char *font_path;
! static char default_font_path[] = DEFAULT_FONT_PATH;
static int *sizes, *sizend;
static char default_size_list[] = DEFAULT_FONT_SIZES;
- /* the corresponding read_char procedures are handled in xdvi.h */
- typedef void (*read_font_index_proc)();
- /* struct font *fontp; */
-
- read_font_index_proc read_GF_index, read_PK_index, read_PXL_index;
-
#ifdef sun
char *sprintf();
#endif
--- 43,57 ----
#define PATH_SEP ':'
#define DEFAULT_TAIL "/%f.%d%p"
#else /* VMS */
#define PATH_SEP '/'
#define DEFAULT_TAIL ":%f.%d%p"
#endif /* VMS */
static char *font_path;
! static char *default_font_path = DEFAULT_FONT_PATH;
static int *sizes, *sizend;
static char default_size_list[] = DEFAULT_FONT_SIZES;
#ifdef sun
char *sprintf();
#endif
***************
*** 93,101 ****
char *malloc(), *getenv();
double atof();
- #define Strcpy (void) strcpy
- #define Sprintf (void) sprintf
-
static void
get_sizes(size_list, spp)
char *size_list;
--- 59,64 ----
***************
*** 117,129 ****
unsigned int n;
char *p;
! if ((font_path = getenv("XDVIFONTS")) == NULL)
font_path = default_font_path;
! else if (*font_path == PATH_SEP)
! /*concatenate default_font_path before font_path */
! font_path = strcat(strcpy(malloc((unsigned)
! strlen(default_font_path) + strlen(font_path) + 1),
! default_font_path), font_path);
size_list = getenv("XDVISIZES");
n = 1; /* count number of sizes */
--- 80,89 ----
unsigned int n;
char *p;
! if ((font_path = getenv("XDVIFONTS")) == NULL) {
font_path = default_font_path;
! default_font_path = NULL;
! }
size_list = getenv("XDVISIZES");
n = 1; /* count number of sizes */
***************
*** 155,170 ****
}
static FILE *
! formatted_open(path, font, pxl, mag, name)
char *path, *font, *pxl;
int mag;
char **name;
{
char *p = path,
nm[128],
*n = nm,
c;
! int f_used = 0;
FILE *f;
for (;;) {
--- 115,132 ----
}
static FILE *
! formatted_open(path, font, pxl, mag, name, count)
char *path, *font, *pxl;
int mag;
char **name;
+ int count;
{
char *p = path,
nm[128],
*n = nm,
c;
! Boolean f_used = False;
! Boolean p_used = False;
FILE *f;
for (;;) {
***************
*** 178,187 ****
c = *p++;
switch (c) {
case 'f':
! f_used=1;
Strcpy(n, font);
break;
case 'p':
Strcpy(n, pxl);
break;
case 'd':
--- 140,150 ----
c = *p++;
switch (c) {
case 'f':
! f_used = True;
Strcpy(n, font);
break;
case 'p':
+ p_used = True;
Strcpy(n, pxl);
break;
case 'd':
***************
*** 195,201 ****
--- 158,166 ----
}
else *n++ = c;
}
+ if (!p_used && count > 0) return NULL;
*n = '\0';
+ if (debug & DBG_OPEN) Printf("Trying font file %s\n", nm);
f = fopen(nm, OPEN_MODE);
if (f == NULL && errno == EMFILE) {
n_fonts_left = 0;
***************
*** 209,272 ****
return f;
}
static FILE *
! pre_pxl_open(font, mag, mag_ret, name, read_font_index)
char *font;
! int mag, *mag_ret;
char **name;
! read_font_index_proc *read_font_index;
{
char *p;
FILE *f;
! int *p1, *p2, pxlmag, pkmag;
/*
! * Loop over sizes. Try closest sizes first.
*/
for (p2 = sizes; p2 < sizend; ++p2) if (*p2 >= mag) break;
p1 = p2;
for (;;) {
if (p1 <= sizes)
if (p2 >= sizend) return NULL;
else pxlmag = *p2++;
! else if (p2 >= sizend || mag * mag <= p1[-1] * *p2) pxlmag = *--p1;
else pxlmag = *p2++;
! *mag_ret = pxlmag;
! pkmag = (pxlmag + 2) / 5;
! /*
! * loop over paths
! */
! for (p = font_path;;) {
! if (read_GF_index &&
! (f = formatted_open(p, font, "gf", pkmag, name)) != NULL) {
! *read_font_index = read_GF_index;
! return f;
! }
! if (read_PK_index &&
! (f = formatted_open(p, font, "pk", pkmag, name)) != NULL) {
! *read_font_index = read_PK_index;
! return f;
! }
! if (read_PXL_index &&
! (f = formatted_open(p, font, "pxl", pxlmag, name)) != NULL)
! {
! *read_font_index = read_PXL_index;
! return f;
! }
! p = index(p, PATH_SEP);
! if (p == NULL) break;
! ++p;
! }
}
}
FILE *
! pxl_open(font, font_ret, mag, mag_ret, factor, name, read_font_index)
char *font, **font_ret;
! int mag, *mag_ret;
float *factor;
char **name;
- read_font_index_proc *read_font_index;
{
FILE *f;
int actual_pt, low_pt, high_pt, trial_pt;
--- 174,274 ----
return f;
}
+ /*
+ * Try a given size
+ */
+
static FILE *
! try_size(font, pxlmag, name, font_path, default_font_path)
char *font;
! int pxlmag;
char **name;
! char *font_path, *default_font_path;
{
char *p;
FILE *f;
! int pkmag = (pxlmag + 2) / 5;
/*
! * loop over paths
*/
+ for (p = font_path;; ++p) {
+ int count = 0;
+
+ if (*p == ':' || *p == '\0') {
+ if (default_font_path != NULL &&
+ (f = try_size(font, pxlmag, name, default_font_path,
+ (char *) NULL)) != NULL)
+ return f;
+ if (*p == '\0') break;
+ continue;
+ }
+ if (read_GF_index &&
+ (f = formatted_open(p, font, "gf", pkmag, name, count++))
+ != NULL)
+ return f;
+ if (read_PK_index &&
+ (f = formatted_open(p, font, "pk", pkmag, name, count++))
+ != NULL)
+ return f;
+ if (read_PXL_index &&
+ (f = formatted_open(p, font, "pxl", pxlmag, name, count++))
+ != NULL)
+ return f;
+ p = index(p, PATH_SEP);
+ if (p == NULL) break;
+ }
+ return NULL;
+ }
+
+ /*
+ * Try a given font name
+ */
+
+ static FILE *
+ pre_pxl_open(font, mag, mag_ret, name)
+ char *font;
+ float mag;
+ int *mag_ret;
+ char **name;
+ {
+ FILE *f;
+ int *p1, *p2, pxlmag;
+
+ /*
+ * Loop over sizes. Try actual size first, then closest sizes.
+ */
+ pxlmag = mag + 0.5;
+ if ((f = try_size(font, *mag_ret = pxlmag, name, font_path,
+ default_font_path)) != NULL)
+ return f;
+ if (pxlmag < mag) ++pxlmag; else --pxlmag;
+ if ((f = try_size(font, *mag_ret = pxlmag, name, font_path,
+ default_font_path)) != NULL)
+ return f;
for (p2 = sizes; p2 < sizend; ++p2) if (*p2 >= mag) break;
p1 = p2;
for (;;) {
+ /* find another magnification */
if (p1 <= sizes)
if (p2 >= sizend) return NULL;
else pxlmag = *p2++;
! else if (p2 >= sizend || mag * mag <= p1[-1] * *p2)
! pxlmag = *--p1;
else pxlmag = *p2++;
! if ((f = try_size(font, *mag_ret = pxlmag, name, font_path,
! default_font_path)) != NULL)
! return f;
}
}
FILE *
! pxl_open(font, font_ret, mag, mag_ret, factor, name)
char *font, **font_ret;
! float mag;
! int *mag_ret;
float *factor;
char **name;
{
FILE *f;
int actual_pt, low_pt, high_pt, trial_pt;
***************
*** 273,279 ****
char fn[50], *fnend;
*factor = 1.0;
! f = pre_pxl_open(font, mag, mag_ret, name, read_font_index);
if (f != NULL) {
*font_ret = NULL;
return f;
--- 275,281 ----
char fn[50], *fnend;
*factor = 1.0;
! f = pre_pxl_open(font, mag, mag_ret, name);
if (f != NULL) {
*font_ret = NULL;
return f;
***************
*** 293,300 ****
else if (high_pt > actual_pt + 5) break;
else trial_pt = high_pt++;
Sprintf(fnend, "%d", trial_pt);
! f = pre_pxl_open(fn, mag * actual_pt / trial_pt, mag_ret, name,
! read_font_index);
if (f != NULL) {
*font_ret = strcpy(malloc((unsigned) strlen(fn) + 1), fn);
*factor = (float) actual_pt / trial_pt;
--- 295,301 ----
else if (high_pt > actual_pt + 5) break;
else trial_pt = high_pt++;
Sprintf(fnend, "%d", trial_pt);
! f = pre_pxl_open(fn, mag * actual_pt / trial_pt, mag_ret, name);
if (f != NULL) {
*font_ret = strcpy(malloc((unsigned) strlen(fn) + 1), fn);
*factor = (float) actual_pt / trial_pt;
***************
*** 304,310 ****
}
if (alt_font != NULL) {
*font_ret = alt_font;
! f = pre_pxl_open(alt_font, mag, mag_ret, name, read_font_index);
if (f != NULL)
*font_ret = strcpy(malloc((unsigned) strlen(alt_font) + 1),
alt_font);
--- 305,311 ----
}
if (alt_font != NULL) {
*font_ret = alt_font;
! f = pre_pxl_open(alt_font, mag, mag_ret, name);
if (f != NULL)
*font_ret = strcpy(malloc((unsigned) strlen(alt_font) + 1),
alt_font);
diff -cr xdvi_old/tpic.c xdvi_new/tpic.c
*** xdvi_old/tpic.c Mon Sep 17 17:36:09 1990
--- xdvi_new/tpic.c Wed Sep 26 11:17:01 1990
***************
*** 410,415 ****
else if (strcmp(command, "sh") == 0) shade_last();
else if (strcmp(command, "wh") == 0) whiten_last();
else if (strcmp(command, "bk") == 0) blacken_last();
! else if (spec_warn)
Fprintf(stderr, "%s: special \"%s\" not implemented\n", prog, orig_cp);
}
--- 410,415 ----
else if (strcmp(command, "sh") == 0) shade_last();
else if (strcmp(command, "wh") == 0) whiten_last();
else if (strcmp(command, "bk") == 0) blacken_last();
! else if (spec_warn_now)
Fprintf(stderr, "%s: special \"%s\" not implemented\n", prog, orig_cp);
}
diff -cr xdvi_old/xdvi.c xdvi_new/xdvi.c
*** xdvi_old/xdvi.c Mon Sep 17 17:36:42 1990
--- xdvi_new/xdvi.c Wed Oct 10 13:35:20 1990
***************
*** 28,38 ****
*/
#ifndef lint
#include "patchlevel.h"
! static struct {char a[36], b, c;}
#ifndef X10
! dv_c = {"$Header: xdvi.c (X11), patchlevel = ", '0' + PATCHLEVEL, 0};
#else
! dv_c = {"$Header: xdvi.c (X10), patchlevel = ", '0' + PATCHLEVEL, 0};
#endif
#endif /* lint */
--- 28,40 ----
*/
#ifndef lint
#include "patchlevel.h"
! static struct {char a[36], b, c, d;}
#ifndef X10
! dv_c = {"$Header: xdvi.c (X11), patchlevel = ", '0' + PATCHLEVEL / 10,
! '0' + PATCHLEVEL % 10, 0};
#else
! dv_c = {"$Header: xdvi.c (X10), patchlevel = ", '0' + PATCHLEVEL / 10,
! '0' + PATCHLEVEL % 10, 0};
#endif
#endif /* lint */
***************
*** 58,63 ****
--- 60,66 ----
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
+ #include <X11/keysym.h>
#include "xdvi.icon"
#else /* X10 */
#include <X/Xlib.h>
***************
*** 154,163 ****
int density = 40;
int pixels_per_inch = 300;
int unshrunk_paper_w, unshrunk_paper_h;
int unshrunk_page_w, unshrunk_page_h;
static char *paper = DEFAULT_PAPER;
! static char *margins, *sidemargin, *topmargin;
static Boolean reverse;
static Dimension bwidth = 2;
static int bak_shrink;
--- 157,169 ----
int density = 40;
int pixels_per_inch = 300;
+ int offset_x, offset_y;
int unshrunk_paper_w, unshrunk_paper_h;
int unshrunk_page_w, unshrunk_page_h;
+ Boolean spec_warn = True;
static char *paper = DEFAULT_PAPER;
! static char *sidemargin, *topmargin;
! static char *xoffset, *yoffset;
static Boolean reverse;
static Dimension bwidth = 2;
static int bak_shrink;
***************
*** 172,177 ****
--- 178,186 ----
int pageno_correct = 1;
Boolean keep_flag = False;
static double specialConv;
+ #ifdef BUTTONS
+ Boolean expert = False;
+ #endif
#ifndef X10
#ifdef TOOLKIT
***************
*** 230,235 ****
--- 239,247 ----
#ifdef TOOLKIT
static Widget top_level, vport_widget, draw_widget, clip_widget;
+ #ifdef BUTTONS
+ static Widget form_widget, line_widget, right_widget;
+ #endif
static Widget x_bar, y_bar; /* horizontal and vertical scroll bars */
static Arg vport_args[] = {
***************
*** 320,325 ****
--- 332,363 ----
{XtNheight, (XtArgVal) 30},
{XtNcallback, (XtArgVal) command_call},
};
+
+ static void
+ create_buttons(h)
+ XtArgVal h;
+ {
+ int i;
+
+ line_args[2].value = h;
+ line_args[3].value = (XtArgVal) vport_widget;
+ line_widget = XtCreateManagedWidget("line", widgetClass, form_widget,
+ line_args, XtNumber(line_args));
+ right_args[0].value = (XtArgVal) line_widget;
+ right_args[2].value = h;
+ right_widget = XtCreateManagedWidget("right", compositeWidgetClass,
+ form_widget, right_args, XtNumber(right_args));
+
+ command_args[2].value = (XtArgVal) vport_widget;
+ for (i = 0; i < XtNumber(command_table); ++i) {
+ command_args[0].value = (XtArgVal) command_table[i].label;
+ command_args[2].value = (XtArgVal) command_table[i].y_pos;
+ command_call[0].closure = (caddr_t) command_table[i].closure;
+ (void) XtCreateManagedWidget(command_table[i].name,
+ commandWidgetClass, right_widget,
+ command_args, XtNumber(command_args));
+ }
+ }
#endif /* BUTTONS */
#else /* !TOOLKIT */
***************
*** 379,384 ****
--- 417,423 ----
char *malloc();
double atof();
+ void exit();
/********************************
* tpic routines *
***************
*** 614,625 ****
#define mane_base_x 0
#define mane_base_y 0
! #define home(x) Xtk_home()
! static
! Xtk_home()
{
register int coord;
get_xy();
if (x_bar) {
coord = 0;
--- 653,665 ----
#define mane_base_x 0
#define mane_base_y 0
! static void
! home(scrl)
! Boolean scrl;
{
register int coord;
+ if (!scrl) XUnmapWindow(DISP, WINDOW(mane));
get_xy();
if (x_bar) {
coord = 0;
***************
*** 639,644 ****
--- 679,689 ----
}
XtCallCallbacks(y_bar, XtNscrollProc, window_y + coord);
}
+ if (!scrl) {
+ XMapWindow(DISP, WINDOW(mane));
+ /* Wait for the server to catch up---this eliminates flicker. */
+ XSync(DISP, False);
+ }
}
static Boolean resized = False;
***************
*** 793,798 ****
--- 838,849 ----
{
int x_thick = 0;
int y_thick = 0;
+ #ifdef X10
+ int old_clip_w = clip_w;
+ int old_clip_h = clip_h;
+ int old_x_thick = x_thick;
+ int old_y_thick = y_thick;
+ #endif
/* determine existence of scrollbars */
if (window_w < page_w) x_thick = BAR_THICK;
***************
*** 821,828 ****
--- 872,887 ----
XMapWindow(DPY WINDOW(mane));
}
else
+ #ifdef X10
+ if (clip_w != old_clip_w || clip_h != old_clip_h ||
+ x_thick != old_x_thick || y_thick != old_y_thick) {
+ #endif
XMoveResizeWindow(DPY WINDOW(mane),
y_thick, x_thick, clip_w, clip_h);
+ #ifdef X10
+ XSync(False);
+ }
+ #endif
/* process scroll bars */
if (x_thick) {
***************
*** 1124,1130 ****
XEvent *eventp;
{
int next_page;
! #ifndef X10
Window ww;
#endif
--- 1183,1189 ----
XEvent *eventp;
{
int next_page;
! #ifdef TOOLKIT
Window ww;
#endif
***************
*** 1190,1195 ****
--- 1249,1279 ----
case 'c':
center(eventp->xkey.x, eventp->xkey.y);
return;
+ case 'M':
+ XTranslateCoordinates(DISP, eventp->xkey.window,
+ WINDOW(mane), eventp->xkey.x, eventp->xkey.y,
+ &home_x, &home_y, &ww); /* throw away last argument */
+ home_x *= mane.shrinkfactor;
+ home_y *= mane.shrinkfactor;
+ return;
+ #ifdef BUTTONS
+ case 'x':
+ if (arg0 && expert == (number0 != 0)) return;
+ if (expert) { /* create buttons */
+ XtResizeWidget(vport_widget, window_w -= XTRA_WID, window_h,
+ 0);
+ create_buttons((XtArgVal) window_h);
+ expert = False;
+ }
+ else { /* destroy buttons */
+ XtResizeWidget(vport_widget, window_w += XTRA_WID, window_h,
+ 0);
+ XtDestroyWidget(right_widget);
+ XtDestroyWidget(line_widget);
+ expert = True;
+ }
+ return;
+ #endif /* BUTTONS */
#else /* !TOOLKIT */
case 'l':
if (mane.base_x <= 0) goto bad;
***************
*** 1219,1246 ****
XWarpMouse(WINDOW(mane), clip_w/2, clip_h/2, GXcopy);
#endif
return;
#endif /* TOOLKIT */
#ifndef X10
- case 'M':
- XTranslateCoordinates(DISP, eventp->xkey.window,
- WINDOW(mane), eventp->xkey.x, eventp->xkey.y,
- &home_x, &home_y, &ww); /* throw away last argument */
- home_x *= mane.shrinkfactor;
- home_y *= mane.shrinkfactor;
- return;
case '\020': /* Control P */
Printf("Unit = %d, bitord = %d, byteord = %d\n",
BitmapUnit(DISP), BitmapBitOrder(DISP),
ImageByteOrder(DISP));
return;
- #else
- case 'M':
- home_x = (XKEY(*eventp).x - (y_bar ? BAR_THICK : 0)
- + mane.base_x) * mane.shrinkfactor;
- home_y = (XKEY(*eventp).y - (x_bar ? BAR_THICK : 0)
- + mane.base_y) * mane.shrinkfactor;
- return;
#endif
case 's':
if (!arg0) {
--- 1303,1322 ----
XWarpMouse(WINDOW(mane), clip_w/2, clip_h/2, GXcopy);
#endif
return;
+ case 'M':
+ home_x = (XKEY(*eventp).x - (y_bar ? BAR_THICK : 0)
+ + mane.base_x) * mane.shrinkfactor;
+ home_y = (XKEY(*eventp).y - (x_bar ? BAR_THICK : 0)
+ + mane.base_y) * mane.shrinkfactor;
+ return;
#endif /* TOOLKIT */
#ifndef X10
case '\020': /* Control P */
Printf("Unit = %d, bitord = %d, byteord = %d\n",
BitmapUnit(DISP), BitmapBitOrder(DISP),
ImageByteOrder(DISP));
return;
#endif
case 's':
if (!arg0) {
***************
*** 1258,1281 ****
reset_fonts();
}
#ifdef TOOLKIT
! XUnmapWindow(DISP, WINDOW(mane));
! {
! Dimension replyW, replyH;
! if (XtMakeResizeRequest(draw_widget, (Dimension) page_w,
! (Dimension) page_h, &replyW, &replyH)
! == XtGeometryAlmost)
! (void) XtMakeResizeRequest(draw_widget, replyW, replyH,
! (Dimension *) NULL, (Dimension *) NULL);
! }
get_geom();
home(False);
- XMapWindow(DISP, WINDOW(mane));
- /* Wait for next event; this will likely be an expose event,
- so we don't redraw the window twice. */
- {
- XEvent event;
- XPeekEvent(DISP, &event);
- }
#else /* TOOLKIT */
reconfig();
home(False);
--- 1334,1344 ----
reset_fonts();
}
#ifdef TOOLKIT
! draw_args[0].value = (XtArgVal) page_w;
! draw_args[1].value = (XtArgVal) page_h;
! XtSetValues(draw_widget, draw_args, (Cardinal) 2);
get_geom();
home(False);
#else /* TOOLKIT */
reconfig();
home(False);
***************
*** 1299,1305 ****
if (0 <= next_page && next_page < total_pages) {
if (current_page != next_page) {
current_page = next_page;
! spec_warn = True;
if (!keep_flag) home(False);
}
canit = True;
--- 1362,1368 ----
if (0 <= next_page && next_page < total_pages) {
if (current_page != next_page) {
current_page = next_page;
! spec_warn_now = spec_warn;
if (!keep_flag) home(False);
}
canit = True;
***************
*** 1566,1578 ****
}
else {
draw_page();
! spec_warn = False;
}
}
redraw_page()
{
! if (debug & DBG_EVENT) fputs("Redraw page: ", stdout);
get_xy();
ClearPage(mane);
mane.min_x = -window_x;
--- 1629,1641 ----
}
else {
draw_page();
! spec_warn_now = False;
}
}
redraw_page()
{
! if (debug & DBG_EVENT) Fputs("Redraw page: ", stdout);
get_xy();
ClearPage(mane);
mane.min_x = -window_x;
***************
*** 1610,1616 ****
windowrec->max_x = windowrec->max_y = 0;
}
! static int
handle_intr() {
event_counter = 1;
event_freq = -1; /* forget Plan B */
--- 1673,1679 ----
windowrec->max_x = windowrec->max_y = 0;
}
! static void
handle_intr() {
event_counter = 1;
event_freq = -1; /* forget Plan B */
***************
*** 1681,1703 ****
usage() {
#ifndef X10
#ifndef VMS
! fputs("\
! Usage: xdvi [+[<page>]] [-s <shrink>] [-S <density>] [-p <pixels>] [-l]\n\
[-paper <papertype>] [-mgs[n] <size>] [-altfont <font>]\n\
! [-margins <inches>] [-sidemargin <inches>] [-topmargin <inches>] [-rv]\
\n\
[-fg <color>] [-bg <color>] [-hl <color>] [-bd <color>] \
[-cr <color>]\n\
[-bw <width>] [-geometry <geometry>] [-icongeometry <geometry>]\n\
[-iconic] [-display <host:display>] [-copy] [-thorough] dvi_file\n",
stderr);
#else /* VMS */
! fputs("\
! Usage: xdvi [+[<page>]] [-s <shrink>] [-density <%>] [-p <pixels>] [-l]\n\
[-paper <papertype>] [-mgs[n] <size>] [-altfont <font>]\n\
! [-margins <inches>] [-sidemargin <inches>] [-topmargin <inches>] [-rv]\
\n", stderr);
! fputs("\
[-fg <color>] [-bg <color>] [-hl <color>] [-bd <color>] \
[-cr <color>]\n\
[-bw <width>] [-geometry <geometry>] [-icongeometry <geometry>]\n\
--- 1744,1782 ----
usage() {
#ifndef X10
#ifndef VMS
! #ifdef BUTTONS
! Fputs("\
! Usage: xdvi [+[<page>]] [-s <shrink>] [-S <density>] [-p <pixels>] [-l] [-sw]\n\
! [-expert] [-paper <papertype>] [-mgs[n] <size>] [-altfont <font>]\n\
! [-margins <dimen>] [-sidemargin <dimen>] [-topmargin <dimen>] [-rv]\
! \n\
! [-offsets <dimen>] [-xoffset <dimen>] [-yoffset <dimen>]\n\
! [-fg <color>] [-bg <color>] [-hl <color>] [-bd <color>] \
! [-cr <color>]\n\
! [-bw <width>] [-geometry <geometry>] [-icongeometry <geometry>]\n\
! [-iconic] [-display <host:display>] [-copy] [-thorough] dvi_file\n",
! stderr);
! #else /* !BUTTONS */
! Fputs("\
! Usage: xdvi [+[<page>]] [-s <shrink>] [-S <density>] [-p <pixels>] [-l] [-sw]\n\
[-paper <papertype>] [-mgs[n] <size>] [-altfont <font>]\n\
! [-margins <dimen>] [-sidemargin <dimen>] [-topmargin <dimen>] [-rv]\
\n\
+ [-offsets <dimen>] [-xoffset <dimen>] [-yoffset <dimen>]\n\
[-fg <color>] [-bg <color>] [-hl <color>] [-bd <color>] \
[-cr <color>]\n\
[-bw <width>] [-geometry <geometry>] [-icongeometry <geometry>]\n\
[-iconic] [-display <host:display>] [-copy] [-thorough] dvi_file\n",
stderr);
+ #endif /* BUTTONS */
#else /* VMS */
! Fputs("\
! Usage: xdvi [+[<page>]] [-s <shrink>] [-density <%>] [-p <pixels>] [-l] [-sw]\n\
[-paper <papertype>] [-mgs[n] <size>] [-altfont <font>]\n\
! [-margins <dimen>] [-sidemargin <dimen>] [-topmargin <dimen>] [-rv]\
\n", stderr);
! Fputs("\
! [-offsets <dimen>] [-xoffset <dimen>] [-yoffset <dimen>]\n\
[-fg <color>] [-bg <color>] [-hl <color>] [-bd <color>] \
[-cr <color>]\n\
[-bw <width>] [-geometry <geometry>] [-icongeometry <geometry>]\n\
***************
*** 1705,1715 ****
stderr);
#endif /* VMS */
#else /* X10 */
! fputs("\
! Usage: xdvi [+[<page>]] [-s <shrink>] [-S <density>] [-p <pixels>] [-l]\n\
[-paper <papertype>] [-mgs[n] <size>] [-altfont <font>]\n\
! [-margins <inches>] [-sidemargin <inches>] [-topmargin <inches>] [-rv]\
\n\
[-fg <color>] [-bg <color>] [-hl <color>] [-bd <color>] \
[-cr <color>]\n\
[-bw <width>] [-geometry <geometry> | =<geometry>]\n\
--- 1784,1795 ----
stderr);
#endif /* VMS */
#else /* X10 */
! Fputs("\
! Usage: xdvi [+[<page>]] [-s <shrink>] [-S <density>] [-p <pixels>] [-l] [-sw]\n\
[-paper <papertype>] [-mgs[n] <size>] [-altfont <font>]\n\
! [-margins <dimen>] [-sidemargin <dimen>] [-topmargin <dimen>] [-rv]\
\n\
+ [-offsets <dimen>] [-xoffset <dimen>] [-yoffset <dimen>]\n\
[-fg <color>] [-bg <color>] [-hl <color>] [-bd <color>] \
[-cr <color>]\n\
[-bw <width>] [-geometry <geometry> | =<geometry>]\n\
***************
*** 1718,1723 ****
--- 1798,1813 ----
exit(1);
}
+ static int
+ atopix(arg)
+ char *arg;
+ {
+ int len = strlen(arg);
+
+ return (len > 2 && arg[len - 2] == 'c' && arg[len - 1] == 'm' ?
+ 1.0 / 2.54 : 1.0) * atof(arg) * pixels_per_inch + 0.5;
+ }
+
/**
** Main programs start here.
**/
***************
*** 1738,1750 ****
#endif
{"-density", ".densityPercent", XrmoptionSepArg, (caddr_t) NULL},
{"-p", ".pixelsPerInch", XrmoptionSepArg, (caddr_t) NULL},
! {"-margins", ".margins", XrmoptionSepArg, (caddr_t) NULL},
{"-sidemargin", ".sideMargin", XrmoptionSepArg, (caddr_t) NULL},
{"-topmargin", ".topMargin", XrmoptionSepArg, (caddr_t) NULL},
{"-paper", ".paper", XrmoptionSepArg, (caddr_t) NULL},
{"-altfont", ".altFont", XrmoptionSepArg, (caddr_t) NULL},
{"-l", ".listFonts", XrmoptionNoArg, (caddr_t) "on"},
{"+l", ".listFonts", XrmoptionNoArg, (caddr_t) "off"},
{"-fg", ".foreground", XrmoptionSepArg, (caddr_t) NULL},
{"-foreground", ".foreground", XrmoptionSepArg, (caddr_t) NULL},
{"-bg", ".background", XrmoptionSepArg, (caddr_t) NULL},
--- 1828,1845 ----
#endif
{"-density", ".densityPercent", XrmoptionSepArg, (caddr_t) NULL},
{"-p", ".pixelsPerInch", XrmoptionSepArg, (caddr_t) NULL},
! {"-margins", ".Margin", XrmoptionSepArg, (caddr_t) NULL},
{"-sidemargin", ".sideMargin", XrmoptionSepArg, (caddr_t) NULL},
{"-topmargin", ".topMargin", XrmoptionSepArg, (caddr_t) NULL},
+ {"-offsets", ".Offset", XrmoptionSepArg, (caddr_t) NULL},
+ {"-xoffset", ".xOffset", XrmoptionSepArg, (caddr_t) NULL},
+ {"-yoffset", ".yOffset", XrmoptionSepArg, (caddr_t) NULL},
{"-paper", ".paper", XrmoptionSepArg, (caddr_t) NULL},
{"-altfont", ".altFont", XrmoptionSepArg, (caddr_t) NULL},
{"-l", ".listFonts", XrmoptionNoArg, (caddr_t) "on"},
{"+l", ".listFonts", XrmoptionNoArg, (caddr_t) "off"},
+ {"-sw", ".specialWarn", XrmoptionNoArg, (caddr_t) "on"},
+ {"+sw", ".specialWarn", XrmoptionNoArg, (caddr_t) "off"},
{"-fg", ".foreground", XrmoptionSepArg, (caddr_t) NULL},
{"-foreground", ".foreground", XrmoptionSepArg, (caddr_t) NULL},
{"-bg", ".background", XrmoptionSepArg, (caddr_t) NULL},
***************
*** 1756,1761 ****
--- 1851,1860 ----
{"+copy", ".copy", XrmoptionNoArg, (caddr_t) "off"},
{"-thorough", ".thorough", XrmoptionNoArg, (caddr_t) "on"},
{"+thorough", ".thorough", XrmoptionNoArg, (caddr_t) "off"},
+ #ifdef BUTTONS
+ {"-expert", ".expert", XrmoptionNoArg, (caddr_t) "on"},
+ {"+expert", ".expert", XrmoptionNoArg, (caddr_t) "off"},
+ #endif
{"-mgs", ".magnifierSize1",XrmoptionSepArg, (caddr_t) NULL},
{"-mgs1", ".magnifierSize1",XrmoptionSepArg, (caddr_t) NULL},
{"-mgs2", ".magnifierSize2",XrmoptionSepArg, (caddr_t) NULL},
***************
*** 1773,1784 ****
(Cardinal) &density, XtRInt, (caddr_t) &density},
{"pixelsPerInch", "PixelsPerInch", XtRInt, sizeof(int),
(Cardinal) &pixels_per_inch, XtRInt, (caddr_t) &pixels_per_inch},
- {"margins", "Margin", XtRString, sizeof(char *),
- (Cardinal) &margins, XtRString, NULL},
{"sideMargin", "Margin", XtRString, sizeof(char *),
(Cardinal) &sidemargin, XtRString, NULL},
{"topMargin", "Margin", XtRString, sizeof(char *),
(Cardinal) &topmargin, XtRString, NULL},
{"paper", "Paper", XtRString, sizeof(char *),
(Cardinal) &paper, XtRString, (caddr_t) DEFAULT_PAPER},
{"altFont", "AltFont", XtRString, sizeof(char *),
--- 1872,1885 ----
(Cardinal) &density, XtRInt, (caddr_t) &density},
{"pixelsPerInch", "PixelsPerInch", XtRInt, sizeof(int),
(Cardinal) &pixels_per_inch, XtRInt, (caddr_t) &pixels_per_inch},
{"sideMargin", "Margin", XtRString, sizeof(char *),
(Cardinal) &sidemargin, XtRString, NULL},
{"topMargin", "Margin", XtRString, sizeof(char *),
(Cardinal) &topmargin, XtRString, NULL},
+ {"xOffset", "Offset", XtRString, sizeof(char *),
+ (Cardinal) &xoffset, XtRString, NULL},
+ {"yOffset", "Offset", XtRString, sizeof(char *),
+ (Cardinal) &yoffset, XtRString, NULL},
{"paper", "Paper", XtRString, sizeof(char *),
(Cardinal) &paper, XtRString, (caddr_t) DEFAULT_PAPER},
{"altFont", "AltFont", XtRString, sizeof(char *),
***************
*** 1787,1792 ****
--- 1888,1895 ----
(Cardinal) &list_fonts, XtRBoolean, (caddr_t) &list_fonts},
{"reverseVideo", "ReverseVideo", XtRBoolean, sizeof(Boolean),
(Cardinal) &reverse, XtRBoolean, (caddr_t) &reverse},
+ {"specialWarn", "SpecialWarn", XtRBoolean, sizeof(Boolean),
+ (Cardinal) &spec_warn, XtRBoolean, (caddr_t) &spec_warn},
{"foreground", "Foreground", XtRPixel, sizeof(Pixel),
(Cardinal)&fore_Pixel, XtRPixel, (caddr_t) &fore_Pixel},
{"foreground", "Foreground", XtRString, sizeof(char *),
***************
*** 1813,1818 ****
--- 1916,1925 ----
(Cardinal)©, XtRBoolean, (caddr_t) ©},
{"thorough", "Thorough", XtRBoolean, sizeof(Boolean),
(Cardinal)&thorough, XtRBoolean, (caddr_t) &thorough},
+ #ifdef BUTTONS
+ {"expert", "Expert", XtRBoolean, sizeof(Boolean),
+ (Cardinal)&expert, XtRBoolean, (caddr_t) &expert},
+ #endif
{"magnifierSize1", "MagnifierSize", XtRInt, sizeof(int),
(Cardinal) &mg_size[0], XtRInt, (caddr_t) &mg_size[0]},
{"magnifierSize2", "MagnifierSize", XtRInt, sizeof(int),
***************
*** 1837,1842 ****
--- 1944,1950 ----
{XtNheight, (XtArgVal) 0},
{XtNiconPixmap, (XtArgVal) 0},
{XtNinput, (XtArgVal) True},
+ {XtNtitle, (XtArgVal) 0},
};
#else /* !TOOLKIT */
***************
*** 1843,1848 ****
--- 1951,1958 ----
static char *display;
static char *geometry;
+ static char *margins;
+ static char *offsets;
#ifndef X10
static Boolean iconic = False;
***************
*** 1879,1933 ****
char *resource;
enum {FalseArg, TrueArg, StickyArg, SepArg} argclass;
enum {BooleanArg, StringArg, NumberArg} argtype;
caddr_t address;
} options[] = {
/* the display option MUST be first */
! {"-display", NULL, SepArg, StringArg, (caddr_t) &display},
! {"-d", "debugLevel", SepArg, StringArg, (caddr_t) &debug_arg},
! {"+", NULL, StickyArg, StringArg, (caddr_t) &curr_page},
! {"-s", "shrinkFactor", SepArg, NumberArg, (caddr_t) &shrink_factor},
! {"-S", "densityPercent", SepArg, NumberArg, (caddr_t) &density},
! {"-density", NULL, SepArg, NumberArg, (caddr_t) &density},
! {"-p", "pixelsPerInch", SepArg, NumberArg, (caddr_t) &pixels_per_inch},
! {"-margins", "margins", SepArg, StringArg, (caddr_t) &margins},
! {"-sidemargin", "sideMargin", SepArg, StringArg, (caddr_t) &sidemargin},
! {"-topmargin", "topMargin", SepArg, StringArg, (caddr_t) &topmargin},
! {"-paper", "paper", SepArg, StringArg, (caddr_t) &paper},
! {"-altfont", "altFont", SepArg, StringArg, (caddr_t) &alt_font},
! {"-l", "listFonts", TrueArg, BooleanArg, (caddr_t) &list_fonts},
! {"+l", NULL, FalseArg, BooleanArg, (caddr_t) &list_fonts},
! {"-rv", "reverseVideo", TrueArg, BooleanArg, (caddr_t) &reverse},
! {"+rv", NULL, FalseArg, BooleanArg, (caddr_t) &reverse},
! {"-bw", "borderWidth", SepArg, NumberArg, (caddr_t) &bwidth},
! {"-borderwidth", NULL, SepArg, NumberArg, (caddr_t) &bwidth},
! {"-fg", "foreground", SepArg, StringArg, (caddr_t) &fore_color},
! {"-foreground", NULL, SepArg, StringArg, (caddr_t) &fore_color},
! {"-bg", "background", SepArg, StringArg, (caddr_t) &back_color},
! {"-background", NULL, SepArg, StringArg, (caddr_t) &back_color},
! {"-bd", "borderColor", SepArg, StringArg, (caddr_t) &brdr_color},
! {"-bordercolor",NULL, SepArg, StringArg, (caddr_t) &brdr_color},
! {"-hl", "highlight", SepArg, StringArg, (caddr_t) &high_color},
! {"-cr", "cursorColor", SepArg, StringArg, (caddr_t) &curs_color},
! {"-geometry", "geometry", SepArg, StringArg, (caddr_t) &geometry},
#ifdef X10
! {"=", NULL, StickyArg, StringArg, (caddr_t) &geometry},
#endif
#ifndef X10
! {"-icongeometry","iconGeometry",StickyArg, StringArg, (caddr_t) &icon_geometry},
! {"-iconic", "iconic", TrueArg, BooleanArg, (caddr_t) &iconic},
! {"+iconic", NULL, FalseArg, BooleanArg, (caddr_t) &iconic},
! {"-copy", "copy", TrueArg, BooleanArg, (caddr_t) ©},
! {"+copy", NULL, FalseArg, BooleanArg, (caddr_t) ©},
! {"-thorough", "thorough", TrueArg, BooleanArg, (caddr_t) &thorough},
! {"+thorough", NULL, FalseArg, BooleanArg, (caddr_t) &thorough},
#endif /* X10 */
! {"-mgs", NULL, SepArg, NumberArg, (caddr_t) &mg_size[0]},
! {"-mgs1", "magnifierSize1",SepArg, NumberArg, (caddr_t) &mg_size[0]},
! {"-mgs2", "magnifierSize2",SepArg, NumberArg, (caddr_t) &mg_size[1]},
! {"-mgs3", "magnifierSize3",SepArg, NumberArg, (caddr_t) &mg_size[2]},
#ifndef X10
! {"-mgs4", "magnifierSize3",SepArg, NumberArg, (caddr_t) &mg_size[3]},
! {"-mgs5", "magnifierSize3",SepArg, NumberArg, (caddr_t) &mg_size[4]},
#endif
};
--- 1989,2049 ----
char *resource;
enum {FalseArg, TrueArg, StickyArg, SepArg} argclass;
enum {BooleanArg, StringArg, NumberArg} argtype;
+ int classcount;
caddr_t address;
} options[] = {
/* the display option MUST be first */
! {"-display", NULL, SepArg, StringArg, 1, (caddr_t) &display},
! {"-d", "debugLevel", SepArg, StringArg, 1, (caddr_t) &debug_arg},
! {"+", NULL, StickyArg, StringArg, 1,(caddr_t) &curr_page},
! {"-s", "shrinkFactor", SepArg, NumberArg, 1, (caddr_t) &shrink_factor},
! {"-S", NULL, SepArg, NumberArg, 2, (caddr_t) &density},
! {"-density", "densityPercent", SepArg, NumberArg, 1, (caddr_t) &density},
! {"-p", "pixelsPerInch", SepArg, NumberArg, 1, (caddr_t) &pixels_per_inch},
! {"-margins", "Margin", SepArg, StringArg, 3, (caddr_t) &margins},
! {"-sidemargin", "sideMargin", SepArg, StringArg, 1, (caddr_t) &sidemargin},
! {"-topmargin", "topMargin", SepArg, StringArg, 1, (caddr_t) &topmargin},
! {"-offsets", "Offset", SepArg, StringArg, 3, (caddr_t) &offsets},
! {"-xoffset", "xOffset", SepArg, StringArg, 1, (caddr_t) &xoffset},
! {"-yoffset", "yOffset", SepArg, StringArg, 1, (caddr_t) &yoffset},
! {"-paper", "paper", SepArg, StringArg, 1, (caddr_t) &paper},
! {"-altfont", "altFont", SepArg, StringArg, 1, (caddr_t) &alt_font},
! {"-l", NULL, TrueArg, BooleanArg, 2, (caddr_t) &list_fonts},
! {"+l", "listFonts", FalseArg, BooleanArg, 1,(caddr_t) &list_fonts},
! {"-rv", NULL, TrueArg, BooleanArg, 2, (caddr_t) &reverse},
! {"+rv", "reverseVideo", FalseArg, BooleanArg, 1,(caddr_t) &reverse},
! {"-sw", NULL, TrueArg, BooleanArg, 2, (caddr_t) &spec_warn},
! {"+sw", "specialWarn", FalseArg, BooleanArg, 1,(caddr_t) &spec_warn},
! {"-bw", NULL, SepArg, NumberArg, 2, (caddr_t) &bwidth},
! {"-borderwidth", "borderWidth", SepArg, NumberArg, 1, (caddr_t) &bwidth},
! {"-fg", NULL, SepArg, StringArg, 2, (caddr_t) &fore_color},
! {"-foreground", "foreground", SepArg, StringArg, 1, (caddr_t) &fore_color},
! {"-bg", NULL, SepArg, StringArg, 2, (caddr_t) &back_color},
! {"-background", "background", SepArg, StringArg, 1, (caddr_t) &back_color},
! {"-bd", NULL, SepArg, StringArg, 2, (caddr_t) &brdr_color},
! {"-bordercolor","borderColor", SepArg, StringArg, 1, (caddr_t) &brdr_color},
! {"-hl", "highlight", SepArg, StringArg, 1, (caddr_t) &high_color},
! {"-cr", "cursorColor", SepArg, StringArg, 1, (caddr_t) &curs_color},
#ifdef X10
! {"=", NULL, StickyArg, StringArg, 2,(caddr_t) &geometry},
#endif
+ {"-geometry", "geometry", SepArg, StringArg, 1, (caddr_t) &geometry},
#ifndef X10
! {"-icongeometry","iconGeometry",StickyArg, StringArg, 1,(caddr_t) &icon_geometry},
! {"-iconic", NULL, TrueArg, BooleanArg, 2, (caddr_t) &iconic},
! {"+iconic", "iconic", FalseArg, BooleanArg, 1,(caddr_t) &iconic},
! {"-copy", NULL, TrueArg, BooleanArg, 2, (caddr_t) ©},
! {"+copy", "copy", FalseArg, BooleanArg, 1,(caddr_t) ©},
! {"-thorough", NULL, TrueArg, BooleanArg, 2, (caddr_t) &thorough},
! {"+thorough", "thorough", FalseArg, BooleanArg, 1,(caddr_t) &thorough},
#endif /* X10 */
! {"-mgs", NULL, SepArg, NumberArg, 2, (caddr_t) &mg_size[0]},
! {"-mgs1", "magnifierSize1",SepArg, NumberArg, 1, (caddr_t) &mg_size[0]},
! {"-mgs2", "magnifierSize2",SepArg, NumberArg, 1, (caddr_t) &mg_size[1]},
! {"-mgs3", "magnifierSize3",SepArg, NumberArg, 1, (caddr_t) &mg_size[2]},
#ifndef X10
! {"-mgs4", "magnifierSize4",SepArg, NumberArg, 1, (caddr_t) &mg_size[3]},
! {"-mgs5", "magnifierSize5",SepArg, NumberArg, 1, (caddr_t) &mg_size[4]},
#endif
};
***************
*** 1946,1952 ****
char *optstring;
caddr_t addr;
struct option *opt, *candidate;
! int len1, len2, matchlen;
for (arg = argv + 1; arg < argvend; ++arg) {
len1 = strlen(*arg);
--- 2062,2068 ----
char *optstring;
caddr_t addr;
struct option *opt, *candidate;
! int len1, len2, matchlen, i;
for (arg = argv + 1; arg < argvend; ++arg) {
len1 = strlen(*arg);
***************
*** 1989,1996 ****
}
}
addr = candidate->address;
- for (opt = options; opt < options + XtNumber(options); ++opt)
- if (opt->address == addr) opt->resource = NULL;
switch (candidate->argclass) {
case FalseArg: *((Boolean *) addr) = False; break;
case TrueArg: *((Boolean *) addr) = True; break;
--- 2105,2110 ----
***************
*** 2006,2011 ****
--- 2120,2127 ----
case StringArg: *((char **) addr) = optstring; break;
case NumberArg: *((int *) addr) = atoi(optstring); break;
}
+ for (i = candidate->classcount; i > 0; --i)
+ (candidate++)->resource = NULL;
}
#ifndef X10
***************
*** 2035,2040 ****
--- 2151,2161 ----
*((Boolean *) opt->address) =
(strcmp(optstring, "on") == 0);
}
+
+ if (!sidemargin) sidemargin = margins;
+ if (!topmargin) topmargin = margins;
+ if (!xoffset) xoffset = offsets;
+ if (!yoffset) yoffset = offsets;
}
#endif /* TOOLKIT */
***************
*** 2102,2140 ****
static Boolean
set_paper_type() {
char temp[21];
- int i;
- double factor = 1.0;
- char c;
char **p;
char *q;
if (strlen(paper) > sizeof(temp) - 1) return False;
! i = 0;
for (;;) { /* convert to lower case */
! c = paper[i];
if (c >= 'A' && c <= 'Z') c ^= ('a' ^ 'A');
! temp[i] = c;
if (c == '\0') break;
- ++i;
}
/* perform substitutions */
for (p = paper_types; p < paper_types + XtNumber(paper_types); p += 2)
if (strcmp(temp, *p) == 0) {
! (void) strcpy(temp, p[1]);
! i = strlen(temp);
break;
}
! if (i > 2 && strcmp(temp + i - 2, "cm") == 0) {
! factor = 1.0 / 2.54;
! temp[i - 2] = '\0';
! }
! q = index(temp, 'x');
if (q == NULL) return False;
! *q = '\0';
! factor *= pixels_per_inch;
! unshrunk_paper_w = atof(temp) * factor + 0.5;
! unshrunk_paper_h = atof(q + 1) * factor + 0.5;
return (unshrunk_paper_w != 0 && unshrunk_paper_h != 0);
}
--- 2223,2253 ----
static Boolean
set_paper_type() {
+ char *arg;
char temp[21];
char **p;
char *q;
if (strlen(paper) > sizeof(temp) - 1) return False;
! arg = paper;
! q = temp;
for (;;) { /* convert to lower case */
! char c = *arg++;
if (c >= 'A' && c <= 'Z') c ^= ('a' ^ 'A');
! *q++ = c;
if (c == '\0') break;
}
+ arg = temp;
/* perform substitutions */
for (p = paper_types; p < paper_types + XtNumber(paper_types); p += 2)
if (strcmp(temp, *p) == 0) {
! arg = p[1];
break;
}
! q = index(arg, 'x');
if (q == NULL) return False;
! unshrunk_paper_w = atopix(arg);
! unshrunk_paper_h = atopix(q + 1);
return (unshrunk_paper_w != 0 && unshrunk_paper_h != 0);
}
***************
*** 2149,2156 ****
#ifdef TOOLKIT
#ifdef BUTTONS
! Widget form_widget;
! Widget right_widget;
#endif
#else /* !TOOLKIT */
#ifndef X10
--- 2262,2268 ----
#ifdef TOOLKIT
#ifdef BUTTONS
! int xtra_wid;
#endif
#else /* !TOOLKIT */
#ifndef X10
***************
*** 2190,2196 ****
XtGetApplicationResources(top_level, (caddr_t) NULL, resources,
XtNumber(resources), NULL, 0);
- if (shrink_factor <= 0 || density <= 0 || pixels_per_inch <= 0) usage();
DISP = XtDisplay(top_level);
SCRN = XtScreen(top_level);
--- 2302,2307 ----
***************
*** 2204,2222 ****
if (high_color) hl_Pixel = string_to_pixel(&high_color);
if (curs_color) cr_Pixel = string_to_pixel(&curs_color);
#endif
- if (shrink_factor <= 0 || density <= 0 || pixels_per_inch <= 0 ||
- dvi_name == NULL) usage();
#endif /* TOOLKIT */
if (shrink_factor != 1) bak_shrink = shrink_factor;
mane.shrinkfactor = shrink_factor;
specialConv = pixels_per_inch / 1000.0;
if (debug_arg != NULL)
debug = isdigit(*debug_arg) ? atoi(debug_arg) : DBG_ALL;
! if (margins) home_x = home_y = atof(margins) * pixels_per_inch;
! if (sidemargin) home_x = atof(sidemargin) * pixels_per_inch;
! if (topmargin) home_y = atof(topmargin) * pixels_per_inch;
if (!set_paper_type()) oops("Don't recognize paper type %s", paper);
init_pxl_open();
--- 2315,2334 ----
if (high_color) hl_Pixel = string_to_pixel(&high_color);
if (curs_color) cr_Pixel = string_to_pixel(&curs_color);
#endif
#endif /* TOOLKIT */
+ if (shrink_factor <= 0 || density <= 0 || pixels_per_inch <= 0 ||
+ dvi_name == NULL) usage();
if (shrink_factor != 1) bak_shrink = shrink_factor;
mane.shrinkfactor = shrink_factor;
specialConv = pixels_per_inch / 1000.0;
if (debug_arg != NULL)
debug = isdigit(*debug_arg) ? atoi(debug_arg) : DBG_ALL;
! if (sidemargin) home_x = atopix(sidemargin);
! if (topmargin) home_y = atopix(topmargin);
! offset_x = xoffset ? atopix(xoffset) : pixels_per_inch;
! offset_y = yoffset ? atopix(yoffset) : pixels_per_inch;
if (!set_paper_type()) oops("Don't recognize paper type %s", paper);
init_pxl_open();
***************
*** 2309,2323 ****
screen_w = WidthOfScreen(SCRN) - 2*bwidth;
screen_h = HeightOfScreen(SCRN) - 2*bwidth;
#ifdef BUTTONS
! temp_args3[0].value = (XtArgVal) (page_w + XTRA_WID < screen_w ?
! page_w + XTRA_WID : screen_w);
#else
! temp_args3[0].value = (XtArgVal) (page_w<screen_w ? page_w : screen_w);
#endif
temp_args3[1].value = (XtArgVal) (page_h<screen_h ? page_h : screen_h);
temp_args3[2].value = (XtArgVal) (XCreateBitmapFromData(DISP,
RootWindowOfScreen(SCRN),
xdvi_bits, xdvi_width, xdvi_height));
XtSetValues(top_level, temp_args3, XtNumber(temp_args3));
#ifdef BUTTONS
--- 2421,2437 ----
screen_w = WidthOfScreen(SCRN) - 2*bwidth;
screen_h = HeightOfScreen(SCRN) - 2*bwidth;
#ifdef BUTTONS
! xtra_wid = expert ? 0 : XTRA_WID;
#else
! #define xtra_wid 0
#endif
+ temp_args3[0].value = (XtArgVal) (page_w + xtra_wid < screen_w ?
+ page_w + xtra_wid : screen_w);
temp_args3[1].value = (XtArgVal) (page_h<screen_h ? page_h : screen_h);
temp_args3[2].value = (XtArgVal) (XCreateBitmapFromData(DISP,
RootWindowOfScreen(SCRN),
xdvi_bits, xdvi_width, xdvi_height));
+ temp_args3[4].value = (XtArgVal) dvi_name;
XtSetValues(top_level, temp_args3, XtNumber(temp_args3));
#ifdef BUTTONS
***************
*** 2324,2358 ****
form_widget = XtCreateManagedWidget("form", formWidgetClass,
top_level, form_args, XtNumber(form_args));
! vport_args[0].value = temp_args3[0].value - XTRA_WID;
vport_args[1].value = temp_args3[1].value;
vport_widget = XtCreateManagedWidget("vport", viewportWidgetClass,
form_widget, vport_args, XtNumber(vport_args));
line_args[0].value = (XtArgVal) high_color ? hl_Pixel : fore_Pixel;
! line_args[2].value = temp_args3[1].value;
! line_args[3].value = (XtArgVal) vport_widget;
! right_args[0].value = (XtArgVal) XtCreateManagedWidget("line",
! widgetClass, form_widget, line_args, XtNumber(line_args));
! right_args[2].value = temp_args3[1].value;
! right_widget = XtCreateManagedWidget("right", compositeWidgetClass,
! form_widget, right_args, XtNumber(right_args));
!
! command_args[2].value = (XtArgVal) vport_widget;
! {
! int i;
! for (i = 0; i < XtNumber(command_table); ++i) {
! command_args[0].value = (XtArgVal) command_table[i].label;
! command_args[2].value = (XtArgVal) command_table[i].y_pos;
! command_call[0].closure = (caddr_t) command_table[i].closure;
! (void) XtCreateManagedWidget(command_table[i].name,
! commandWidgetClass, right_widget,
! command_args, XtNumber(command_args));
! }
! }
#else /* !BUTTONS */
vport_widget = XtCreateManagedWidget("vport", viewportWidgetClass,
top_level, vport_args, XtNumber(vport_args));
#endif /* BUTTONS */
clip_widget = XtNameToWidget(vport_widget, "clip");
draw_args[0].value = (XtArgVal) page_w;
--- 2438,2454 ----
form_widget = XtCreateManagedWidget("form", formWidgetClass,
top_level, form_args, XtNumber(form_args));
! vport_args[0].value = temp_args3[0].value - xtra_wid;
vport_args[1].value = temp_args3[1].value;
vport_widget = XtCreateManagedWidget("vport", viewportWidgetClass,
form_widget, vport_args, XtNumber(vport_args));
line_args[0].value = (XtArgVal) high_color ? hl_Pixel : fore_Pixel;
! if (!expert) create_buttons(temp_args3[1].value);
#else /* !BUTTONS */
vport_widget = XtCreateManagedWidget("vport", viewportWidgetClass,
top_level, vport_args, XtNumber(vport_args));
+ #define form_widget vport_widget /* for calls to XtAddEventHandler */
#endif /* BUTTONS */
clip_widget = XtNameToWidget(vport_widget, "clip");
draw_args[0].value = (XtArgVal) page_w;
***************
*** 2364,2370 ****
XtSetValues(draw_widget, &back_args, 1);
XtSetValues(clip_widget, &back_args, 1);
}
! XtAddEventHandler(vport_widget, KeyPressMask, False, handle_key,
(caddr_t) NULL);
XtAddEventHandler(vport_widget, StructureNotifyMask, False,
handle_resize, (caddr_t) NULL);
--- 2460,2466 ----
XtSetValues(draw_widget, &back_args, 1);
XtSetValues(clip_widget, &back_args, 1);
}
! XtAddEventHandler(form_widget, KeyPressMask, False, handle_key,
(caddr_t) NULL);
XtAddEventHandler(vport_widget, StructureNotifyMask, False,
handle_resize, (caddr_t) NULL);
***************
*** 2445,2450 ****
--- 2541,2554 ----
#endif /* TOOLKIT */
+ XRebindKeysym(DISP, XK_Home, NULL, 0, (ubyte *) "^", 1);
+ XRebindKeysym(DISP, XK_Left, NULL, 0, (ubyte *) "l", 1);
+ XRebindKeysym(DISP, XK_Up, NULL, 0, (ubyte *) "u", 1);
+ XRebindKeysym(DISP, XK_Right, NULL, 0, (ubyte *) "r", 1);
+ XRebindKeysym(DISP, XK_Down, NULL, 0, (ubyte *) "d", 1);
+ XRebindKeysym(DISP, XK_Prior, NULL, 0, (ubyte *) "b", 1);
+ XRebindKeysym(DISP, XK_Next, NULL, 0, (ubyte *) "f", 1);
+
image = XCreateImage(DISP, DefaultVisualOfScreen(SCRN), 1, XYBitmap, 0,
(char *)NULL, 0, 0, BITS_PER_BMUNIT, 0);
image->bitmap_unit = BITS_PER_BMUNIT;
***************
*** 2533,2536 ****
--- 2637,2643 ----
#endif /* X10 */
do_pages();
+ #ifdef lint
+ return 0;
+ #endif
}
diff -cr xdvi_old/xdvi.h xdvi_new/xdvi.h
*** xdvi_old/xdvi.h Mon Sep 17 17:36:48 1990
--- xdvi_new/xdvi.h Wed Oct 10 11:26:37 1990
***************
*** 40,46 ****
--- 40,50 ----
#define Sprintf (void) sprintf
#define Fseek (void) fseek
#define Fread (void) fread
+ #define Fputs (void) fputs
+ #define Putc (void) putc
+ #define Putchar (void) putchar
#define Fclose (void) fclose
+ #define Strcpy (void) strcpy
unsigned long num();
long snum();
***************
*** 143,149 ****
/*
* Mechanism for reducing repeated warning about specials.
*/
! extern Boolean spec_warn;
/*
--- 147,153 ----
/*
* Mechanism for reducing repeated warning about specials.
*/
! extern Boolean spec_warn, spec_warn_now;
/*
***************
*** 189,197 ****
/* struct font *fp; */
/* ubyte ch; */
! /* the corresponding read_font_index procedures occur in pxl_open.c */
typedef void (*read_font_index_proc)();
/* struct font *fontp; */
struct font {
struct font *next; /* link to next font info block */
--- 193,202 ----
/* struct font *fp; */
/* ubyte ch; */
! /* the corresponding read_font_index procedures occur in dvi_init.c */
typedef void (*read_font_index_proc)();
/* struct font *fontp; */
+ extern read_font_index_proc read_GF_index, read_PK_index, read_PXL_index;
struct font {
struct font *next; /* link to next font info block */
***************
*** 221,231 ****
#define DBG_PK 0x4
#define DBG_BATCH 0x8
#define DBG_EVENT 0x10
! #define DBG_ALL (DBG_BITMAP|DBG_DVI|DBG_PK|DBG_EVENT)
extern Boolean list_fonts;
extern int pixels_per_inch;
extern int unshrunk_paper_w, unshrunk_paper_h;
extern int unshrunk_page_w, unshrunk_page_h;
extern int density;
--- 226,238 ----
#define DBG_PK 0x4
#define DBG_BATCH 0x8
#define DBG_EVENT 0x10
! #define DBG_OPEN 0x20
! #define DBG_ALL (DBG_BITMAP|DBG_DVI|DBG_PK|DBG_EVENT|DBG_OPEN)
extern Boolean list_fonts;
extern int pixels_per_inch;
+ extern int offset_x, offset_y;
extern int unshrunk_paper_w, unshrunk_paper_h;
extern int unshrunk_page_w, unshrunk_page_h;
extern int density;
***************
*** 232,237 ****
--- 239,245 ----
extern char *dvi_name;
extern FILE *dvi_file; /* user's file */
+ extern char *alt_font;
extern char *prog;
extern struct WindowRec {
diff -cr xdvi_old/xdvi_man.sed xdvi_new/xdvi_man.sed
*** xdvi_old/xdvi_man.sed Mon Sep 17 17:36:59 1990
--- xdvi_new/xdvi_man.sed Wed Sep 26 16:42:39 1990
***************
*** 9,21 ****
.B xdvi
.nh
[+[\fIpage\fP]] [\-s \fIshrink\fP] [\-S \fIdensity\fP] [\-p \fIpixels\fP] [\-l]
! [\-paper \fIpapertype\fP] [\-mgs[\fIn\fP] \fIsize\fP] [\-altfont \fIfont\fP]
! [\-margins \fIinches\fP] [\-sidemargin \fIinches\fP] [\-topmargin \fIinches\fP]
[\-rv] [\-fg \fIcolor\fP] [\-bg \fIcolor\fP]
[\-hl \fIcolor\fP] [\-bd \fIcolor\fP] [\-cr \fIcolor\fP] [\-bw \fIwidth\fP]
#ifx11
! [\-geometry \fIgeometry\fP] [-icongeometry \fIgeometry\fP] [-iconic]
! [\-display \fIdisplay\fP] [-copy] [-thorough]
#ifx10
[\-geometry \fIgeometry\fP | =\fIgeometry\fP]
[\-display \fIhost\fP:\fIdisplay\fP | \fIhost\fP:\fIdisplay\fP]
--- 9,25 ----
.B xdvi
.nh
[+[\fIpage\fP]] [\-s \fIshrink\fP] [\-S \fIdensity\fP] [\-p \fIpixels\fP] [\-l]
! [\-sw] [\-paper \fIpapertype\fP] [\-mgs[\fIn\fP] \fIsize\fP]
! [\-altfont \fIfont\fP]
! [\-margins \fIdimen\fP] [\-sidemargin \fIdimen\fP] [\-topmargin \fIdimen\fP]
! [\-offsets \fIdimen\fP] [\-xoffset \fIdimen\fP] [\-yoffset \fIdimen\fP]
[\-rv] [\-fg \fIcolor\fP] [\-bg \fIcolor\fP]
[\-hl \fIcolor\fP] [\-bd \fIcolor\fP] [\-cr \fIcolor\fP] [\-bw \fIwidth\fP]
#ifx11
! [\-geometry \fIgeometry\fP] [\-icongeometry \fIgeometry\fP] [\-iconic]
! [\-display \fIdisplay\fP] [\-copy] [\-thorough]
! #ifbuttons
! [\-expert]
#ifx10
[\-geometry \fIgeometry\fP | =\fIgeometry\fP]
[\-display \fIhost\fP:\fIdisplay\fP | \fIhost\fP:\fIdisplay\fP]
***************
*** 90,95 ****
--- 94,105 ----
(%%dot%%listFonts)
Causes the names of the fonts used to be listed.
.TP
+ .B \-sw
+ (%%dot%%specialWarn)
+ Causes \fIxdvi\fR to warn the user when it encounters a \\special string
+ which it cannot process. This option is on by default; to turn it off,
+ use \fB+sw\fR.
+ .TP
.B \-rv
(%%dot%%reverseVideo)
Causes the page to be displayed with white characters on a
***************
*** 149,160 ****
Always use the \fIcopy\fR operation when writing characters to the display.
This option may be necessary for correct operation on a color display, but
overstrike characters will be incorrect.
#endif
.TP
! .BI \-margins " inches"
! (%%dot%%margins)
! Specifies the size of both the top margin and side margin. This
! can be a decimal number, \fIe.g.\fR, 1.5. It determines
the ``home'' position of the page within the window as follows. If the entire
page fits in the window, then the margin settings are ignored. If, even
after removing the margins from the left, right, top, and bottom, the page
--- 159,176 ----
Always use the \fIcopy\fR operation when writing characters to the display.
This option may be necessary for correct operation on a color display, but
overstrike characters will be incorrect.
+ #ifbuttons
+ .TP
+ .B \-expert
+ (.expert)
+ Prevent the buttons from appearing.
#endif
.TP
! .BI \-margins " dimen"
! (%%dot%%Margin)
! Specifies the size of both the top margin and side margin.
! This should be a decimal number optionally followed by "cm", e.g., 1.5 or 3cm,
! giving a measurement in inches or centimeters. It determines
the ``home'' position of the page within the window as follows. If the entire
page fits in the window, then the margin settings are ignored. If, even
after removing the margins from the left, right, top, and bottom, the page
***************
*** 164,177 ****
Otherwise, the text is centered in the window. See also `\fBM\fR' under
the KEY\%STROKES section.
.TP
! .BI \-sidemargin " inches"
(%%dot%%sideMargin)
Specifies the side margin (see above).
.TP
! .BI \-topmargin " inches"
(%%dot%%topMargin)
Specifies the top and bottom margins (see above).
.TP
.BI \-paper " papertype"
(%%dot%%paper)
Specifies the size of the printed page. This may be of the form
--- 180,213 ----
Otherwise, the text is centered in the window. See also `\fBM\fR' under
the KEY\%STROKES section.
.TP
! .BI \-sidemargin " dimen"
(%%dot%%sideMargin)
Specifies the side margin (see above).
.TP
! .BI \-topmargin " dimen"
(%%dot%%topMargin)
Specifies the top and bottom margins (see above).
.TP
+ .BI \-offsets " dimen"
+ (%%dot%%Offset)
+ Specifies the size of both the horizontal and vertical offsets of the
+ output on the page. This should be a decimal number optionally followed by
+ "cm", e.g., 1.5 or 3cm, giving a measurement in inches or centimeters.
+ By decree
+ of the Stanford TeX Project, the default TeX page origin is always 1 inch
+ over and down from the top-left page corner, even when non-American paper
+ sizes are used. Therefore, the default offsets are 1.0 inch.
+ .TP
+ .BI \-xoffset " dimen"
+ (%%dot%%xOffset)
+ Specifies the size of the horizontal offset of the output on the page
+ (see above).
+ .TP
+ .BI \-yoffset " dimen"
+ (%%dot%%yOffset)
+ Specifies the size of the vertical offset of the output on the page
+ (see above).
+ .TP
.BI \-paper " papertype"
(%%dot%%paper)
Specifies the size of the printed page. This may be of the form
***************
*** 240,245 ****
--- 276,285 ----
\fBXdvi\fR recognizes the following keystrokes when typed in its window.
Each may optionally be preceded by a (positive or negative) number, whose
interpretation will depend on the particular keystroke.
+ #ifx11
+ Also, the "Home", "Prior", "Next", and arrow cursor keys are synonyms for
+ `^', `b', `f', `l', `r', `u', and `d' keys, respectively.
+ #endif
.TP
.B q
Quits the program. Control-C and control-D will do this, too.
***************
*** 309,314 ****
--- 349,360 ----
The `k' keystroke toggles a `keep-position' flag which, when set, will keep
the same position when moving between pages. Also `0k' and `1k' clear and
set this flag, respectively.
+ #ifbuttons
+ .TP
+ .B x
+ Toggles expert mode (in which the buttons do not appear). Also `0x' and `1x'
+ clear and reset this mode, respectively.
+ #endif
.SH MOUSE ACTIONS
If the shrink factor is set to any number other than one, then clicking
any mouse button will pop up a ``magnifying glass'' which shows the unshrunk
***************
*** 336,343 ****
the end. For example, if the string is ``/usr/local/tex/fonts'' and the font is
cmr10 at 300dpi, then it searches for /usr/local/tex/fonts/cmr10.300gf,
/usr/local/tex/fonts/cmr10.300pk, and /usr/local/tex/fonts/cmr10.1500pxl,
! in that order. If the first character of the ``XDVIFONTS'' variable
! is a colon, then the system default paths are tried first. If the font is not
found in the desired size, then \fIxdvi\fR will try to find the nearest size.
If the font cannot be found at all, then \fIxdvi\fR will try to vary the point
size of the font (within a certain range), and if this fails, then it will
--- 382,389 ----
the end. For example, if the string is ``/usr/local/tex/fonts'' and the font is
cmr10 at 300dpi, then it searches for /usr/local/tex/fonts/cmr10.300gf,
/usr/local/tex/fonts/cmr10.300pk, and /usr/local/tex/fonts/cmr10.1500pxl,
! in that order. An extra colon anywhere in the ``XDVIFONTS'' variable
! causes the system default paths to be tried at that point. If the font is not
found in the desired size, then \fIxdvi\fR will try to find the nearest size.
If the font cannot be found at all, then \fIxdvi\fR will try to vary the point
size of the font (within a certain range), and if this fails, then it will
***************
*** 349,355 ****
Sizes are expressed in dots per inch; decimals may be used for ``pxl'' files:
for example, a 300 dots per inch file magnified by half a step comes out to
1643 dots per five inches, which should be encoded as 328.6. The current
! default set of sizes is %%DEFAULT_FONT_SIZES%%.
.SH FILES
.br
%%DEFAULT_FONT_PATH%% Font pixel files.
--- 395,402 ----
Sizes are expressed in dots per inch; decimals may be used for ``pxl'' files:
for example, a 300 dots per inch file magnified by half a step comes out to
1643 dots per five inches, which should be encoded as 328.6. The current
! default set of sizes is %%DEFAULT_FONT_SIZES%%. \fIxdvi\fR will also try the
! actual size of the font before trying any of the given sizes.
.SH FILES
.br
%%DEFAULT_FONT_PATH%% Font pixel files.
dan
----------------------------------------------------
O'Reilly && Associates argv at sun.com / argv at ora.com
Opinions expressed reflect those of the author only.
More information about the Comp.sources.x
mailing list