argv@island.uu.net (Dan Heller) (08/30/89)
Submitted-by: vojta@math.Berkeley.EDU Posting-number: Volume 4, Issue 96 Archive-name: xdvi/patch5 Patch-To: xdvi: Volume 3, Issue 37 Patch 5 of xdvi does the following: 1. Fixes a bug in the gf file reading routines, dealing with fonts that have specials at the beginnings of characters. 2. Implements scrollbars and tpic specials under X10. 3. Optionally can be compiled under X11 without the toolkit. 4. Should now work with color VAXstations. 5. Implements a 'k' keystroke, which toggles whether you stay in the same position on the page when changing pages. Thanks go to kevin@amath.washington.edu and to tuna@mirch.lcs.mit.edu for fixes and useful information. --Paul Vojta, vojta@math.berkeley.edu -- cut here -- diff -cr old/Makefile new/Makefile *** old/Makefile Mon Aug 28 00:05:41 1989 --- new/Makefile Sun Aug 27 23:52:43 1989 *************** *** 39,51 **** xdvi.o: xdvi.h patchlevel.h xdvi.icon dvi_init.o:xdvi.h dvi.h dvi_draw.o:xdvi.h dvi.h ! tpic.c: xdvi.h gf.o: xdvi.h pk.o: xdvi.h pxl.o: xdvi.h ! xdvi.man: sed -e "s;%%FONT_PATH%%;$(FONT_PATH);g" \ -e "s;%%DEFAULT_FONT_PATH%%;$(DEFAULT_FONT_PATH);g" \ < xdvi.man.sed \ --- 39,51 ---- xdvi.o: xdvi.h patchlevel.h xdvi.icon dvi_init.o:xdvi.h dvi.h dvi_draw.o:xdvi.h dvi.h ! tpic.o: xdvi.h gf.o: xdvi.h pk.o: xdvi.h pxl.o: xdvi.h ! xdvi.man: xdvi.man.sed sed -e "s;%%FONT_PATH%%;$(FONT_PATH);g" \ -e "s;%%DEFAULT_FONT_PATH%%;$(DEFAULT_FONT_PATH);g" \ < xdvi.man.sed \ diff -cr old/Makefile_10 new/Makefile_10 *** old/Makefile_10 Mon Aug 28 00:05:42 1989 --- new/Makefile_10 Sun Aug 27 23:49:34 1989 *************** *** 15,24 **** BINDIR=/usr/sipb/$$(MACHTYPE)bin INCLUDES=-I/usr/include/X CFLAGS=-O $(DEFINES) ! LIBS=-lX ! SRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c \ xdvi.h dvi.h xdvi_curs.h xdvi_mask.h ! OBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o CC=/tuna_a/gnu/bin/gcc RM=rm -f --- 15,24 ---- BINDIR=/usr/sipb/$$(MACHTYPE)bin INCLUDES=-I/usr/include/X CFLAGS=-O $(DEFINES) ! LIBS=-lX -lm ! SRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c tpic.c \ xdvi.h dvi.h xdvi_curs.h xdvi_mask.h ! OBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o tpic.o CC=/tuna_a/gnu/bin/gcc RM=rm -f *************** *** 32,37 **** --- 32,38 ---- xdvi.o: xdvi.h patchlevel.h xdvi_curs.h xdvi_mask.h dvi_init.o:xdvi.h dvi.h dvi_draw.o:xdvi.h dvi.h + tpic.o: xdvi.h gf.o: xdvi.h pk.o: xdvi.h *************** *** 50,53 **** $(RM) *.o *.BAK *.CKP xdvi.man xdvi a.out core errs *~ lint: ! lint $(DEFINES) xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c --- 51,55 ---- $(RM) *.o *.BAK *.CKP xdvi.man xdvi a.out core errs *~ lint: ! lint $(DEFINES) xdvi.c dvi_init.c dvi_draw.c \ ! $(FONTFORMATS_C) pxl_open.c tpic.c diff -cr old/README new/README *** old/README Mon Aug 28 00:05:44 1989 --- new/README Mon Aug 28 00:07:21 1989 *************** *** 35,43 **** You can also change the `make' variables FONTFORMATS_C and FONTFORMATS_O to reflect which font formats are actually used at your site. - Apparently this program does not work on color VAXstations; it is my - understanding that this is caused by a server bug. - Other compilation flags are: FONT_PATH (xdvi.c) Name of the environment variable to use when searching for the font path --- 35,40 ---- *************** *** 64,69 **** --- 61,67 ---- ALTFONT Default font to use if the font named in the dvi file cannot be found. Can be set to NULL. By default, it is "cmr10". + NOTOOL (X11 only; xdvi.c) Compile using raw X calls. All flags should be set in the appropriate Makefile. ================================================================ *************** *** 126,131 **** --- 124,137 ---- -- Patchlevel 4: -- 14. Removed MAXCHARS compilation option. It's automatic now. Made X10 scrolling smoother. Implemented the moving magnifying glass. + -- Patchlevel 5: -- + 15. Implemented compilation without the toolkit, as well as scrollbars + and tpic support in X10. Also this version should work with color + VAXstations, although overstrike characters will come out incorrectly. + 16. Fixed a bug in gf reading routines: specials at the beginning of + a character def. were not being processed. Thanks to + kevin@amath.washington.edu for a bug report and fix. + 17. Added 'k' keystroke. Paul Vojta, vojta@math.berkeley.edu ================================================================================ diff -cr old/dvi_draw.c new/dvi_draw.c *** old/dvi_draw.c Mon Aug 28 00:05:50 1989 --- new/dvi_draw.c Thu Aug 24 12:25:22 1989 *************** *** 16,21 **** --- 16,22 ---- * Compilation options: * SYSV compile for System V * X10 compile for X10 + * NOTOOL compile without toolkit (X11 only) * MSBITFIRST store bitmaps internally in with significant bit first * BMSHORT store bitmaps in shorts instead of bytes * BMLONG store bitmaps in longs instead of bytes diff -cr old/dvi_init.c new/dvi_init.c *** old/dvi_init.c Mon Aug 28 00:05:53 1989 --- new/dvi_init.c Thu Aug 24 12:25:30 1989 *************** *** 16,21 **** --- 16,22 ---- * Compilation options: * SYSV compile for System V * X10 compile for X10 + * NOTOOL compile without toolkit (X11 only) * MSBITFIRST store bitmaps internally in with significant bit first * BMSHORT store bitmaps in shorts instead of bytes * BMLONG store bitmaps in longs instead of bytes *************** *** 66,72 **** */ static long last_page_offset; ! #ifndef SYSV char *sprintf(); #endif char *malloc(), *strcpy(); --- 67,73 ---- */ static long last_page_offset; ! #ifndef ANSI_LIB char *sprintf(); #endif char *malloc(), *strcpy(); diff -cr old/gf.c new/gf.c *** old/gf.c Mon Aug 28 00:05:55 1989 --- new/gf.c Mon Aug 21 16:26:26 1989 *************** *** 168,195 **** if(debug & DBG_PK) Printf("Loading gf char %d", ch); ! switch (cmnd = one(GF_file)) { ! case BOC: ! (void) four(GF_file); /* skip character code */ ! (void) four(GF_file); /* skip pointer to prev char */ ! min_m = sfour(GF_file); ! max_m = sfour(GF_file); ! g->x = -min_m; ! min_n = sfour(GF_file); ! g->y = max_n = sfour(GF_file); ! g->bitmap.w = max_m - min_m + 1; ! g->bitmap.h = max_n - min_n + 1; ! break; ! case BOC1: ! (void) one(GF_file); /* skip character code */ ! g->bitmap.w = one(GF_file); /* max_m - min_m */ ! g->x = g->bitmap.w - one(GF_file); /* ditto - max_m */ ! ++g->bitmap.w; ! g->bitmap.h = one(GF_file) + 1; ! g->y = one(GF_file); ! break; ! default: ! oops("Bad BOC code: %d", cmnd); } paint_switch = White; --- 168,207 ---- if(debug & DBG_PK) Printf("Loading gf char %d", ch); ! for (;;) { ! switch (cmnd = one(GF_file)) { ! case XXX1: ! case XXX2: ! case XXX3: ! case XXX4: ! Fseek(GF_file, (long) num(GF_file, cmnd - XXX1 + 1), 1); ! continue; ! case YYY: ! (void) four(GF_file); ! continue; ! case BOC: ! (void) four(GF_file); /* skip character code */ ! (void) four(GF_file); /* skip pointer to prev char */ ! min_m = sfour(GF_file); ! max_m = sfour(GF_file); ! g->x = -min_m; ! min_n = sfour(GF_file); ! g->y = max_n = sfour(GF_file); ! g->bitmap.w = max_m - min_m + 1; ! g->bitmap.h = max_n - min_n + 1; ! break; ! case BOC1: ! (void) one(GF_file); /* skip character code */ ! g->bitmap.w = one(GF_file); /* max_m - min_m */ ! g->x = g->bitmap.w - one(GF_file); /* ditto - max_m */ ! ++g->bitmap.w; ! g->bitmap.h = one(GF_file) + 1; ! g->y = one(GF_file); ! break; ! default: ! oops("Bad BOC code: %d", cmnd); ! } ! break; } paint_switch = White; *************** *** 204,210 **** */ bytes_wide = ROUNDUP(g->bitmap.w, BITS_PER_BMUNIT) * BYTES_PER_BMUNIT; maxp = ADD(basep, g->bitmap.h * bytes_wide); ! bzero(g->bitmap.bits, g->bitmap.h * bytes_wide); new_row = False; word_weight = BITS_PER_BMUNIT; for (;;) { --- 216,222 ---- */ bytes_wide = ROUNDUP(g->bitmap.w, BITS_PER_BMUNIT) * BYTES_PER_BMUNIT; maxp = ADD(basep, g->bitmap.h * bytes_wide); ! bzero(g->bitmap.bits, g->bitmap.h * bytes_wide); new_row = False; word_weight = BITS_PER_BMUNIT; for (;;) { diff -cr old/patchlevel.h new/patchlevel.h *** old/patchlevel.h Mon Aug 28 00:05:56 1989 --- new/patchlevel.h Sun Aug 27 23:35:18 1989 *************** *** 1 **** ! #define PATCHLEVEL 4 --- 1 ---- ! #define PATCHLEVEL 5 diff -cr old/pxl_open.c new/pxl_open.c *** old/pxl_open.c Mon Aug 28 00:06:01 1989 --- new/pxl_open.c Tue Aug 22 13:29:33 1989 *************** *** 43,49 **** read_font_index_proc read_GF_index, read_PK_index, read_PXL_index; ! #ifndef SYSV char *sprintf(); #endif char *malloc(), *index(); --- 43,49 ---- read_font_index_proc read_GF_index, read_PK_index, read_PXL_index; ! #ifndef ANSI_LIB char *sprintf(); #endif char *malloc(), *index(); diff -cr old/xdvi.c new/xdvi.c *** old/xdvi.c Mon Aug 28 00:06:10 1989 --- new/xdvi.c Sat Aug 26 15:54:43 1989 *************** *** 16,21 **** --- 16,22 ---- * Compilation options: * SYSV compile for System V * X10 compile for X10 + * NOTOOL compile without toolkit (X11 only) * MSBITFIRST store bitmaps internally in with significant bit first * BMSHORT store bitmaps in shorts instead of bytes * BMLONG store bitmaps in longs instead of bytes *************** *** 35,45 **** #define ALTFONT "cmr10" #endif ALTFONT ! #ifndef X10 #undef Boolean #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Intrinsic.h> #ifdef OLD_X11_TOOLKIT #include <X11/Atoms.h> --- 36,58 ---- #define ALTFONT "cmr10" #endif ALTFONT ! #if !defined(X10) && !defined(NOTOOL) ! #define TOOLKIT ! #else ! #undef TOOLKIT ! #endif + #ifndef X10 #undef Boolean #include <X11/Xlib.h> #include <X11/Xutil.h> + #include <X11/cursorfont.h> + #include "xdvi.icon" + #else X10 + #include <X/Xlib.h> + #endif X10 + + #ifdef TOOLKIT #include <X11/Intrinsic.h> #ifdef OLD_X11_TOOLKIT #include <X11/Atoms.h> *************** *** 49,62 **** #endif not OLD_X11_TOOLKIT #include <X11/Shell.h> /* needed for def. of XtNiconX */ #include <X11/Viewport.h> ! #include <X11/cursorfont.h> ! #include "xdvi.icon" ! #else X10 ! ! #include <X/Xlib.h> ! #endif X10 #include <stdio.h> #include <ctype.h> --- 62,79 ---- #endif not OLD_X11_TOOLKIT #include <X11/Shell.h> /* needed for def. of XtNiconX */ #include <X11/Viewport.h> ! #else TOOLKIT ! #define XtNumber(arr) (sizeof(arr)/sizeof(arr[0])) ! typedef int Position; ! typedef int Dimension; ! #ifndef X10 ! typedef unsigned int Pixel; ! #define XtPending() XPending(DISP) #else X10 ! #define XtPending XPending ! #define XMoveResizeWindow XConfigureWindow #endif X10 + #endif TOOLKIT #include <stdio.h> #include <ctype.h> *************** *** 72,82 **** #define SetCursor(x) XDefineCursor(DISP, mane.win, x) #define ClearPage(wr) XClearWindow(DISP, (wr).win); #define ClearArea(win, x, y, w, h) XClearArea(DISP, win, x, y, w, h, False) #define CopyArea(win, x, y, w, h, x2, y2) \ XCopyArea(DISP, win, win, DefaultGCOfScreen(SCRN), \ x, y, w, h, x2, y2) #define Flush() XFlush(DISP) - static Boolean resized = False; #ifndef X11HEIGHT #define X11HEIGHT 8 /* Height of server default font */ #endif X11HEIGHT --- 89,100 ---- #define SetCursor(x) XDefineCursor(DISP, mane.win, x) #define ClearPage(wr) XClearWindow(DISP, (wr).win); #define ClearArea(win, x, y, w, h) XClearArea(DISP, win, x, y, w, h, False) + #define DarkenArea(win, x, y, w, h) \ + XFillRectangle(DISP, win, ruleGC, x, y, w, h) #define CopyArea(win, x, y, w, h, x2, y2) \ XCopyArea(DISP, win, win, DefaultGCOfScreen(SCRN), \ x, y, w, h, x2, y2) #define Flush() XFlush(DISP) #ifndef X11HEIGHT #define X11HEIGHT 8 /* Height of server default font */ #endif X11HEIGHT *************** *** 83,97 **** #else X10 #define DPY #define GC int - #define XtNumber(arr) (sizeof(arr)/sizeof(arr[0])) - #define XtPending XPending - typedef int Position; - typedef int Dimension; #define SetCursor(x) #define ClearPage(wr) XClear((wr).win); #define ClearArea(win, x, y, w, h) XPixSet(win, x, y, w, h, backpix) #define CopyArea(win, x, y, w, h, x2, y2) \ ! XCopyArea(win, x, y, x2, y2, w, h, GXcopy); #define XBell(a,b) XFeep(b/10-1) #define Flush() XFlush() #define ConnectionNumber(DISP) (_XlibCurrentDisplay->fd) --- 101,112 ---- #else X10 #define DPY #define GC int #define SetCursor(x) #define ClearPage(wr) XClear((wr).win); #define ClearArea(win, x, y, w, h) XPixSet(win, x, y, w, h, backpix) + #define DarkenArea(win, x, y, w, h) XPixSet(win, x, y, w, h, foreGC) #define CopyArea(win, x, y, w, h, x2, y2) \ ! XMoveArea(win, x, y, x2, y2, w, h, GXcopy); #define XBell(a,b) XFeep(b/10-1) #define Flush() XFlush() #define ConnectionNumber(DISP) (_XlibCurrentDisplay->fd) *************** *** 126,136 **** char *prog; char *curr_page = NULL; ! #ifndef X10 static double specialConv; /* fg and bg colors */ static Arg fore_args = {XtNforeground, (XtArgVal) 0}; static Arg back_args = {XtNbackground, (XtArgVal) 0}; static Pixel hl_Pixel, cr_Pixel; #endif X10 --- 141,160 ---- char *prog; char *curr_page = NULL; ! int pageno_correct = 1; ! Boolean keep_flag = False; static double specialConv; + + #ifndef X10 + #ifdef TOOLKIT /* fg and bg colors */ static Arg fore_args = {XtNforeground, (XtArgVal) 0}; + #define fore_Pixel fore_args.value static Arg back_args = {XtNbackground, (XtArgVal) 0}; + #define back_Pixel back_args.value + #else TOOLKIT + static Pixel fore_Pixel, back_Pixel; + #endif TOOLKIT static Pixel hl_Pixel, cr_Pixel; #endif X10 *************** *** 150,164 **** static int screen_w, screen_h; #define clip_w mane.width #define clip_h mane.height - #ifndef X10 static Dimension window_w, window_h; static Position main_x, main_y; #else X10 - #define window_w clip_w - #define window_h clip_h #define main_x 0 #define main_y 0 #endif X10 static Position mag_x, mag_y, new_mag_x, new_mag_y; static Boolean mag_moved = False; static int home_x, home_y; --- 174,195 ---- static int screen_w, screen_h; #define clip_w mane.width #define clip_h mane.height static Dimension window_w, window_h; + #ifndef X10 static Position main_x, main_y; + static XImage *image; #else X10 #define main_x 0 #define main_y 0 + static int GXfunc; + static int backpix, backmap, bdrmap; + /* + * Cursor and mask for valid cursor + */ + #include "xdvi_curs.h" + #include "xdvi_mask.h" #endif X10 + static Position mag_x, mag_y, new_mag_x, new_mag_y; static Boolean mag_moved = False; static int home_x, home_y; *************** *** 169,174 **** --- 200,246 ---- /* curr is temporary storage except for within redraw() */ struct WindowRec curr = {NULL, 3, 0, 0, 0, 0, MAXDIM, 0, MAXDIM, 0}; + #ifdef TOOLKIT + static Widget top_level, vport_widget, draw_widget, clip_widget; + static Widget x_bar, y_bar; /* horizontal and vertical scroll bars */ + + static Arg vport_args[] = { + {XtNallowHoriz, (XtArgVal) True}, + {XtNallowVert, (XtArgVal) True}, + }; + + /* Note: Argument order in the following is important! */ + + static Arg draw_args[] = { + {XtNwidth, (XtArgVal) 0}, + {XtNheight, (XtArgVal) 0}, + {XtNx, (XtArgVal) 0}, + {XtNy, (XtArgVal) 0}, + {XtNlabel, (XtArgVal) ""}, + }; + + static void set_draw_args(); + #else TOOLKIT + #define BAR_WID 12 /* width of darkened area */ + #define BAR_THICK 15 /* gross amount removed */ + + static Window top_level; + static Window x_bar, y_bar; + static int x_bgn, x_end, y_bgn, y_end; /* scrollbar positions */ + #endif TOOLKIT + + #ifdef lint + #ifndef X10 + char xdvi_bits[288]; + #ifdef TOOLKIT + WidgetClass viewportWidgetClass, widgetClass; + #endif TOOLKIT + #else X10 + short xdvi_bits[15], xdvi_mask_bits[15]; + Display *_XlibCurrentDisplay; + #endif X10 + #endif lint + /* * Mechanism to keep track of the magnifier window. The problems are, * (a) if the button is released while the window is being drawn, this *************** *** 182,189 **** /* -1 = destroy upon expose */ static Boolean alt_canit; /* stop drawing this window */ - int pageno_correct = 1; - /* * Data for buffered events. */ --- 254,259 ---- *************** *** 198,204 **** static void can_exposures(), read_events(); ! #ifndef SYSV char *sprintf(); #endif char *malloc(), *index(), *rindex(), *getenv(), *strcpy(), *strcat(); --- 268,274 ---- static void can_exposures(), read_events(); ! #ifndef ANSI_LIB char *sprintf(); #endif char *malloc(), *index(), *rindex(), *getenv(), *strcpy(), *strcat(); *************** *** 205,211 **** double atof(); ! #ifndef X10 /* Things we need from spec_draw, unfortunately */ /* (ignored for now) --- 275,284 ---- double atof(); ! /******************************** ! * tpic routines * ! *******************************/ ! /* Things we need from spec_draw, unfortunately */ /* (ignored for now) *************** *** 231,239 **** --- 304,319 ---- if ((fcx < max_x || tcx < max_x) && (fcx >= min_x || tcx >= min_x) && (fcy < max_y || tcy < max_y) && (fcy >= min_y || tcy >= min_y)) + #ifndef X10 XDrawLine(DISP, curr.win, ruleGC, fcx - curr.base_x, fcy - curr.base_y, tcx - curr.base_x, tcy - curr.base_y); + #else X10 + XLine(curr.win, + fcx - curr.base_x, fcy - curr.base_y, + tcx - curr.base_x, tcy - curr.base_y, + 1, 1, ruleGC, GXcopy, AllPlanes); + #endif X10 } /* *************** *** 246,253 **** --- 326,338 ---- cy = yconv(y); if (cx < max_x && cx >= min_x && cy < max_y && cy >= min_y) + #ifndef X10 XDrawPoint(DISP, curr.win, ruleGC, cx - curr.base_x, cy - curr.base_y); + #else X10 + XPixSet((Window) curr.win, cx - curr.base_x, cy - curr.base_y, + 1, 1, ruleGC); + #endif X10 } /* *************** *** 261,320 **** int last_min_x, last_max_x, last_min_y, last_max_y; { } - #else X10 - /* - * Specials are not implemented in X10. - */ - void - applicationDoSpecial(cmd) - char *cmd; - { - if (spec_warn) Fprintf(stderr, "special ``%s'' not implemented\n", cmd); - } - #endif X10 - - #ifndef X10 - static Widget top_level, vport_widget, draw_widget, clip_widget; - static Widget x_bar, y_bar; /* horizontal and vertical scroll bars */ - static XImage *image; - - static Arg vport_args[] = { - {XtNallowHoriz, (XtArgVal) True}, - {XtNallowVert, (XtArgVal) True}, - }; - - /* Note: Argument order in the following is important! */ - - static Arg draw_args[] = { - {XtNwidth, (XtArgVal) 0}, - {XtNheight, (XtArgVal) 0}, - {XtNx, (XtArgVal) 0}, - {XtNy, (XtArgVal) 0}, - {XtNlabel, (XtArgVal) ""}, - }; - - static void set_draw_args(); - #else X10 - static int GXfunc; - static int backpix, backmap, bdrmap; - /* - * Cursor and mask for valid cursor - */ - #include "xdvi_curs.h" - #include "xdvi_mask.h" - #endif X10 - - #ifdef lint - #ifndef X10 - WidgetClass viewportWidgetClass, widgetClass; - char xdvi_bits[288]; - #else X10 - short xdvi_bits[15], xdvi_mask_bits[15]; - Display *_XlibCurrentDisplay; - #endif X10 - #endif lint - /** ** Put a rectangle on the screen. hl determines the GC. **/ --- 346,352 ---- *************** *** 326,335 **** if (x < max_x && x + w >= min_x && y < max_y && y + h >= min_y) { if (--event_counter == 0) read_events(False); #ifndef X10 ! XFillRectangle(DISP, curr.win, hl ? highGC : ruleGC, x - curr.base_x, y - curr.base_y, w?w:1, h?h:1); #else X10 ! XPixSet(curr.win, x - curr.base_x, y - curr.base_y, w?w:1, h?h:1, hl ? highGC : ruleGC); #endif X10 } --- 358,367 ---- if (x < max_x && x + w >= min_x && y < max_y && y + h >= min_y) { if (--event_counter == 0) read_events(False); #ifndef X10 ! XFillRectangle(DISP, (Window) curr.win, hl ? highGC : ruleGC, x - curr.base_x, y - curr.base_y, w?w:1, h?h:1); #else X10 ! XPixSet((Window) curr.win, x - curr.base_x, y - curr.base_y, w?w:1, h?h:1, hl ? highGC : ruleGC); #endif X10 } *************** *** 348,354 **** #ifndef X10 image->width = bitmap->w; image->height = bitmap->h; ! image->data = (char *)bitmap->bits; image->bytes_per_line = bitmap->bytes_wide; XPutImage(DISP, curr.win, foreGC, image, 0, 0, --- 380,386 ---- #ifndef X10 image->width = bitmap->w; image->height = bitmap->h; ! image->data = bitmap->bits; image->bytes_per_line = bitmap->bytes_wide; XPutImage(DISP, curr.win, foreGC, image, 0, 0, *************** *** 361,367 **** bitmap->w, bitmap->h); #else X10 XBitmapBitsPut(curr.win, x - curr.base_x, y - curr.base_y, ! bitmap->w, bitmap->h, (char *) bitmap->bits, foreGC, backpix, NULL, GXfunc, AllPlanes); #endif X10 } --- 393,399 ---- bitmap->w, bitmap->h); #else X10 XBitmapBitsPut(curr.win, x - curr.base_x, y - curr.base_y, ! bitmap->w, bitmap->h, bitmap->bits, foreGC, backpix, NULL, GXfunc, AllPlanes); #endif X10 } *************** *** 398,404 **** struct WindowRec *windowrec; int x, y, w, h; { ! ClearArea(windowrec->win, x, y, w, h); expose(windowrec, x, y, w, h); } --- 430,436 ---- struct WindowRec *windowrec; int x, y, w, h; { ! ClearArea((Window) windowrec->win, x, y, w, h); expose(windowrec, x, y, w, h); } *************** *** 456,462 **** } } ! #ifndef X10 /* * routines for X11 toolkit */ --- 488,494 ---- } } ! #ifdef TOOLKIT /* * routines for X11 toolkit */ *************** *** 466,478 **** {XtNheight, (XtArgVal) &window_h}, }; - static Arg arg_wh_clip[] = { - {XtNwidth, (XtArgVal) &clip_w}, - {XtNheight, (XtArgVal) &clip_h}, - }; - static Position window_x, window_y; ! static Arg arg_xy[] = { {XtNx, (XtArgVal) &window_x}, {XtNy, (XtArgVal) &window_y}, }; --- 498,505 ---- {XtNheight, (XtArgVal) &window_h}, }; static Position window_x, window_y; ! static Arg arg_xy[] = { {XtNx, (XtArgVal) &window_x}, {XtNy, (XtArgVal) &window_y}, }; *************** *** 509,523 **** } } static get_geom() { ! register Dimension old_clip_w = clip_w; XtGetValues(vport_widget, arg_wh, 2); XtGetValues(clip_widget, arg_wh_clip, 2); x_bar = XtNameToWidget(vport_widget, "horizontal"); y_bar = XtNameToWidget(vport_widget, "vertical"); if (old_clip_w == 0) home(False); resized = False; } --- 536,562 ---- } } + static Boolean resized = False; + static get_geom() { ! static Dimension new_clip_w, new_clip_h; ! static Arg arg_wh_clip[] = { ! {XtNwidth, (XtArgVal) &new_clip_w}, ! {XtNheight, (XtArgVal) &new_clip_h}, ! }; ! register int old_clip_w; XtGetValues(vport_widget, arg_wh, 2); XtGetValues(clip_widget, arg_wh_clip, 2); x_bar = XtNameToWidget(vport_widget, "horizontal"); y_bar = XtNameToWidget(vport_widget, "vertical"); + old_clip_w = clip_w; + /* we need to do this because */ + /* sizeof(Dimension) != sizeof(int) */ + clip_w = new_clip_w; + clip_h = new_clip_h; if (old_clip_w == 0) home(False); resized = False; } *************** *** 559,565 **** --- 598,771 ---- resized = True; } + #else TOOLKIT + + /* + * brute force scrollbar routines + */ + + static void + paint_x_bar() + { + register int new_x_bgn = mane.base_x * clip_w / page_w; + register int new_x_end = (mane.base_x + clip_w) * clip_w / page_w; + + if (new_x_bgn >= x_end || x_bgn >= new_x_end) { /* no overlap */ + ClearArea(x_bar, x_bgn, 1, x_end - x_bgn, BAR_WID); + DarkenArea(x_bar, new_x_bgn, 1, new_x_end - new_x_bgn, BAR_WID); + } + else { /* this stuff avoids flicker */ + if (x_bgn <= new_x_bgn) + ClearArea(x_bar, x_bgn, 1, new_x_bgn - x_bgn, BAR_WID); + else + DarkenArea(x_bar, new_x_bgn, 1, x_bgn - new_x_bgn, BAR_WID); + if (new_x_end <= x_end) + ClearArea(x_bar, new_x_end, 1, x_end - new_x_end, BAR_WID); + else + DarkenArea(x_bar, x_end, 1, new_x_end - x_end, BAR_WID); + } + x_bgn = new_x_bgn; + x_end = new_x_end; + } + + static void + paint_y_bar() + { + register int new_y_bgn = mane.base_y * clip_h / page_h; + register int new_y_end = (mane.base_y + clip_h) * clip_h / page_h; + + if (new_y_bgn >= y_end || y_bgn >= new_y_end) { /* no overlap */ + ClearArea(y_bar, 1, y_bgn, BAR_WID, y_end - y_bgn); + DarkenArea(y_bar, 1, new_y_bgn, BAR_WID, new_y_end - new_y_bgn); + } + else { /* this stuff avoids flicker */ + if (y_bgn <= new_y_bgn) + ClearArea(y_bar, 1, y_bgn, BAR_WID, new_y_bgn - y_bgn); + else + DarkenArea(y_bar, 1, new_y_bgn, BAR_WID, y_bgn - new_y_bgn); + if (new_y_end <= y_end) + ClearArea(y_bar, 1, new_y_end, BAR_WID, y_end - new_y_end); + else + DarkenArea(y_bar, 1, y_end, BAR_WID, new_y_end - y_end); + } + y_bgn = new_y_bgn; + y_end = new_y_end; + } + + static void + scrollmane(x, y) + int x, y; + { + register int old_base_x = mane.base_x; + register int old_base_y = mane.base_y; + if (x > page_w - clip_w) x = page_w - clip_w; + if (x < 0) x = 0; + if (y > page_h - clip_h) y = page_h - clip_h; + if (y < 0) y = 0; + scrollwindow(&mane, x, y); + if (old_base_x != mane.base_x && x_bar) paint_x_bar(); + if (old_base_y != mane.base_y && y_bar) paint_y_bar(); + } + + static void + reconfig() + { + int x_thick = 0; + int y_thick = 0; + + /* determine existence of scrollbars */ + if (window_w < page_w) x_thick = BAR_THICK; + if (window_h - x_thick < page_h) y_thick = BAR_THICK; + clip_w = window_w - y_thick; + if (clip_w < page_w) x_thick = BAR_THICK; + clip_h = window_h - x_thick; + + /* process drawing (clip) window */ + if (mane.win == NULL) { /* initial creation */ + #ifndef X10 + mane.win = (void *) XCreateSimpleWindow(DISP, top_level, + y_thick, x_thick, clip_w, clip_h, 0, + fore_Pixel, back_Pixel); + XSelectInput(DPY (Window) mane.win, ExposureMask | + ButtonPressMask | ButtonMotionMask | ButtonReleaseMask); #else X10 + mane.win = (void *) XCreateWindow(top_level, + y_thick, x_thick, clip_w, clip_h, 0, + bdrmap, backmap); + XSelectInput((Window) mane.win, ExposeRegion | ExposeCopy | + ButtonPressed | ButtonReleased | + LeftDownMotion | MiddleDownMotion | RightDownMotion); + #endif X10 + XMapWindow(DPY (Window) mane.win); + } + else + XMoveResizeWindow(DPY (Window) mane.win, + y_thick, x_thick, clip_w, clip_h); + + /* process scroll bars */ + if (x_thick) { + if (x_bar) { + XMoveResizeWindow(DPY x_bar, + y_thick - 1, -1, clip_w, BAR_THICK - 1); + paint_x_bar(); + } + else { + #ifndef X10 + x_bar = XCreateSimpleWindow(DISP, top_level, + y_thick - 1, -1, clip_w, BAR_THICK - 1, 1, + fore_Pixel, back_Pixel); + XSelectInput(DISP, x_bar, + ExposureMask | ButtonPressMask | Button2MotionMask); + #else X10 + x_bar = XCreateWindow(top_level, + y_thick - 1, -1, clip_w, BAR_THICK - 1, 1, + bdrmap, backmap); + XSelectInput(x_bar, + ExposeRegion | ButtonPressed | MiddleDownMotion); + #endif X10 + XMapWindow(DPY x_bar); + } + x_bgn = mane.base_x * clip_w / page_w; + x_end = (mane.base_x + clip_w) * clip_w / page_w; + } + else + if (x_bar) { + XDestroyWindow(DPY x_bar); + x_bar = NULL; + } + + if (y_thick) { + if (y_bar) { + XMoveResizeWindow(DPY y_bar, + -1, x_thick - 1, BAR_THICK - 1, clip_h); + paint_y_bar(); + } + else { + #ifndef X10 + y_bar = XCreateSimpleWindow(DISP, top_level, + -1, x_thick - 1, BAR_THICK - 1, clip_h, 1, + fore_Pixel, back_Pixel); + XSelectInput(DISP, y_bar, + ExposureMask | ButtonPressMask | Button2MotionMask); + #else X10 + y_bar = XCreateWindow(top_level, + -1, x_thick - 1, BAR_THICK - 1, clip_h, 1, + bdrmap, backmap); + XSelectInput(y_bar, + ExposeRegion | ButtonPressed | MiddleDownMotion); + #endif X10 + XMapWindow(DPY y_bar); + } + y_bgn = mane.base_y * clip_h / page_h; + y_end = (mane.base_y + clip_h) * clip_h / page_h; + } + else + if (y_bar) { + XDestroyWindow(DPY y_bar); + y_bar = NULL; + } + } + static void home(scrl) Boolean scrl; *************** *** 577,583 **** y = home_y / mane.shrinkfactor; } if (scrl) ! scrollwindow(&mane, x, y); else { mane.base_x = x; mane.base_y = y; --- 783,789 ---- y = home_y / mane.shrinkfactor; } if (scrl) ! scrollmane(x, y); else { mane.base_x = x; mane.base_y = y; *************** *** 585,590 **** --- 791,798 ---- curr.base_x = x; curr.base_y = y; } + if (x_bar) paint_x_bar(); + if (y_bar) paint_y_bar(); } } *************** *** 593,599 **** #define window_y 0 #define mane_base_x mane.base_x #define mane_base_y mane.base_y ! #endif X10 static void compute_mag_pos(xp, yp) --- 801,807 ---- #define window_y 0 #define mane_base_x mane.base_x #define mane_base_y mane.base_y ! #endif TOOLKIT static void compute_mag_pos(xp, yp) *************** *** 623,640 **** *yp = t; } ! #ifndef X10 /*ARGSUSED*/ static void handle_button(widget, junk, event) Widget widget; caddr_t junk; ! XButtonEvent *event; ! #else X10 static void handle_button(event) ! XButtonPressedEvent *event; ! #endif X10 { int x, y; #ifndef X10 --- 831,847 ---- *yp = t; } ! #ifdef TOOLKIT /*ARGSUSED*/ static void handle_button(widget, junk, event) Widget widget; caddr_t junk; ! #else TOOLKIT static void handle_button(event) ! #endif TOOLKIT ! XButtonEvent *event; { int x, y; #ifndef X10 *************** *** 641,646 **** --- 848,855 ---- XSetWindowAttributes attr; alt.width = alt.height = mg_size[event->button - 1]; + #else X10 + alt.width = alt.height = mg_size[2 - (event->detail & ValueMask)]; #endif X10 if (alt.win != NULL || mane.shrinkfactor == 1 || alt.width <= 0) XBell(DISP, 20); *************** *** 658,685 **** alt.height/2; #ifndef X10 attr.save_under = True; ! attr.border_pixel = fore_args.value; ! attr.background_pixel = back_args.value; attr.override_redirect = True; ! alt.win = XCreateWindow(DISP, RootWindowOfScreen(SCRN), x, y, alt.width, alt.height, MAGBORD, 0, /* depth from parent */ InputOutput, CopyFromParent, CWSaveUnder | CWBorderPixel | CWBackPixel | CWOverrideRedirect, &attr); ! XSelectInput(DISP, alt.win, ExposureMask); #else X10 ! alt.win = XCreateWindow(mane.win, x, y, alt.width, alt.height, MAGBORD, bdrmap, backmap); ! XSelectInput(alt.win, ExposeRegion); #endif X10 ! XMapWindow(DPY alt.win); alt_stat = 1; /* waiting for exposure */ } } ! #ifndef X10 /*ARGSUSED*/ static void handle_motion(widget, junk, event) --- 867,894 ---- alt.height/2; #ifndef X10 attr.save_under = True; ! attr.border_pixel = fore_Pixel; ! attr.background_pixel = back_Pixel; attr.override_redirect = True; ! alt.win = (void *) XCreateWindow(DISP, RootWindowOfScreen(SCRN), x, y, alt.width, alt.height, MAGBORD, 0, /* depth from parent */ InputOutput, CopyFromParent, CWSaveUnder | CWBorderPixel | CWBackPixel | CWOverrideRedirect, &attr); ! XSelectInput(DISP, (Window) alt.win, ExposureMask); #else X10 ! alt.win = (void *) XCreateWindow((Window) mane.win, x, y, alt.width, alt.height, MAGBORD, bdrmap, backmap); ! XSelectInput((Window) alt.win, ExposeRegion); #endif X10 ! XMapWindow(DPY (Window) alt.win); alt_stat = 1; /* waiting for exposure */ } } ! #ifdef TOOLKIT /*ARGSUSED*/ static void handle_motion(widget, junk, event) *************** *** 693,699 **** main_y = event->y_root - new_mag_y; mag_moved = (new_mag_x != mag_x || new_mag_y != mag_y); } ! #endif X10 static void movemag(x, y) --- 902,908 ---- main_y = event->y_root - new_mag_y; mag_moved = (new_mag_x != mag_x || new_mag_y != mag_y); } ! #endif TOOLKIT static void movemag(x, y) *************** *** 710,716 **** (y + mane_base_y) * mane.shrinkfactor - alt.height/2); } ! #ifndef X10 /*ARGSUSED*/ static void handle_release(widget, junk, event) --- 919,925 ---- (y + mane_base_y) * mane.shrinkfactor - alt.height/2); } ! #ifdef TOOLKIT /*ARGSUSED*/ static void handle_release(widget, junk, event) *************** *** 717,731 **** Widget widget; caddr_t junk; XButtonEvent *event; ! #else X10 static void handle_release() ! #endif X10 { if (alt.win) if (alt_stat) alt_stat = -1; /* destroy upon expose */ else { ! XDestroyWindow(DPY alt.win); if (curr.win == alt.win) alt_canit = True; alt.win = NULL; mag_moved = False; --- 926,940 ---- Widget widget; caddr_t junk; XButtonEvent *event; ! #else TOOLKIT static void handle_release() ! #endif TOOLKIT { if (alt.win) if (alt_stat) alt_stat = -1; /* destroy upon expose */ else { ! XDestroyWindow(DPY (Window) alt.win); if (curr.win == alt.win) alt_canit = True; alt.win = NULL; mag_moved = False; *************** *** 733,739 **** } } ! #ifndef X10 /*ARGSUSED*/ static void handle_exp(widget, windowrec, event) --- 942,948 ---- } } ! #ifdef TOOLKIT /*ARGSUSED*/ static void handle_exp(widget, windowrec, event) *************** *** 751,757 **** alt_stat = 0; expose(windowrec, event->x, event->y, event->width, event->height); } ! #endif X10 #ifndef X10 #define TRSIZE 100 --- 960,966 ---- alt_stat = 0; expose(windowrec, event->x, event->y, event->width, event->height); } ! #endif TOOLKIT #ifndef X10 #define TRSIZE 100 *************** *** 785,794 **** alt.min_x < MAXDIM || mag_moved)) if (alt_canit) longjmp(canit_env, 1); else return; ! #ifndef X10 XtNextEvent(&event); if (resized) get_geom(); ! if (event.xany.window == alt.win && event.type == Expose) { handle_exp((Widget) NULL, &alt, &event.xexpose); continue; --- 994,1003 ---- alt.min_x < MAXDIM || mag_moved)) if (alt_canit) longjmp(canit_env, 1); else return; ! #ifdef TOOLKIT XtNextEvent(&event); if (resized) get_geom(); ! if (event.xany.window == (Window) alt.win && event.type == Expose) { handle_exp((Widget) NULL, &alt, &event.xexpose); continue; *************** *** 801,879 **** nbytes = XLookupString(&event, string, TRSIZE, NULL, NULL); if (nbytes > 1) goto bad; if (nbytes != 0) ch = *string; #else X10 ! XNextEvent(&event); ! switch (event.type) { ! case ExposeWindow: ! if (event.window == mane.win) { ! register Dimension old_clip_w = clip_w; ! window_w = ((XExposeEvent *) &event)->width; ! window_h = ((XExposeEvent *) &event)->height; ! if (old_clip_w == 0) home(False); ! } ! /* control falls through */ ! case ExposeRegion: ! /* check in case we already destroyed the window */ ! if (event.window == mane.win || alt.win != NULL) { ! struct WindowRec *wr = ! (event.window == mane.win ? &mane : &alt); ! if (wr == &alt) ! if (alt_stat < 0) { /* destroy upon exposure */ ! alt_stat = 0; ! handle_release(); ! break; ! } ! else ! alt_stat = 0; ! if (((XExposeEvent *) &event)->detail & ExposeCopy) ! ClearArea(event.window, ! ((XExposeEvent *) &event)->x, ! ((XExposeEvent *) &event)->y, ! ((XExposeEvent *) &event)->width, ! ((XExposeEvent *) &event)->height); ! expose(wr, ((XExposeEvent *) &event)->x, ! ((XExposeEvent *) &event)->y, ! ((XExposeEvent *) &event)->width, ! ((XExposeEvent *) &event)->height); } ! case ExposeCopy: /* throw away junk event */ ! break; ! case MouseMoved: ! case LeftDownMotion: ! case MiddleDownMotion: ! case RightDownMotion: ! new_mag_x = ((XMouseMovedEvent *) &event)->x; ! new_mag_y = ((XMouseMovedEvent *) &event)->y; ! mag_moved = (new_mag_x != mag_x || new_mag_y != mag_y); ! break; ! case ButtonPressed: { ! register int n = 0; ! switch (((XButtonPressedEvent *) &event)->detail & ! ValueMask) { ! case MiddleButton: n=1; break; ! case RightButton: n=2; break; ! } ! alt.width = alt.height = mg_size[n]; ! handle_button((XButtonPressedEvent *) &event); } - break; - case ButtonReleased: - handle_release(); - break; - case KeyPressed: - string = XLookupMapping (&event, &nbytes); - if (nbytes > 1) goto bad; - if (nbytes != 0) ch = *string; - break; - /*MouseMoved */ - default: - Fprintf(stderr, "???: %x\n", event.type); } #endif X10 if (ch == '\0') continue; if (ch >= '0' && ch <= '9') { arg = True; --- 1010,1182 ---- nbytes = XLookupString(&event, string, TRSIZE, NULL, NULL); if (nbytes > 1) goto bad; if (nbytes != 0) ch = *string; + #else TOOLKIT + + /* ||| + * Currently the event handler does not coordinate XCopyArea requests + * with GraphicsExpose events. This can lead to problems if the window + * is partially obscured and one, for example, drags a scrollbar. + */ + + #ifndef X10 + #define XANY(ev) ev.xany + #define XCONFIG(ev) ev.xconfigure + #define XEXPOSE(ev) ev.xexpose + #define XMOTION(ev) ev.xmotion + #define XBUTTON(ev) ev.xbutton + #define XKEY(ev) ev.xkey + #define ISEXPOSE(ev) ((ev).type == Expose) #else X10 ! #define XANY(ev) ev ! #define XCONFIG(ev) (*((XExposeEvent *) &(ev))) ! #define XEXPOSE(ev) (*((XExposeEvent *) &(ev))) ! #define XMOTION(ev) (*((XMouseMovedEvent *) &(ev))) ! #define XBUTTON(ev) (*((XButtonEvent *) &(ev))) ! #define XKEY(ev) (*((XKeyEvent *) &(ev))) ! #define ConfigureNotify ExposeWindow ! #define Expose ExposeRegion ! #define ISEXPOSE(ev) ((ev).type == ExposeWindow || (ev).type == ExposeRegion) ! #define MotionNotify MouseMoved ! #define ButtonPress ButtonPressed ! #define ButtonRelease ButtonReleased ! #define KeyPress KeyPressed ! #endif X10 ! XNextEvent(DPY &event); ! if (XANY(event).window == (Window) mane.win || ! XANY(event).window == (Window) alt.win) { ! struct WindowRec *wr = &mane; ! ! if (XANY(event).window == (Window) alt.win) { ! wr = &alt; ! /* check in case we already destroyed the window */ ! if (alt_stat < 0) { /* destroy upon exposure */ ! alt_stat = 0; ! handle_release(); ! continue; ! } ! else ! alt_stat = 0; } ! switch (event.type) { ! #ifndef X10 ! case GraphicsExpose: ! #else X10 ! case ExposeWindow: ! #endif X10 ! case Expose: ! #ifdef X10 ! if (XEXPOSE(event).detail & ExposeCopy) ! ClearArea(event.window, ! XEXPOSE(event).x, XEXPOSE(event).y, ! XEXPOSE(event).width, XEXPOSE(event).height); ! #endif X10 ! expose(wr, XEXPOSE(event).x, XEXPOSE(event).y, ! XEXPOSE(event).width, XEXPOSE(event).height); ! #ifdef X10 ! case ExposeCopy: /* throw away junk event */ ! #endif X10 ! break; ! case MotionNotify: ! #ifdef X10 ! case LeftDownMotion: ! case MiddleDownMotion: ! case RightDownMotion: ! #endif X10 ! new_mag_x = XMOTION(event).x; ! new_mag_y = XMOTION(event).y; ! mag_moved = (new_mag_x != mag_x || new_mag_y != mag_y); ! break; ! case ButtonPress: ! handle_button(&XBUTTON(event)); ! break; ! ! case ButtonRelease: ! handle_release(); ! break; ! } /* end switch */ ! } /* end if window == {mane,alt}.win */ ! ! else if (XANY(event).window == x_bar) { ! if (ISEXPOSE(event)) ! DarkenArea(x_bar, x_bgn, 1, x_end - x_bgn, BAR_WID); ! else if (event.type == MotionNotify) ! scrollmane(XMOTION(event).x * page_w / clip_w, ! mane.base_y); ! #ifndef X10 ! else switch (XBUTTON(event).button) ! #else X10 ! else if (event.type == ButtonPress) ! switch (3 - (XBUTTON(event).detail & ValueMask)) ! #endif X10 ! { ! case 1: ! scrollmane(mane.base_x + XBUTTON(event).x, mane.base_y); ! break; ! case 2: ! scrollmane(XBUTTON(event).x * page_w / clip_w, ! mane.base_y); ! break; ! case 3: ! scrollmane(mane.base_x - XBUTTON(event).x, mane.base_y); } } + + else if (XANY(event).window == y_bar) { + if (ISEXPOSE(event)) + DarkenArea(y_bar, 1, y_bgn, BAR_WID, y_end - y_bgn); + else if (event.type == MotionNotify) + scrollmane(mane.base_x, + XMOTION(event).y * page_h / clip_h); + #ifndef X10 + else switch (XBUTTON(event).button) + #else X10 + else if (event.type == ButtonPress) + switch (3 - (XBUTTON(event).detail & ValueMask)) #endif X10 + { + case 1: + scrollmane(mane.base_x, mane.base_y + XBUTTON(event).y); + break; + case 2: + scrollmane(mane.base_x, + XBUTTON(event).y * page_h / clip_h); + break; + case 3: + scrollmane(mane.base_x, mane.base_y - XBUTTON(event).y); + } + } + + else if (XANY(event).window == top_level) + switch (event.type) { + case ConfigureNotify: + if (XANY(event).window == top_level && + (XCONFIG(event).width != window_w || + XCONFIG(event).height != window_h)) { + register Dimension old_window_w = window_w; + + window_w = XCONFIG(event).width; + window_h = XCONFIG(event).height; + reconfig(); + if (old_window_w == 0) home(False); + } + break; + + case KeyPress: + #ifndef X10 + string = trbuf; + nbytes = XLookupString(&event, string, TRSIZE, NULL, NULL); + #else X10 + string = XLookupMapping(&event, &nbytes); + #endif X10 + if (nbytes > 1) goto bad; + if (nbytes != 0) ch = *string; + break; + } + #endif TOOLKIT if (ch == '\0') continue; if (ch >= '0' && ch <= '9') { arg = True; *************** *** 921,926 **** --- 1224,1232 ---- case 'P': /* declare current page */ pageno_correct = arg0 * number0 - current_page; continue; + case 'k': /* toggle keep-position flag */ + keep_flag = (arg0 ? number0 : !keep_flag); + continue; case '\f': /* redisplay current page */ break; *************** *** 927,933 **** case '^': home(True); continue; ! #ifndef X10 case 'l': if (!x_bar) goto bad; XtCallCallbacks(x_bar, XtNscrollProc, --- 1233,1239 ---- case '^': home(True); continue; ! #ifdef TOOLKIT case 'l': if (!x_bar) goto bad; XtCallCallbacks(x_bar, XtNscrollProc, *************** *** 951,956 **** --- 1257,1294 ---- case 'c': center(event.xkey.x, event.xkey.y); continue; + #else TOOLKIT + case 'l': + if (mane.base_x <= 0) goto bad; + scrollmane(mane.base_x - 2 * clip_w / 3, mane.base_y); + continue; + case 'r': + if (mane.base_x >= page_w - clip_w) goto bad; + scrollmane(mane.base_x + 2 * clip_w / 3, mane.base_y); + continue; + case 'u': + if (mane.base_y <= 0) goto bad; + scrollmane(mane.base_x, mane.base_y - 2 * clip_h / 3); + continue; + case 'd': + if (mane.base_y >= page_h - clip_h) goto bad; + scrollmane(mane.base_x, mane.base_y + 2 * clip_h / 3); + continue; + case 'c': /* unchecked scrollmane() */ + scrollwindow(&mane, mane.base_x + XKEY(event).x - clip_w/2, + mane.base_y + XKEY(event).y - clip_h/2); + paint_x_bar(); + paint_y_bar(); + #ifndef X10 + XWarpPointer(DISP, None, None, 0, 0, 0, 0, + clip_w/2 - XKEY(event).x, clip_h/2 - XKEY(event).y); + #else X10 + XWarpMouse(mane.win, clip_w/2, clip_h/2, GXcopy); + #endif X10 + continue; + #endif TOOLKIT + + #ifndef X10 case 'M': XTranslateCoordinates(DISP, event.xkey.window, mane.win, event.xkey.x, event.xkey.y, &home_x, &home_y, *************** *** 964,1004 **** ImageByteOrder(DISP)); continue; #else X10 - case 'l': - if (mane.base_x == 0) goto bad; - number0 = mane.base_x - 2 * clip_w / 3; - if (number0 < 0) number0 = 0; - scrollwindow(&mane, number0, mane.base_y); - continue; - case 'r': - number0 = mane.base_x + 2 * clip_w / 3; - if (number0 > page_w - clip_w) number0 = page_w - clip_w; - if (number0 == mane.base_x) goto bad; - scrollwindow(&mane, number0, mane.base_y); - continue; - case 'u': - if (mane.base_y == 0) goto bad; - number0 = mane.base_y - 2 * clip_h / 3; - if (number0 < 0) number0 = 0; - scrollwindow(&mane, mane.base_x, number0); - continue; - case 'd': - number0 = mane.base_y + 2 * clip_h / 3; - if (number0 > page_h - clip_h) number0 = page_h - clip_h; - if (number0 == mane.base_y) goto bad; - scrollwindow(&mane, mane.base_x, number0); - continue; - case 'c': - #define ev ((XKeyPressedEvent *) &event) - scrollwindow(&mane, mane.base_x + ev->x - window_w/2, - mane.base_y + ev->y - window_h/2); - XWarpMouse(mane.win, window_w/2, window_h/2, 3); - continue; case 'M': ! home_x = (ev->x + mane.base_x) * mane.shrinkfactor; ! home_y = (ev->y + mane.base_y) * mane.shrinkfactor; continue; - #undef ev #endif X10 case 's': if (!arg0) { --- 1302,1311 ---- ImageByteOrder(DISP)); continue; #else X10 case 'M': ! home_x = (XKEY(event).x + mane.base_x) * mane.shrinkfactor; ! home_y = (XKEY(event).y + mane.base_y) * mane.shrinkfactor; continue; #endif X10 case 's': if (!arg0) { *************** *** 1019,1036 **** bak_shrink = number0; reset_fonts(); } ! #ifndef X10 XUnmapWindow(DISP, mane.win); set_draw_args(); XtSetValues(draw_widget, draw_args, 2); get_geom(); home(False); ! XMapWindow(DISP, mane.win); continue; ! #else X10 home(False); break; ! #endif X10 case 'S': if (!arg0) goto bad; if (number0 < 0) goto bad; --- 1326,1344 ---- bak_shrink = number0; reset_fonts(); } ! #ifdef TOOLKIT XUnmapWindow(DISP, mane.win); set_draw_args(); XtSetValues(draw_widget, draw_args, 2); get_geom(); home(False); ! XMapWindow(DISP, (Window) mane.win); continue; ! #else TOOLKIT ! reconfig(); home(False); break; ! #endif TOOLKIT case 'S': if (!arg0) goto bad; if (number0 < 0) goto bad; *************** *** 1050,1056 **** if (current_page != next_page) { current_page = next_page; spec_warn = True; ! home(False); } canit = True; Flush(); --- 1358,1364 ---- if (current_page != next_page) { current_page = next_page; spec_warn = True; ! if (!keep_flag) home(False); } canit = True; Flush(); *************** *** 1151,1157 **** static void enable_intr() { ! #ifndef SYSV int socket = ConnectionNumber(DISP); if (!isatty(0)) { puts("trying..."); --- 1459,1465 ---- static void enable_intr() { ! #ifdef HAS_SIGIO int socket = ConnectionNumber(DISP); if (!isatty(0)) { puts("trying..."); *************** *** 1168,1180 **** do_pages() { if (debug & DBG_BATCH) { ! #ifndef X10 while (mane.min_x == MAXDIM) read_events(True); ! #else X10 while (mane.min_x == MAXDIM) if (setjmp(canit_env)) break; else read_events(True); ! #endif X10 for (current_page = 0; current_page < total_pages; ++current_page) redraw_page(); exit(0); --- 1476,1488 ---- do_pages() { if (debug & DBG_BATCH) { ! #ifdef TOOLKIT while (mane.min_x == MAXDIM) read_events(True); ! #else TOOLKIT while (mane.min_x == MAXDIM) if (setjmp(canit_env)) break; else read_events(True); ! #endif TOOLKIT for (current_page = 0; current_page < total_pages; ++current_page) redraw_page(); exit(0); *************** *** 1183,1189 **** enable_intr(); (void) setjmp(canit_env); for (;;) { ! SetCursor(ready_cursor); read_events(True); if (canit) { canit = False; --- 1491,1497 ---- enable_intr(); (void) setjmp(canit_env); for (;;) { ! if (mane.win) SetCursor(ready_cursor); read_events(True); if (canit) { canit = False; *************** *** 1217,1223 **** [-cr <color>]\n\ [-margins <inches>] [-sidemargin <inches>] [-topmargin <inches>]\n\ [-mgs[n] <size>] [-geometry <geometry>] [#<geometry>]\n\ ! [-altfont <font>] [-display <host:display>] dvi_file\n", stderr); #else X10 fputs("\ Usage: xdvi [+[<page>]] [-s <shrink>] [-S <density>] [-p <pixels>] [-l] [-rv]\n\ --- 1525,1532 ---- [-cr <color>]\n\ [-margins <inches>] [-sidemargin <inches>] [-topmargin <inches>]\n\ [-mgs[n] <size>] [-geometry <geometry>] [#<geometry>]\n\ ! [-altfont <font>] [-thorough] [-copy] [-display <host:display>] \ ! dvi_file\n", stderr); #else X10 fputs("\ Usage: xdvi [+[<page>]] [-s <shrink>] [-S <density>] [-p <pixels>] [-l] [-rv]\n\ *************** *** 1237,1244 **** --- 1546,1556 ---- #ifndef X10 static char *icon_geometry; + static Boolean copy = 2; static Boolean thorough; + #endif X10 + #ifdef TOOLKIT static XrmOptionDescRec options[] = { {"-d", ".debugLevel", XrmoptionSepArg, (caddr_t) NULL}, {"+", ".gotoPage", XrmoptionStickyArg, (caddr_t) NULL}, *************** *** 1258,1263 **** --- 1570,1577 ---- {"-hl", ".highlight", XrmoptionSepArg, (caddr_t) NULL}, {"-cr", ".cursorColor", XrmoptionSepArg, (caddr_t) NULL}, {"#", ".iconGeometry",XrmoptionStickyArg, (caddr_t) NULL}, + {"-copy", ".copy", XrmoptionNoArg, (caddr_t) "on"}, + {"+copy", ".copy", XrmoptionNoArg, (caddr_t) "off"}, {"-thorough", ".thorough", XrmoptionNoArg, (caddr_t) "on"}, {"+thorough", ".thorough", XrmoptionNoArg, (caddr_t) "off"}, {"-mgs", ".magnifierSize1",XrmoptionSepArg, (caddr_t) NULL}, *************** *** 1292,1302 **** {"reverseVideo", "ReverseVideo", XtRBoolean, sizeof(Boolean), (Cardinal) &reverse, XtRBoolean, (caddr_t) &reverse}, {"foreground", "Foreground", XtRPixel, sizeof(Pixel), ! (Cardinal)&fore_args.value, XtRPixel, (caddr_t) &fore_args.value}, {"foreground", "Foreground", XtRString, sizeof(char *), (Cardinal)&fore_color, XtRString, NULL}, {"background", "Background", XtRPixel, sizeof(Pixel), ! (Cardinal)&back_args.value, XtRPixel, (caddr_t) &back_args.value}, {"background", "Background", XtRString, sizeof(char *), (Cardinal)&back_color, XtRString, NULL}, {"highlight", "Highlight", XtRPixel, sizeof(Pixel), --- 1606,1616 ---- {"reverseVideo", "ReverseVideo", XtRBoolean, sizeof(Boolean), (Cardinal) &reverse, XtRBoolean, (caddr_t) &reverse}, {"foreground", "Foreground", XtRPixel, sizeof(Pixel), ! (Cardinal)&fore_Pixel, XtRPixel, (caddr_t) &fore_Pixel}, {"foreground", "Foreground", XtRString, sizeof(char *), (Cardinal)&fore_color, XtRString, NULL}, {"background", "Background", XtRPixel, sizeof(Pixel), ! (Cardinal)&back_Pixel, XtRPixel, (caddr_t) &back_Pixel}, {"background", "Background", XtRString, sizeof(char *), (Cardinal)&back_color, XtRString, NULL}, {"highlight", "Highlight", XtRPixel, sizeof(Pixel), *************** *** 1309,1314 **** --- 1623,1630 ---- (Cardinal)&curs_color, XtRString, NULL}, {"iconGeometry", "IconGeometry", XtRString, sizeof(char *), (Cardinal)&icon_geometry, XtRString, (caddr_t) NULL}, + {"copy", "Copy", XtRBoolean, sizeof(Boolean), + (Cardinal)©, XtRBoolean, (caddr_t) ©}, {"thorough", "Thorough", XtRBoolean, sizeof(Boolean), (Cardinal)&thorough, XtRBoolean, (caddr_t) &thorough}, {"magnifierSize1", "MagnifierSize", XtRInt, sizeof(int), *************** *** 1342,1513 **** {XtNiconPixmap, (XtArgVal) 0}, }; ! /* ! * X11 main program ! */ ! main(argc, argv) ! int argc; ! char **argv; ! { ! prog = *argv; ! if (*prog == '/') prog = rindex(prog, '/') + 1; ! top_level = XtInitialize(prog, "XDvi", options, XtNumber(options), ! &argc, argv); ! if (argc != 2) usage(); ! dvi_name = argv[1]; ! XtGetApplicationResources(top_level, (caddr_t) NULL, resources, ! XtNumber(resources), NULL, 0); ! if (shrink_factor <= 0 || density <= 0 || pixels_per_inch <= 0) 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 (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; ! /* The following code is lifted from Xterm */ ! DISP = XtDisplay(top_level); ! SCRN = XtScreen(top_level); ! if (icon_geometry != NULL) { ! int scr, junk; ! for(scr = 0; /* yyuucchh */ ! SCRN != ScreenOfDisplay(DISP, scr); ! scr++); ! ! temp_args1[0].name = XtNiconX; ! temp_args1[1].name = XtNiconY; ! XGeometry(DISP, scr, icon_geometry, "", 0, 0, 0, 0, 0, ! &temp_args1[0].value, &temp_args1[1].value, &junk, &junk); ! XtSetValues(top_level, temp_args1, 2); } ! ! if ((font_path = getenv(FONT_PATH)) == NULL) ! font_path = default_font_path; ! else if (*font_path == ':') ! /*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); ! ! open_dvi_file(); ! if (curr_page) { ! current_page = (*curr_page ? atoi(curr_page) : total_pages) - 1; ! if (current_page < 0 || current_page >= total_pages) usage(); } ! ! /* Set default window size and icon */ ! XtGetValues(top_level, &temp_args2, 1); /* get border width */ ! screen_w = WidthOfScreen(SCRN) - 2*bwidth; ! screen_h = HeightOfScreen(SCRN) - 2*bwidth; ! temp_args3[0].value = (XtArgVal) (page_w<screen_w ? page_w : 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)); ! XtSetValues(top_level, temp_args3, 3); ! ! vport_widget = XtCreateManagedWidget("vport", viewportWidgetClass, ! top_level, vport_args, XtNumber(vport_args)); ! clip_widget = XtNameToWidget(vport_widget, "clip"); ! set_draw_args(); ! draw_widget = XtCreateManagedWidget("drawing", widgetClass, ! vport_widget, draw_args, XtNumber(draw_args)); ! XtAddEventHandler(vport_widget, KeyPressMask, False, handle_key, ! (caddr_t) NULL); ! XtAddEventHandler(vport_widget, StructureNotifyMask, False, ! handle_resize, (caddr_t) NULL); ! XtAddEventHandler(draw_widget, ExposureMask, False, handle_exp, ! (caddr_t) &mane); ! XtAddEventHandler(draw_widget, ButtonPressMask, False, handle_button, ! (caddr_t) NULL); ! XtAddEventHandler(draw_widget, ButtonMotionMask, False, handle_motion, ! (caddr_t) NULL); ! XtAddEventHandler(draw_widget, ButtonReleaseMask, False, handle_release, ! (caddr_t) NULL); ! XtRealizeWidget(top_level); ! curr.win = mane.win = XtWindow(draw_widget); ! ! if (reverse) { ! if (!fore_color) fore_args.value = WhitePixelOfScreen(SCRN); ! if (!back_color) back_args.value = BlackPixelOfScreen(SCRN); ! fore_color = back_color = (char *)1; /* nonzero */ ! } else { ! if (!fore_color) fore_args.value = BlackPixelOfScreen(SCRN); ! if (!back_color) back_args.value = WhitePixelOfScreen(SCRN); ! } ! if (fore_color) XtSetValues(draw_widget, &fore_args, 1); ! if (back_color) { ! XtSetValues(draw_widget, &back_args, 1); ! XtSetValues(clip_widget, &back_args, 1); ! } ! { ! XGCValues values; ! Pixel set_bits = (Pixel) (fore_args.value & ~back_args.value); ! Pixel clr_bits = (Pixel) (back_args.value & ~fore_args.value); ! #define MakeGC(fcn, fg, bg) (values.function = fcn, values.foreground=fg,\ ! values.background=bg,\ ! XCreateGC(DISP, RootWindowOfScreen(SCRN),\ ! GCFunction|GCForeground|GCBackground, &values)) ! ! if (set_bits && clr_bits) ! ruleGC = MakeGC(GXcopy, fore_args.value, back_args.value); ! if (!thorough && ruleGC) { ! foreGC = ruleGC; ! puts("Note: overstrike characters may be incorrect."); ! } ! else { ! if (set_bits) foreGC = MakeGC(GXor, set_bits, 0); ! if (clr_bits) ! *(foreGC ? &foreGC2 : &foreGC) = ! MakeGC(GXandInverted, clr_bits, 0); ! if (!ruleGC) ruleGC = foreGC; ! } ! highGC = ruleGC; ! if (high_color) ! highGC = MakeGC(GXcopy, hl_Pixel, back_args.value); ! } ! ! ready_cursor = XCreateFontCursor(DISP, XC_cross); ! redraw_cursor = XCreateFontCursor(DISP, XC_watch); ! if (!curs_color) ! cr_Pixel = high_color ? hl_Pixel : fore_args.value; ! { ! XColor bg_Color, cr_Color; ! ! bg_Color.pixel = back_args.value; ! XQueryColor(DISP, DefaultColormapOfScreen(SCRN), &bg_Color); ! cr_Color.pixel = cr_Pixel; ! XQueryColor(DISP, DefaultColormapOfScreen(SCRN), &cr_Color); ! XRecolorCursor(DISP, ready_cursor, &cr_Color, &bg_Color); ! XRecolorCursor(DISP, redraw_cursor, &cr_Color, &bg_Color); ! } ! ! image = XCreateImage(DISP, DefaultVisualOfScreen(SCRN), 1, XYBitmap, 0, ! (char *)NULL, 0, 0, BITS_PER_BMUNIT, 0); ! image->bitmap_unit = BITS_PER_BMUNIT; ! #ifndef MSBITFIRST ! image->bitmap_bit_order = LSBFirst; ! #else MSBITFIRST ! image->bitmap_bit_order = MSBFirst; ! #endif MSBITFIRST ! { ! short endian = (MSBFirst << 8) + LSBFirst; ! image->byte_order = *((char *) &endian); ! } ! ! do_pages(); } - #else X10 - static char *display; - static char *brdr_color; - static char *geometry; - static struct option { char *name; char *resource; --- 1658,1701 ---- {XtNiconPixmap, (XtArgVal) 0}, }; ! #else TOOLKIT ! static char *display; ! static char *geometry; ! #ifdef X10 ! static char *brdr_color; ! #endif X10 ! #ifndef X10 ! static Boolean iconic = False; ! static Pixel ! string_to_pixel(strp) /* adapted from the toolkit */ ! char **strp; ! { ! char *str = *strp; ! Status status; ! XColor color, junk; ! if (*str == '#') { /* an rgb definition */ ! status = XParseColor(DISP, DefaultColormapOfScreen(SCRN), ! str, &color); ! if (status != 0) ! status = XAllocColor(DISP, DefaultColormapOfScreen(SCRN), ! &color); } ! else /* a name */ ! status = XAllocNamedColor(DISP, DefaultColormapOfScreen(SCRN), ! str, &color, &junk); ! if (status == 0) { ! Fprintf(stderr, "Cannot allocate colormap entry for \"%s\"\n", str); ! *strp = NULL; ! return (Pixel) 0; } ! return color.pixel; } + #endif X10 static struct option { char *name; char *resource; *************** *** 1537,1557 **** {"-bg", "background", SepArg, StringArg, (caddr_t) &back_color}, {"-background", NULL, SepArg, StringArg, (caddr_t) &back_color}, {"-hl", "highlight", SepArg, StringArg, (caddr_t) &high_color}, {"-bd", "borderColor", SepArg, StringArg, (caddr_t) &brdr_color}, {"-cr", "cursorColor", SepArg, StringArg, (caddr_t) &curs_color}, {"-geometry", "geometry", SepArg, StringArg, (caddr_t) &geometry}, {"=", NULL, StickyArg, StringArg, (caddr_t) &geometry}, {"-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]}, }; /* ! * X10 main program */ ! main(argc, argv) int argc; char **argv; { --- 1725,1762 ---- {"-bg", "background", SepArg, StringArg, (caddr_t) &back_color}, {"-background", NULL, SepArg, StringArg, (caddr_t) &back_color}, {"-hl", "highlight", SepArg, StringArg, (caddr_t) &high_color}, + #ifdef X10 {"-bd", "borderColor", SepArg, StringArg, (caddr_t) &brdr_color}, + #endif X10 {"-cr", "cursorColor", SepArg, StringArg, (caddr_t) &curs_color}, {"-geometry", "geometry", SepArg, StringArg, (caddr_t) &geometry}, {"=", NULL, StickyArg, StringArg, (caddr_t) &geometry}, + #ifndef X10 + {"#", "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 X10 }; /* ! * Process the option table. This is not guaranteed for all possible ! * option tables, but at least it works for this one. */ ! static void ! parse_options(argc, argv) int argc; char **argv; { *************** *** 1561,1577 **** caddr_t addr; struct option *opt, *candidate; int len1, len2, matchlen; - OpaqueFrame frame; - char def[32]; - int mouspix; - Color cdef; - prog = *argv; - if (*prog == '/') prog = rindex(prog, '/') + 1; - /* - * Process the option table. This is not guaranteed for all possible - * option tables, but at least it works for this one. - */ for (arg = argv + 1; arg < argvend; ++arg) { len1 = strlen(*arg); candidate = NULL; --- 1766,1772 ---- *************** *** 1628,1637 **** } } if (XOpenDisplay(display) == NULL) oops("Can't open display\n"); for (opt = options; opt < options + XtNumber(options); ++opt) ! if (opt->resource && (optstring = XGetDefault(prog, opt->resource))) switch (opt->argtype) { case StringArg: *((char **) opt->address) = optstring; --- 1823,1844 ---- } } + #ifndef X10 + if ((DISP = XOpenDisplay(display)) == NULL) + oops("Can't open display\n"); + SCRN = DefaultScreenOfDisplay(DISP); + #else X10 if (XOpenDisplay(display) == NULL) oops("Can't open display\n"); + #endif X10 for (opt = options; opt < options + XtNumber(options); ++opt) ! if (opt->resource && ! #ifndef X10 ! ((optstring = XGetDefault(DISP, prog, opt->resource)) || ! (optstring = XGetDefault(DISP, "XDvi", opt->resource)))) ! #else X10 ! (optstring = XGetDefault(DPY prog, opt->resource))) ! #endif X10 switch (opt->argtype) { case StringArg: *((char **) opt->address) = optstring; *************** *** 1643,1653 **** --- 1850,1910 ---- *((Boolean *) opt->address) = (strcmp(optstring, "on") == 0); } + } + #endif TOOLKIT + /* + * main program + */ + + main(argc, argv) + int argc; + char **argv; + { + #ifndef TOOLKIT + #ifndef X10 + XSizeHints size_hints; + XWMHints wmhints; + #else X10 + OpaqueFrame frame; + char def[32]; + int mouspix; + Color cdef; + #endif X10 + #endif TOOLKIT + + prog = rindex(*argv, '/'); + if (prog != NULL) ++prog; else prog = *argv; + + #ifdef TOOLKIT + top_level = XtInitialize(prog, "XDvi", options, XtNumber(options), + &argc, argv); + if (argc != 2) usage(); + dvi_name = argv[1]; + + 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); + + #else TOOLKIT + + parse_options(argc, argv); + #ifndef X10 + if (fore_color) fore_Pixel = string_to_pixel(&fore_color); + if (back_color) back_Pixel = string_to_pixel(&back_color); + if (high_color) hl_Pixel = string_to_pixel(&high_color); + if (curs_color) cr_Pixel = string_to_pixel(&curs_color); + #endif X10 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; *************** *** 1668,1674 **** --- 1925,2116 ---- if (current_page < 0 || current_page >= total_pages) usage(); } + #ifndef X10 + + /* + * X11 colors + */ + if (reverse) { + if (!fore_color) fore_Pixel = WhitePixelOfScreen(SCRN); + if (!back_color) back_Pixel = BlackPixelOfScreen(SCRN); + fore_color = back_color = (char *) &fore_color; /* nonzero */ + } else { + if (!fore_color) fore_Pixel = BlackPixelOfScreen(SCRN); + if (!back_color) back_Pixel = WhitePixelOfScreen(SCRN); + } + { + XGCValues values; + Pixel set_bits = (Pixel) (fore_Pixel & ~back_Pixel); + Pixel clr_bits = (Pixel) (back_Pixel & ~fore_Pixel); + #define MakeGC(fcn, fg, bg) (values.function = fcn, values.foreground=fg,\ + values.background=bg,\ + XCreateGC(DISP, RootWindowOfScreen(SCRN),\ + GCFunction|GCForeground|GCBackground, &values)) + + if (copy == 2) copy = (PlanesOfScreen(SCRN) > 1); + if (copy || (set_bits && clr_bits)) + ruleGC = MakeGC(GXcopy, fore_Pixel, back_Pixel); + if (copy) foreGC = ruleGC; + else if (!thorough && ruleGC) { + foreGC = ruleGC; + puts("Note: overstrike characters may be incorrect."); + } + else { + if (set_bits) foreGC = MakeGC(GXor, set_bits, 0); + if (clr_bits) + *(foreGC ? &foreGC2 : &foreGC) = + MakeGC(GXandInverted, clr_bits, 0); + if (!ruleGC) ruleGC = foreGC; + } + highGC = ruleGC; + if (high_color) + highGC = MakeGC(GXcopy, hl_Pixel, back_Pixel); + } + + ready_cursor = XCreateFontCursor(DISP, XC_cross); + redraw_cursor = XCreateFontCursor(DISP, XC_watch); + if (!curs_color) + cr_Pixel = high_color ? hl_Pixel : fore_Pixel; + { + XColor bg_Color, cr_Color; + + bg_Color.pixel = back_Pixel; + XQueryColor(DISP, DefaultColormapOfScreen(SCRN), &bg_Color); + cr_Color.pixel = cr_Pixel; + XQueryColor(DISP, DefaultColormapOfScreen(SCRN), &cr_Color); + XRecolorCursor(DISP, ready_cursor, &cr_Color, &bg_Color); + XRecolorCursor(DISP, redraw_cursor, &cr_Color, &bg_Color); + } + + #ifdef TOOLKIT + + /* + * X11 windows (toolkit) + */ + + /* The following code is lifted from Xterm */ + if (icon_geometry != NULL) { + int scr, junk; + + for(scr = 0; /* yyuucchh */ + SCRN != ScreenOfDisplay(DISP, scr); + scr++); + + XGeometry(DISP, scr, icon_geometry, "", 0, 0, 0, 0, 0, + &temp_args1[0].value, &temp_args1[1].value, &junk, &junk); + XtSetValues(top_level, temp_args1, 2); + } + /* Set default window size and icon */ + XtGetValues(top_level, &temp_args2, 1); /* get border width */ + screen_w = WidthOfScreen(SCRN) - 2*bwidth; + screen_h = HeightOfScreen(SCRN) - 2*bwidth; + temp_args3[0].value = (XtArgVal) (page_w<screen_w ? page_w : 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)); + XtSetValues(top_level, temp_args3, 3); + + vport_widget = XtCreateManagedWidget("vport", viewportWidgetClass, + top_level, vport_args, XtNumber(vport_args)); + clip_widget = XtNameToWidget(vport_widget, "clip"); + set_draw_args(); + draw_widget = XtCreateManagedWidget("drawing", widgetClass, + vport_widget, draw_args, XtNumber(draw_args)); + if (fore_color) XtSetValues(draw_widget, &fore_args, 1); + if (back_color) { + 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); + XtAddEventHandler(draw_widget, ExposureMask, False, handle_exp, + (caddr_t) &mane); + XtAddEventHandler(draw_widget, ButtonPressMask, False, handle_button, + (caddr_t) NULL); + XtAddEventHandler(draw_widget, ButtonMotionMask, False, handle_motion, + (caddr_t) NULL); + XtAddEventHandler(draw_widget, ButtonReleaseMask, False, handle_release, + (caddr_t) NULL); + XtRealizeWidget(top_level); + curr.win = mane.win = (void *) XtWindow(draw_widget); + + #else TOOLKIT + + /* + * X11 windows (non toolkit) + */ + + screen_w = WidthOfScreen(SCRN) - 2*bwidth; + screen_h = HeightOfScreen(SCRN) - 2*bwidth; + size_hints.flags = PMinSize; + size_hints.min_width = size_hints.min_height = 50; + size_hints.x = size_hints.y = 0; + if (geometry != NULL) { + int flag = XParseGeometry(geometry, &size_hints.x, &size_hints.y, + &size_hints.width, &size_hints.height); + + if (flag & (XValue | YValue)) + size_hints.flags |= USSize | USPosition; + if (flag & (WidthValue | HeightValue)) + size_hints.flags |= USSize; + if (flag & XNegative) size_hints.x += screen_w - size_hints.width; + if (flag & YNegative) size_hints.y += screen_h - size_hints.height; + } + if (!(size_hints.flags & USSize)) { + size_hints.flags |= PSize; + size_hints.width = page_w < screen_w ? page_w : screen_w; + size_hints.height = page_h < screen_h ? page_h : screen_h; + } + top_level = XCreateSimpleWindow(DISP, RootWindowOfScreen(SCRN), + size_hints.x, size_hints.y, size_hints.width, size_hints.height, + bwidth, fore_Pixel, back_Pixel); + XSetStandardProperties(DISP, top_level, dvi_name, prog, NULL, + argv, argc, &size_hints); + + wmhints.flags = StateHint | IconPixmapHint; + wmhints.initial_state = iconic ? IconicState : NormalState; + wmhints.icon_pixmap = XCreateBitmapFromData(DISP, + RootWindowOfScreen(SCRN), + xdvi_bits, xdvi_width, xdvi_height); + if (icon_geometry != NULL) { + int junk; + + wmhints.flags |= IconPositionHint; + XGeometry(DISP, DefaultScreen(DISP), icon_geometry, "", + 0, 0, 0, 0, 0, &wmhints.icon_x, &wmhints.icon_y, &junk, &junk); + } + XSetWMHints(DISP, top_level, &wmhints); + + XSelectInput(DISP, top_level, KeyPressMask | StructureNotifyMask); + XMapWindow(DISP, top_level); + Flush(); + + #endif TOOLKIT + + image = XCreateImage(DISP, DefaultVisualOfScreen(SCRN), 1, XYBitmap, 0, + (char *)NULL, 0, 0, BITS_PER_BMUNIT, 0); + image->bitmap_unit = BITS_PER_BMUNIT; + #ifndef MSBITFIRST + image->bitmap_bit_order = LSBFirst; + #else MSBITFIRST + image->bitmap_bit_order = MSBFirst; + #endif MSBITFIRST + { + short endian = (MSBFirst << 8) + LSBFirst; + image->byte_order = *((char *) &endian); + } + + #else X10 + + /* + * X10 colors + */ + + if (reverse) { foreGC = WhitePixel; highGC = WhitePixel; backpix = BlackPixel; *************** *** 1705,1710 **** --- 2147,2156 ---- mouspix = cdef.pixel; } + /* + * X10 windows + */ + frame.bdrwidth = bwidth; screen_w = DisplayWidth() - 2*bwidth; screen_h = DisplayHeight() - 2*bwidth; *************** *** 1715,1730 **** frame.x = 0; frame.y = 0; Sprintf(def, "=%dx%d+0+0", frame.width, frame.height); ! mane.win = XCreate("DVI Previewer", prog, geometry, def, &frame, 50, 50); ! XSelectInput(mane.win, ! KeyPressed|ButtonPressed|ButtonReleased| ! ExposeWindow|ExposeRegion|ExposeCopy| ! LeftDownMotion|MiddleDownMotion|RightDownMotion); ! XMapWindow(mane.win); ! XDefineCursor(mane.win, XCreateCursor(xdvi_width, xdvi_height, xdvi_bits, xdvi_mask_bits, xdvi_x_hot, xdvi_y_hot, mouspix, backpix, GXcopy)); do_pages(); } - #endif X10 --- 2161,2174 ---- frame.x = 0; frame.y = 0; Sprintf(def, "=%dx%d+0+0", frame.width, frame.height); ! top_level = XCreate("DVI Previewer", prog, geometry, def, &frame, 50, 50); ! XSelectInput(top_level, ExposeWindow | KeyPressed); ! XMapWindow(top_level); ! XDefineCursor(top_level, XCreateCursor(xdvi_width, xdvi_height, xdvi_bits, xdvi_mask_bits, xdvi_x_hot, xdvi_y_hot, mouspix, backpix, GXcopy)); + #endif X10 + do_pages(); } diff -cr old/xdvi.h new/xdvi.h *** old/xdvi.h Mon Aug 28 00:06:12 1989 --- new/xdvi.h Tue Aug 22 13:29:47 1989 *************** *** 48,53 **** --- 48,59 ---- #define BMSHORT #endif X10 + #ifdef SYSV + #define ANSI_LIB + #else + #define HAS_SIGIO /* has SIGIO on _sockets_ */ + #endif + #ifdef BMLONG #define BMUNIT unsigned long #define BITS_PER_BMUNIT 32 *************** *** 200,206 **** extern char *prog; extern struct WindowRec { ! long win; /* type Window is not defined yet */ int shrinkfactor; int base_x, base_y; int width, height; --- 206,212 ---- extern char *prog; extern struct WindowRec { ! void *win; /* type Window is not defined yet */ int shrinkfactor; int base_x, base_y; int width, height; diff -cr old/xdvi.man.sed new/xdvi.man.sed *** old/xdvi.man.sed Mon Aug 28 00:06:16 1989 --- new/xdvi.man.sed Thu Aug 24 12:33:50 1989 *************** *** 6,12 **** .nh [+[\fIpage\fP]] [\-s \fIshrink\fP] [\-S \fIdensity\fP] [\-p \fIpixels\fP] [\-altfont \fIfont\fP] [\-l] [\-rv] [\-fg \fIcolor\fP] [\-bg \fIcolor\fP] ! [\-hl \fIcolor\fP] [\-bd \fIcolor\fP] [\-cr \fIcolor\fP] [-thorough] [\-margins \fIinches\fP] [\-sidemargin \fIinches\fP] [\-topmargin \fIinches\fP] [\-mgs[\fIn\fP] \fIsize\fP] [\-geometry \fIgeometry\fP | =\fIgeometry\fP] [%\fIgeometry\fP] [\-display \fIdisplay\fP] file --- 6,12 ---- .nh [+[\fIpage\fP]] [\-s \fIshrink\fP] [\-S \fIdensity\fP] [\-p \fIpixels\fP] [\-altfont \fIfont\fP] [\-l] [\-rv] [\-fg \fIcolor\fP] [\-bg \fIcolor\fP] ! [\-hl \fIcolor\fP] [\-bd \fIcolor\fP] [\-cr \fIcolor\fP] [-thorough] [-copy] [\-margins \fIinches\fP] [\-sidemargin \fIinches\fP] [\-topmargin \fIinches\fP] [\-mgs[\fIn\fP] \fIsize\fP] [\-geometry \fIgeometry\fP | =\fIgeometry\fP] [%\fIgeometry\fP] [\-display \fIdisplay\fP] file *************** *** 113,120 **** appropriate bits and one to clear other bits. If this is the case, then by default \fIxdvi\fR will instead use the \fIcopy\fR operation, which does not handle overstriking correctly. The ``thorough'' option ! chooses the slower but more correct choice. .TP .BI \-margins " inches" (.margins) Specifies the size of both the top margin and side margin. This --- 113,126 ---- appropriate bits and one to clear other bits. If this is the case, then by default \fIxdvi\fR will instead use the \fIcopy\fR operation, which does not handle overstriking correctly. The ``thorough'' option ! chooses the slower but more correct choice. See also \fI-copy\fR, below. .TP + .B \-copy + (.copy) + 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. + .TP .BI \-margins " inches" (.margins) Specifies the size of both the top margin and side margin. This *************** *** 224,238 **** .B R Forces the dvi file to be reread. This allows you to preview many versions of the same file while running \fIxdvi\fR only once. .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 image in the vicinity of the mouse click. This subwindow disappears when the mouse button is released. Different mouse buttons produce different sized ! windows, as indicated by the \fB\-mgs\fR option, above. .PP Also, the scrollbars (if present) behave in the standard way: pushing Button 2 ! in a scrollbar moves the top or left edge of the scrollbar to that point; pushing Button 1 moves the image up or right by an amount equal to the distance from the button press to the upper left-hand corner of the window; pushing Button 3 moves the image down or left by the same amount. --- 230,252 ---- .B R Forces the dvi file to be reread. This allows you to preview many versions of the same file while running \fIxdvi\fR only once. + .TP + .B k + Normally when \fIxdvi\fR switches pages it moves to the home position as well. + 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. .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 image in the vicinity of the mouse click. This subwindow disappears when the mouse button is released. Different mouse buttons produce different sized ! windows, as indicated by the \fB\-mgs\fR option, above. Moving the cursor ! while holding the button down will move the magnifying glass. .PP Also, the scrollbars (if present) behave in the standard way: pushing Button 2 ! in a scrollbar moves the top or left edge of the scrollbar to that point ! and optionally drags it; pushing Button 1 moves the image up or right by an amount equal to the distance from the button press to the upper left-hand corner of the window; pushing Button 3 moves the image down or left by the same amount. diff -cr old/xdvi10.man.s new/xdvi10.man.s *** old/xdvi10.man.s Mon Aug 28 00:06:18 1989 --- new/xdvi10.man.s Thu Aug 24 12:33:35 1989 *************** *** 219,230 **** .B R Forces the dvi file to be reread. This allows you to preview many versions of the same file while running \fIxdvi\fR only once. .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 image in the vicinity of the mouse click. This subwindow disappears when the mouse button is released. Different mouse buttons produce different sized ! windows, as indicated by the \fB\-mgs\fR option, above. .SH ENVIRONMENT Uses the environment variable ``DISPLAY'' to specify which bit map display terminal to use. --- 219,244 ---- .B R Forces the dvi file to be reread. This allows you to preview many versions of the same file while running \fIxdvi\fR only once. + .TP + .B k + Normally when \fIxdvi\fR switches pages it moves to the home position as well. + 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. .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 image in the vicinity of the mouse click. This subwindow disappears when the mouse button is released. Different mouse buttons produce different sized ! windows, as indicated by the \fB\-mgs\fR option, above. Moving the cursor ! while holding the button down will move the magnifying glass. ! .PP ! Also, the scrollbars (if present) behave in the standard way: pushing Button 2 ! in a scrollbar moves the top or left edge of the scrollbar to that point ! and optionally drags it; ! pushing Button 1 moves the image up or right by an amount equal to the distance ! from the button press to the upper left-hand corner of the window; pushing ! Button 3 moves the image down or left by the same amount. .SH ENVIRONMENT Uses the environment variable ``DISPLAY'' to specify which bit map display terminal to use.