home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / lemming / part01 / lemedit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-08-05  |  1.7 KB  |  102 lines

  1. /*
  2.  * lemedit.c - object manipulation
  3.  *
  4.  * copyright (c) by Alan W. Paeth, 1987. All rights reserved.
  5.  */
  6.  
  7. #include "lem.h"
  8.  
  9. moveselect(x, y)
  10.     {
  11.     int i;
  12. /*
  13.  * set flag and record last movement for undo
  14.  */
  15.     unx = x;
  16.     uny = y;
  17.     undo = UNDOMOVE;
  18. /*
  19.  * do the move
  20.  */
  21.     if (!anysel) return;
  22.     forobjects
  23.     {
  24.     if (Osel)
  25.         {
  26.         objectop(i, SEL, DEL);
  27.         objmove(i, x, y);
  28.         objectop(i, DEL, SEL);
  29.         }
  30.     }
  31.     }
  32.  
  33. tugunselect(xs, ys, xe, ye)
  34.     {
  35.     int i;
  36. /*
  37.  * set flag and record last movement for undo
  38.  */
  39.     unx =  xs;
  40.     uny =  ys;
  41.     unxe = xe;
  42.     unye = ye;
  43.     undo = UNDOTUG;
  44. /*
  45.  * do the tug
  46.  */
  47.     if (anysel) return;
  48.     forobjects
  49.     {
  50.     if (Oundel && objcantug(i, xs, ys))
  51.         {
  52.         objectop(i, UNDEL, DEL);
  53.         objtug(i, xs, ys, xe, ye);
  54.         objectop(i, DEL, UNDEL);
  55.         }
  56.     }
  57.     }
  58.  
  59. copyattr(j, i)
  60.     {
  61.     objs[j]->stat = Ostat;
  62.     objs[j]->type = Otype;
  63.     objs[j]->x0 = Oxs;
  64.     objs[j]->y0 = Oys;
  65.     objs[j]->x1 = Oxe;
  66.     objs[j]->y1 = Oye;
  67.     objs[j]->align = Oalign;
  68.     objs[j]->emph = Oemph;
  69.     objs[j]->size = Osize;
  70.     objs[j]->group = Ogroup;
  71.     if (Otext) objs[j]->text = salloc(Otext);
  72.     }
  73.  
  74. copysel()
  75.     {
  76.     int i, j, g, dx, dy;
  77.     if (!anysel) return;
  78.     dx = tickflag ? tx : DEFCOPYWID;
  79.     dy = tickflag ? ty : DEFCOPYWID;
  80.     g = uniquegroup();
  81.     forobjects
  82.     {
  83.     if (Osel)
  84.         {
  85.         j = objalloc(Otype);
  86.         copyattr(j, i);
  87.         objs[j]->x0 = Oxs+dx;
  88.         objs[j]->y0 = Oys+dy;
  89.         if (Otype != TEXT)
  90.             {
  91.         objs[j]->x1 = Oxe+dx;
  92.             objs[j]->y1 = Oye+dy;
  93.         }
  94.         objs[j]->group = g;
  95.         objs[j]->stat = DEL;
  96.         objectop(i, SEL, UNDEL);
  97.         objectop(j, DEL, UNDEL);
  98.         }
  99.     }
  100.     if (markobj) markupdate(markx+dx, marky+dy);
  101.     }
  102.