home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume4 / xdvi / patch5 < prev    next >
Encoding:
Internet Message Format  |  1989-08-29  |  79.1 KB

  1. Path: uunet!island!argv
  2. From: argv@island.uu.net (Dan Heller)
  3. Newsgroups: comp.sources.x
  4. Subject: v04i096: xdvi, dvi previewer, Patch5
  5. Message-ID: <1035@island.uu.net>
  6. Date: 30 Aug 89 05:04:46 GMT
  7. Sender: news@island.uu.net
  8. Organization: Island Graphics, Marin County, California
  9. Lines: 2714
  10. Approved: island!argv@sun.com
  11.  
  12. Submitted-by: vojta@math.Berkeley.EDU
  13. Posting-number: Volume 4, Issue 96
  14. Archive-name: xdvi/patch5
  15. Patch-To: xdvi: Volume 3, Issue 37
  16.  
  17. Patch 5 of xdvi does the following:
  18.  
  19.     1.  Fixes a bug in the gf file reading routines, dealing with fonts
  20.     that have specials at the beginnings of characters.
  21.     2.  Implements scrollbars and tpic specials under X10.
  22.     3.  Optionally can be compiled under X11 without the toolkit.
  23.     4.  Should now work with color VAXstations.
  24.     5.  Implements a 'k' keystroke, which toggles whether you stay in the same
  25.     position on the page when changing pages.
  26.  
  27. Thanks go to kevin@amath.washington.edu and to tuna@mirch.lcs.mit.edu for
  28. fixes and useful information.
  29.  
  30. --Paul Vojta, vojta@math.berkeley.edu
  31.  
  32. -- cut here --
  33. diff -cr old/Makefile new/Makefile
  34. *** old/Makefile    Mon Aug 28 00:05:41 1989
  35. --- new/Makefile    Sun Aug 27 23:52:43 1989
  36. ***************
  37. *** 39,51 ****
  38.   xdvi.o: xdvi.h patchlevel.h xdvi.icon
  39.   dvi_init.o:xdvi.h dvi.h
  40.   dvi_draw.o:xdvi.h dvi.h
  41. ! tpic.c:    xdvi.h
  42.   
  43.   gf.o:    xdvi.h
  44.   pk.o:    xdvi.h
  45.   pxl.o:    xdvi.h
  46.   
  47. ! xdvi.man:
  48.       sed -e "s;%%FONT_PATH%%;$(FONT_PATH);g" \
  49.           -e "s;%%DEFAULT_FONT_PATH%%;$(DEFAULT_FONT_PATH);g" \
  50.           < xdvi.man.sed \
  51. --- 39,51 ----
  52.   xdvi.o: xdvi.h patchlevel.h xdvi.icon
  53.   dvi_init.o:xdvi.h dvi.h
  54.   dvi_draw.o:xdvi.h dvi.h
  55. ! tpic.o:    xdvi.h
  56.   
  57.   gf.o:    xdvi.h
  58.   pk.o:    xdvi.h
  59.   pxl.o:    xdvi.h
  60.   
  61. ! xdvi.man: xdvi.man.sed
  62.       sed -e "s;%%FONT_PATH%%;$(FONT_PATH);g" \
  63.           -e "s;%%DEFAULT_FONT_PATH%%;$(DEFAULT_FONT_PATH);g" \
  64.           < xdvi.man.sed \
  65. diff -cr old/Makefile_10 new/Makefile_10
  66. *** old/Makefile_10    Mon Aug 28 00:05:42 1989
  67. --- new/Makefile_10    Sun Aug 27 23:49:34 1989
  68. ***************
  69. *** 15,24 ****
  70.   BINDIR=/usr/sipb/$$(MACHTYPE)bin
  71.   INCLUDES=-I/usr/include/X
  72.   CFLAGS=-O $(DEFINES)
  73. ! LIBS=-lX
  74. ! SRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c \
  75.     xdvi.h dvi.h xdvi_curs.h xdvi_mask.h
  76. ! OBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o
  77.   CC=/tuna_a/gnu/bin/gcc
  78.   RM=rm -f
  79.   
  80. --- 15,24 ----
  81.   BINDIR=/usr/sipb/$$(MACHTYPE)bin
  82.   INCLUDES=-I/usr/include/X
  83.   CFLAGS=-O $(DEFINES)
  84. ! LIBS=-lX -lm
  85. ! SRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c tpic.c \
  86.     xdvi.h dvi.h xdvi_curs.h xdvi_mask.h
  87. ! OBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o tpic.o
  88.   CC=/tuna_a/gnu/bin/gcc
  89.   RM=rm -f
  90.   
  91. ***************
  92. *** 32,37 ****
  93. --- 32,38 ----
  94.   xdvi.o: xdvi.h patchlevel.h xdvi_curs.h xdvi_mask.h
  95.   dvi_init.o:xdvi.h dvi.h
  96.   dvi_draw.o:xdvi.h dvi.h
  97. + tpic.o:    xdvi.h
  98.   
  99.   gf.o:    xdvi.h
  100.   pk.o:    xdvi.h
  101. ***************
  102. *** 50,53 ****
  103.       $(RM) *.o *.BAK *.CKP xdvi.man xdvi a.out core errs *~
  104.   
  105.   lint:
  106. !     lint $(DEFINES) xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c
  107. --- 51,55 ----
  108.       $(RM) *.o *.BAK *.CKP xdvi.man xdvi a.out core errs *~
  109.   
  110.   lint:
  111. !     lint $(DEFINES) xdvi.c dvi_init.c dvi_draw.c \
  112. !         $(FONTFORMATS_C) pxl_open.c tpic.c
  113. diff -cr old/README new/README
  114. *** old/README    Mon Aug 28 00:05:44 1989
  115. --- new/README    Mon Aug 28 00:07:21 1989
  116. ***************
  117. *** 35,43 ****
  118.       You can also change the `make' variables FONTFORMATS_C and FONTFORMATS_O
  119.       to reflect which font formats are actually used at your site.
  120.   
  121. - Apparently this program does not work on color VAXstations; it is my
  122. - understanding that this is caused by a server bug.
  123.   Other compilation flags are:
  124.       FONT_PATH    (xdvi.c)  Name of the environment variable to use when
  125.               searching for the font path
  126. --- 35,40 ----
  127. ***************
  128. *** 64,69 ****
  129. --- 61,67 ----
  130.       ALTFONT        Default font to use if the font named in the dvi file
  131.               cannot be found.  Can be set to NULL.  By default, it
  132.               is "cmr10".
  133. +     NOTOOL        (X11 only; xdvi.c)  Compile using raw X calls.
  134.   
  135.   All flags should be set in the appropriate Makefile.
  136.   ================================================================
  137. ***************
  138. *** 126,131 ****
  139. --- 124,137 ----
  140.   --  Patchlevel 4:  --
  141.      14.  Removed MAXCHARS compilation option.  It's automatic now.  Made X10
  142.       scrolling smoother.  Implemented the moving magnifying glass.
  143. + --  Patchlevel 5:  --
  144. +    15.  Implemented compilation without the toolkit, as well as scrollbars
  145. +     and tpic support in X10.  Also this version should work with color
  146. +     VAXstations, although overstrike characters will come out incorrectly.
  147. +    16.  Fixed a bug in gf reading routines:  specials at the beginning of
  148. +     a character def. were not being processed.  Thanks to
  149. +     kevin@amath.washington.edu for a bug report and fix.
  150. +    17.  Added 'k' keystroke.
  151.   
  152.   Paul Vojta, vojta@math.berkeley.edu
  153.   ================================================================================
  154. diff -cr old/dvi_draw.c new/dvi_draw.c
  155. *** old/dvi_draw.c    Mon Aug 28 00:05:50 1989
  156. --- new/dvi_draw.c    Thu Aug 24 12:25:22 1989
  157. ***************
  158. *** 16,21 ****
  159. --- 16,22 ----
  160.    *    Compilation options:
  161.    *    SYSV    compile for System V
  162.    *    X10    compile for X10
  163. +  *    NOTOOL    compile without toolkit (X11 only)
  164.    *    MSBITFIRST    store bitmaps internally in with significant bit first
  165.    *    BMSHORT    store bitmaps in shorts instead of bytes
  166.    *    BMLONG    store bitmaps in longs instead of bytes
  167. diff -cr old/dvi_init.c new/dvi_init.c
  168. *** old/dvi_init.c    Mon Aug 28 00:05:53 1989
  169. --- new/dvi_init.c    Thu Aug 24 12:25:30 1989
  170. ***************
  171. *** 16,21 ****
  172. --- 16,22 ----
  173.    *    Compilation options:
  174.    *    SYSV    compile for System V
  175.    *    X10    compile for X10
  176. +  *    NOTOOL    compile without toolkit (X11 only)
  177.    *    MSBITFIRST    store bitmaps internally in with significant bit first
  178.    *    BMSHORT    store bitmaps in shorts instead of bytes
  179.    *    BMLONG    store bitmaps in longs instead of bytes
  180. ***************
  181. *** 66,72 ****
  182.    */
  183.   static    long    last_page_offset;
  184.   
  185. ! #ifndef SYSV
  186.   char    *sprintf();
  187.   #endif
  188.   char    *malloc(), *strcpy();
  189. --- 67,73 ----
  190.    */
  191.   static    long    last_page_offset;
  192.   
  193. ! #ifndef    ANSI_LIB
  194.   char    *sprintf();
  195.   #endif
  196.   char    *malloc(), *strcpy();
  197. diff -cr old/gf.c new/gf.c
  198. *** old/gf.c    Mon Aug 28 00:05:55 1989
  199. --- new/gf.c    Mon Aug 21 16:26:26 1989
  200. ***************
  201. *** 168,195 ****
  202.       if(debug & DBG_PK)
  203.           Printf("Loading gf char %d", ch);
  204.   
  205. !     switch (cmnd = one(GF_file)) {
  206. !         case BOC:
  207. !         (void) four(GF_file);        /* skip character code */
  208. !         (void) four(GF_file);        /* skip pointer to prev char */
  209. !         min_m = sfour(GF_file);
  210. !         max_m = sfour(GF_file);
  211. !         g->x = -min_m;
  212. !         min_n = sfour(GF_file);
  213. !         g->y = max_n = sfour(GF_file);
  214. !         g->bitmap.w = max_m - min_m + 1;
  215. !         g->bitmap.h = max_n - min_n + 1;
  216. !         break;
  217. !         case BOC1:
  218. !         (void) one(GF_file);        /* skip character code */
  219. !         g->bitmap.w = one(GF_file);    /* max_m - min_m */
  220. !         g->x = g->bitmap.w - one(GF_file);    /* ditto - max_m */
  221. !         ++g->bitmap.w;
  222. !         g->bitmap.h = one(GF_file) + 1;
  223. !         g->y = one(GF_file);
  224. !         break;
  225. !         default:
  226. !         oops("Bad BOC code:  %d", cmnd);
  227.       }
  228.       paint_switch = White;
  229.   
  230. --- 168,207 ----
  231.       if(debug & DBG_PK)
  232.           Printf("Loading gf char %d", ch);
  233.   
  234. !     for (;;) {
  235. !         switch (cmnd = one(GF_file)) {
  236. !         case XXX1:
  237. !         case XXX2:
  238. !         case XXX3:
  239. !         case XXX4:
  240. !             Fseek(GF_file, (long) num(GF_file, cmnd - XXX1 + 1), 1);
  241. !             continue;
  242. !         case YYY:
  243. !             (void) four(GF_file);
  244. !             continue;
  245. !         case BOC:
  246. !             (void) four(GF_file);    /* skip character code */
  247. !             (void) four(GF_file);    /* skip pointer to prev char */
  248. !             min_m = sfour(GF_file);
  249. !             max_m = sfour(GF_file);
  250. !             g->x = -min_m;
  251. !             min_n = sfour(GF_file);
  252. !             g->y = max_n = sfour(GF_file);
  253. !             g->bitmap.w = max_m - min_m + 1;
  254. !             g->bitmap.h = max_n - min_n + 1;
  255. !             break;
  256. !         case BOC1:
  257. !             (void) one(GF_file);    /* skip character code */
  258. !             g->bitmap.w = one(GF_file);    /* max_m - min_m */
  259. !             g->x = g->bitmap.w - one(GF_file);    /* ditto - max_m */
  260. !             ++g->bitmap.w;
  261. !             g->bitmap.h = one(GF_file) + 1;
  262. !             g->y = one(GF_file);
  263. !             break;
  264. !         default:
  265. !             oops("Bad BOC code:  %d", cmnd);
  266. !         }
  267. !         break;
  268.       }
  269.       paint_switch = White;
  270.   
  271. ***************
  272. *** 204,210 ****
  273.    */
  274.       bytes_wide = ROUNDUP(g->bitmap.w, BITS_PER_BMUNIT) * BYTES_PER_BMUNIT;
  275.       maxp = ADD(basep, g->bitmap.h * bytes_wide);
  276. !         bzero(g->bitmap.bits, g->bitmap.h * bytes_wide);
  277.       new_row = False;
  278.       word_weight = BITS_PER_BMUNIT;
  279.       for (;;) {
  280. --- 216,222 ----
  281.    */
  282.       bytes_wide = ROUNDUP(g->bitmap.w, BITS_PER_BMUNIT) * BYTES_PER_BMUNIT;
  283.       maxp = ADD(basep, g->bitmap.h * bytes_wide);
  284. !     bzero(g->bitmap.bits, g->bitmap.h * bytes_wide);
  285.       new_row = False;
  286.       word_weight = BITS_PER_BMUNIT;
  287.       for (;;) {
  288. diff -cr old/patchlevel.h new/patchlevel.h
  289. *** old/patchlevel.h    Mon Aug 28 00:05:56 1989
  290. --- new/patchlevel.h    Sun Aug 27 23:35:18 1989
  291. ***************
  292. *** 1 ****
  293. ! #define PATCHLEVEL 4
  294. --- 1 ----
  295. ! #define PATCHLEVEL 5
  296. diff -cr old/pxl_open.c new/pxl_open.c
  297. *** old/pxl_open.c    Mon Aug 28 00:06:01 1989
  298. --- new/pxl_open.c    Tue Aug 22 13:29:33 1989
  299. ***************
  300. *** 43,49 ****
  301.   
  302.   read_font_index_proc read_GF_index, read_PK_index, read_PXL_index;
  303.   
  304. ! #ifndef SYSV
  305.   char    *sprintf();
  306.   #endif
  307.   char    *malloc(), *index();
  308. --- 43,49 ----
  309.   
  310.   read_font_index_proc read_GF_index, read_PK_index, read_PXL_index;
  311.   
  312. ! #ifndef    ANSI_LIB
  313.   char    *sprintf();
  314.   #endif
  315.   char    *malloc(), *index();
  316. diff -cr old/xdvi.c new/xdvi.c
  317. *** old/xdvi.c    Mon Aug 28 00:06:10 1989
  318. --- new/xdvi.c    Sat Aug 26 15:54:43 1989
  319. ***************
  320. *** 16,21 ****
  321. --- 16,22 ----
  322.    *    Compilation options:
  323.    *    SYSV    compile for System V
  324.    *    X10    compile for X10
  325. +  *    NOTOOL    compile without toolkit (X11 only)
  326.    *    MSBITFIRST    store bitmaps internally in with significant bit first
  327.    *    BMSHORT    store bitmaps in shorts instead of bytes
  328.    *    BMLONG    store bitmaps in longs instead of bytes
  329. ***************
  330. *** 35,45 ****
  331.   #define    ALTFONT    "cmr10"
  332.   #endif    ALTFONT
  333.   
  334. ! #ifndef X10
  335.   
  336.   #undef Boolean
  337.   #include <X11/Xlib.h>
  338.   #include <X11/Xutil.h>
  339.   #include <X11/Intrinsic.h>
  340.   #ifdef OLD_X11_TOOLKIT
  341.   #include <X11/Atoms.h>
  342. --- 36,58 ----
  343.   #define    ALTFONT    "cmr10"
  344.   #endif    ALTFONT
  345.   
  346. ! #if    !defined(X10) && !defined(NOTOOL)
  347. ! #define    TOOLKIT
  348. ! #else
  349. ! #undef    TOOLKIT
  350. ! #endif
  351.   
  352. + #ifndef X10
  353.   #undef Boolean
  354.   #include <X11/Xlib.h>
  355.   #include <X11/Xutil.h>
  356. + #include <X11/cursorfont.h>
  357. + #include "xdvi.icon"
  358. + #else X10
  359. + #include <X/Xlib.h>
  360. + #endif X10
  361. + #ifdef    TOOLKIT
  362.   #include <X11/Intrinsic.h>
  363.   #ifdef OLD_X11_TOOLKIT
  364.   #include <X11/Atoms.h>
  365. ***************
  366. *** 49,62 ****
  367.   #endif not OLD_X11_TOOLKIT
  368.   #include <X11/Shell.h>    /* needed for def. of XtNiconX */
  369.   #include <X11/Viewport.h>
  370. ! #include <X11/cursorfont.h>
  371. ! #include "xdvi.icon"
  372.   #else X10
  373. ! #include <X/Xlib.h>
  374.   #endif X10
  375.   
  376.   #include <stdio.h>
  377.   #include <ctype.h>
  378. --- 62,79 ----
  379.   #endif not OLD_X11_TOOLKIT
  380.   #include <X11/Shell.h>    /* needed for def. of XtNiconX */
  381.   #include <X11/Viewport.h>
  382. ! #else    TOOLKIT
  383. ! #define    XtNumber(arr)    (sizeof(arr)/sizeof(arr[0]))
  384. ! typedef    int        Position;
  385. ! typedef    int        Dimension;
  386. ! #ifndef X10
  387. ! typedef    unsigned int    Pixel;
  388. ! #define    XtPending()    XPending(DISP)
  389.   #else X10
  390. ! #define    XtPending    XPending
  391. ! #define    XMoveResizeWindow XConfigureWindow
  392.   #endif X10
  393. + #endif    TOOLKIT
  394.   
  395.   #include <stdio.h>
  396.   #include <ctype.h>
  397. ***************
  398. *** 72,82 ****
  399.   #define    SetCursor(x)    XDefineCursor(DISP, mane.win, x)
  400.   #define    ClearPage(wr)    XClearWindow(DISP, (wr).win);
  401.   #define    ClearArea(win, x, y, w, h)    XClearArea(DISP, win, x, y, w, h, False)
  402.   #define    CopyArea(win, x, y, w, h, x2, y2) \
  403.               XCopyArea(DISP, win, win, DefaultGCOfScreen(SCRN), \
  404.                   x, y, w, h, x2, y2)
  405.   #define    Flush()        XFlush(DISP)
  406. - static    Boolean    resized    = False;
  407.   #ifndef X11HEIGHT
  408.   #define    X11HEIGHT    8    /* Height of server default font */
  409.   #endif X11HEIGHT
  410. --- 89,100 ----
  411.   #define    SetCursor(x)    XDefineCursor(DISP, mane.win, x)
  412.   #define    ClearPage(wr)    XClearWindow(DISP, (wr).win);
  413.   #define    ClearArea(win, x, y, w, h)    XClearArea(DISP, win, x, y, w, h, False)
  414. + #define    DarkenArea(win, x, y, w, h) \
  415. +             XFillRectangle(DISP, win, ruleGC, x, y, w, h)
  416.   #define    CopyArea(win, x, y, w, h, x2, y2) \
  417.               XCopyArea(DISP, win, win, DefaultGCOfScreen(SCRN), \
  418.                   x, y, w, h, x2, y2)
  419.   #define    Flush()        XFlush(DISP)
  420.   #ifndef X11HEIGHT
  421.   #define    X11HEIGHT    8    /* Height of server default font */
  422.   #endif X11HEIGHT
  423. ***************
  424. *** 83,97 ****
  425.   #else X10
  426.   #define    DPY
  427.   #define    GC        int
  428. - #define    XtNumber(arr)    (sizeof(arr)/sizeof(arr[0]))
  429. - #define    XtPending    XPending
  430. - typedef    int        Position;
  431. - typedef    int        Dimension;
  432.   #define    SetCursor(x)
  433.   #define    ClearPage(wr)    XClear((wr).win);
  434.   #define    ClearArea(win, x, y, w, h)    XPixSet(win, x, y, w, h, backpix)
  435.   #define    CopyArea(win, x, y, w, h, x2, y2) \
  436. !             XCopyArea(win, x, y, x2, y2, w, h, GXcopy);
  437.   #define    XBell(a,b)    XFeep(b/10-1)
  438.   #define    Flush()        XFlush()
  439.   #define    ConnectionNumber(DISP)    (_XlibCurrentDisplay->fd)
  440. --- 101,112 ----
  441.   #else X10
  442.   #define    DPY
  443.   #define    GC        int
  444.   #define    SetCursor(x)
  445.   #define    ClearPage(wr)    XClear((wr).win);
  446.   #define    ClearArea(win, x, y, w, h)    XPixSet(win, x, y, w, h, backpix)
  447. + #define    DarkenArea(win, x, y, w, h)    XPixSet(win, x, y, w, h, foreGC)
  448.   #define    CopyArea(win, x, y, w, h, x2, y2) \
  449. !             XMoveArea(win, x, y, x2, y2, w, h, GXcopy);
  450.   #define    XBell(a,b)    XFeep(b/10-1)
  451.   #define    Flush()        XFlush()
  452.   #define    ConnectionNumber(DISP)    (_XlibCurrentDisplay->fd)
  453. ***************
  454. *** 126,136 ****
  455.   char    *prog;
  456.   char    *curr_page = NULL;
  457.   
  458. ! #ifndef X10
  459.   static    double    specialConv;
  460.           /* fg and bg colors */
  461.   static    Arg    fore_args = {XtNforeground,    (XtArgVal) 0};
  462.   static    Arg    back_args = {XtNbackground,    (XtArgVal) 0};
  463.   static    Pixel    hl_Pixel, cr_Pixel;
  464.   #endif X10
  465.   
  466. --- 141,160 ----
  467.   char    *prog;
  468.   char    *curr_page = NULL;
  469.   
  470. ! int    pageno_correct    = 1;
  471. ! Boolean    keep_flag    = False;
  472.   static    double    specialConv;
  473. + #ifndef X10
  474. + #ifdef    TOOLKIT
  475.           /* fg and bg colors */
  476.   static    Arg    fore_args = {XtNforeground,    (XtArgVal) 0};
  477. + #define    fore_Pixel    fore_args.value
  478.   static    Arg    back_args = {XtNbackground,    (XtArgVal) 0};
  479. + #define    back_Pixel    back_args.value
  480. + #else    TOOLKIT
  481. + static    Pixel    fore_Pixel, back_Pixel;
  482. + #endif    TOOLKIT
  483.   static    Pixel    hl_Pixel, cr_Pixel;
  484.   #endif X10
  485.   
  486. ***************
  487. *** 150,164 ****
  488.   static    int    screen_w, screen_h;
  489.   #define    clip_w    mane.width
  490.   #define    clip_h    mane.height
  491. - #ifndef X10
  492.   static    Dimension    window_w, window_h;
  493.   static    Position    main_x, main_y;
  494.   #else X10
  495. - #define    window_w clip_w
  496. - #define    window_h clip_h
  497.   #define    main_x    0
  498.   #define    main_y    0
  499.   #endif X10
  500.   static    Position mag_x, mag_y, new_mag_x, new_mag_y;
  501.   static    Boolean    mag_moved = False;
  502.   static    int    home_x, home_y;
  503. --- 174,195 ----
  504.   static    int    screen_w, screen_h;
  505.   #define    clip_w    mane.width
  506.   #define    clip_h    mane.height
  507.   static    Dimension    window_w, window_h;
  508. + #ifndef X10
  509.   static    Position    main_x, main_y;
  510. + static    XImage    *image;
  511.   #else X10
  512.   #define    main_x    0
  513.   #define    main_y    0
  514. + static    int    GXfunc;
  515. + static    int    backpix, backmap, bdrmap;
  516. + /*
  517. +  * Cursor and mask for valid cursor
  518. +  */
  519. + #include "xdvi_curs.h"
  520. + #include "xdvi_mask.h"
  521.   #endif X10
  522.   static    Position mag_x, mag_y, new_mag_x, new_mag_y;
  523.   static    Boolean    mag_moved = False;
  524.   static    int    home_x, home_y;
  525. ***************
  526. *** 169,174 ****
  527. --- 200,246 ----
  528.   /*    curr is temporary storage except for within redraw() */
  529.   struct WindowRec curr    = {NULL, 3, 0, 0, 0, 0, MAXDIM, 0, MAXDIM, 0};
  530.   
  531. + #ifdef    TOOLKIT
  532. + static    Widget    top_level, vport_widget, draw_widget, clip_widget;
  533. + static    Widget    x_bar, y_bar;    /* horizontal and vertical scroll bars */
  534. + static    Arg    vport_args[] = {
  535. +     {XtNallowHoriz,    (XtArgVal) True},
  536. +     {XtNallowVert,    (XtArgVal) True},
  537. + };
  538. + /*    Note:  Argument order in the following is important! */
  539. + static    Arg    draw_args[] = {
  540. +     {XtNwidth,    (XtArgVal) 0},
  541. +     {XtNheight,    (XtArgVal) 0},
  542. +     {XtNx,        (XtArgVal) 0},
  543. +     {XtNy,        (XtArgVal) 0},
  544. +     {XtNlabel,    (XtArgVal) ""},
  545. + };
  546. + static    void    set_draw_args();
  547. + #else    TOOLKIT
  548. + #define    BAR_WID        12    /* width of darkened area */
  549. + #define    BAR_THICK    15    /* gross amount removed */
  550. + static    Window    top_level;
  551. + static    Window    x_bar, y_bar;
  552. + static    int    x_bgn, x_end, y_bgn, y_end;    /* scrollbar positions */
  553. + #endif    TOOLKIT
  554. + #ifdef lint
  555. + #ifndef X10
  556. + char    xdvi_bits[288];
  557. + #ifdef    TOOLKIT
  558. + WidgetClass    viewportWidgetClass, widgetClass;
  559. + #endif    TOOLKIT
  560. + #else X10
  561. + short    xdvi_bits[15], xdvi_mask_bits[15];
  562. + Display    *_XlibCurrentDisplay;
  563. + #endif X10
  564. + #endif lint
  565.   /*
  566.    *    Mechanism to keep track of the magnifier window.  The problems are,
  567.    *    (a) if the button is released while the window is being drawn, this
  568. ***************
  569. *** 182,189 ****
  570.                   /* -1 = destroy upon expose */
  571.   static    Boolean    alt_canit;    /* stop drawing this window */
  572.   
  573. - int    pageno_correct    = 1;
  574.   /*
  575.    *    Data for buffered events.
  576.    */
  577. --- 254,259 ----
  578. ***************
  579. *** 198,204 ****
  580.   
  581.   static    void    can_exposures(), read_events();
  582.   
  583. ! #ifndef SYSV
  584.   char    *sprintf();
  585.   #endif
  586.   char    *malloc(), *index(), *rindex(), *getenv(), *strcpy(), *strcat();
  587. --- 268,274 ----
  588.   
  589.   static    void    can_exposures(), read_events();
  590.   
  591. ! #ifndef    ANSI_LIB
  592.   char    *sprintf();
  593.   #endif
  594.   char    *malloc(), *index(), *rindex(), *getenv(), *strcpy(), *strcat();
  595. ***************
  596. *** 205,211 ****
  597.   
  598.   double    atof();
  599.   
  600. ! #ifndef X10
  601.   /* Things we need from spec_draw, unfortunately */
  602.   
  603.   /* (ignored for now)
  604. --- 275,284 ----
  605.   
  606.   double    atof();
  607.   
  608. ! /********************************
  609. !  *      tpic routines        *
  610. !  *******************************/
  611.   /* Things we need from spec_draw, unfortunately */
  612.   
  613.   /* (ignored for now)
  614. ***************
  615. *** 231,239 ****
  616. --- 304,319 ----
  617.   
  618.       if ((fcx < max_x || tcx < max_x) && (fcx >= min_x || tcx >= min_x) &&
  619.           (fcy < max_y || tcy < max_y) && (fcy >= min_y || tcy >= min_y))
  620. + #ifndef X10
  621.           XDrawLine(DISP, curr.win, ruleGC,
  622.               fcx - curr.base_x, fcy - curr.base_y,
  623.               tcx - curr.base_x, tcy - curr.base_y);
  624. + #else X10
  625. +         XLine(curr.win,
  626. +             fcx - curr.base_x, fcy - curr.base_y,
  627. +             tcx - curr.base_x, tcy - curr.base_y,
  628. +             1, 1, ruleGC, GXcopy, AllPlanes);
  629. + #endif X10
  630.   }
  631.   
  632.   /*
  633. ***************
  634. *** 246,253 ****
  635. --- 326,338 ----
  636.               cy = yconv(y);
  637.   
  638.       if (cx < max_x && cx >= min_x && cy < max_y && cy >= min_y)
  639. + #ifndef X10
  640.           XDrawPoint(DISP, curr.win, ruleGC,
  641.           cx - curr.base_x, cy - curr.base_y);
  642. + #else X10
  643. +         XPixSet((Window) curr.win, cx - curr.base_x, cy - curr.base_y,
  644. +         1, 1, ruleGC);
  645. + #endif X10
  646.   }
  647.   
  648.   /*
  649. ***************
  650. *** 261,320 ****
  651.   int last_min_x, last_max_x, last_min_y, last_max_y;
  652.   {
  653.   }
  654. - #else X10
  655. - /*
  656. -  *    Specials are not implemented in X10.
  657. -  */
  658.   
  659. - void
  660. - applicationDoSpecial(cmd)
  661. - char    *cmd;
  662. - {
  663. -     if (spec_warn) Fprintf(stderr, "special ``%s'' not implemented\n", cmd);
  664. - }
  665. - #endif X10
  666. - #ifndef X10
  667. - static    Widget    top_level, vport_widget, draw_widget, clip_widget;
  668. - static    Widget    x_bar, y_bar;    /* horizontal and vertical scroll bars */
  669. - static    XImage    *image;
  670. - static    Arg    vport_args[] = {
  671. -     {XtNallowHoriz,    (XtArgVal) True},
  672. -     {XtNallowVert,    (XtArgVal) True},
  673. - };
  674. - /*    Note:  Argument order in the following is important! */
  675. - static    Arg    draw_args[] = {
  676. -     {XtNwidth,    (XtArgVal) 0},
  677. -     {XtNheight,    (XtArgVal) 0},
  678. -     {XtNx,        (XtArgVal) 0},
  679. -     {XtNy,        (XtArgVal) 0},
  680. -     {XtNlabel,    (XtArgVal) ""},
  681. - };
  682. - static    void    set_draw_args();
  683. - #else X10
  684. - static    int    GXfunc;
  685. - static    int    backpix, backmap, bdrmap;
  686. - /*
  687. -  * Cursor and mask for valid cursor
  688. -  */
  689. - #include "xdvi_curs.h"
  690. - #include "xdvi_mask.h"
  691. - #endif X10
  692. - #ifdef lint
  693. - #ifndef X10
  694. - WidgetClass    viewportWidgetClass, widgetClass;
  695. - char    xdvi_bits[288];
  696. - #else X10
  697. - short    xdvi_bits[15], xdvi_mask_bits[15];
  698. - Display    *_XlibCurrentDisplay;
  699. - #endif X10
  700. - #endif lint
  701.   /**
  702.    **    Put a rectangle on the screen.  hl determines the GC.
  703.    **/
  704. --- 346,352 ----
  705. ***************
  706. *** 326,335 ****
  707.       if (x < max_x && x + w >= min_x && y < max_y && y + h >= min_y) {
  708.           if (--event_counter == 0) read_events(False);
  709.   #ifndef X10
  710. !         XFillRectangle(DISP, curr.win, hl ? highGC : ruleGC,
  711.                      x - curr.base_x, y - curr.base_y, w?w:1, h?h:1);
  712.   #else X10
  713. !         XPixSet(curr.win, x - curr.base_x, y - curr.base_y,
  714.               w?w:1, h?h:1, hl ? highGC : ruleGC);
  715.   #endif X10
  716.       }
  717. --- 358,367 ----
  718.       if (x < max_x && x + w >= min_x && y < max_y && y + h >= min_y) {
  719.           if (--event_counter == 0) read_events(False);
  720.   #ifndef X10
  721. !         XFillRectangle(DISP, (Window) curr.win, hl ? highGC : ruleGC,
  722.                      x - curr.base_x, y - curr.base_y, w?w:1, h?h:1);
  723.   #else X10
  724. !         XPixSet((Window) curr.win, x - curr.base_x, y - curr.base_y,
  725.               w?w:1, h?h:1, hl ? highGC : ruleGC);
  726.   #endif X10
  727.       }
  728. ***************
  729. *** 348,354 ****
  730.   #ifndef X10
  731.           image->width = bitmap->w;
  732.           image->height = bitmap->h;
  733. !         image->data = (char *)bitmap->bits;
  734.           image->bytes_per_line = bitmap->bytes_wide;
  735.           XPutImage(DISP, curr.win, foreGC, image,
  736.               0, 0,
  737. --- 380,386 ----
  738.   #ifndef X10
  739.           image->width = bitmap->w;
  740.           image->height = bitmap->h;
  741. !         image->data = bitmap->bits;
  742.           image->bytes_per_line = bitmap->bytes_wide;
  743.           XPutImage(DISP, curr.win, foreGC, image,
  744.               0, 0,
  745. ***************
  746. *** 361,367 ****
  747.               bitmap->w, bitmap->h);
  748.   #else X10
  749.           XBitmapBitsPut(curr.win, x - curr.base_x, y - curr.base_y,
  750. !             bitmap->w, bitmap->h, (char *) bitmap->bits,
  751.               foreGC, backpix, NULL, GXfunc, AllPlanes);
  752.   #endif X10
  753.       }
  754. --- 393,399 ----
  755.               bitmap->w, bitmap->h);
  756.   #else X10
  757.           XBitmapBitsPut(curr.win, x - curr.base_x, y - curr.base_y,
  758. !             bitmap->w, bitmap->h, bitmap->bits,
  759.               foreGC, backpix, NULL, GXfunc, AllPlanes);
  760.   #endif X10
  761.       }
  762. ***************
  763. *** 398,404 ****
  764.       struct WindowRec *windowrec;
  765.       int    x, y, w, h;
  766.   {
  767. !     ClearArea(windowrec->win, x, y, w, h);
  768.       expose(windowrec, x, y, w, h);
  769.   }
  770.   
  771. --- 430,436 ----
  772.       struct WindowRec *windowrec;
  773.       int    x, y, w, h;
  774.   {
  775. !     ClearArea((Window) windowrec->win, x, y, w, h);
  776.       expose(windowrec, x, y, w, h);
  777.   }
  778.   
  779. ***************
  780. *** 456,462 ****
  781.       }
  782.   }
  783.   
  784. ! #ifndef X10
  785.   /*
  786.    *    routines for X11 toolkit
  787.    */
  788. --- 488,494 ----
  789.       }
  790.   }
  791.   
  792. ! #ifdef    TOOLKIT
  793.   /*
  794.    *    routines for X11 toolkit
  795.    */
  796. ***************
  797. *** 466,478 ****
  798.       {XtNheight,    (XtArgVal) &window_h},
  799.   };
  800.   
  801. - static    Arg    arg_wh_clip[] = {
  802. -     {XtNwidth,    (XtArgVal) &clip_w},
  803. -     {XtNheight,    (XtArgVal) &clip_h},
  804. - };
  805.   static    Position    window_x, window_y;
  806. ! static    Arg        arg_xy[] = {
  807.       {XtNx,        (XtArgVal) &window_x},
  808.       {XtNy,        (XtArgVal) &window_y},
  809.   };
  810. --- 498,505 ----
  811.       {XtNheight,    (XtArgVal) &window_h},
  812.   };
  813.   
  814.   static    Position    window_x, window_y;
  815. ! static    Arg    arg_xy[] = {
  816.       {XtNx,        (XtArgVal) &window_x},
  817.       {XtNy,        (XtArgVal) &window_y},
  818.   };
  819. ***************
  820. *** 509,523 ****
  821.       }
  822.   }
  823.   
  824.   static
  825.   get_geom()
  826.   {
  827. !     register Dimension old_clip_w = clip_w;
  828.   
  829.       XtGetValues(vport_widget, arg_wh, 2);
  830.       XtGetValues(clip_widget, arg_wh_clip, 2);
  831.       x_bar = XtNameToWidget(vport_widget, "horizontal");
  832.       y_bar = XtNameToWidget(vport_widget, "vertical");
  833.       if (old_clip_w == 0) home(False);
  834.       resized = False;
  835.   }
  836. --- 536,562 ----
  837.       }
  838.   }
  839.   
  840. + static    Boolean    resized    = False;
  841.   static
  842.   get_geom()
  843.   {
  844. !     static    Dimension    new_clip_w, new_clip_h;
  845. !     static    Arg    arg_wh_clip[] = {
  846. !         {XtNwidth,    (XtArgVal) &new_clip_w},
  847. !         {XtNheight,    (XtArgVal) &new_clip_h},
  848. !     };
  849. !     register int    old_clip_w;
  850.   
  851.       XtGetValues(vport_widget, arg_wh, 2);
  852.       XtGetValues(clip_widget, arg_wh_clip, 2);
  853.       x_bar = XtNameToWidget(vport_widget, "horizontal");
  854.       y_bar = XtNameToWidget(vport_widget, "vertical");
  855. +     old_clip_w = clip_w;
  856. +             /* we need to do this because */
  857. +             /* sizeof(Dimension) != sizeof(int) */
  858. +     clip_w = new_clip_w;
  859. +     clip_h = new_clip_h;
  860.       if (old_clip_w == 0) home(False);
  861.       resized = False;
  862.   }
  863. ***************
  864. *** 559,565 ****
  865. --- 598,771 ----
  866.       resized = True;
  867.   }
  868.   
  869. + #else    TOOLKIT
  870. + /*
  871. +  *    brute force scrollbar routines
  872. +  */
  873. + static    void
  874. + paint_x_bar()
  875. + {
  876. +     register int    new_x_bgn = mane.base_x * clip_w / page_w;
  877. +     register int    new_x_end = (mane.base_x + clip_w) * clip_w / page_w;
  878. +     if (new_x_bgn >= x_end || x_bgn >= new_x_end) {    /* no overlap */
  879. +         ClearArea(x_bar, x_bgn, 1, x_end - x_bgn, BAR_WID);
  880. +         DarkenArea(x_bar, new_x_bgn, 1, new_x_end - new_x_bgn, BAR_WID);
  881. +     }
  882. +     else {        /* this stuff avoids flicker */
  883. +         if (x_bgn <= new_x_bgn)
  884. +         ClearArea(x_bar, x_bgn, 1, new_x_bgn - x_bgn, BAR_WID);
  885. +         else
  886. +         DarkenArea(x_bar, new_x_bgn, 1, x_bgn - new_x_bgn, BAR_WID);
  887. +         if (new_x_end <= x_end)
  888. +         ClearArea(x_bar, new_x_end, 1, x_end - new_x_end, BAR_WID);
  889. +         else
  890. +         DarkenArea(x_bar, x_end, 1, new_x_end - x_end, BAR_WID);
  891. +     }
  892. +     x_bgn = new_x_bgn;
  893. +     x_end = new_x_end;
  894. + }
  895. + static    void
  896. + paint_y_bar()
  897. + {
  898. +     register int    new_y_bgn = mane.base_y * clip_h / page_h;
  899. +     register int    new_y_end = (mane.base_y + clip_h) * clip_h / page_h;
  900. +     if (new_y_bgn >= y_end || y_bgn >= new_y_end) {    /* no overlap */
  901. +         ClearArea(y_bar, 1, y_bgn, BAR_WID, y_end - y_bgn);
  902. +         DarkenArea(y_bar, 1, new_y_bgn, BAR_WID, new_y_end - new_y_bgn);
  903. +     }
  904. +     else {        /* this stuff avoids flicker */
  905. +         if (y_bgn <= new_y_bgn)
  906. +         ClearArea(y_bar, 1, y_bgn, BAR_WID, new_y_bgn - y_bgn);
  907. +         else
  908. +         DarkenArea(y_bar, 1, new_y_bgn, BAR_WID, y_bgn - new_y_bgn);
  909. +         if (new_y_end <= y_end)
  910. +         ClearArea(y_bar, 1, new_y_end, BAR_WID, y_end - new_y_end);
  911. +         else
  912. +         DarkenArea(y_bar, 1, y_end, BAR_WID, new_y_end - y_end);
  913. +     }
  914. +     y_bgn = new_y_bgn;
  915. +     y_end = new_y_end;
  916. + }
  917. + static    void
  918. + scrollmane(x, y)
  919. +     int    x, y;
  920. + {
  921. +     register int    old_base_x = mane.base_x;
  922. +     register int    old_base_y = mane.base_y;
  923. +     if (x > page_w - clip_w) x = page_w - clip_w;
  924. +     if (x < 0) x = 0;
  925. +     if (y > page_h - clip_h) y = page_h - clip_h;
  926. +     if (y < 0) y = 0;
  927. +     scrollwindow(&mane, x, y);
  928. +     if (old_base_x != mane.base_x && x_bar) paint_x_bar();
  929. +     if (old_base_y != mane.base_y && y_bar) paint_y_bar();
  930. + }
  931. + static    void
  932. + reconfig()
  933. + {
  934. +     int    x_thick = 0;
  935. +     int    y_thick = 0;
  936. +         /* determine existence of scrollbars */
  937. +     if (window_w < page_w) x_thick = BAR_THICK;
  938. +     if (window_h - x_thick < page_h) y_thick = BAR_THICK;
  939. +     clip_w = window_w - y_thick;
  940. +     if (clip_w < page_w) x_thick = BAR_THICK;
  941. +     clip_h = window_h - x_thick;
  942. +         /* process drawing (clip) window */
  943. +     if (mane.win == NULL) {    /* initial creation */
  944. + #ifndef X10
  945. +         mane.win = (void *) XCreateSimpleWindow(DISP, top_level,
  946. +             y_thick, x_thick, clip_w, clip_h, 0,
  947. +             fore_Pixel, back_Pixel);
  948. +         XSelectInput(DPY (Window) mane.win, ExposureMask |
  949. +             ButtonPressMask | ButtonMotionMask | ButtonReleaseMask);
  950.   #else X10
  951. +         mane.win = (void *) XCreateWindow(top_level,
  952. +             y_thick, x_thick, clip_w, clip_h, 0,
  953. +             bdrmap, backmap);
  954. +         XSelectInput((Window) mane.win,  ExposeRegion | ExposeCopy |
  955. +             ButtonPressed | ButtonReleased |
  956. +             LeftDownMotion | MiddleDownMotion | RightDownMotion);
  957. + #endif X10
  958. +         XMapWindow(DPY (Window) mane.win);
  959. +     }
  960. +     else
  961. +         XMoveResizeWindow(DPY (Window) mane.win,
  962. +         y_thick, x_thick, clip_w, clip_h);
  963. +         /* process scroll bars */
  964. +     if (x_thick) {
  965. +         if (x_bar) {
  966. +         XMoveResizeWindow(DPY x_bar,
  967. +             y_thick - 1, -1, clip_w, BAR_THICK - 1);
  968. +         paint_x_bar();
  969. +         }
  970. +         else {
  971. + #ifndef X10
  972. +         x_bar = XCreateSimpleWindow(DISP, top_level,
  973. +                 y_thick - 1, -1, clip_w, BAR_THICK - 1, 1,
  974. +                 fore_Pixel, back_Pixel);
  975. +         XSelectInput(DISP, x_bar,
  976. +             ExposureMask | ButtonPressMask | Button2MotionMask);
  977. + #else X10
  978. +         x_bar = XCreateWindow(top_level,
  979. +                 y_thick - 1, -1, clip_w, BAR_THICK - 1, 1,
  980. +                 bdrmap, backmap);
  981. +         XSelectInput(x_bar,
  982. +             ExposeRegion | ButtonPressed | MiddleDownMotion);
  983. + #endif X10
  984. +         XMapWindow(DPY x_bar);
  985. +         }
  986. +         x_bgn = mane.base_x * clip_w / page_w;
  987. +         x_end = (mane.base_x + clip_w) * clip_w / page_w;
  988. +     }
  989. +     else
  990. +         if (x_bar) {
  991. +         XDestroyWindow(DPY x_bar);
  992. +         x_bar = NULL;
  993. +         }
  994. +     if (y_thick) {
  995. +         if (y_bar) {
  996. +         XMoveResizeWindow(DPY y_bar,
  997. +             -1, x_thick - 1, BAR_THICK - 1, clip_h);
  998. +         paint_y_bar();
  999. +         }
  1000. +         else {
  1001. + #ifndef X10
  1002. +         y_bar = XCreateSimpleWindow(DISP, top_level,
  1003. +                 -1, x_thick - 1, BAR_THICK - 1, clip_h, 1,
  1004. +                 fore_Pixel, back_Pixel);
  1005. +         XSelectInput(DISP, y_bar,
  1006. +             ExposureMask | ButtonPressMask | Button2MotionMask);
  1007. + #else X10
  1008. +         y_bar = XCreateWindow(top_level,
  1009. +                 -1, x_thick - 1, BAR_THICK - 1, clip_h, 1,
  1010. +                 bdrmap, backmap);
  1011. +         XSelectInput(y_bar,
  1012. +             ExposeRegion | ButtonPressed | MiddleDownMotion);
  1013. + #endif X10
  1014. +         XMapWindow(DPY y_bar);
  1015. +         }
  1016. +         y_bgn = mane.base_y * clip_h / page_h;
  1017. +         y_end = (mane.base_y + clip_h) * clip_h / page_h;
  1018. +     }
  1019. +     else
  1020. +         if (y_bar) {
  1021. +         XDestroyWindow(DPY y_bar);
  1022. +         y_bar = NULL;
  1023. +         }
  1024. + }
  1025.   static    void
  1026.   home(scrl)
  1027.       Boolean    scrl;
  1028. ***************
  1029. *** 577,583 ****
  1030.           y = home_y / mane.shrinkfactor;
  1031.       }
  1032.       if (scrl)
  1033. !         scrollwindow(&mane, x, y);
  1034.       else {
  1035.           mane.base_x = x;
  1036.           mane.base_y = y;
  1037. --- 783,789 ----
  1038.           y = home_y / mane.shrinkfactor;
  1039.       }
  1040.       if (scrl)
  1041. !         scrollmane(x, y);
  1042.       else {
  1043.           mane.base_x = x;
  1044.           mane.base_y = y;
  1045. ***************
  1046. *** 585,590 ****
  1047. --- 791,798 ----
  1048.           curr.base_x = x;
  1049.           curr.base_y = y;
  1050.           }
  1051. +         if (x_bar) paint_x_bar();
  1052. +         if (y_bar) paint_y_bar();
  1053.       }
  1054.   }
  1055.   
  1056. ***************
  1057. *** 593,599 ****
  1058.   #define    window_y 0
  1059.   #define    mane_base_x    mane.base_x
  1060.   #define    mane_base_y    mane.base_y
  1061. ! #endif X10
  1062.   
  1063.   static    void
  1064.   compute_mag_pos(xp, yp)
  1065. --- 801,807 ----
  1066.   #define    window_y 0
  1067.   #define    mane_base_x    mane.base_x
  1068.   #define    mane_base_y    mane.base_y
  1069. ! #endif    TOOLKIT
  1070.   
  1071.   static    void
  1072.   compute_mag_pos(xp, yp)
  1073. ***************
  1074. *** 623,640 ****
  1075.       *yp = t;
  1076.   }
  1077.   
  1078. ! #ifndef X10
  1079.       /*ARGSUSED*/
  1080.   static    void
  1081.   handle_button(widget, junk, event)
  1082.       Widget    widget;
  1083.       caddr_t    junk;
  1084. !     XButtonEvent *event;
  1085. ! #else X10
  1086.   static    void
  1087.   handle_button(event)
  1088. !     XButtonPressedEvent *event;
  1089. ! #endif X10
  1090.   {
  1091.       int x, y;
  1092.   #ifndef X10
  1093. --- 831,847 ----
  1094.       *yp = t;
  1095.   }
  1096.   
  1097. ! #ifdef    TOOLKIT
  1098.       /*ARGSUSED*/
  1099.   static    void
  1100.   handle_button(widget, junk, event)
  1101.       Widget    widget;
  1102.       caddr_t    junk;
  1103. ! #else    TOOLKIT
  1104.   static    void
  1105.   handle_button(event)
  1106. ! #endif    TOOLKIT
  1107. !     XButtonEvent *event;
  1108.   {
  1109.       int x, y;
  1110.   #ifndef X10
  1111. ***************
  1112. *** 641,646 ****
  1113. --- 848,855 ----
  1114.       XSetWindowAttributes attr;
  1115.   
  1116.       alt.width = alt.height = mg_size[event->button - 1];
  1117. + #else X10
  1118. +     alt.width = alt.height = mg_size[2 - (event->detail & ValueMask)];
  1119.   #endif X10
  1120.       if (alt.win != NULL || mane.shrinkfactor == 1 || alt.width <= 0)
  1121.           XBell(DISP, 20);
  1122. ***************
  1123. *** 658,685 ****
  1124.           alt.height/2;
  1125.   #ifndef X10
  1126.           attr.save_under = True;
  1127. !         attr.border_pixel = fore_args.value;
  1128. !         attr.background_pixel = back_args.value;
  1129.           attr.override_redirect = True;
  1130. !         alt.win = XCreateWindow(DISP, RootWindowOfScreen(SCRN),
  1131.               x, y, alt.width, alt.height, MAGBORD,
  1132.               0,    /* depth from parent */
  1133.               InputOutput, CopyFromParent,
  1134.               CWSaveUnder | CWBorderPixel | CWBackPixel |
  1135.               CWOverrideRedirect, &attr);
  1136. !         XSelectInput(DISP, alt.win, ExposureMask);
  1137.   #else X10
  1138. !         alt.win = XCreateWindow(mane.win,
  1139.               x, y, alt.width, alt.height, MAGBORD,
  1140.               bdrmap, backmap);
  1141. !         XSelectInput(alt.win, ExposeRegion);
  1142.   #endif X10
  1143. !         XMapWindow(DPY alt.win);
  1144.           alt_stat = 1;    /* waiting for exposure */
  1145.       }
  1146.   }
  1147.   
  1148. ! #ifndef X10
  1149.       /*ARGSUSED*/
  1150.   static    void
  1151.   handle_motion(widget, junk, event)
  1152. --- 867,894 ----
  1153.           alt.height/2;
  1154.   #ifndef X10
  1155.           attr.save_under = True;
  1156. !         attr.border_pixel = fore_Pixel;
  1157. !         attr.background_pixel = back_Pixel;
  1158.           attr.override_redirect = True;
  1159. !         alt.win = (void *) XCreateWindow(DISP, RootWindowOfScreen(SCRN),
  1160.               x, y, alt.width, alt.height, MAGBORD,
  1161.               0,    /* depth from parent */
  1162.               InputOutput, CopyFromParent,
  1163.               CWSaveUnder | CWBorderPixel | CWBackPixel |
  1164.               CWOverrideRedirect, &attr);
  1165. !         XSelectInput(DISP, (Window) alt.win, ExposureMask);
  1166.   #else X10
  1167. !         alt.win = (void *) XCreateWindow((Window) mane.win,
  1168.               x, y, alt.width, alt.height, MAGBORD,
  1169.               bdrmap, backmap);
  1170. !         XSelectInput((Window) alt.win, ExposeRegion);
  1171.   #endif X10
  1172. !         XMapWindow(DPY (Window) alt.win);
  1173.           alt_stat = 1;    /* waiting for exposure */
  1174.       }
  1175.   }
  1176.   
  1177. ! #ifdef    TOOLKIT
  1178.       /*ARGSUSED*/
  1179.   static    void
  1180.   handle_motion(widget, junk, event)
  1181. ***************
  1182. *** 693,699 ****
  1183.       main_y = event->y_root - new_mag_y;
  1184.       mag_moved = (new_mag_x != mag_x || new_mag_y != mag_y);
  1185.   }
  1186. ! #endif X10
  1187.   
  1188.   static    void
  1189.   movemag(x, y)
  1190. --- 902,908 ----
  1191.       main_y = event->y_root - new_mag_y;
  1192.       mag_moved = (new_mag_x != mag_x || new_mag_y != mag_y);
  1193.   }
  1194. ! #endif    TOOLKIT
  1195.   
  1196.   static    void
  1197.   movemag(x, y)
  1198. ***************
  1199. *** 710,716 ****
  1200.           (y + mane_base_y) * mane.shrinkfactor - alt.height/2);
  1201.   }
  1202.   
  1203. ! #ifndef X10
  1204.       /*ARGSUSED*/
  1205.   static    void
  1206.   handle_release(widget, junk, event)
  1207. --- 919,925 ----
  1208.           (y + mane_base_y) * mane.shrinkfactor - alt.height/2);
  1209.   }
  1210.   
  1211. ! #ifdef    TOOLKIT
  1212.       /*ARGSUSED*/
  1213.   static    void
  1214.   handle_release(widget, junk, event)
  1215. ***************
  1216. *** 717,731 ****
  1217.       Widget    widget;
  1218.       caddr_t    junk;
  1219.       XButtonEvent *event;
  1220. ! #else X10
  1221.   static    void
  1222.   handle_release()
  1223. ! #endif X10
  1224.   {
  1225.       if (alt.win)
  1226.           if (alt_stat) alt_stat = -1;    /* destroy upon expose */
  1227.           else {
  1228. !         XDestroyWindow(DPY alt.win);
  1229.           if (curr.win == alt.win) alt_canit = True;
  1230.           alt.win = NULL;
  1231.           mag_moved = False;
  1232. --- 926,940 ----
  1233.       Widget    widget;
  1234.       caddr_t    junk;
  1235.       XButtonEvent *event;
  1236. ! #else    TOOLKIT
  1237.   static    void
  1238.   handle_release()
  1239. ! #endif    TOOLKIT
  1240.   {
  1241.       if (alt.win)
  1242.           if (alt_stat) alt_stat = -1;    /* destroy upon expose */
  1243.           else {
  1244. !         XDestroyWindow(DPY (Window) alt.win);
  1245.           if (curr.win == alt.win) alt_canit = True;
  1246.           alt.win = NULL;
  1247.           mag_moved = False;
  1248. ***************
  1249. *** 733,739 ****
  1250.           }
  1251.   }
  1252.   
  1253. ! #ifndef X10
  1254.       /*ARGSUSED*/
  1255.   static    void
  1256.   handle_exp(widget, windowrec, event)
  1257. --- 942,948 ----
  1258.           }
  1259.   }
  1260.   
  1261. ! #ifdef    TOOLKIT
  1262.       /*ARGSUSED*/
  1263.   static    void
  1264.   handle_exp(widget, windowrec, event)
  1265. ***************
  1266. *** 751,757 ****
  1267.           alt_stat = 0;
  1268.       expose(windowrec, event->x, event->y, event->width, event->height);
  1269.   }
  1270. ! #endif X10
  1271.   
  1272.   #ifndef X10
  1273.   #define    TRSIZE    100
  1274. --- 960,966 ----
  1275.           alt_stat = 0;
  1276.       expose(windowrec, event->x, event->y, event->width, event->height);
  1277.   }
  1278. ! #endif    TOOLKIT
  1279.   
  1280.   #ifndef X10
  1281.   #define    TRSIZE    100
  1282. ***************
  1283. *** 785,794 ****
  1284.               alt.min_x < MAXDIM || mag_moved))
  1285.           if (alt_canit) longjmp(canit_env, 1);
  1286.           else return;
  1287. ! #ifndef X10
  1288.           XtNextEvent(&event);
  1289.           if (resized) get_geom();
  1290. !         if (event.xany.window == alt.win &&
  1291.               event.type == Expose) {
  1292.           handle_exp((Widget) NULL, &alt, &event.xexpose);
  1293.           continue;
  1294. --- 994,1003 ----
  1295.               alt.min_x < MAXDIM || mag_moved))
  1296.           if (alt_canit) longjmp(canit_env, 1);
  1297.           else return;
  1298. ! #ifdef    TOOLKIT
  1299.           XtNextEvent(&event);
  1300.           if (resized) get_geom();
  1301. !         if (event.xany.window == (Window) alt.win &&
  1302.               event.type == Expose) {
  1303.           handle_exp((Widget) NULL, &alt, &event.xexpose);
  1304.           continue;
  1305. ***************
  1306. *** 801,879 ****
  1307.           nbytes = XLookupString(&event, string, TRSIZE, NULL, NULL);
  1308.           if (nbytes > 1) goto bad;
  1309.           if (nbytes != 0) ch = *string;
  1310.   #else X10
  1311. !         XNextEvent(&event);
  1312. !         switch (event.type) {
  1313. !         case ExposeWindow:
  1314. !         if (event.window == mane.win) {
  1315. !             register Dimension old_clip_w = clip_w;
  1316.   
  1317. !             window_w = ((XExposeEvent *) &event)->width;
  1318. !             window_h = ((XExposeEvent *) &event)->height;
  1319. !             if (old_clip_w == 0) home(False);
  1320. !         }
  1321. !         /* control falls through */
  1322. !         case ExposeRegion:
  1323. !             /* check in case we already destroyed the window */
  1324. !         if (event.window == mane.win || alt.win != NULL) {
  1325. !             struct WindowRec *wr =
  1326. !             (event.window == mane.win ? &mane : &alt);
  1327.   
  1328. !             if (wr == &alt)
  1329. !             if (alt_stat < 0) { /* destroy upon exposure */
  1330. !                 alt_stat = 0;
  1331. !                 handle_release();
  1332. !                 break;
  1333. !             }
  1334. !             else
  1335. !                 alt_stat = 0;
  1336. !             if (((XExposeEvent *) &event)->detail & ExposeCopy)
  1337. !             ClearArea(event.window,
  1338. !                 ((XExposeEvent *) &event)->x,
  1339. !                 ((XExposeEvent *) &event)->y,
  1340. !                 ((XExposeEvent *) &event)->width,
  1341. !                 ((XExposeEvent *) &event)->height);
  1342. !             expose(wr, ((XExposeEvent *) &event)->x,
  1343. !             ((XExposeEvent *) &event)->y,
  1344. !             ((XExposeEvent *) &event)->width,
  1345. !             ((XExposeEvent *) &event)->height);
  1346.           }
  1347. !         case ExposeCopy:    /* throw away junk event */
  1348. !         break;
  1349.   
  1350. !         case MouseMoved:
  1351. !         case LeftDownMotion:
  1352. !         case MiddleDownMotion:
  1353. !         case RightDownMotion:
  1354. !         new_mag_x = ((XMouseMovedEvent *) &event)->x;
  1355. !         new_mag_y = ((XMouseMovedEvent *) &event)->y;
  1356. !         mag_moved = (new_mag_x != mag_x || new_mag_y != mag_y);
  1357. !         break;
  1358.   
  1359. !         case ButtonPressed: {
  1360. !             register int n = 0;
  1361. !             switch (((XButtonPressedEvent *) &event)->detail &
  1362. !                 ValueMask) {
  1363. !             case MiddleButton:  n=1; break;
  1364. !             case RightButton:  n=2; break;
  1365. !             }
  1366. !             alt.width = alt.height = mg_size[n];
  1367. !             handle_button((XButtonPressedEvent *) &event);
  1368.           }
  1369. -         break;
  1370. -         case ButtonReleased:
  1371. -         handle_release();
  1372. -         break;
  1373. -         case KeyPressed:
  1374. -         string = XLookupMapping (&event, &nbytes);
  1375. -         if (nbytes > 1) goto bad;
  1376. -         if (nbytes != 0) ch = *string;
  1377. -         break;
  1378. - /*MouseMoved */
  1379. -         default:
  1380. -         Fprintf(stderr, "???:  %x\n", event.type);
  1381.           }
  1382.   #endif X10
  1383.           if (ch == '\0') continue;
  1384.           if (ch >= '0' && ch <= '9') {
  1385.           arg = True;
  1386. --- 1010,1182 ----
  1387.           nbytes = XLookupString(&event, string, TRSIZE, NULL, NULL);
  1388.           if (nbytes > 1) goto bad;
  1389.           if (nbytes != 0) ch = *string;
  1390. + #else    TOOLKIT
  1391. + /* |||
  1392. +  *    Currently the event handler does not coordinate XCopyArea requests
  1393. +  *    with GraphicsExpose events.  This can lead to problems if the window
  1394. +  *    is partially obscured and one, for example, drags a scrollbar.
  1395. +  */
  1396. + #ifndef X10
  1397. + #define    XANY(ev)    ev.xany
  1398. + #define    XCONFIG(ev)    ev.xconfigure
  1399. + #define    XEXPOSE(ev)    ev.xexpose
  1400. + #define    XMOTION(ev)    ev.xmotion
  1401. + #define    XBUTTON(ev)    ev.xbutton
  1402. + #define    XKEY(ev)    ev.xkey
  1403. + #define    ISEXPOSE(ev)    ((ev).type == Expose)
  1404.   #else X10
  1405. ! #define    XANY(ev)    ev
  1406. ! #define    XCONFIG(ev)    (*((XExposeEvent *) &(ev)))
  1407. ! #define    XEXPOSE(ev)    (*((XExposeEvent *) &(ev)))
  1408. ! #define    XMOTION(ev)    (*((XMouseMovedEvent *) &(ev)))
  1409. ! #define    XBUTTON(ev)    (*((XButtonEvent *) &(ev)))
  1410. ! #define    XKEY(ev)    (*((XKeyEvent *) &(ev)))
  1411. ! #define    ConfigureNotify    ExposeWindow
  1412. ! #define    Expose        ExposeRegion
  1413. ! #define    ISEXPOSE(ev)    ((ev).type == ExposeWindow || (ev).type == ExposeRegion)
  1414. ! #define    MotionNotify    MouseMoved
  1415. ! #define    ButtonPress    ButtonPressed
  1416. ! #define    ButtonRelease    ButtonReleased
  1417. ! #define    KeyPress    KeyPressed
  1418. ! #endif X10
  1419.   
  1420. !         XNextEvent(DPY &event);
  1421. !         if (XANY(event).window == (Window) mane.win ||
  1422. !         XANY(event).window == (Window) alt.win) {
  1423.   
  1424. !         struct WindowRec *wr = &mane;
  1425. !         if (XANY(event).window == (Window) alt.win) {
  1426. !             wr = &alt;
  1427. !             /* check in case we already destroyed the window */
  1428. !             if (alt_stat < 0) { /* destroy upon exposure */
  1429. !             alt_stat = 0;
  1430. !             handle_release();
  1431. !             continue;
  1432. !             }
  1433. !             else
  1434. !             alt_stat = 0;
  1435.           }
  1436. !         switch (event.type) {
  1437. ! #ifndef X10
  1438. !         case GraphicsExpose:
  1439. ! #else X10
  1440. !         case ExposeWindow:
  1441. ! #endif X10
  1442. !         case Expose:
  1443. ! #ifdef X10
  1444. !             if (XEXPOSE(event).detail & ExposeCopy)
  1445. !             ClearArea(event.window,
  1446. !                 XEXPOSE(event).x, XEXPOSE(event).y,
  1447. !                 XEXPOSE(event).width, XEXPOSE(event).height);
  1448. ! #endif X10
  1449. !             expose(wr, XEXPOSE(event).x, XEXPOSE(event).y,
  1450. !             XEXPOSE(event).width, XEXPOSE(event).height);
  1451. ! #ifdef X10
  1452. !         case ExposeCopy:    /* throw away junk event */
  1453. ! #endif X10
  1454. !             break;
  1455.   
  1456. !         case MotionNotify:
  1457. ! #ifdef X10
  1458. !         case LeftDownMotion:
  1459. !         case MiddleDownMotion:
  1460. !         case RightDownMotion:
  1461. ! #endif X10
  1462. !             new_mag_x = XMOTION(event).x;
  1463. !             new_mag_y = XMOTION(event).y;
  1464. !             mag_moved = (new_mag_x != mag_x || new_mag_y != mag_y);
  1465. !             break;
  1466.   
  1467. !         case ButtonPress:
  1468. !             handle_button(&XBUTTON(event));
  1469. !             break;
  1470. !         case ButtonRelease:
  1471. !             handle_release();
  1472. !             break;
  1473. !         }    /* end switch */
  1474. !         }    /* end if window == {mane,alt}.win */
  1475. !         else if (XANY(event).window == x_bar) {
  1476. !         if (ISEXPOSE(event))
  1477. !             DarkenArea(x_bar, x_bgn, 1, x_end - x_bgn, BAR_WID);
  1478. !         else if (event.type == MotionNotify)
  1479. !             scrollmane(XMOTION(event).x * page_w / clip_w,
  1480. !             mane.base_y);
  1481. ! #ifndef X10
  1482. !         else switch (XBUTTON(event).button)
  1483. ! #else X10
  1484. !         else if (event.type == ButtonPress)
  1485. !             switch (3 - (XBUTTON(event).detail & ValueMask))
  1486. ! #endif X10
  1487. !         {
  1488. !             case 1:
  1489. !             scrollmane(mane.base_x + XBUTTON(event).x, mane.base_y);
  1490. !             break;
  1491. !             case 2:
  1492. !             scrollmane(XBUTTON(event).x * page_w / clip_w,
  1493. !                 mane.base_y);
  1494. !             break;
  1495. !             case 3:
  1496. !             scrollmane(mane.base_x - XBUTTON(event).x, mane.base_y);
  1497.           }
  1498.           }
  1499. +         else if (XANY(event).window == y_bar) {
  1500. +         if (ISEXPOSE(event))
  1501. +             DarkenArea(y_bar, 1, y_bgn, BAR_WID, y_end - y_bgn);
  1502. +         else if (event.type == MotionNotify)
  1503. +             scrollmane(mane.base_x,
  1504. +             XMOTION(event).y * page_h / clip_h);
  1505. + #ifndef X10
  1506. +         else switch (XBUTTON(event).button)
  1507. + #else X10
  1508. +         else if (event.type == ButtonPress)
  1509. +             switch (3 - (XBUTTON(event).detail & ValueMask))
  1510.   #endif X10
  1511. +         {
  1512. +             case 1:
  1513. +             scrollmane(mane.base_x, mane.base_y + XBUTTON(event).y);
  1514. +             break;
  1515. +             case 2:
  1516. +             scrollmane(mane.base_x,
  1517. +                 XBUTTON(event).y * page_h / clip_h);
  1518. +             break;
  1519. +             case 3:
  1520. +             scrollmane(mane.base_x, mane.base_y - XBUTTON(event).y);
  1521. +         }
  1522. +         }
  1523. +         else if (XANY(event).window == top_level)
  1524. +         switch (event.type) {
  1525. +         case ConfigureNotify:
  1526. +             if (XANY(event).window == top_level &&
  1527. +             (XCONFIG(event).width != window_w ||
  1528. +             XCONFIG(event).height != window_h)) {
  1529. +                 register Dimension old_window_w = window_w;
  1530. +                 window_w = XCONFIG(event).width;
  1531. +                 window_h = XCONFIG(event).height;
  1532. +                 reconfig();
  1533. +                 if (old_window_w == 0) home(False);
  1534. +             }
  1535. +             break;
  1536. +         case KeyPress:
  1537. + #ifndef X10
  1538. +             string = trbuf;
  1539. +             nbytes = XLookupString(&event, string, TRSIZE, NULL, NULL);
  1540. + #else X10
  1541. +             string = XLookupMapping(&event, &nbytes);
  1542. + #endif X10
  1543. +             if (nbytes > 1) goto bad;
  1544. +             if (nbytes != 0) ch = *string;
  1545. +             break;
  1546. +         }
  1547. + #endif    TOOLKIT
  1548.           if (ch == '\0') continue;
  1549.           if (ch >= '0' && ch <= '9') {
  1550.           arg = True;
  1551. ***************
  1552. *** 921,926 ****
  1553. --- 1224,1232 ----
  1554.           case 'P':        /* declare current page */
  1555.               pageno_correct = arg0 * number0 - current_page;
  1556.               continue;
  1557. +         case 'k':        /* toggle keep-position flag */
  1558. +             keep_flag = (arg0 ? number0 : !keep_flag);
  1559. +             continue;
  1560.           case '\f':
  1561.               /* redisplay current page */
  1562.               break;
  1563. ***************
  1564. *** 927,933 ****
  1565.           case '^':
  1566.               home(True);
  1567.               continue;
  1568. ! #ifndef X10
  1569.           case 'l':
  1570.               if (!x_bar) goto bad;
  1571.               XtCallCallbacks(x_bar, XtNscrollProc,
  1572. --- 1233,1239 ----
  1573.           case '^':
  1574.               home(True);
  1575.               continue;
  1576. ! #ifdef    TOOLKIT
  1577.           case 'l':
  1578.               if (!x_bar) goto bad;
  1579.               XtCallCallbacks(x_bar, XtNscrollProc,
  1580. ***************
  1581. *** 951,956 ****
  1582. --- 1257,1294 ----
  1583.           case 'c':
  1584.               center(event.xkey.x, event.xkey.y);
  1585.               continue;
  1586. + #else    TOOLKIT
  1587. +         case 'l':
  1588. +             if (mane.base_x <= 0) goto bad;
  1589. +             scrollmane(mane.base_x - 2 * clip_w / 3, mane.base_y);
  1590. +             continue;
  1591. +         case 'r':
  1592. +             if (mane.base_x >= page_w - clip_w) goto bad;
  1593. +             scrollmane(mane.base_x + 2 * clip_w / 3, mane.base_y);
  1594. +             continue;
  1595. +         case 'u':
  1596. +             if (mane.base_y <= 0) goto bad;
  1597. +             scrollmane(mane.base_x, mane.base_y - 2 * clip_h / 3);
  1598. +             continue;
  1599. +         case 'd':
  1600. +             if (mane.base_y >= page_h - clip_h) goto bad;
  1601. +             scrollmane(mane.base_x, mane.base_y + 2 * clip_h / 3);
  1602. +             continue;
  1603. +         case 'c':    /* unchecked scrollmane() */
  1604. +             scrollwindow(&mane, mane.base_x + XKEY(event).x - clip_w/2,
  1605. +             mane.base_y + XKEY(event).y - clip_h/2);
  1606. +             paint_x_bar();
  1607. +             paint_y_bar();
  1608. + #ifndef X10
  1609. +             XWarpPointer(DISP, None, None, 0, 0, 0, 0,
  1610. +             clip_w/2 - XKEY(event).x, clip_h/2 - XKEY(event).y);
  1611. + #else X10
  1612. +             XWarpMouse(mane.win, clip_w/2, clip_h/2, GXcopy);
  1613. + #endif X10
  1614. +             continue;
  1615. + #endif    TOOLKIT
  1616. + #ifndef X10
  1617.           case 'M':
  1618.               XTranslateCoordinates(DISP, event.xkey.window, mane.win,
  1619.                   event.xkey.x, event.xkey.y, &home_x, &home_y,
  1620. ***************
  1621. *** 964,1004 ****
  1622.               ImageByteOrder(DISP));
  1623.               continue;
  1624.   #else X10
  1625. -         case 'l':
  1626. -             if (mane.base_x == 0) goto bad;
  1627. -             number0 = mane.base_x - 2 * clip_w / 3;
  1628. -             if (number0 < 0) number0 = 0;
  1629. -             scrollwindow(&mane, number0, mane.base_y);
  1630. -             continue;
  1631. -         case 'r':
  1632. -             number0 = mane.base_x + 2 * clip_w / 3;
  1633. -             if (number0 > page_w - clip_w) number0 = page_w - clip_w;
  1634. -             if (number0 == mane.base_x) goto bad;
  1635. -             scrollwindow(&mane, number0, mane.base_y);
  1636. -             continue;
  1637. -         case 'u':
  1638. -             if (mane.base_y == 0) goto bad;
  1639. -             number0 = mane.base_y - 2 * clip_h / 3;
  1640. -             if (number0 < 0) number0 = 0;
  1641. -             scrollwindow(&mane, mane.base_x, number0);
  1642. -             continue;
  1643. -         case 'd':
  1644. -             number0 = mane.base_y + 2 * clip_h / 3;
  1645. -             if (number0 > page_h - clip_h) number0 = page_h - clip_h;
  1646. -             if (number0 == mane.base_y) goto bad;
  1647. -             scrollwindow(&mane, mane.base_x, number0);
  1648. -             continue;
  1649. -         case 'c':
  1650. - #define    ev        ((XKeyPressedEvent *) &event)
  1651. -             scrollwindow(&mane, mane.base_x + ev->x - window_w/2,
  1652. -             mane.base_y + ev->y - window_h/2);
  1653. -             XWarpMouse(mane.win, window_w/2, window_h/2, 3);
  1654. -             continue;
  1655.           case 'M':
  1656. !             home_x = (ev->x + mane.base_x) * mane.shrinkfactor;
  1657. !             home_y = (ev->y + mane.base_y) * mane.shrinkfactor;
  1658.               continue;
  1659. - #undef    ev
  1660.   #endif X10
  1661.           case 's':
  1662.               if (!arg0) {
  1663. --- 1302,1311 ----
  1664.               ImageByteOrder(DISP));
  1665.               continue;
  1666.   #else X10
  1667.           case 'M':
  1668. !             home_x = (XKEY(event).x + mane.base_x) * mane.shrinkfactor;
  1669. !             home_y = (XKEY(event).y + mane.base_y) * mane.shrinkfactor;
  1670.               continue;
  1671.   #endif X10
  1672.           case 's':
  1673.               if (!arg0) {
  1674. ***************
  1675. *** 1019,1036 ****
  1676.               bak_shrink = number0;
  1677.               reset_fonts();
  1678.               }
  1679. ! #ifndef X10
  1680.               XUnmapWindow(DISP, mane.win);
  1681.               set_draw_args();
  1682.               XtSetValues(draw_widget, draw_args, 2);
  1683.               get_geom();
  1684.               home(False);
  1685. !             XMapWindow(DISP, mane.win);
  1686.               continue;
  1687. ! #else X10
  1688.               home(False);
  1689.               break;
  1690. ! #endif X10
  1691.           case 'S':
  1692.               if (!arg0) goto bad;
  1693.               if (number0 < 0) goto bad;
  1694. --- 1326,1344 ----
  1695.               bak_shrink = number0;
  1696.               reset_fonts();
  1697.               }
  1698. ! #ifdef    TOOLKIT
  1699.               XUnmapWindow(DISP, mane.win);
  1700.               set_draw_args();
  1701.               XtSetValues(draw_widget, draw_args, 2);
  1702.               get_geom();
  1703.               home(False);
  1704. !             XMapWindow(DISP, (Window) mane.win);
  1705.               continue;
  1706. ! #else    TOOLKIT
  1707. !             reconfig();
  1708.               home(False);
  1709.               break;
  1710. ! #endif    TOOLKIT
  1711.           case 'S':
  1712.               if (!arg0) goto bad;
  1713.               if (number0 < 0) goto bad;
  1714. ***************
  1715. *** 1050,1056 ****
  1716.           if (current_page != next_page) {
  1717.               current_page = next_page;
  1718.               spec_warn = True;
  1719. !             home(False);
  1720.           }
  1721.           canit = True;
  1722.           Flush();
  1723. --- 1358,1364 ----
  1724.           if (current_page != next_page) {
  1725.               current_page = next_page;
  1726.               spec_warn = True;
  1727. !             if (!keep_flag) home(False);
  1728.           }
  1729.           canit = True;
  1730.           Flush();
  1731. ***************
  1732. *** 1151,1157 ****
  1733.   
  1734.   static    void
  1735.   enable_intr() {
  1736. ! #ifndef SYSV
  1737.       int    socket    = ConnectionNumber(DISP);
  1738.       if (!isatty(0)) {
  1739.           puts("trying...");
  1740. --- 1459,1465 ----
  1741.   
  1742.   static    void
  1743.   enable_intr() {
  1744. ! #ifdef    HAS_SIGIO
  1745.       int    socket    = ConnectionNumber(DISP);
  1746.       if (!isatty(0)) {
  1747.           puts("trying...");
  1748. ***************
  1749. *** 1168,1180 ****
  1750.   do_pages()
  1751.   {
  1752.       if (debug & DBG_BATCH) {
  1753. ! #ifndef X10
  1754.           while (mane.min_x == MAXDIM) read_events(True);
  1755. ! #else X10
  1756.           while (mane.min_x == MAXDIM)
  1757.           if (setjmp(canit_env)) break;
  1758.           else read_events(True);
  1759. ! #endif X10
  1760.           for (current_page = 0; current_page < total_pages; ++current_page)
  1761.           redraw_page();
  1762.           exit(0);
  1763. --- 1476,1488 ----
  1764.   do_pages()
  1765.   {
  1766.       if (debug & DBG_BATCH) {
  1767. ! #ifdef    TOOLKIT
  1768.           while (mane.min_x == MAXDIM) read_events(True);
  1769. ! #else    TOOLKIT
  1770.           while (mane.min_x == MAXDIM)
  1771.           if (setjmp(canit_env)) break;
  1772.           else read_events(True);
  1773. ! #endif    TOOLKIT
  1774.           for (current_page = 0; current_page < total_pages; ++current_page)
  1775.           redraw_page();
  1776.           exit(0);
  1777. ***************
  1778. *** 1183,1189 ****
  1779.           enable_intr();
  1780.           (void) setjmp(canit_env);
  1781.           for (;;) {
  1782. !         SetCursor(ready_cursor);
  1783.           read_events(True);
  1784.           if (canit) {
  1785.               canit = False;
  1786. --- 1491,1497 ----
  1787.           enable_intr();
  1788.           (void) setjmp(canit_env);
  1789.           for (;;) {
  1790. !         if (mane.win) SetCursor(ready_cursor);
  1791.           read_events(True);
  1792.           if (canit) {
  1793.               canit = False;
  1794. ***************
  1795. *** 1217,1223 ****
  1796.   [-cr <color>]\n\
  1797.       [-margins <inches>] [-sidemargin <inches>] [-topmargin <inches>]\n\
  1798.       [-mgs[n] <size>] [-geometry <geometry>]  [#<geometry>]\n\
  1799. !     [-altfont <font>] [-display <host:display>] dvi_file\n", stderr);
  1800.   #else X10
  1801.       fputs("\
  1802.   Usage: xdvi [+[<page>]] [-s <shrink>] [-S <density>] [-p <pixels>] [-l] [-rv]\n\
  1803. --- 1525,1532 ----
  1804.   [-cr <color>]\n\
  1805.       [-margins <inches>] [-sidemargin <inches>] [-topmargin <inches>]\n\
  1806.       [-mgs[n] <size>] [-geometry <geometry>]  [#<geometry>]\n\
  1807. !     [-altfont <font>] [-thorough] [-copy] [-display <host:display>] \
  1808. ! dvi_file\n", stderr);
  1809.   #else X10
  1810.       fputs("\
  1811.   Usage: xdvi [+[<page>]] [-s <shrink>] [-S <density>] [-p <pixels>] [-l] [-rv]\n\
  1812. ***************
  1813. *** 1237,1244 ****
  1814. --- 1546,1556 ----
  1815.   
  1816.   #ifndef X10
  1817.   static    char    *icon_geometry;
  1818. + static    Boolean    copy    = 2;
  1819.   static    Boolean    thorough;
  1820. + #endif X10
  1821.   
  1822. + #ifdef    TOOLKIT
  1823.   static    XrmOptionDescRec    options[] = {
  1824.   {"-d",        ".debugLevel",    XrmoptionSepArg,    (caddr_t) NULL},
  1825.   {"+",        ".gotoPage",    XrmoptionStickyArg,    (caddr_t) NULL},
  1826. ***************
  1827. *** 1258,1263 ****
  1828. --- 1570,1577 ----
  1829.   {"-hl",        ".highlight",    XrmoptionSepArg,    (caddr_t) NULL},
  1830.   {"-cr",        ".cursorColor",    XrmoptionSepArg,    (caddr_t) NULL},
  1831.   {"#",        ".iconGeometry",XrmoptionStickyArg,     (caddr_t) NULL},
  1832. + {"-copy",    ".copy",    XrmoptionNoArg,        (caddr_t) "on"},
  1833. + {"+copy",    ".copy",    XrmoptionNoArg,        (caddr_t) "off"},
  1834.   {"-thorough",    ".thorough",    XrmoptionNoArg,        (caddr_t) "on"},
  1835.   {"+thorough",    ".thorough",    XrmoptionNoArg,        (caddr_t) "off"},
  1836.   {"-mgs",    ".magnifierSize1",XrmoptionSepArg,    (caddr_t) NULL},
  1837. ***************
  1838. *** 1292,1302 ****
  1839.   {"reverseVideo", "ReverseVideo", XtRBoolean, sizeof(Boolean),
  1840.     (Cardinal) &reverse, XtRBoolean, (caddr_t) &reverse},
  1841.   {"foreground", "Foreground", XtRPixel, sizeof(Pixel),
  1842. !   (Cardinal)&fore_args.value, XtRPixel, (caddr_t) &fore_args.value},
  1843.   {"foreground", "Foreground", XtRString, sizeof(char *),
  1844.     (Cardinal)&fore_color, XtRString, NULL},
  1845.   {"background", "Background", XtRPixel, sizeof(Pixel),
  1846. !   (Cardinal)&back_args.value, XtRPixel, (caddr_t) &back_args.value},
  1847.   {"background", "Background", XtRString, sizeof(char *),
  1848.     (Cardinal)&back_color, XtRString, NULL},
  1849.   {"highlight", "Highlight", XtRPixel, sizeof(Pixel),
  1850. --- 1606,1616 ----
  1851.   {"reverseVideo", "ReverseVideo", XtRBoolean, sizeof(Boolean),
  1852.     (Cardinal) &reverse, XtRBoolean, (caddr_t) &reverse},
  1853.   {"foreground", "Foreground", XtRPixel, sizeof(Pixel),
  1854. !   (Cardinal)&fore_Pixel, XtRPixel, (caddr_t) &fore_Pixel},
  1855.   {"foreground", "Foreground", XtRString, sizeof(char *),
  1856.     (Cardinal)&fore_color, XtRString, NULL},
  1857.   {"background", "Background", XtRPixel, sizeof(Pixel),
  1858. !   (Cardinal)&back_Pixel, XtRPixel, (caddr_t) &back_Pixel},
  1859.   {"background", "Background", XtRString, sizeof(char *),
  1860.     (Cardinal)&back_color, XtRString, NULL},
  1861.   {"highlight", "Highlight", XtRPixel, sizeof(Pixel),
  1862. ***************
  1863. *** 1309,1314 ****
  1864. --- 1623,1630 ----
  1865.     (Cardinal)&curs_color, XtRString, NULL},
  1866.   {"iconGeometry", "IconGeometry", XtRString, sizeof(char *),
  1867.     (Cardinal)&icon_geometry, XtRString, (caddr_t) NULL},
  1868. + {"copy", "Copy", XtRBoolean, sizeof(Boolean),
  1869. +   (Cardinal)©, XtRBoolean, (caddr_t) ©},
  1870.   {"thorough", "Thorough", XtRBoolean, sizeof(Boolean),
  1871.     (Cardinal)&thorough, XtRBoolean, (caddr_t) &thorough},
  1872.   {"magnifierSize1", "MagnifierSize", XtRInt, sizeof(int),
  1873. ***************
  1874. *** 1342,1513 ****
  1875.       {XtNiconPixmap,    (XtArgVal) 0},
  1876.   };
  1877.   
  1878. ! /*
  1879. !  *    X11 main program
  1880. !  */
  1881.   
  1882. ! main(argc, argv)
  1883. !     int argc;
  1884. !     char **argv;
  1885. ! {
  1886. !     prog = *argv;
  1887. !     if (*prog == '/') prog = rindex(prog, '/') + 1;
  1888.   
  1889. !     top_level = XtInitialize(prog, "XDvi", options, XtNumber(options),
  1890. !         &argc, argv);
  1891. !     if (argc != 2) usage();
  1892. !     dvi_name = argv[1];
  1893.   
  1894. !     XtGetApplicationResources(top_level, (caddr_t) NULL, resources,
  1895. !         XtNumber(resources), NULL, 0);
  1896. !     if (shrink_factor <= 0 || density <= 0 || pixels_per_inch <= 0) usage();
  1897. !     if (shrink_factor != 1) bak_shrink = shrink_factor;
  1898. !     mane.shrinkfactor = shrink_factor;
  1899. !     specialConv = pixels_per_inch / 1000.0;
  1900. !     if (debug_arg != NULL)
  1901. !         debug = isdigit(*debug_arg) ? atoi(debug_arg) : DBG_ALL;
  1902. !     if (margins) home_x = home_y = atof(margins) * pixels_per_inch;
  1903. !     if (sidemargin) home_x = atof(sidemargin) * pixels_per_inch;
  1904. !     if (topmargin) home_y = atof(topmargin) * pixels_per_inch;
  1905. !         /* The following code is lifted from Xterm */
  1906. !     DISP = XtDisplay(top_level);
  1907. !     SCRN = XtScreen(top_level);
  1908. !     if (icon_geometry != NULL) {
  1909. !         int scr, junk;
  1910.   
  1911. !         for(scr = 0;    /* yyuucchh */
  1912. !         SCRN != ScreenOfDisplay(DISP, scr);
  1913. !         scr++);
  1914. !         temp_args1[0].name = XtNiconX;
  1915. !         temp_args1[1].name = XtNiconY;
  1916. !         XGeometry(DISP, scr, icon_geometry, "", 0, 0, 0, 0, 0,
  1917. !               &temp_args1[0].value, &temp_args1[1].value, &junk, &junk);
  1918. !         XtSetValues(top_level, temp_args1, 2);
  1919.       }
  1920. !     if ((font_path = getenv(FONT_PATH)) == NULL)
  1921. !         font_path = default_font_path;
  1922. !     else if (*font_path == ':')
  1923. !         /*concatenate default_font_path before font_path */
  1924. !         font_path = strcat(strcpy(malloc((unsigned)
  1925. !         strlen(default_font_path) + strlen(font_path) + 1),
  1926. !         default_font_path), font_path);
  1927. !     open_dvi_file();
  1928. !     if (curr_page) {
  1929. !         current_page = (*curr_page ? atoi(curr_page) : total_pages) - 1;
  1930. !         if (current_page < 0 || current_page >= total_pages) usage();
  1931.       }
  1932. !         /* Set default window size and icon */
  1933. !     XtGetValues(top_level, &temp_args2, 1);    /* get border width */
  1934. !     screen_w = WidthOfScreen(SCRN) - 2*bwidth;
  1935. !     screen_h = HeightOfScreen(SCRN) - 2*bwidth;
  1936. !     temp_args3[0].value = (XtArgVal) (page_w<screen_w ? page_w : screen_w);
  1937. !     temp_args3[1].value = (XtArgVal) (page_h<screen_h ? page_h : screen_h);
  1938. !     temp_args3[2].value = (XtArgVal) (XCreateBitmapFromData(DISP,
  1939. !                 RootWindowOfScreen(SCRN),
  1940. !                 xdvi_bits, xdvi_width, xdvi_height));
  1941. !     XtSetValues(top_level, temp_args3, 3);
  1942. !     vport_widget = XtCreateManagedWidget("vport", viewportWidgetClass,
  1943. !         top_level, vport_args, XtNumber(vport_args));
  1944. !     clip_widget = XtNameToWidget(vport_widget, "clip");
  1945. !     set_draw_args();
  1946. !     draw_widget = XtCreateManagedWidget("drawing", widgetClass,
  1947. !         vport_widget, draw_args, XtNumber(draw_args));
  1948. !     XtAddEventHandler(vport_widget, KeyPressMask, False, handle_key,
  1949. !         (caddr_t) NULL);
  1950. !     XtAddEventHandler(vport_widget, StructureNotifyMask, False,
  1951. !         handle_resize, (caddr_t) NULL);
  1952. !     XtAddEventHandler(draw_widget, ExposureMask, False, handle_exp,
  1953. !         (caddr_t) &mane);
  1954. !     XtAddEventHandler(draw_widget, ButtonPressMask, False, handle_button,
  1955. !         (caddr_t) NULL);
  1956. !     XtAddEventHandler(draw_widget, ButtonMotionMask, False, handle_motion,
  1957. !         (caddr_t) NULL);
  1958. !     XtAddEventHandler(draw_widget, ButtonReleaseMask, False, handle_release,
  1959. !         (caddr_t) NULL);
  1960. !     XtRealizeWidget(top_level);
  1961. !     curr.win = mane.win = XtWindow(draw_widget);
  1962. !     if (reverse) {
  1963. !         if (!fore_color) fore_args.value = WhitePixelOfScreen(SCRN);
  1964. !         if (!back_color) back_args.value = BlackPixelOfScreen(SCRN);
  1965. !         fore_color = back_color = (char *)1;    /* nonzero */
  1966. !     } else {
  1967. !         if (!fore_color) fore_args.value = BlackPixelOfScreen(SCRN);
  1968. !         if (!back_color) back_args.value = WhitePixelOfScreen(SCRN);
  1969. !     }
  1970. !     if (fore_color) XtSetValues(draw_widget, &fore_args, 1);
  1971. !     if (back_color) {
  1972. !         XtSetValues(draw_widget, &back_args, 1);
  1973. !         XtSetValues(clip_widget, &back_args, 1);
  1974. !     }
  1975. !     {
  1976. !         XGCValues    values;
  1977. !         Pixel    set_bits = (Pixel) (fore_args.value & ~back_args.value);
  1978. !         Pixel    clr_bits = (Pixel) (back_args.value & ~fore_args.value);
  1979. ! #define    MakeGC(fcn, fg, bg)    (values.function = fcn, values.foreground=fg,\
  1980. !         values.background=bg,\
  1981. !         XCreateGC(DISP, RootWindowOfScreen(SCRN),\
  1982. !             GCFunction|GCForeground|GCBackground, &values))
  1983. !         if (set_bits && clr_bits)
  1984. !         ruleGC = MakeGC(GXcopy, fore_args.value, back_args.value);
  1985. !         if (!thorough && ruleGC) {
  1986. !         foreGC = ruleGC;
  1987. !         puts("Note:  overstrike characters may be incorrect.");
  1988. !         }
  1989. !         else {
  1990. !         if (set_bits) foreGC = MakeGC(GXor, set_bits, 0);
  1991. !         if (clr_bits)
  1992. !             *(foreGC ? &foreGC2 : &foreGC) =
  1993. !             MakeGC(GXandInverted, clr_bits, 0);
  1994. !         if (!ruleGC) ruleGC = foreGC;
  1995. !         }
  1996. !         highGC = ruleGC;
  1997. !         if (high_color)
  1998. !         highGC = MakeGC(GXcopy, hl_Pixel, back_args.value);
  1999. !     }
  2000. !     ready_cursor = XCreateFontCursor(DISP, XC_cross);
  2001. !     redraw_cursor = XCreateFontCursor(DISP, XC_watch);
  2002. !     if (!curs_color)
  2003. !         cr_Pixel = high_color ? hl_Pixel : fore_args.value;
  2004. !     {
  2005. !         XColor bg_Color, cr_Color;
  2006. !         bg_Color.pixel = back_args.value;
  2007. !         XQueryColor(DISP, DefaultColormapOfScreen(SCRN), &bg_Color);
  2008. !         cr_Color.pixel = cr_Pixel;
  2009. !         XQueryColor(DISP, DefaultColormapOfScreen(SCRN), &cr_Color);
  2010. !         XRecolorCursor(DISP, ready_cursor, &cr_Color, &bg_Color);
  2011. !         XRecolorCursor(DISP, redraw_cursor, &cr_Color, &bg_Color);
  2012. !     }
  2013. !     image = XCreateImage(DISP, DefaultVisualOfScreen(SCRN), 1, XYBitmap, 0,
  2014. !                  (char *)NULL, 0, 0, BITS_PER_BMUNIT, 0);
  2015. !     image->bitmap_unit = BITS_PER_BMUNIT;
  2016. ! #ifndef    MSBITFIRST
  2017. !     image->bitmap_bit_order = LSBFirst;
  2018. ! #else    MSBITFIRST
  2019. !     image->bitmap_bit_order = MSBFirst;
  2020. ! #endif    MSBITFIRST
  2021. !     {
  2022. !         short endian = (MSBFirst << 8) + LSBFirst;
  2023. !         image->byte_order = *((char *) &endian);
  2024. !     }
  2025. !     do_pages();
  2026.   }
  2027.   
  2028. - #else X10
  2029. - static    char    *display;
  2030. - static    char    *brdr_color;
  2031. - static    char    *geometry;
  2032.   static    struct option {
  2033.       char    *name;
  2034.       char    *resource;
  2035. --- 1658,1701 ----
  2036.       {XtNiconPixmap,    (XtArgVal) 0},
  2037.   };
  2038.   
  2039. ! #else    TOOLKIT
  2040.   
  2041. ! static    char    *display;
  2042. ! static    char    *geometry;
  2043. ! #ifdef X10
  2044. ! static    char    *brdr_color;
  2045. ! #endif X10
  2046.   
  2047. ! #ifndef X10
  2048. ! static    Boolean    iconic    = False;
  2049.   
  2050. ! static    Pixel
  2051. ! string_to_pixel(strp)        /* adapted from the toolkit */
  2052. !     char    **strp;
  2053. ! {
  2054. !     char    *str = *strp;
  2055. !     Status    status;
  2056. !     XColor    color, junk;
  2057.   
  2058. !     if (*str == '#') {    /* an rgb definition */
  2059. !         status = XParseColor(DISP, DefaultColormapOfScreen(SCRN),
  2060. !         str, &color);
  2061. !         if (status != 0)
  2062. !         status = XAllocColor(DISP, DefaultColormapOfScreen(SCRN),
  2063. !             &color);
  2064.       }
  2065. !     else    /* a name */
  2066. !         status = XAllocNamedColor(DISP, DefaultColormapOfScreen(SCRN),
  2067. !         str, &color, &junk);
  2068. !     if (status == 0) {
  2069. !         Fprintf(stderr, "Cannot allocate colormap entry for \"%s\"\n", str);
  2070. !         *strp = NULL;
  2071. !         return (Pixel) 0;
  2072.       }
  2073. !     return color.pixel;
  2074.   }
  2075. + #endif X10
  2076.   
  2077.   static    struct option {
  2078.       char    *name;
  2079.       char    *resource;
  2080. ***************
  2081. *** 1537,1557 ****
  2082.   {"-bg",        "background",    SepArg,    StringArg,    (caddr_t) &back_color},
  2083.   {"-background",    NULL,        SepArg,    StringArg,    (caddr_t) &back_color},
  2084.   {"-hl",        "highlight",    SepArg,    StringArg,    (caddr_t) &high_color},
  2085.   {"-bd",        "borderColor",    SepArg,    StringArg,    (caddr_t) &brdr_color},
  2086.   {"-cr",        "cursorColor",    SepArg,    StringArg,    (caddr_t) &curs_color},
  2087.   {"-geometry",    "geometry",    SepArg,    StringArg,    (caddr_t) &geometry},
  2088.   {"=",        NULL,        StickyArg, StringArg,    (caddr_t) &geometry},
  2089.   {"-mgs",    NULL,        SepArg, NumberArg,    (caddr_t) &mg_size[0]},
  2090.   {"-mgs1",    "magnifierSize1",SepArg, NumberArg,    (caddr_t) &mg_size[0]},
  2091.   {"-mgs2",    "magnifierSize2",SepArg, NumberArg,    (caddr_t) &mg_size[1]},
  2092.   {"-mgs3",    "magnifierSize3",SepArg, NumberArg,    (caddr_t) &mg_size[2]},
  2093.   };
  2094.   
  2095.   /*
  2096. !  *    X10 main program
  2097.    */
  2098.   
  2099. ! main(argc, argv)
  2100.       int argc;
  2101.       char **argv;
  2102.   {
  2103. --- 1725,1762 ----
  2104.   {"-bg",        "background",    SepArg,    StringArg,    (caddr_t) &back_color},
  2105.   {"-background",    NULL,        SepArg,    StringArg,    (caddr_t) &back_color},
  2106.   {"-hl",        "highlight",    SepArg,    StringArg,    (caddr_t) &high_color},
  2107. + #ifdef X10
  2108.   {"-bd",        "borderColor",    SepArg,    StringArg,    (caddr_t) &brdr_color},
  2109. + #endif X10
  2110.   {"-cr",        "cursorColor",    SepArg,    StringArg,    (caddr_t) &curs_color},
  2111.   {"-geometry",    "geometry",    SepArg,    StringArg,    (caddr_t) &geometry},
  2112.   {"=",        NULL,        StickyArg, StringArg,    (caddr_t) &geometry},
  2113. + #ifndef X10
  2114. + {"#",        "iconGeometry",    StickyArg, StringArg,    (caddr_t) &icon_geometry},
  2115. + {"-iconic",    "iconic",    TrueArg, BooleanArg,    (caddr_t) &iconic},
  2116. + {"+iconic",    NULL,        FalseArg, BooleanArg,    (caddr_t) &iconic},
  2117. + {"-copy",    "copy",        TrueArg, BooleanArg,    (caddr_t) ©},
  2118. + {"+copy",    NULL,        FalseArg, BooleanArg,    (caddr_t) ©},
  2119. + {"-thorough",    "thorough",    TrueArg, BooleanArg,    (caddr_t) &thorough},
  2120. + {"+thorough",    NULL,        FalseArg, BooleanArg,    (caddr_t) &thorough},
  2121. + #endif X10
  2122.   {"-mgs",    NULL,        SepArg, NumberArg,    (caddr_t) &mg_size[0]},
  2123.   {"-mgs1",    "magnifierSize1",SepArg, NumberArg,    (caddr_t) &mg_size[0]},
  2124.   {"-mgs2",    "magnifierSize2",SepArg, NumberArg,    (caddr_t) &mg_size[1]},
  2125.   {"-mgs3",    "magnifierSize3",SepArg, NumberArg,    (caddr_t) &mg_size[2]},
  2126. + #ifndef X10
  2127. + {"-mgs4",    "magnifierSize3",SepArg, NumberArg,    (caddr_t) &mg_size[3]},
  2128. + {"-mgs5",    "magnifierSize3",SepArg, NumberArg,    (caddr_t) &mg_size[4]},
  2129. + #endif X10
  2130.   };
  2131.   
  2132.   /*
  2133. !  *    Process the option table.  This is not guaranteed for all possible
  2134. !  *    option tables, but at least it works for this one.
  2135.    */
  2136.   
  2137. ! static    void
  2138. ! parse_options(argc, argv)
  2139.       int argc;
  2140.       char **argv;
  2141.   {
  2142. ***************
  2143. *** 1561,1577 ****
  2144.       caddr_t    addr;
  2145.       struct option *opt, *candidate;
  2146.       int    len1, len2, matchlen;
  2147. -     OpaqueFrame frame;
  2148. -     char    def[32];
  2149. -     int    mouspix;
  2150. -     Color    cdef;
  2151.   
  2152. -     prog = *argv;
  2153. -     if (*prog == '/') prog = rindex(prog, '/') + 1;
  2154. - /*
  2155. -  *    Process the option table.  This is not guaranteed for all possible
  2156. -  *    option tables, but at least it works for this one.
  2157. -  */
  2158.       for (arg = argv + 1; arg < argvend; ++arg) {
  2159.           len1 = strlen(*arg);
  2160.           candidate = NULL;
  2161. --- 1766,1772 ----
  2162. ***************
  2163. *** 1628,1637 ****
  2164.           }
  2165.       }
  2166.   
  2167.       if (XOpenDisplay(display) == NULL)
  2168.           oops("Can't open display\n");
  2169.       for (opt = options; opt < options + XtNumber(options); ++opt)
  2170. !         if (opt->resource && (optstring = XGetDefault(prog, opt->resource)))
  2171.           switch (opt->argtype) {
  2172.               case StringArg:
  2173.               *((char **) opt->address) = optstring;
  2174. --- 1823,1844 ----
  2175.           }
  2176.       }
  2177.   
  2178. + #ifndef X10
  2179. +     if ((DISP = XOpenDisplay(display)) == NULL)
  2180. +         oops("Can't open display\n");
  2181. +     SCRN = DefaultScreenOfDisplay(DISP);
  2182. + #else X10
  2183.       if (XOpenDisplay(display) == NULL)
  2184.           oops("Can't open display\n");
  2185. + #endif X10
  2186.       for (opt = options; opt < options + XtNumber(options); ++opt)
  2187. !         if (opt->resource &&
  2188. ! #ifndef X10
  2189. !             ((optstring = XGetDefault(DISP, prog, opt->resource)) ||
  2190. !             (optstring = XGetDefault(DISP, "XDvi", opt->resource))))
  2191. ! #else X10
  2192. !             (optstring = XGetDefault(DPY prog, opt->resource)))
  2193. ! #endif X10
  2194.           switch (opt->argtype) {
  2195.               case StringArg:
  2196.               *((char **) opt->address) = optstring;
  2197. ***************
  2198. *** 1643,1653 ****
  2199. --- 1850,1910 ----
  2200.               *((Boolean *) opt->address) =
  2201.                   (strcmp(optstring, "on") == 0);
  2202.           }
  2203. + }
  2204. + #endif    TOOLKIT
  2205.   
  2206. + /*
  2207. +  *    main program
  2208. +  */
  2209. + main(argc, argv)
  2210. +     int argc;
  2211. +     char **argv;
  2212. + {
  2213. + #ifndef    TOOLKIT
  2214. + #ifndef X10
  2215. +     XSizeHints    size_hints;
  2216. +     XWMHints    wmhints;
  2217. + #else X10
  2218. +     OpaqueFrame frame;
  2219. +     char    def[32];
  2220. +     int    mouspix;
  2221. +     Color    cdef;
  2222. + #endif X10
  2223. + #endif    TOOLKIT
  2224. +     prog = rindex(*argv, '/');
  2225. +     if (prog != NULL) ++prog; else prog = *argv;
  2226. + #ifdef    TOOLKIT
  2227. +     top_level = XtInitialize(prog, "XDvi", options, XtNumber(options),
  2228. +         &argc, argv);
  2229. +     if (argc != 2) usage();
  2230. +     dvi_name = argv[1];
  2231. +     XtGetApplicationResources(top_level, (caddr_t) NULL, resources,
  2232. +         XtNumber(resources), NULL, 0);
  2233. +     if (shrink_factor <= 0 || density <= 0 || pixels_per_inch <= 0) usage();
  2234. +     DISP = XtDisplay(top_level);
  2235. +     SCRN = XtScreen(top_level);
  2236. + #else    TOOLKIT
  2237. +     parse_options(argc, argv);
  2238. + #ifndef X10
  2239. +     if (fore_color) fore_Pixel = string_to_pixel(&fore_color);
  2240. +     if (back_color) back_Pixel = string_to_pixel(&back_color);
  2241. +     if (high_color) hl_Pixel = string_to_pixel(&high_color);
  2242. +     if (curs_color) cr_Pixel = string_to_pixel(&curs_color);
  2243. + #endif X10
  2244.       if (shrink_factor <= 0 || density <= 0 || pixels_per_inch <= 0 ||
  2245.           dvi_name == NULL) usage();
  2246. + #endif    TOOLKIT
  2247.       if (shrink_factor != 1) bak_shrink = shrink_factor;
  2248.       mane.shrinkfactor = shrink_factor;
  2249. +     specialConv = pixels_per_inch / 1000.0;
  2250.       if (debug_arg != NULL)
  2251.           debug = isdigit(*debug_arg) ? atoi(debug_arg) : DBG_ALL;
  2252.       if (margins) home_x = home_y = atof(margins) * pixels_per_inch;
  2253. ***************
  2254. *** 1668,1674 ****
  2255. --- 1925,2116 ----
  2256.           if (current_page < 0 || current_page >= total_pages) usage();
  2257.       }
  2258.   
  2259. + #ifndef X10
  2260. +     /*
  2261. +      *    X11 colors
  2262. +      */
  2263.       if (reverse) {
  2264. +         if (!fore_color) fore_Pixel = WhitePixelOfScreen(SCRN);
  2265. +         if (!back_color) back_Pixel = BlackPixelOfScreen(SCRN);
  2266. +         fore_color = back_color = (char *) &fore_color;    /* nonzero */
  2267. +     } else {
  2268. +         if (!fore_color) fore_Pixel = BlackPixelOfScreen(SCRN);
  2269. +         if (!back_color) back_Pixel = WhitePixelOfScreen(SCRN);
  2270. +     }
  2271. +     {
  2272. +         XGCValues    values;
  2273. +         Pixel    set_bits = (Pixel) (fore_Pixel & ~back_Pixel);
  2274. +         Pixel    clr_bits = (Pixel) (back_Pixel & ~fore_Pixel);
  2275. + #define    MakeGC(fcn, fg, bg)    (values.function = fcn, values.foreground=fg,\
  2276. +         values.background=bg,\
  2277. +         XCreateGC(DISP, RootWindowOfScreen(SCRN),\
  2278. +             GCFunction|GCForeground|GCBackground, &values))
  2279. +         if (copy == 2) copy = (PlanesOfScreen(SCRN) > 1);
  2280. +         if (copy || (set_bits && clr_bits))
  2281. +         ruleGC = MakeGC(GXcopy, fore_Pixel, back_Pixel);
  2282. +         if (copy) foreGC = ruleGC;
  2283. +         else if (!thorough && ruleGC) {
  2284. +         foreGC = ruleGC;
  2285. +         puts("Note:  overstrike characters may be incorrect.");
  2286. +         }
  2287. +         else {
  2288. +         if (set_bits) foreGC = MakeGC(GXor, set_bits, 0);
  2289. +         if (clr_bits)
  2290. +             *(foreGC ? &foreGC2 : &foreGC) =
  2291. +             MakeGC(GXandInverted, clr_bits, 0);
  2292. +         if (!ruleGC) ruleGC = foreGC;
  2293. +         }
  2294. +         highGC = ruleGC;
  2295. +         if (high_color)
  2296. +         highGC = MakeGC(GXcopy, hl_Pixel, back_Pixel);
  2297. +     }
  2298. +     ready_cursor = XCreateFontCursor(DISP, XC_cross);
  2299. +     redraw_cursor = XCreateFontCursor(DISP, XC_watch);
  2300. +     if (!curs_color)
  2301. +         cr_Pixel = high_color ? hl_Pixel : fore_Pixel;
  2302. +     {
  2303. +         XColor bg_Color, cr_Color;
  2304. +         bg_Color.pixel = back_Pixel;
  2305. +         XQueryColor(DISP, DefaultColormapOfScreen(SCRN), &bg_Color);
  2306. +         cr_Color.pixel = cr_Pixel;
  2307. +         XQueryColor(DISP, DefaultColormapOfScreen(SCRN), &cr_Color);
  2308. +         XRecolorCursor(DISP, ready_cursor, &cr_Color, &bg_Color);
  2309. +         XRecolorCursor(DISP, redraw_cursor, &cr_Color, &bg_Color);
  2310. +     }
  2311. + #ifdef    TOOLKIT
  2312. +     /*
  2313. +      *    X11 windows (toolkit)
  2314. +      */
  2315. +         /* The following code is lifted from Xterm */
  2316. +     if (icon_geometry != NULL) {
  2317. +         int scr, junk;
  2318. +         for(scr = 0;    /* yyuucchh */
  2319. +         SCRN != ScreenOfDisplay(DISP, scr);
  2320. +         scr++);
  2321. +         XGeometry(DISP, scr, icon_geometry, "", 0, 0, 0, 0, 0,
  2322. +               &temp_args1[0].value, &temp_args1[1].value, &junk, &junk);
  2323. +         XtSetValues(top_level, temp_args1, 2);
  2324. +     }
  2325. +         /* Set default window size and icon */
  2326. +     XtGetValues(top_level, &temp_args2, 1);    /* get border width */
  2327. +     screen_w = WidthOfScreen(SCRN) - 2*bwidth;
  2328. +     screen_h = HeightOfScreen(SCRN) - 2*bwidth;
  2329. +     temp_args3[0].value = (XtArgVal) (page_w<screen_w ? page_w : screen_w);
  2330. +     temp_args3[1].value = (XtArgVal) (page_h<screen_h ? page_h : screen_h);
  2331. +     temp_args3[2].value = (XtArgVal) (XCreateBitmapFromData(DISP,
  2332. +                 RootWindowOfScreen(SCRN),
  2333. +                 xdvi_bits, xdvi_width, xdvi_height));
  2334. +     XtSetValues(top_level, temp_args3, 3);
  2335. +     vport_widget = XtCreateManagedWidget("vport", viewportWidgetClass,
  2336. +         top_level, vport_args, XtNumber(vport_args));
  2337. +     clip_widget = XtNameToWidget(vport_widget, "clip");
  2338. +     set_draw_args();
  2339. +     draw_widget = XtCreateManagedWidget("drawing", widgetClass,
  2340. +         vport_widget, draw_args, XtNumber(draw_args));
  2341. +     if (fore_color) XtSetValues(draw_widget, &fore_args, 1);
  2342. +     if (back_color) {
  2343. +         XtSetValues(draw_widget, &back_args, 1);
  2344. +         XtSetValues(clip_widget, &back_args, 1);
  2345. +     }
  2346. +     XtAddEventHandler(vport_widget, KeyPressMask, False, handle_key,
  2347. +         (caddr_t) NULL);
  2348. +     XtAddEventHandler(vport_widget, StructureNotifyMask, False,
  2349. +         handle_resize, (caddr_t) NULL);
  2350. +     XtAddEventHandler(draw_widget, ExposureMask, False, handle_exp,
  2351. +         (caddr_t) &mane);
  2352. +     XtAddEventHandler(draw_widget, ButtonPressMask, False, handle_button,
  2353. +         (caddr_t) NULL);
  2354. +     XtAddEventHandler(draw_widget, ButtonMotionMask, False, handle_motion,
  2355. +         (caddr_t) NULL);
  2356. +     XtAddEventHandler(draw_widget, ButtonReleaseMask, False, handle_release,
  2357. +         (caddr_t) NULL);
  2358. +     XtRealizeWidget(top_level);
  2359. +     curr.win = mane.win = (void *) XtWindow(draw_widget);
  2360. + #else    TOOLKIT
  2361. +     /*
  2362. +      *    X11 windows (non toolkit)
  2363. +      */
  2364. +     screen_w = WidthOfScreen(SCRN) - 2*bwidth;
  2365. +     screen_h = HeightOfScreen(SCRN) - 2*bwidth;
  2366. +     size_hints.flags = PMinSize;
  2367. +     size_hints.min_width = size_hints.min_height = 50;
  2368. +     size_hints.x = size_hints.y = 0;
  2369. +     if (geometry != NULL) {
  2370. +         int flag = XParseGeometry(geometry, &size_hints.x, &size_hints.y,
  2371. +         &size_hints.width, &size_hints.height);
  2372. +         if (flag & (XValue | YValue))
  2373. +         size_hints.flags |= USSize | USPosition;
  2374. +         if (flag & (WidthValue | HeightValue))
  2375. +         size_hints.flags |= USSize;
  2376. +         if (flag & XNegative) size_hints.x += screen_w - size_hints.width;
  2377. +         if (flag & YNegative) size_hints.y += screen_h - size_hints.height;
  2378. +     }
  2379. +     if (!(size_hints.flags & USSize)) {
  2380. +         size_hints.flags |= PSize;
  2381. +         size_hints.width = page_w < screen_w ? page_w : screen_w;
  2382. +         size_hints.height = page_h < screen_h ? page_h : screen_h;
  2383. +     }
  2384. +     top_level = XCreateSimpleWindow(DISP, RootWindowOfScreen(SCRN),
  2385. +         size_hints.x, size_hints.y, size_hints.width, size_hints.height,
  2386. +         bwidth, fore_Pixel, back_Pixel);
  2387. +     XSetStandardProperties(DISP, top_level, dvi_name, prog, NULL,
  2388. +         argv, argc, &size_hints);
  2389. +     wmhints.flags = StateHint | IconPixmapHint;
  2390. +     wmhints.initial_state = iconic ? IconicState : NormalState;
  2391. +     wmhints.icon_pixmap = XCreateBitmapFromData(DISP,
  2392. +                 RootWindowOfScreen(SCRN),
  2393. +                 xdvi_bits, xdvi_width, xdvi_height);
  2394. +     if (icon_geometry != NULL) {
  2395. +         int junk;
  2396. +         wmhints.flags |= IconPositionHint;
  2397. +         XGeometry(DISP, DefaultScreen(DISP), icon_geometry, "",
  2398. +         0, 0, 0, 0, 0, &wmhints.icon_x, &wmhints.icon_y, &junk, &junk);
  2399. +     }
  2400. +     XSetWMHints(DISP, top_level, &wmhints);
  2401. +     XSelectInput(DISP, top_level, KeyPressMask | StructureNotifyMask);
  2402. +     XMapWindow(DISP, top_level);
  2403. +     Flush();
  2404. + #endif    TOOLKIT
  2405. +     image = XCreateImage(DISP, DefaultVisualOfScreen(SCRN), 1, XYBitmap, 0,
  2406. +                  (char *)NULL, 0, 0, BITS_PER_BMUNIT, 0);
  2407. +     image->bitmap_unit = BITS_PER_BMUNIT;
  2408. + #ifndef    MSBITFIRST
  2409. +     image->bitmap_bit_order = LSBFirst;
  2410. + #else    MSBITFIRST
  2411. +     image->bitmap_bit_order = MSBFirst;
  2412. + #endif    MSBITFIRST
  2413. +     {
  2414. +         short endian = (MSBFirst << 8) + LSBFirst;
  2415. +         image->byte_order = *((char *) &endian);
  2416. +     }
  2417. + #else X10
  2418. +     /*
  2419. +      *    X10 colors
  2420. +      */
  2421. +     if (reverse) {
  2422.           foreGC = WhitePixel;
  2423.           highGC = WhitePixel;
  2424.           backpix = BlackPixel;
  2425. ***************
  2426. *** 1705,1710 ****
  2427. --- 2147,2156 ----
  2428.               mouspix = cdef.pixel;
  2429.       }
  2430.   
  2431. +     /*
  2432. +      *    X10 windows
  2433. +      */
  2434.       frame.bdrwidth = bwidth;
  2435.       screen_w = DisplayWidth() - 2*bwidth;
  2436.       screen_h = DisplayHeight() - 2*bwidth;
  2437. ***************
  2438. *** 1715,1730 ****
  2439.       frame.x = 0;
  2440.       frame.y = 0;
  2441.       Sprintf(def, "=%dx%d+0+0", frame.width, frame.height);
  2442. !     mane.win = XCreate("DVI Previewer", prog, geometry, def,
  2443.           &frame, 50, 50);
  2444. !     XSelectInput(mane.win,
  2445. !         KeyPressed|ButtonPressed|ButtonReleased|
  2446. !         ExposeWindow|ExposeRegion|ExposeCopy|
  2447. !         LeftDownMotion|MiddleDownMotion|RightDownMotion);
  2448. !     XMapWindow(mane.win);
  2449. !     XDefineCursor(mane.win,
  2450.           XCreateCursor(xdvi_width, xdvi_height, xdvi_bits, xdvi_mask_bits,
  2451.                 xdvi_x_hot, xdvi_y_hot, mouspix, backpix, GXcopy));
  2452.       do_pages();
  2453.   }
  2454. - #endif X10
  2455. --- 2161,2174 ----
  2456.       frame.x = 0;
  2457.       frame.y = 0;
  2458.       Sprintf(def, "=%dx%d+0+0", frame.width, frame.height);
  2459. !     top_level = XCreate("DVI Previewer", prog, geometry, def,
  2460.           &frame, 50, 50);
  2461. !     XSelectInput(top_level, ExposeWindow | KeyPressed);
  2462. !     XMapWindow(top_level);
  2463. !     XDefineCursor(top_level,
  2464.           XCreateCursor(xdvi_width, xdvi_height, xdvi_bits, xdvi_mask_bits,
  2465.                 xdvi_x_hot, xdvi_y_hot, mouspix, backpix, GXcopy));
  2466. + #endif X10
  2467.       do_pages();
  2468.   }
  2469. diff -cr old/xdvi.h new/xdvi.h
  2470. *** old/xdvi.h    Mon Aug 28 00:06:12 1989
  2471. --- new/xdvi.h    Tue Aug 22 13:29:47 1989
  2472. ***************
  2473. *** 48,53 ****
  2474. --- 48,59 ----
  2475.   #define    BMSHORT
  2476.   #endif X10
  2477.   
  2478. + #ifdef    SYSV
  2479. + #define    ANSI_LIB
  2480. + #else
  2481. + #define    HAS_SIGIO        /* has SIGIO on _sockets_ */
  2482. + #endif
  2483.   #ifdef    BMLONG
  2484.   #define    BMUNIT            unsigned long
  2485.   #define    BITS_PER_BMUNIT        32
  2486. ***************
  2487. *** 200,206 ****
  2488.   extern    char    *prog;
  2489.   
  2490.   extern    struct    WindowRec {
  2491. !     long    win;        /* type Window is not defined yet */
  2492.       int    shrinkfactor;
  2493.       int    base_x, base_y;
  2494.       int    width, height;
  2495. --- 206,212 ----
  2496.   extern    char    *prog;
  2497.   
  2498.   extern    struct    WindowRec {
  2499. !     void    *win;        /* type Window is not defined yet */
  2500.       int    shrinkfactor;
  2501.       int    base_x, base_y;
  2502.       int    width, height;
  2503. diff -cr old/xdvi.man.sed new/xdvi.man.sed
  2504. *** old/xdvi.man.sed    Mon Aug 28 00:06:16 1989
  2505. --- new/xdvi.man.sed    Thu Aug 24 12:33:50 1989
  2506. ***************
  2507. *** 6,12 ****
  2508.   .nh
  2509.   [+[\fIpage\fP]] [\-s \fIshrink\fP] [\-S \fIdensity\fP] [\-p \fIpixels\fP]
  2510.   [\-altfont \fIfont\fP] [\-l] [\-rv] [\-fg \fIcolor\fP] [\-bg \fIcolor\fP]
  2511. ! [\-hl \fIcolor\fP] [\-bd \fIcolor\fP] [\-cr \fIcolor\fP] [-thorough]
  2512.   [\-margins \fIinches\fP] [\-sidemargin \fIinches\fP] [\-topmargin \fIinches\fP]
  2513.   [\-mgs[\fIn\fP] \fIsize\fP] [\-geometry \fIgeometry\fP | =\fIgeometry\fP]
  2514.   [%\fIgeometry\fP] [\-display \fIdisplay\fP] file
  2515. --- 6,12 ----
  2516.   .nh
  2517.   [+[\fIpage\fP]] [\-s \fIshrink\fP] [\-S \fIdensity\fP] [\-p \fIpixels\fP]
  2518.   [\-altfont \fIfont\fP] [\-l] [\-rv] [\-fg \fIcolor\fP] [\-bg \fIcolor\fP]
  2519. ! [\-hl \fIcolor\fP] [\-bd \fIcolor\fP] [\-cr \fIcolor\fP] [-thorough] [-copy]
  2520.   [\-margins \fIinches\fP] [\-sidemargin \fIinches\fP] [\-topmargin \fIinches\fP]
  2521.   [\-mgs[\fIn\fP] \fIsize\fP] [\-geometry \fIgeometry\fP | =\fIgeometry\fP]
  2522.   [%\fIgeometry\fP] [\-display \fIdisplay\fP] file
  2523. ***************
  2524. *** 113,120 ****
  2525.   appropriate bits and one to clear other bits.  If this is the case, then
  2526.   by default \fIxdvi\fR will instead use the \fIcopy\fR operation,
  2527.   which does not handle overstriking correctly.  The ``thorough'' option
  2528. ! chooses the slower but more correct choice.
  2529.   .TP
  2530.   .BI \-margins " inches"
  2531.   (.margins)
  2532.   Specifies the size of both the top margin and side margin.  This
  2533. --- 113,126 ----
  2534.   appropriate bits and one to clear other bits.  If this is the case, then
  2535.   by default \fIxdvi\fR will instead use the \fIcopy\fR operation,
  2536.   which does not handle overstriking correctly.  The ``thorough'' option
  2537. ! chooses the slower but more correct choice.  See also \fI-copy\fR, below.
  2538.   .TP
  2539. + .B \-copy
  2540. + (.copy)
  2541. + Always use the \fIcopy\fR operation when writing characters to the display.
  2542. + This option may be necessary for correct operation on a color display, but
  2543. + overstrike characters will be incorrect.
  2544. + .TP
  2545.   .BI \-margins " inches"
  2546.   (.margins)
  2547.   Specifies the size of both the top margin and side margin.  This
  2548. ***************
  2549. *** 224,238 ****
  2550.   .B R
  2551.   Forces the dvi file to be reread.  This allows you to preview many versions
  2552.   of the same file while running \fIxdvi\fR only once.
  2553.   .SH MOUSE ACTIONS
  2554.   If the shrink factor is set to any number other than one, then clicking
  2555.   any mouse button will pop up a ``magnifying glass'' which shows the unshrunk
  2556.   image in the vicinity of the mouse click.  This subwindow disappears when
  2557.   the mouse button is released.  Different mouse buttons produce different sized
  2558. ! windows, as indicated by the \fB\-mgs\fR option, above.
  2559.   .PP
  2560.   Also, the scrollbars (if present) behave in the standard way:  pushing Button 2
  2561. ! in a scrollbar moves the top or left edge of the scrollbar to that point;
  2562.   pushing Button 1 moves the image up or right by an amount equal to the distance
  2563.   from the button press to the upper left-hand corner of the window; pushing
  2564.   Button 3 moves the image down or left by the same amount.
  2565. --- 230,252 ----
  2566.   .B R
  2567.   Forces the dvi file to be reread.  This allows you to preview many versions
  2568.   of the same file while running \fIxdvi\fR only once.
  2569. + .TP
  2570. + .B k
  2571. + Normally when \fIxdvi\fR switches pages it moves to the home position as well.
  2572. + The `k' keystroke toggles a `keep-position' flag which, when set, will keep
  2573. + the same position when moving between pages.  Also `0k' and `1k' clear and
  2574. + set this flag, respectively.
  2575.   .SH MOUSE ACTIONS
  2576.   If the shrink factor is set to any number other than one, then clicking
  2577.   any mouse button will pop up a ``magnifying glass'' which shows the unshrunk
  2578.   image in the vicinity of the mouse click.  This subwindow disappears when
  2579.   the mouse button is released.  Different mouse buttons produce different sized
  2580. ! windows, as indicated by the \fB\-mgs\fR option, above.  Moving the cursor
  2581. ! while holding the button down will move the magnifying glass.
  2582.   .PP
  2583.   Also, the scrollbars (if present) behave in the standard way:  pushing Button 2
  2584. ! in a scrollbar moves the top or left edge of the scrollbar to that point
  2585. ! and optionally drags it;
  2586.   pushing Button 1 moves the image up or right by an amount equal to the distance
  2587.   from the button press to the upper left-hand corner of the window; pushing
  2588.   Button 3 moves the image down or left by the same amount.
  2589. diff -cr old/xdvi10.man.s new/xdvi10.man.s
  2590. *** old/xdvi10.man.s    Mon Aug 28 00:06:18 1989
  2591. --- new/xdvi10.man.s    Thu Aug 24 12:33:35 1989
  2592. ***************
  2593. *** 219,230 ****
  2594.   .B R
  2595.   Forces the dvi file to be reread.  This allows you to preview many versions
  2596.   of the same file while running \fIxdvi\fR only once.
  2597.   .SH MOUSE ACTIONS
  2598.   If the shrink factor is set to any number other than one, then clicking
  2599.   any mouse button will pop up a ``magnifying glass'' which shows the unshrunk
  2600.   image in the vicinity of the mouse click.  This subwindow disappears when
  2601.   the mouse button is released.  Different mouse buttons produce different sized
  2602. ! windows, as indicated by the \fB\-mgs\fR option, above.
  2603.   .SH ENVIRONMENT
  2604.   Uses the environment variable ``DISPLAY'' to specify which bit map display
  2605.   terminal to use.
  2606. --- 219,244 ----
  2607.   .B R
  2608.   Forces the dvi file to be reread.  This allows you to preview many versions
  2609.   of the same file while running \fIxdvi\fR only once.
  2610. + .TP
  2611. + .B k
  2612. + Normally when \fIxdvi\fR switches pages it moves to the home position as well.
  2613. + The `k' keystroke toggles a `keep-position' flag which, when set, will keep
  2614. + the same position when moving between pages.  Also `0k' and `1k' clear and
  2615. + set this flag, respectively.
  2616.   .SH MOUSE ACTIONS
  2617.   If the shrink factor is set to any number other than one, then clicking
  2618.   any mouse button will pop up a ``magnifying glass'' which shows the unshrunk
  2619.   image in the vicinity of the mouse click.  This subwindow disappears when
  2620.   the mouse button is released.  Different mouse buttons produce different sized
  2621. ! windows, as indicated by the \fB\-mgs\fR option, above.  Moving the cursor
  2622. ! while holding the button down will move the magnifying glass.
  2623. ! .PP
  2624. ! Also, the scrollbars (if present) behave in the standard way:  pushing Button 2
  2625. ! in a scrollbar moves the top or left edge of the scrollbar to that point
  2626. ! and optionally drags it;
  2627. ! pushing Button 1 moves the image up or right by an amount equal to the distance
  2628. ! from the button press to the upper left-hand corner of the window; pushing
  2629. ! Button 3 moves the image down or left by the same amount.
  2630.   .SH ENVIRONMENT
  2631.   Uses the environment variable ``DISPLAY'' to specify which bit map display
  2632.   terminal to use.
  2633.