home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / lemming / part02 / lemmain.c next >
Encoding:
C/C++ Source or Header  |  1987-08-05  |  2.5 KB  |  90 lines

  1. /*
  2.  * lemmain.c - little editor for mice and other furry rodents (aka lemming)
  3.  *
  4.  * copyright (c) by Alan W. Paeth, 1987. All rights reserved.
  5.  */
  6.  
  7. #include "lem.h"
  8.  
  9. main(argc, argv)
  10.     char **argv;
  11.     {
  12.     int x, y, xup, yup, mup;
  13.     int event, near, drag, dragdist;
  14.     char ch;
  15.  
  16.     startup(argc, argv);
  17.  
  18.     while(1)
  19.     {
  20.     event = getevent(&x, &y, &xup, &yup, &ch);
  21.     if (event != NOEVT) msgclear();
  22.     switch(event)
  23.         {
  24. case NOEVT: idle(); break;
  25. case ALPHA: charadd(line, ch); break;
  26. case CNTRL: switch(ch)
  27.         {
  28.         case C(Q): if (quitconfirm()) break;
  29.         case C(A): all(SELECT, 0); break;
  30.         case C(B): remake(BOX); break;
  31.         case C(C): copysel(); break;
  32.         case C(D): objcompress(); all(DELETE, 0); undo=UNDODEL; break;
  33.         case C(E): remake(ELLI); break;
  34.         case C(F): forceattr(); break;
  35.         case C(G): addgroup(); break;
  36.         case '\177':                     /* <DEL>  */
  37.         case C(H): chardel(line,1); break;        /* <BS>  */
  38.         case C(I): cycleselect(); markdelete(); break;    /* <TAB> */
  39.         case C(J):                    /* <LF>, */
  40.         case C(M): if (markon) stringadd(); break;    /* <CR>  */
  41. /*        case C(K): curveify(); break; */
  42.         case C(L): redraw(); break;
  43.         case C(N): all(DESELECT, 0); break;
  44.         case C(O): writepic(); break;
  45.         case C(P): removegroup(); break;
  46.         case C(R): readfile(); break;
  47.         case C(S): specialfunc(); break;
  48.         case C(T): tickset(); break;
  49.         case C(U): undocmd(); break;
  50.         case C(V): remake(LINE); break;
  51.         case C(W): writefile(); break;
  52.         case C(X): cutlines(); break;
  53.         case C([): all(DESELECT, 0); markdelete(); break; /* <ESC> */
  54.         case C(^): help(); break;            /* ^^ */
  55.         default:   break;
  56.         } break;
  57. case MOUSE: markobj = objnearany(x, y);
  58.         near = markon && (dist(x, y, markx, marky) < MARKTOL);
  59.         dragdist = near ? (anysel ? 0 : MARKTOL) : DRAGTOL;
  60.         drag = dist(x,y,xup,yup) > dragdist;
  61.         if (markobj) objectalign(markobj, &x, &y); else spacealign(&x, &y);
  62.         if (drag)        /* drag stuff */
  63.         {
  64.         if (near)
  65.             {
  66.             markhide();        /* for cleaner update */
  67.             mup = objnearany(xup, yup);
  68.             if (mup && (mup != markobj)) objectalign(mup, &xup, &yup);
  69.             else spacealign(&xup, &yup);
  70.             if (anysel) moveselect(xup-markx, yup-marky);
  71.             else if (markobj) tugunselect(markx, marky, xup, yup);
  72.             markupdate(xup, yup);
  73.             }
  74.         else rectselect(x, y, xup, yup);
  75.         }
  76.         else        /* draw (move mark) cases */
  77.         {
  78.         if (near) markdelete();
  79.         else
  80.             {
  81.             markhide();        /* for cleaner update */
  82.             if (markon && !anysel) lineadd(markx, marky, x, y);
  83.             markupdate(x, y);
  84.             }
  85.         }
  86.         break;
  87.         }
  88.     }
  89.     }
  90.