home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume11 / lemming / patch1 next >
Encoding:
Internet Message Format  |  1987-09-20  |  35.9 KB

  1. Subject:  v11i063:  Update kit for lemming editor, Patch1
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rs@uunet.UU.NET
  5.  
  6. Submitted-by: "Alan W. Paeth" <awpaeth%watcgl.waterloo.edu@RELAY.CS.NET>
  7. Posting-number: Volume 11, Issue 63
  8. Archive-name: lemming/Patch1
  9.  
  10.  
  11. The "LEMMING - Little Editor for Mice and Other Rodents" editor has a fast-
  12. growing user community, and minor bug fixes and addenda are coming in. In
  13. addition, I've continued to extend the editor, hense these two postings.
  14.  
  15. These patches, plus may latest features are in this first mail message
  16. In addition, I've added source code for PostScript output, and included a
  17. Silicon Graphics/IRIS driver. The second posting includes an installers
  18. guide, updates to the tutorial, a new font file, and sample *.lem documents.
  19.  
  20. This posting contains source related code: new source modules (for PostScript
  21. and the IRIS), "diff"-style patch code, plus a shell script to run the latter.
  22. This code allows one to update the comp.sources.unix version of "lemming" to
  23. incorporate the latest features.
  24.  
  25. # This is a shell archive.  Remove anything before this line,
  26. # then unpack it by saving it in a file and typing "sh file".
  27. #
  28. # Contents:  lemir.c lempost.c dif-.lemrc dif-Makefile dif-lem.h dif-lemedit.c
  29. #    dif-lemgeo.c dif-lemhelp.c dif-lemio.c dif-lemline.c dif-lemmain.c
  30. #    dif-lemmisc.c dif-lemobj.c dif-lemobjsup.c dif-lempic.c dif-lemselect.c
  31. #    dif-lemspecial.c dif-lemstart.c dif-lemstop.c dif-lemtick.c dif-lemx.c
  32. #    runpatches
  33.  
  34. echo x - lemir.c
  35. sed 's/^@//' > "lemir.c" <<'@//E*O*F lemir.c//'
  36. /*
  37.  * lemir.c - lemming driver for Iris package
  38.  *
  39.  * copyright (c) by Alan W. Paeth, 1987. All rights reserved.
  40.  */
  41.  
  42. #include "lem.h"
  43. #include <gl.h>
  44. #include <device.h>
  45.  
  46. #define SOLID 0
  47. #define DASHES 1
  48. #define DOTS 2
  49.  
  50. #define DEFWIDTH 512
  51. #define DEFHEIGHT 512
  52.  
  53. #define SELMENU "Selections%t|none%x14|delete%x4|box%x2|ellipse%x5|vector%x22|undo%x21|refresh%x12"
  54.  
  55. #define NOSELMENU "No Select%t|all%x1|read%x18|write%x23|output%x15|quit%x17|undo%x21|refresh%x12"
  56.  
  57. int sysmsgloc;
  58. char sysmsg[120];
  59.     
  60. long winid, selmenu, noselmenu;
  61. long left, right, bottom, top, screenw, screenh;
  62.  
  63. unsigned char maptab[256];
  64.  
  65. Cursor lemcur =
  66.       { 0x0080, 0x0080, 0x0080, 0x0080, 0x03e0, 0x0630, 0x0410, 0x7c1f,
  67.     0x0410, 0x0630, 0x03e0, 0x0080, 0x0080, 0x0080, 0x0080, 0x0000 };
  68.  
  69. start()
  70.     {
  71. #define NOWIND -1
  72.     winid = NOWIND;
  73.     if (ismex())
  74.     {
  75.     /* prefsize(DEFWIDTH, DEFHEIGHT); */ /* suggested, not mandated */
  76.     minsize(200, 200);
  77.         winid = winopen("lemming 1.0");
  78.         if (winid == NOWIND)
  79.             {
  80.         fprintf(stderr, "can't open window");
  81.         exit(1);
  82.         }
  83.     wintitle("lemming 1.0");
  84.         }
  85.     else ginit();
  86.     greset();
  87.     writemask(0x7);
  88.     
  89.     qdevice(KEYBD);
  90.     qdevice(LEFTMOUSE);
  91.     qdevice(MIDDLEMOUSE);
  92.     if (ismex())
  93.         {
  94.     qdevice(MENUBUTTON);    /* add for popup menus */
  95.     selmenu = defpup(SELMENU);
  96.     noselmenu = defpup(NOSELMENU);
  97.         qdevice(REDRAW); /* must be done for MEX to post to queue! */
  98.     }
  99.     tie(LEFTMOUSE, MOUSEX, MOUSEY);
  100.     tie(MIDDLEMOUSE, MOUSEX, MOUSEY);
  101.  
  102.     cblack = BLACK;
  103.     cwhite = WHITE;
  104.     cred   = RED;
  105.     cgreen = GREEN;
  106.  
  107.     tickdot = 0;
  108.  
  109.     deflinestyle(1, 0x00ff);
  110.     deflinestyle(2, 0x0303);
  111.     lsbackup(1);
  112.  
  113.     defcursor(1, lemcur);
  114.     curorigin(1, 8, 7);
  115.     setcursor(1, 0x7, 0xffffff);
  116.     resize();
  117.     }
  118.  
  119. stop()
  120.     {
  121.     setcursor(0, 0x7, 0x7);
  122.     if (ismex())
  123.     {
  124.     if (winid != NOWIND) winclose(winid);
  125.     }
  126.     gexit();
  127.     }
  128.         
  129. resize()
  130.     {
  131.     if (ismex())
  132.         {
  133.     getsize(&screenw, &screenh);
  134.         getorigin(&left, &bottom);
  135.         right = left + screenw;
  136.         top = bottom + screenh;
  137.         ortho2(0.0, (float)(screenw), 0.0, (float)(screenh));
  138.         viewport(0, screenw, 0, screenh);
  139.         }
  140.     else
  141.     {
  142.     bottom = 128;
  143.     top = bottom + DEFHEIGHT;
  144.     left = 256;
  145.     right = left + DEFWIDTH;
  146.         screenw = right - left;
  147.         screenh = top - bottom;
  148.     ortho2(0.0, (float)(screenw), 0.0, (float)(screenh));
  149.         viewport(left, right, bottom, top);
  150.     }
  151.     }
  152.  
  153. getevent(xdn, ydn, xup, yup, ch)
  154.     int *xdn, *ydn, *xup, *yup;
  155.     char *ch;
  156.     {
  157.     static mousedown, midflag, postflag, xd, xu, yd, yu;
  158.     short val, m, type;
  159.     int ret;
  160. /*
  161.  * special test for pending selection on middle button
  162.  */
  163.     if (midflag && postflag)
  164.         {
  165.     *ch = C(I);    /* ^I == <TAB> */
  166.     midflag = postflag = 0;
  167.     return(CNTRL);
  168.     }
  169. /*
  170.  * on to the conventional testing
  171.  */
  172.     ret = NOEVT;
  173.     if (type = qtest())
  174.         switch(qread(&val))
  175.         {
  176.  
  177. case LEFTMOUSE:
  178. case MIDDLEMOUSE:
  179.         midflag = ((type == MIDDLEMOUSE) && !val);
  180.         mousedown = val;
  181.         if (mousedown) postflag = m = 0;
  182.         break;
  183.  
  184. case MOUSEX:
  185. case MOUSEY:
  186.         if ((type == MOUSEX) &&  mousedown) { m |= 1; xd = val-left; } 
  187.         if ((type == MOUSEX) && !mousedown) { m |= 2; xu = val-left; }
  188.         if ((type == MOUSEY) &&  mousedown) { m |= 4; yd = val-bottom; }
  189.         if ((type == MOUSEY) && !mousedown) { m |= 8; yu = val-bottom; }
  190.             if (m == 15)
  191.             {
  192.             m = 0;
  193.             ret = MOUSE;
  194.                 *xdn = MIN(MAX(xd, 0), screenw);
  195.                 *ydn = MIN(MAX(yd, 0), screenh);
  196.                 *xup = MIN(MAX(xu, 0), screenw);
  197.                 *yup = MIN(MAX(yu, 0), screenh);
  198.             postflag = 1;
  199.         }
  200.         break;
  201.  
  202. case MENUBUTTON:
  203.         if (val)
  204.         {
  205.         char code;
  206.         /* pupmode(); */    /* mex document lies! */
  207.         code = dopup(anysel ? selmenu : noselmenu);
  208.         /* endpupmode(); */    /* see above */
  209.             setcursor(1, 0x7, 0xffffff); /* mex took it away */
  210.         if (code != -1)
  211.             {
  212.             *ch = code;
  213.             ret = CNTRL;
  214.             }
  215.         }
  216.         break;
  217.  
  218. case KEYBD:
  219.             *ch = val;
  220.             if (*ch)
  221.             {
  222.             if ((*ch >= ' ') && (*ch != '\177'))
  223.             ret = ALPHA;
  224.             else if (*ch > 0) ret = CNTRL;
  225.             }    
  226.             break;
  227.  
  228. case REDRAW:
  229.             resize();
  230.         redraw();
  231.         break;
  232.  
  233. default:        /* unknown event in queue */
  234.         break;
  235.             }    
  236.     return(ret);
  237.     }
  238.  
  239. drawvec(x0, y0, x1, y1, col, wid, emph)
  240.     {
  241.     cursoff();
  242.     setlinestyle( (emph==EMPHNONE) ? SOLID:((emph==EMPHBOLD) ? DASHES:DOTS) );
  243.     linewidth(wid);
  244.     color(col);
  245.     move2i(x0, y0);
  246.     draw2i(x1, y1);
  247.     curson();
  248.     }
  249.  
  250. charshow(str)
  251.     char *str;
  252.     {
  253.     int i;
  254.     for(i=0; i<strlen(str); i++) sysmsg[sysmsgloc++] = str[i];
  255.     sysmsg[sysmsgloc] = '\0';
  256.     fontwrite(SYSFONT, 10, 10, sysmsg, EMPHNONE, cgreen);
  257.     }
  258.  
  259. charunshow(n)
  260.     {
  261.     fontwrite(SYSFONT, 10, 10, sysmsg, EMPHNONE, cblack);
  262.     while (n--)
  263.     {
  264.     if (sysmsgloc) sysmsg[--sysmsgloc] = '\0';
  265.     }
  266.     fontwrite(SYSFONT, 10, 10, sysmsg, EMPHNONE, cgreen);
  267.     }
  268.  
  269. erase()
  270.     {
  271.     cursoff();
  272.     color(BLACK);
  273.     clear();
  274.     if (!ismex())    /* add border in vanilla version */
  275.         {
  276.     drawvec(0,         0, screenw-1, 0,         cgreen, 1, EMPHNONE);
  277.     drawvec(0,         0, 0,         screenh-1, cgreen, 1, EMPHNONE);
  278.     drawvec(screenw-1, 0, screenw-1, screenh-1, cgreen, 1, EMPHNONE);
  279.     drawvec(0, screenh-1, screenw-1, screenh-1, cgreen, 1, EMPHNONE);
  280.         }
  281.     curson();
  282.     }
  283.  
  284. writescan(x, y, pixels, outaddr, col)
  285.     int x, y, pixels, col;
  286.     long *outaddr;
  287.     {
  288.     int dx;
  289.     long mask;
  290.     cursoff();
  291. /*
  292.  * remap bits for IRIS byte conventions
  293.  */
  294.     swapshorts(outaddr, (pixels+31)/8);
  295.     
  296.     mask = 0x1;
  297.     color(col);
  298.     for(dx=0; dx<pixels; dx++)
  299.         {
  300.         if (mask & *outaddr) pnti(x+dx, screenh-1-y, 0);
  301.     mask<<=1;
  302.         if (!mask)
  303.             {
  304.             mask = 0x1;
  305.             outaddr++;
  306.             }
  307.         }
  308.     curson();
  309.     }
  310.  
  311. /*
  312.  * byte reversal stuff
  313.  */
  314.  
  315. swapshorts(buf, len)
  316.     register unsigned char *buf;
  317.     {
  318.     unsigned char c1, c2, c3, c4;
  319.     register int count, i;
  320.     if (!maptab[1]) maptabinit();
  321.     count = len/4;
  322.     for (i=0; i<count; i++)
  323.     {
  324.     c1 = *buf++;
  325.     c2 = *buf++;
  326.     c3 = *buf++;
  327.     c4 = *buf;
  328.     *buf-- = maptab[c1];
  329.     *buf-- = maptab[c2];
  330.     *buf-- = maptab[c3];
  331.     *buf   = maptab[c4];
  332.     buf += 4;
  333.     }
  334.     }
  335.  
  336. maptabinit()
  337.     {
  338.     register int i, j;
  339.     unsigned char mask;
  340.     for(i = 0; i<256; i++)
  341.     {
  342.     mask = 0;
  343.     for(j = 0; j < 8; j++) if (i & (1<<j)) mask |= 1<<(7-j);
  344.     maptab[i] = mask;
  345.     }
  346.     }
  347. @//E*O*F lemir.c//
  348. chmod u=rw,g=r,o= lemir.c
  349.  
  350. echo x - lempost.c
  351. sed 's/^@//' > "lempost.c" <<'@//E*O*F lempost.c//'
  352. /*
  353.  * lempost.c - PostScript output processor
  354.  *
  355.  * copyright (c) by Alan W. Paeth, 1987. All rights reserved.
  356.  */
  357.  
  358. /*
  359.  * NOTE: this file may be substituted for "lempic.c" to provide
  360.  * PostScript output. The module is not complete in that the author
  361.  * as no easy access to verify the PostScript macros which are defined
  362.  * for each of the various lemming internal primitives. It is hoped that
  363.  * this macros will be completed by a regular PostScript user.
  364.  */
  365.  
  366. #include "lem.h"
  367.  
  368. FILE *f;
  369. int psize, pthick, pemph;
  370. char *pfont;
  371.  
  372. writepicint(fname)
  373.     char *fname;
  374.     {
  375.     char msgstr[50];
  376.     int i;
  377.     f = (fname && (strlen(fname) > 0)) ? fopen(fname, "w") : 0;
  378.     if (f)
  379.     {
  380.     pthick = psize = pemph = -1;
  381.     postopen();
  382.     forobjects
  383.         {
  384.         if (Odel) continue;
  385.         switch (Otype)
  386.         {
  387.         case TEXT:    ptext(i); break;
  388.         case LINE:    pline(i); break;
  389.         case BOX:    pbox(i);  break;
  390.         case ELLI:    pelli(i); break;
  391.         }
  392.         }
  393.     postclose();
  394.     fclose(f);
  395.     sprintf(msgstr, "PostScript output done [%s]", fname);
  396.     msgpost(msgstr);
  397.     }
  398.     else
  399.     {
  400.     sprintf(msgstr, "PostScript output failed [%s]", fname);
  401.     msgpost(msgstr);
  402.     }
  403.     free(fname);
  404.     }
  405.  
  406. writepic()
  407.     {
  408.     char *fname;
  409.     if (lastobj == 1) msgpost("work area empty -- no output");
  410.     else
  411.     {
  412.         fname = prompt("PostScript file: ");
  413.         writepicint(fname);
  414.         free(fname);
  415.     }
  416.     }
  417.  
  418. thick(i)
  419.     {
  420.     if (pthick != lemfont[Osizer].thick)
  421.     {
  422.     pthick = lemfont[Osizer].thick;
  423.         fprintf(f, "%d stwid\n", pthick);
  424.     }
  425.     }
  426.  
  427. emph(i)
  428.     {
  429.     if (Oemph != pemph)
  430.     {
  431.     switch(Oemph)
  432.         {
  433.         case EMPHNONE: out("snone"); break;
  434.         case EMPHBOLD: out("sbold"); break;
  435.         case EMPHITAL: out("sital"); break;
  436.         }
  437.         pemph = Oemph;
  438.     }
  439.     }
  440.     
  441. font(i)
  442.     {
  443.     if ((Oemph != pemph) || (lemfont[Osizer].psize != psize))
  444.     {
  445.     switch(Oemph)
  446.         {
  447.         case EMPHNONE: pfont = lemfont[Osizer].psr; break;
  448.         case EMPHBOLD: pfont = lemfont[Osizer].psb; break;
  449.         case EMPHITAL: pfont = lemfont[Osizer].psi; break;
  450.         }
  451.         pemph = Oemph;
  452.         psize = lemfont[Osizer].psize;
  453.     fprintf(f, "/%s %d sfont\n", pfont, psize);
  454.     }
  455.     }
  456.  
  457. ptext(i)
  458.     {
  459.     font(i);
  460.     fprintf(f, "(%s) %d %d", Otext, Oxs, Oys);
  461.     switch(Oalign)
  462.     {
  463.     case ALIGNLEFT:    out(" ltext"); break;
  464.     case ALIGNRGHT:    out(" rtext"); break;
  465.     case ALIGNCENT:    out(" ctext"); break;
  466.     }
  467.     }
  468.  
  469. pline(i)
  470.     {
  471.     thick(i);
  472.     emph(i);
  473.     fprintf(f, "%d %d %d %d ", Oxs, Oys, Oxe, Oye);
  474.     switch(Oalign)
  475.     {
  476.     case ALIGNLEFT: out("lline");
  477.     case ALIGNRGHT: out("rline");
  478.     case ALIGNCENT: out("cline");
  479.     }
  480.     }
  481.  
  482. pbox(i)
  483.     {
  484.     thick(i);
  485.     emph(i);
  486.     fprintf(f, "%d %d %d %d boxer\n", Ox, Oy, ABS(Ow), ABS(Oh));
  487.     }
  488.  
  489. pelli(i)
  490.     {
  491.     thick(i);
  492.     emph(i);
  493.     fprintf(f, "%d %d %d %d ellip\n", Ox, Oy, ABS(Ow), ABS(Oh));
  494.     }
  495.  
  496. out(s)
  497.     char *s;
  498.     {
  499.     fprintf(f, "%s\n", s);
  500.     }
  501.  
  502. postopen()
  503.     {
  504. out("%!PSAdobe-1.0");
  505. out("%%Creator: AWPaeth@watCGL");
  506. out("%%Title: Lemming-PostScript");
  507. out("%%Pages: 1");
  508. out("%%DocumentFonts Times-Bold");
  509. out("%%BoundingBox 0 0 612 792");
  510. out("%%EndComments");
  511. out("%%EndProlog");
  512. out("%%Page: 0 1");
  513. out("%");
  514. out("% attribute macros");
  515. out("/sbold {[4 4] 0 setdash} def");
  516. out("/sital {[1 1] 0 setdash} def");
  517. out("/snone {[   ] 0 setdash} def");
  518. out("/swidt {setlinewidth} def");
  519. out("/sfont {exch scalefont setfont} def");
  520. out("%");
  521. out("% object macros");
  522. out("/ltext {moveto 5 0 8#040 4 3 roll widthshow} def");
  523. out("/ctext {moveto dup stringwidth pop 2 div neg 0 rmoveto show} def");
  524. out("/rtext {moveto dup stringwidth pop neg 0 rmoveto show} def");
  525. out("/cline {newpath 2 4 roll moveto drawto stroke} def");
  526. out("/lline {newpath 2 4 roll moveto drawto stroke} def");
  527. out("/rline {newpath 2 4 roll moveto drawto stroke} def");
  528. out("/boxer {lline} def");
  529. out(" /edict {/edict 8 dict def");
  530. out(" edict /mtrx matrix put");
  531. out("/ellip { edict begin /endangle exch def /startangle exch def");
  532. out("         yrad exch def xrad exch def /y exch def /x exch def");
  533. out("         /savematrix mtrx currentmatrix def x y translate");
  534. out("         x y translate xrad yrad scazle 0 0 1 startangle endangle arc");
  535. out("         savematrix setmatrix end stroke }");
  536. out("%");
  537. out("% global defaults");
  538. out("%");
  539. out("1 setlinecap");
  540. out("1 setlinejoin");
  541. out("%");
  542. out("% THE STUFF");
  543. out("%");
  544.     }
  545.  
  546. postclose()
  547.     {
  548.     out("showpage");
  549.     out("%");
  550.     out("%%Trailer");
  551.     out("%%Pages: 1");
  552.     }
  553. @//E*O*F lempost.c//
  554. chmod u=rw,g=r,o= lempost.c
  555.  
  556. echo x - dif-.lemrc
  557. sed 's/^@//' > "dif-.lemrc" <<'@//E*O*F dif-.lemrc//'
  558. diff ./.lemrc /u/awpaeth/lem/src/.lemrc
  559. 11,19c11,19
  560. < 12   1    TimesRoman    TR TB TI    Times-Bold Times-Bold Times-Bold
  561. < 10   2    TimesRoman    TR TB TI    Times-Bold Times-Bold Times-Bold
  562. < 18   3    TimesRoman    TR TB TI    Times-Bold Times-Bold Times-Bold
  563. < 12   4    Helvetica    SR SB SI    Times-Bold Times-Bold Times-Bold
  564. < 10   5    Helvetica    SR SB SI    Times-Bold Times-Bold Times-Bold
  565. < 18   6    Helvetica    SR SB SI    Times-Bold Times-Bold Times-Bold
  566. < 6    7    Helvetica    SR SB SI    Times-Bold Times-Bold Times-Bold
  567. < 10   8    Gacha        CW CW CW    Times-Bold Times-Bold Times-Bold
  568. < 12   9    Hippo         GM GM GM    Times-Bold Times-Bold Times-Bold
  569. ---
  570. > 12   1    TimesRoman    TR TB TI   Times-Roman Times-Bold     Times-Italic 
  571. > 10   2    TimesRoman    TR TB TI   Times-Roman Times-Bold     Times-Italic 
  572. > 18   3    TimesRoman    TR TB TI   Times-Roman Times-Bold     Times-Italic 
  573. > 12   4    Helvetica    SR SB SI   Helvetica   Helvetica-Bold Helvetica-Oblique
  574. > 10   5    Helvetica    SR SB SI   Helvetica   Helvetica-Bold Helvetica-Oblique
  575. > 18   6    Helvetica    SR SB SI   Helvetica   Helvetica-Bold Helvetica-Oblique
  576. > 6    7    Helvetica    SR SB SI   Helvetica   Helvetica-Bold Helvetica-Oblique
  577. > 10   8    Gacha        CW CW CW   Courier     Courier-Bold   Courier-Oblique
  578. > 12   9    Hippo         GM GM GM   Symbol      Symbol         Symbol
  579. 23c23
  580. <  18 1    OldEnglish    oe oe oe    Times-Bold Times-Bold Times-Bold
  581. ---
  582. >  18 1    OldEnglish    oe oe oe   unknown     unknown        unknown
  583. @//E*O*F dif-.lemrc//
  584. chmod u=rw,g=r,o=r dif-.lemrc
  585.  
  586. echo x - dif-Makefile
  587. sed 's/^@//' > "dif-Makefile" <<'@//E*O*F dif-Makefile//'
  588. diff ./Makefile /u/awpaeth/lem/src/Makefile
  589. 23d22
  590. <     lempic.o \
  591. 31,32c30
  592. <     lemundo.o \
  593. <     lemvec.o
  594. ---
  595. >     lemundo.o
  596. 34,35c32
  597. < lemik::    $(OBJ) lemik.o
  598. <     cc $(CFLAGS) $(OBJ) lemik.o -lIkonas -lLocator -lm -o /u/awpaeth/bin/lemik
  599. ---
  600. > NOVEC =    lemvec.o
  601. 37,38c34,64
  602. < lemx::    $(OBJ) lemx.o
  603. <     cc $(CFLAGS) $(OBJ) lemx.o -lX -lm -o /u/awpaeth/bin/lemx
  604. ---
  605. > POST =    lempost.o
  606. > PIC =    lempic.o
  607. > ADAGE =    lemik.o
  608. > XWIND =    lemx.o
  609. > IRIS =    lemir.o
  610. > lemik::    $(OBJ) $(PIC) $(NOVEC) $(ADAGE)
  611. >     cc $(CFLAGS) $(OBJ) $(PIC) $(NOVEC) $(ADAGE) \
  612. >         -lIkonas -lLocator -lm -o /u/awpaeth/bin/lemik
  613. > lemikps:: $(OBJ) $(POST) $(NOVEC) $(ADAGE)
  614. >     cc $(CFLAGS) $(OBJ) $(PIC) $(NOVEC) $(ADAGE) \
  615. >         -lIkonas -lLocator -lm -o /u/awpaeth/bin/lemikps
  616. > lemx::    $(OBJ) $(PIC) $(NOVEC) $(XWIND)
  617. >     cc $(CFLAGS) $(OBJ) $(PIC) $(NOVEC) $(XWIND) \
  618. >         -lXr -lX -lm -o /u/awpaeth/bin/lemx
  619. > lemxps:: $(OBJ) $(POST) $(NOVEC) $(XWIND)
  620. >     cc $(CFLAGS) $(OBJ) $(POST) $(NOVEC) $(XWIND) \
  621. >         -lXr -lX -lm -o /u/awpaeth/bin/lemxps
  622. > lemir::    $(OBJ) $(PIC) $(IRIS)
  623. >     cc $(CFLAGS) $(OBJ) $(PIC) $(IRIS)
  624. >         -lm -Zg -o /u/awpaeth/bin/lemir
  625. > lemirps::    $(OBJ) $(POST) $(IRIS)
  626. >     cc $(CFLAGS) $(OBJ) $(POST) $(IRIS)
  627. >         -lm -Zg -o /u/awpaeth/bin/lemirps
  628. @//E*O*F dif-Makefile//
  629. chmod u=rw,g=r,o=r dif-Makefile
  630.  
  631. echo x - dif-lem.h
  632. sed 's/^@//' > "dif-lem.h" <<'@//E*O*F dif-lem.h//'
  633. diff ./lem.h /u/awpaeth/lem/src/lem.h
  634. 14c14
  635. <  * useful arithmetic functions
  636. ---
  637. >  * useful ASCII functions
  638. 17,19d16
  639. < #define MIN(a,b) ((a)<(b)?(a):(b))
  640. < #define MAX(a,b) ((a)>(b)?(a):(b))
  641. < #define ABS(a) ((a)>0?(a):(-(a)))
  642. 22a20,24
  643. > /* see "lemmisc.c" */
  644. > /* #define MIN(a,b) ((a)<(b)?(a):(b)) */
  645. > /* #define MAX(a,b) ((a)>(b)?(a):(b)) */
  646. > /* #define ABS(a) ((a)>0?(a):(-(a)))  */
  647. 163a166
  648. > #define SNAPTOL 8    /* max units to move when placing point along a line */
  649. 276c279
  650. < char *salloc(), *prompt(), getstroke();
  651. ---
  652. > char *salloc(), *prompt(), *filefind(), getstroke();
  653. @//E*O*F dif-lem.h//
  654. chmod u=rw,g=r,o=r dif-lem.h
  655.  
  656. echo x - dif-lemedit.c
  657. sed 's/^@//' > "dif-lemedit.c" <<'@//E*O*F dif-lemedit.c//'
  658. diff ./lemedit.c /u/awpaeth/lem/src/lemedit.c
  659. 76,77c76
  660. <     int i, j, g, dx, dy;
  661. <     if (!anysel) return;
  662. ---
  663. >     int dx, dy;
  664. 79a79,85
  665. >     copyoffset(dx, dy);
  666. >     }
  667. > copyoffset(dx, dy)
  668. >     {
  669. >     int i, j, g;
  670. >     if (!anysel) return;
  671. 96c102
  672. <         objectop(i, SEL, UNDEL);
  673. ---
  674. > /*        objectop(i, SEL, SEL); */
  675. @//E*O*F dif-lemedit.c//
  676. chmod u=rw,g=r,o=r dif-lemedit.c
  677.  
  678. echo x - dif-lemgeo.c
  679. sed 's/^@//' > "dif-lemgeo.c" <<'@//E*O*F dif-lemgeo.c//'
  680. diff ./lemgeo.c /u/awpaeth/lem/src/lemgeo.c
  681. 18c18
  682. < hypot(x, y)
  683. ---
  684. > ihypot(x, y)
  685. 28c28
  686. <     return(hypot(x1-x0, y1-y0));
  687. ---
  688. >     return(ihypot(x1-x0, y1-y0));
  689. @//E*O*F dif-lemgeo.c//
  690. chmod u=rw,g=r,o=r dif-lemgeo.c
  691.  
  692. echo x - dif-lemhelp.c
  693. sed 's/^@//' > "dif-lemhelp.c" <<'@//E*O*F dif-lemhelp.c//'
  694. diff ./lemhelp.c /u/awpaeth/lem/src/lemhelp.c
  695. 10c10
  696. < #define HELPCHARS "[IHMABCDEFGLNOPRSTUVWX^?"
  697. ---
  698. > #define HELPCHARS "[IHMABDEFGKLNOPRSTUVWX^?"
  699. 15c15
  700. <     msgpost("[help]: <space> - all; \"/\" - fonts; <key> - function: ");
  701. ---
  702. >     msgpost("[help]: ? - all; \"/\" - fonts; <key> - function: ");
  703. 17c17
  704. <     if (c == ' ') helpall();
  705. ---
  706. >     if (c == '?') helpall();
  707. 32c32
  708. <     case 'C': s = "^C   Copy selections (in place)"; break;
  709. ---
  710. >     case 'C': s = "^C   Curve (arc) line [unimplemented]"; break;
  711. 39d38
  712. <     case 'L': s = "^L   Refresh display"; break;
  713. 41a41,42
  714. >     case 'K': s = "^K   Copy selections (with offset)"; break;
  715. >     case 'L': s = "^L   Refresh display"; break;
  716. 47c48
  717. <     case 'S': s = "^Sc  Special function escape"; break;
  718. ---
  719. >     case 'S': s = "^Sc  Special function escape (caps for copy)"; break;
  720. @//E*O*F dif-lemhelp.c//
  721. chmod u=rw,g=r,o=r dif-lemhelp.c
  722.  
  723. echo x - dif-lemio.c
  724. sed 's/^@//' > "dif-lemio.c" <<'@//E*O*F dif-lemio.c//'
  725. diff ./lemio.c /u/awpaeth/lem/src/lemio.c
  726. 8a9,32
  727. > char *filefind(fname)
  728. >     char *fname;
  729. >     {
  730. >     FILE *f;
  731. >     char filename[50];
  732. >     f = 0;
  733. >     if (fname && (strlen(fname) > 0))
  734. >     {
  735. >         sprintf(filename, "%s", fname, LEMEXTN);
  736. >     f = fopen(filename, "r");
  737. >     if (!f)
  738. >         {
  739. >             sprintf(filename, "%s.%s", fname, LEMEXTN);
  740. >             f = fopen(filename, "r");
  741. >         }
  742. >         if (f)
  743. >         {
  744. >         fclose(f);
  745. >         return(salloc(filename));
  746. >         }
  747. >     }
  748. >     return(0);
  749. >     }
  750. 11c35,66
  751. <     int i;
  752. ---
  753. >     char *fname, *fname2, msgstr[50];
  754. >     FILE *f;
  755. >     if (lastobj == 1)
  756. >     {
  757. >     msgpost("work area empty -- no write");
  758. >     return;    /* nothing on display -- fast return */
  759. >     }
  760. >     sprintf(msgstr, firstfile ? "output file [%s]:":"output file: ",firstfile);
  761. >     fname = prompt(msgstr);
  762. >     f = (fname && (strlen(fname) > 0)) ? fopen(fname, "r") : 0;
  763. >     if (f)
  764. >     {
  765. >     sprintf(msgstr,"**write fail** file [%s] exists", fname);
  766. >     msgpost(msgstr);
  767. >         free(fname);
  768. >     fclose(f);
  769. >     return;
  770. >     }
  771. >     if (!fname || (strlen(fname) == 0))
  772. >     {
  773. >     if (fname) free(fname);
  774. >     fname = salloc(firstfile);
  775. >     if (!fname)
  776. >         {
  777. >         msgpost("**write fail** no filename given");
  778. >         return;
  779. >         }
  780. >         }
  781. >     writefileint(fname);
  782. >     }
  783. > writefileint(fname)
  784. 12a68,70
  785. >     {
  786. >     int i;
  787. >     char msgstr[50];
  788. 14,16c72
  789. <     if (lastobj == 1) return;    /* nothing on display -- fast return */
  790. <     fname = prompt("output file: ");
  791. <     f = (fname && (strlen(fname) > 1)) ? fopen(fname, "w") : 0;
  792. ---
  793. >     f = fopen(fname, "w");
  794. 32c88,89
  795. <     msgpost("output done");
  796. ---
  797. >     sprintf(msgstr, "output done [%s]", fname);
  798. >     msgpost(msgstr);
  799. 34c91,95
  800. <     else msgpost("output failed");
  801. ---
  802. >     else
  803. >     {
  804. >     sprintf(msgstr, "output failed [%s]", fname);
  805. >     msgpost(msgstr);
  806. >     }
  807. 42c103
  808. <     char *s, fline[MAXCHAR+50];
  809. ---
  810. >     char *s, msgstr[50], *goodname, fline[MAXCHAR+50];
  811. 44,45c105,106
  812. <     f = 0;
  813. <     if (fname && (strlen(fname) > 0))
  814. ---
  815. >     goodname = filefind(fname);
  816. >     if (goodname)
  817. 47,56c108
  818. <     f = fopen(fname, "r");
  819. <     if (!f)
  820. <         {
  821. <         char filename[100];
  822. <         sprintf(filename, "%s.%s", fname, LEMEXTN);
  823. <         f = fopen(filename, "r");
  824. <         }
  825. <     }
  826. <     if (f)
  827. <     {
  828. ---
  829. >         f = fopen(goodname, "r");
  830. 91c143,145
  831. <         msgpost("input done");
  832. ---
  833. >         sprintf(msgstr, "input done [%s]", goodname);
  834. >         free(goodname);
  835. >         msgpost(msgstr);
  836. 93c147,152
  837. <     else msgpost("bogus input file");
  838. ---
  839. >     else
  840. >         {
  841. >         sprintf(msgstr, "bogus input file [%s]", goodname);
  842. >         free(goodname);
  843. >         msgpost(msgstr);
  844. >         }
  845. 95c154,158
  846. <     else msgpost("input not found");
  847. ---
  848. >     else
  849. >     {
  850. >     sprintf(msgstr, "input not found [%s]", fname);
  851. >     msgpost(msgstr);
  852. >     }
  853. @//E*O*F dif-lemio.c//
  854. chmod u=rw,g=r,o=r dif-lemio.c
  855.  
  856. echo x - dif-lemline.c
  857. sed 's/^@//' > "dif-lemline.c" <<'@//E*O*F dif-lemline.c//'
  858. diff ./lemline.c /u/awpaeth/lem/src/lemline.c
  859. 34c34
  860. <     hy = hypot(Ow, Oh);
  861. ---
  862. >     hy = ihypot(Ow, Oh);
  863. 73,76c73,108
  864. <     int frac;
  865. <     frac = (ABS(Ow) > ABS(Oh)) ? (12*(*x-Oxs)+6)/Ow : (12*(*y-Oys)+6)/Oh;
  866. <     *x = ((12-frac)*Oxs + frac*Oxe)/12;
  867. <     *y = ((12-frac)*Oys + frac*Oye)/12;
  868. ---
  869. >     int j, prox, oldprox;
  870. >     long fx, fy, oldfx, oldfy, snap;
  871. >     static long frac, snapfrac[5] = { 150, 200, 300, 400, 450 };
  872. >     oldprox = SNAPTOL;
  873. > /*
  874. >  * frac is fractional distance along segment in 1/600 units. Update (*x,*y)
  875. >  * to the nearest point along the line.
  876. >  */
  877. >     frac = (ABS(Ow)>ABS(Oh)) ? (600*(*x-Oxs)+300)/Ow:(600*(*y-Oys)+300)/Oh;
  878. >     *x = ((600-frac)*Oxs + frac*Oxe)/600;
  879. >     *y = ((600-frac)*Oys + frac*Oye)/600;
  880. > /*
  881. >  * check to see if there is a nearby cardinal point along this line segment,
  882. >  * and if so, snap to that point exactly.
  883. >  */
  884. >     for (j=0; j<5; j++)
  885. >         {
  886. >         snap = snapfrac[j];
  887. >         fx = ((600-snap)*Oxs + snap*Oxe + 300)/600;
  888. >         fy = ((600-snap)*Oys + snap*Oye + 300)/600;
  889. >         prox = dist(*x, *y, fx, fy);
  890. >         if (prox < oldprox)
  891. >         {
  892. >          oldfx = fx;
  893. >         oldfy = fy;
  894. >         oldprox = prox;
  895. >         }
  896. >         }
  897. > /*
  898. >  * (oldfx, oldfy) have nearest approach to a cardinal point. Use it or lose it.
  899. >  */
  900. >         if (oldprox < SNAPTOL)
  901. >         {
  902. >         *x = oldfx;
  903. >         *y = oldfy;
  904. >         }
  905. 99c131
  906. <     h = hypot(Ow, Oh)*13;
  907. ---
  908. >     h = ihypot(Ow, Oh)*13;
  909. 112c144
  910. <     h = hypot(Ow, Oh)*13;
  911. ---
  912. >     h = ihypot(Ow, Oh)*13;
  913. @//E*O*F dif-lemline.c//
  914. chmod u=rw,g=r,o=r dif-lemline.c
  915.  
  916. echo x - dif-lemmain.c
  917. sed 's/^@//' > "dif-lemmain.c" <<'@//E*O*F dif-lemmain.c//'
  918. diff ./lemmain.c /u/awpaeth/lem/src/lemmain.c
  919. 31c31
  920. <         case C(C): copysel(); break;
  921. ---
  922. > /*        case C(C): curveify(); break; */
  923. 41c41
  924. < /*        case C(K): curveify(); break; */
  925. ---
  926. >         case C(K): copysel(); break;
  927. @//E*O*F dif-lemmain.c//
  928. chmod u=rw,g=r,o=r dif-lemmain.c
  929.  
  930. echo x - dif-lemmisc.c
  931. sed 's/^@//' > "dif-lemmisc.c" <<'@//E*O*F dif-lemmisc.c//'
  932. diff ./lemmisc.c /u/awpaeth/lem/src/lemmisc.c
  933. 8a9,19
  934. > /*
  935. >  * The following started life as #define's but some compilers couldn't
  936. >  * swallow the complex nested expressions generated. If speed is an issue,
  937. >  * then putting these back in "lem.h" might help a bit.
  938. >  */
  939. >  
  940. > MIN(a,b) { return((a)<(b)?(a):(b)); }
  941. > MAX(a,b) { return((a)>(b)?(a):(b)); }
  942. > ABS(a)   { return((a)>0?(a):(-(a))); }
  943. @//E*O*F dif-lemmisc.c//
  944. chmod u=rw,g=r,o=r dif-lemmisc.c
  945.  
  946. echo x - dif-lemobj.c
  947. sed 's/^@//' > "dif-lemobj.c" <<'@//E*O*F dif-lemobj.c//'
  948. diff ./lemobj.c /u/awpaeth/lem/src/lemobj.c
  949. 24,27c24,27
  950. <     case LINE: return(linenearpt(i, x, y)); break;
  951. <     case TEXT: return(textnearpt(i, x, y)); break;
  952. <     case BOX:  return( boxnearpt(i, x, y)); break;
  953. <     case ELLI: return(ellinearpt(i, x, y)); break;
  954. ---
  955. >     case LINE: return(linenearpt(i, x, y));
  956. >     case TEXT: return(textnearpt(i, x, y));
  957. >     case BOX:  return( boxnearpt(i, x, y));
  958. >     case ELLI: return(ellinearpt(i, x, y));
  959. 35,38c35,38
  960. <     case TEXT: return(textinrect(i, xl, yl, xh, yh)); break;
  961. <     case LINE: return(lineinrect(i, xl, yl, xh, yh)); break;
  962. <     case BOX:  return( boxinrect(i, xl, yl, xh, yh)); break;
  963. <     case ELLI: return(elliinrect(i, xl, yl, xh, yh)); break;
  964. ---
  965. >     case TEXT: return(textinrect(i, xl, yl, xh, yh));
  966. >     case LINE: return(lineinrect(i, xl, yl, xh, yh));
  967. >     case BOX:  return( boxinrect(i, xl, yl, xh, yh));
  968. >     case ELLI: return(elliinrect(i, xl, yl, xh, yh));
  969. 46,49c46,49
  970. <     case TEXT: return(textcantug(i, x, y)); break;
  971. <     case LINE: return(linecantug(i, x, y)); break;
  972. <     case BOX:  return( boxcantug(i, x, y)); break;
  973. <     case ELLI: return(ellicantug(i, x, y)); break;
  974. ---
  975. >     case TEXT: return(textcantug(i, x, y));
  976. >     case LINE: return(linecantug(i, x, y));
  977. >     case BOX:  return( boxcantug(i, x, y));
  978. >     case ELLI: return(ellicantug(i, x, y));
  979. @//E*O*F dif-lemobj.c//
  980. chmod u=rw,g=r,o=r dif-lemobj.c
  981.  
  982. echo x - dif-lemobjsup.c
  983. sed 's/^@//' > "dif-lemobjsup.c" <<'@//E*O*F dif-lemobjsup.c//'
  984. diff ./lemobjsup.c /u/awpaeth/lem/src/lemobjsup.c
  985. 7d6
  986. < #include <math.h>        /* to define "double floor()" */
  987. 8a8,9
  988. > double floor();        /* from math library (we don't want y1() as well) */
  989. @//E*O*F dif-lemobjsup.c//
  990. chmod u=rw,g=r,o=r dif-lemobjsup.c
  991.  
  992. echo x - dif-lempic.c
  993. sed 's/^@//' > "dif-lempic.c" <<'@//E*O*F dif-lempic.c//'
  994. diff ./lempic.c /u/awpaeth/lem/src/lempic.c
  995. 18a19
  996. >     char msgstr[50];
  997. 20c21
  998. <     f = (fname && (strlen(fname) > 1)) ? fopen(fname, "w") : 0;
  999. ---
  1000. >     f = (fname && (strlen(fname) > 0)) ? fopen(fname, "w") : 0;
  1001. 56c57,58
  1002. <     msgpost("pic output done");
  1003. ---
  1004. >     sprintf(msgstr, "pic output done [%s]", fname);
  1005. >     msgpost(msgstr);
  1006. 58c60,64
  1007. <     else msgpost("pic output failed");
  1008. ---
  1009. >     else
  1010. >     {
  1011. >     sprintf(msgstr, "pic output failed [%s]", fname);
  1012. >     msgpost(msgstr);
  1013. >     }
  1014. 66,68c72,78
  1015. <     fname = prompt("pic file: ");
  1016. <     writepicint(fname);
  1017. <     free(fname);
  1018. ---
  1019. >     if (lastobj == 1) msgpost("work area empty -- no output");
  1020. >     else
  1021. >     {
  1022. >         fname = prompt("pic file: ");
  1023. >         writepicint(fname);
  1024. >         free(fname);
  1025. >     }
  1026. @//E*O*F dif-lempic.c//
  1027. chmod u=rw,g=r,o=r dif-lempic.c
  1028.  
  1029. echo x - dif-lemselect.c
  1030. sed 's/^@//' > "dif-lemselect.c" <<'@//E*O*F dif-lemselect.c//'
  1031. diff ./lemselect.c /u/awpaeth/lem/src/lemselect.c
  1032. 11c11
  1033. <     if (markobj)
  1034. ---
  1035. >     if (markobj && objs[markobj])
  1036. @//E*O*F dif-lemselect.c//
  1037. chmod u=rw,g=r,o=r dif-lemselect.c
  1038.  
  1039. echo x - dif-lemspecial.c
  1040. sed 's/^@//' > "dif-lemspecial.c" <<'@//E*O*F dif-lemspecial.c//'
  1041. diff ./lemspecial.c /u/awpaeth/lem/src/lemspecial.c
  1042. 9a10,14
  1043. > /*
  1044. >  * note: x1 and y1 renamed to X1 and Y1 because of conflict with
  1045. >  * Bessel functions of the same name (in the math.h library)
  1046. >  */
  1047. >  
  1048. 12a18
  1049. >     int t;
  1050. 14a21
  1051. >     t = (UC(ch) == ch);
  1052. 17,22c24,29
  1053. <     case 'F': flip(); break;
  1054. <     case 'C': ccw(); break;
  1055. <     case 'M': magnify(); break;
  1056. <     case 'R': rotate(); break;
  1057. <     case 'S': stretch(); break;
  1058. <     case 'A': align(); break;
  1059. ---
  1060. >     case 'F': if (t) copyoffset(0,0); flip();    if (t) redraw(); break;
  1061. >     case 'C': if (t) copyoffset(0,0); ccw();     if (t) redraw(); break;
  1062. >     case 'M': if (t) copyoffset(0,0); magnify(); if (t) redraw(); break;
  1063. >     case 'R': if (t) copyoffset(0,0); rotate();  if (t) redraw(); break;
  1064. >     case 'S': if (t) copyoffset(0,0); stretch(); if (t) redraw(); break;
  1065. >     case 'A': if (t) copyoffset(0,0); align();   if (t) redraw(); break;
  1066. 80c87
  1067. <     int x1, y1, x2, y2, xs, ys, xe, ye;
  1068. ---
  1069. >     int X1, Y1, x2, y2, xs, ys, xe, ye;
  1070. 82c89
  1071. <     if (findmark(&x1, &y1, &x2, &y2))
  1072. ---
  1073. >     if (findmark(&X1, &Y1, &x2, &y2))
  1074. 86,87c93,94
  1075. <     xe = x1-markx;
  1076. <     ye = y1-marky;
  1077. ---
  1078. >     xe = X1-markx;
  1079. >     ye = Y1-marky;
  1080. 102c109
  1081. <     int x1, y1, x2, y2, xs, ys, xe, ye;
  1082. ---
  1083. >     int X1, Y1, x2, y2, xs, ys, xe, ye;
  1084. 104c111
  1085. <     if (findmark(&x1, &y1, &x2, &y2))
  1086. ---
  1087. >     if (findmark(&X1, &Y1, &x2, &y2))
  1088. 108,109c115,116
  1089. <     xe = x1-markx;
  1090. <     ye = y1-marky;
  1091. ---
  1092. >     xe = X1-markx;
  1093. >     ye = Y1-marky;
  1094. 121c128
  1095. <     int x1, y1, x2, y2, xs, ys, xe, ye;
  1096. ---
  1097. >     int X1, Y1, x2, y2, xs, ys, xe, ye;
  1098. 123c130
  1099. <     if (findmark(&x1, &y1, &x2, &y2))
  1100. ---
  1101. >     if (findmark(&X1, &Y1, &x2, &y2))
  1102. 127,128c134,135
  1103. <     xe = x1-markx;
  1104. <     ye = y1-marky;
  1105. ---
  1106. >     xe = X1-markx;
  1107. >     ye = Y1-marky;
  1108. 143c150
  1109. <     int x1, y1, x2, y2, xs, ys, xe, ye, scale;
  1110. ---
  1111. >     int X1, Y1, x2, y2, xs, ys, xe, ye, scale;
  1112. 145c152
  1113. <     if (findmark(&x1, &y1, &x2, &y2))
  1114. ---
  1115. >     if (findmark(&X1, &Y1, &x2, &y2))
  1116. 149,150c156,157
  1117. <     xe = x1-markx;
  1118. <     ye = y1-marky;
  1119. ---
  1120. >     xe = X1-markx;
  1121. >     ye = Y1-marky;
  1122. 162,163c169,170
  1123. < findmark(x1, y1, x2, y2)
  1124. <     int *x1, *y1, *x2, *y2;
  1125. ---
  1126. > findmark(X1, Y1, x2, y2)
  1127. >     int *X1, *Y1, *x2, *y2;
  1128. 183,184c190,191
  1129. < case ALIGNCENT:        *x1 = s ? Oxe : Oxs;
  1130. <             *y1 = s ? Oye : Oys;
  1131. ---
  1132. > case ALIGNCENT:        *X1 = s ? Oxe : Oxs;
  1133. >             *Y1 = s ? Oye : Oys;
  1134. @//E*O*F dif-lemspecial.c//
  1135. chmod u=rw,g=r,o=r dif-lemspecial.c
  1136.  
  1137. echo x - dif-lemstart.c
  1138. sed 's/^@//' > "dif-lemstart.c" <<'@//E*O*F dif-lemstart.c//'
  1139. diff ./lemstart.c /u/awpaeth/lem/src/lemstart.c
  1140. 54c54
  1141. <         if (!firstfile) firstfile = argv[i]; /* record first input file */
  1142. ---
  1143. >         if (!firstfile) firstfile=filefind(argv[i]); /* record 1st input */
  1144. @//E*O*F dif-lemstart.c//
  1145. chmod u=rw,g=r,o=r dif-lemstart.c
  1146.  
  1147. echo x - dif-lemstop.c
  1148. sed 's/^@//' > "dif-lemstop.c" <<'@//E*O*F dif-lemstop.c//'
  1149. diff ./lemstop.c /u/awpaeth/lem/src/lemstop.c
  1150. 22a23
  1151. >     msgclear();
  1152. @//E*O*F dif-lemstop.c//
  1153. chmod u=rw,g=r,o=r dif-lemstop.c
  1154.  
  1155. echo x - dif-lemtick.c
  1156. sed 's/^@//' > "dif-lemtick.c" <<'@//E*O*F dif-lemtick.c//'
  1157. diff ./lemtick.c /u/awpaeth/lem/src/lemtick.c
  1158. 96,97c96,97
  1159. <     y = tyoff;
  1160. <     for(iy=0; iy<ylim; iy++)
  1161. ---
  1162. >     y = tyoff - 2*ty;
  1163. >     for(iy=0; y<screenh; iy++)
  1164. @//E*O*F dif-lemtick.c//
  1165. chmod u=rw,g=r,o=r dif-lemtick.c
  1166.  
  1167. echo x - dif-lemx.c
  1168. sed 's/^@//' > "dif-lemx.c" <<'@//E*O*F dif-lemx.c//'
  1169. diff ./lemx.c /u/awpaeth/lem/src/lemx.c
  1170. 6a7,22
  1171. > /*
  1172. >    Notes: there are two "#ifdef" statments in this code.
  1173. >    [1] #ifdef title 
  1174. >        This allows Xwindow toolkit titlebars to be added. They are
  1175. >        not well implemented, as they subtract live area from the
  1176. >        current window, and are not a true subwindow. Further, proper
  1177. >        timing of their redraw does not interact well with the redraw
  1178. >        signal and lemming window refresh fielded from the event queue.
  1179. >    [2] #ifdef vax
  1180. >        This allows proper byte ordering which allows the proper display
  1181. >        of text glyphs. If not true, an alternate byte ordering for a
  1182. >        32-bit integer (halfword swap) is chosen as the most likely ordering
  1183. >        for the hardware.
  1184. >  */
  1185. 8a25
  1186. > #include <X/Xr/Xrlib.h>
  1187. 17a35,69
  1188. > xrWindowData windata;
  1189. > #ifdef title
  1190. > xrEditor *tbar;
  1191. > xrTitleBarInfo titlebar =
  1192. >     {
  1193. >     0,                /* window Id */
  1194. >     {0,0,0,0},            /* editor rectangle */
  1195. >     XrVISIBLE | XrSENSITIVE,    /* editor state */
  1196. >     -1, -1,            /* editor colors - use defaults */
  1197. >     NULL,            /* editor font - use defaults */
  1198. >     "Hello World",        /* Title name */
  1199. >     NULL,            /* gadget 1 - unused */
  1200. >     NULL            /* gadget 2 - unused */
  1201. >     };
  1202. > #endif
  1203. > xrMenu *active_menu, *selmenu, *noselmenu;
  1204. > char noselmap[7] = { C(A), C(R), C(W), C(O), C(Q), C(U), C(L) };
  1205. > INT8 *noselmenuItems[9] =
  1206. >     {
  1207. >     "\\KEAall", "\\KERread", "\\KEWwrite", "\\KEOoutput",
  1208. >     "\\KEQquit", "\\KEUundo", "\\KELrefresh" };
  1209. > char selmap[7] = { C(N), C(D), C(B), C(E), C(V), C(U), C(L) };
  1210. >     
  1211. > INT8 *selmenuItems[9] =
  1212. >     {   "\\KENnone", "\\KEDdelete", "\\KEBbox", "\\KEEellipse",
  1213. >     "\\KEVvector", "\\KEUundo", "\\KELrefresh" };
  1214. >     
  1215. > xrMenuInfo selmenuinfo = { "Selections", selmenuItems, 7, NULL, 0 };
  1216. >     
  1217. > xrMenuInfo noselmenuinfo = { "No Select", noselmenuItems, 7, NULL, 1 };
  1218. >     
  1219. 22a75
  1220. >     if (!XrInit(NULL)) err("Xrlib open failed");
  1221. 27a81,98
  1222. > /* 
  1223. >  * create title bar
  1224. >  */
  1225. >     XrInput(win, MSG_ADDWINDOW, &windata);
  1226. > #ifdef title
  1227. >     titlebar.editorWindowId = win;
  1228. >     tbar = XrTitleBar(NULL, MSG_NEW, &titlebar);
  1229. > #endif
  1230. > /*
  1231. >  * create menus
  1232. >  */
  1233. >     selmenu = XrMenu(NULL, MSG_NEW, &selmenuinfo);
  1234. >     noselmenu = XrMenu(NULL, MSG_NEW, &noselmenuinfo);
  1235. >     active_menu = noselmenu;
  1236. >     XrMenu(active_menu, MSG_ACTIVATEMENU, win);
  1237. > /*
  1238. >  * get input and colors 
  1239. >  */
  1240. 52c123,134
  1241. < getevent(xdn, ydn, xup, yup, ch)
  1242. ---
  1243. > /*
  1244. >    The X interface is not nice in menu binding. Rather than allowing the
  1245. >    user to pop up a menu of his own chosing in response to an event, the
  1246. >    menu is bound to a button throughout the application. Because we allow
  1247. >    two menus (select and noselect) to be tied to one button, we must take
  1248. >    the time to rebind on each call to "getevent", as this is the routine
  1249. >    called from the lemming command interpreter inner loop. Addditionally,
  1250. >    we maintain the state of the last menu bound, to avoid the overhead
  1251. >    of redundant rebindings to identical menus, if menus need not be changed.
  1252. > */
  1253. >  getevent(xdn, ydn, xup, yup, ch)
  1254. 55a138
  1255. >     static int selflag;
  1256. 56a140
  1257. >     char *chptr;
  1258. 58c142,167
  1259. <     XWindowEvent(win, EV, &ev);
  1260. ---
  1261. > /*
  1262. >  * check for quick return on select (middle) key
  1263. >  */
  1264. >     if (selflag)
  1265. >     {
  1266. >     selflag = 0;
  1267. >     *ch = C(I);    /* force a pending <TAB> */
  1268. >     return(CNTRL);
  1269. >     }
  1270. > /*
  1271. >  * bind the correct menu to the rightmost mouse key
  1272. >  */
  1273. >     if ((active_menu == noselmenu) && anysel)
  1274. >     {
  1275. >     active_menu = selmenu;
  1276. >     XrMenu(active_menu, MSG_ACTIVATEMENU, win);
  1277. >     }
  1278. >     else if ((active_menu == selmenu) && !anysel)
  1279. >     {
  1280. >     active_menu = noselmenu;
  1281. >     XrMenu(active_menu, MSG_ACTIVATEMENU, win);
  1282. >     }
  1283. > /*
  1284. >  * see if this was a popup menu event
  1285. >  */
  1286. >     XrInput(0,MSG_BLKHOTREAD,&ev);    /* like XWindowEvent(win, EV, &ev); */
  1287. 60c169
  1288. <     switch(ev.type)
  1289. ---
  1290. >     if (ev.type & XrXRAY)
  1291. 62,82c171,226
  1292. <     case ButtonPressed:    xsave = mx(&ev);
  1293. <                 ysave = my(&ev);
  1294. <                 break;
  1295. <     case ButtonReleased:    *xdn = xsave;
  1296. <                 *ydn = ysave;
  1297. <                 *xup = mx(&ev);
  1298. <                 *yup = my(&ev);
  1299. <                 ret = MOUSE;
  1300. <                 break;
  1301. <     case KeyPressed:    *ch = *XLookupMapping(&ev, &count);
  1302. <                 if (*ch)
  1303. <                    {
  1304. <                    if ((*ch >= ' ') && (*ch != '\177'))
  1305. <                        ret = ALPHA;
  1306. <                    else if (*ch > 0) ret = CNTRL;
  1307. <                    }     
  1308. <                 break;
  1309. <     case ExposeRegion:
  1310. <     case ExposeWindow:    checkwindowsize();
  1311. <                 redraw();
  1312. <                 break;
  1313. ---
  1314. >     xrEvent *xrev = (xrEvent*) &ev;
  1315. >     if( xrev->inputType == XrMENU )
  1316. >         {
  1317. >         *ch = active_menu == selmenu ?
  1318. >         selmap[xrev->value3] : noselmap[xrev->value3];
  1319. >         ret = CNTRL;
  1320. >         }
  1321. >         }
  1322. > /*
  1323. >  * normal event -- field it
  1324. >  */
  1325. >     else switch(ev.type)
  1326. >     {
  1327. > case ButtonPressed:
  1328. >     if (mbutton(&ev) != RightButton)
  1329. >         {        /* left or middle */
  1330. >         xsave = mx(&ev);
  1331. >         ysave = my(&ev);
  1332. >         }
  1333. >     break;
  1334. > case ButtonReleased:
  1335. >     if (mbutton(&ev) != RightButton)
  1336. >         {
  1337. > /*
  1338. >  * must offset y coordinates by -2 in SUN X implementation
  1339. >  */
  1340. >         *xdn = MIN(MAX(xsave,0), screenw);
  1341. >         *ydn = MIN(MAX(ysave-2*tickdot,0),screenh);
  1342. >         *xup = MIN(MAX(mx(&ev), 0), screenw);
  1343. >         *yup = MIN(MAX(my(&ev)-2*tickdot,0),screenh);
  1344. >         if (mbutton(&ev) == MiddleButton) selflag = 1;
  1345. >         ret =  MOUSE;
  1346. >         }
  1347. >     break;
  1348. > case KeyPressed:
  1349. >     *ch = 0;
  1350. >     chptr = XLookupMapping(&ev, &count);
  1351. >     if (chptr) *ch = *chptr;        /* may return null ptr */
  1352. >     if (*ch)
  1353. >        {
  1354. >        if ((*ch >= ' ') && (*ch != '\177')) ret = ALPHA;
  1355. >        else if (*ch > 0) ret = CNTRL;
  1356. >        }     
  1357. >     break;
  1358. > case ExposeRegion:
  1359. > case ExposeWindow:
  1360. >     checkwindowsize();
  1361. >     redraw();
  1362. > #ifdef title
  1363. >     XrTitleBar(tbar, MSG_REDRAW, XrREDRAW_ALL);
  1364. > #endif
  1365. >     break;
  1366. > default:
  1367. >     XFeep(0);
  1368. >     if (ev.type == 0) break;
  1369. >     if(ev.type & XrXRAY) { xrEvent *xrev = (xrEvent*) &ev; }
  1370. 196a341,346
  1371. > mbutton(ev)
  1372. >     XKeyEvent *ev;
  1373. >     {
  1374. >     return(ev->detail & 0xff);
  1375. >     }
  1376. 238a389
  1377. > #ifdef vax
  1378. 242a394,399
  1379. > #else
  1380. >     *buf-- = maptab[c3];
  1381. >     *buf-- = maptab[c4];
  1382. >     *buf-- = maptab[c1];
  1383. >     *buf   = maptab[c2];
  1384. > #endif
  1385. @//E*O*F dif-lemx.c//
  1386. chmod u=rw,g=r,o=r dif-lemx.c
  1387.  
  1388. echo x - runpatches
  1389. sed 's/^@//' > "runpatches" <<'@//E*O*F runpatches//'
  1390. patch .lemrc       dif-.lemrc
  1391. patch Makefile     dif-Makefile
  1392. patch lem.h        dif-lem.h
  1393. patch lemedit.c    dif-lemedit.c
  1394. patch lemgeo.c     dif-lemgeo.c
  1395. patch lemhelp.c    dif-lemhelp.c
  1396. patch lemio.c      dif-lemio.c
  1397. patch lemline.c    dif-lemline.c
  1398. patch lemmain.c    dif-lemmain.c
  1399. patch lemmisc.c    dif-lemmisc.c
  1400. patch lemobj.c     dif-lemobj.c
  1401. patch lemobjsup.c  dif-lemobjsup.c
  1402. patch lempic.c     dif-lempic.c
  1403. patch lemselect.c  dif-lemselect.c
  1404. patch lemspecial.c dif-lemspecial.c
  1405. patch lemstart.c   dif-lemstart.c
  1406. patch lemstop.c    dif-lemstop.c
  1407. patch lemtick.c    dif-lemtick.c
  1408. patch lemx.c       dif-lemx.c
  1409. @//E*O*F runpatches//
  1410. chmod u=rwx,g=rwx,o=rwx runpatches
  1411.  
  1412. exit 0
  1413.  
  1414.