home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 389.lha / dme_v1.40 / src / mods.c < prev    next >
C/C++ Source or Header  |  1990-07-03  |  3KB  |  167 lines

  1.  
  2. /*
  3.  *  KTS.C
  4.  *
  5.  *  Additional DME commands written by Kevin T. Seghetti fixed up and
  6.  *  incorporated by Matt Dillon 17 April 1988.
  7.  */
  8.  
  9. #include "defs.h"
  10. #include <intuition/intuitionbase.h>
  11.  
  12. #define BLOCKDEPTH  5
  13. #define PINGDEPTH   10
  14.  
  15. static long BSstack[BLOCKDEPTH];
  16. static long BEstack[BLOCKDEPTH];
  17. static ED   *Bp[BLOCKDEPTH];
  18. static int  CurrDepth = 0;
  19.  
  20. static long PingLine[PINGDEPTH];
  21. static long PingCol[PINGDEPTH];
  22. static ED   *PingWin[PINGDEPTH];
  23.  
  24. void
  25. PMAdd()
  26. {
  27. }
  28.  
  29. void
  30. PMRem()
  31. {
  32. }
  33.  
  34. void
  35. PMKill(ep)
  36. ED *ep;
  37. {
  38.     short i, j;
  39.  
  40.     for (i = 0; i < PINGDEPTH; ++i) {       /*  remove ping-pong marks  */
  41.     if (PingWin[i] == ep)
  42.         PingWin[i] = NULL;
  43.     }
  44.     for (i = j = 0; i < CurrDepth; ++i) {   /*  remove block marks      */
  45.     Bp[j] = Bp[i];
  46.     if (Bp[i] != ep)
  47.         ++j;
  48.     }
  49.     CurrDepth = j;
  50. }
  51.  
  52. do_pushmark()
  53. {
  54.     text_sync();
  55.     if (blockok()) {
  56.     if (CurrDepth == BLOCKDEPTH) {
  57.         title("pushmark: stack limit reached");
  58.         return(-1);
  59.     }
  60.     BSstack[CurrDepth] = BSline;
  61.     BEstack[CurrDepth] = BEline;
  62.     Bp[CurrDepth] = BEp;
  63.  
  64.     ++CurrDepth;
  65.     text_redrawblock(0);
  66.     }
  67.     return(0);
  68. }
  69.  
  70. void
  71. do_popmark()
  72. {
  73.     text_sync();
  74.  
  75.     if (!CurrDepth) {           /*  no error message on purpose */
  76.     text_redrawblock(0);    /*  remove any existing block   */
  77.     return;
  78.     }
  79.     text_redrawblock(0);
  80.     --CurrDepth;
  81.     BSline = BSstack[CurrDepth];
  82.     BEline = BEstack[CurrDepth];
  83.     BEp = Bp[CurrDepth];
  84.     if (BEp == NULL || BEline >= BEp->Lines) {
  85.     BEp = NULL;
  86.     BSline = BEline = -1;
  87.     } else
  88.     text_redrawblock(1);
  89. }
  90.  
  91. void
  92. do_swapmark()
  93. {
  94.     short i;
  95.     long *ptmp;
  96.     long tmp;
  97.  
  98.     if (do_pushmark() < 0)
  99.     return;
  100.     i = CurrDepth - 2;
  101.     if (i >= 0) {
  102.     ptmp = PingLine + i;
  103.     tmp = ptmp[0]; ptmp[0] = ptmp[1]; ptmp[1] = tmp;
  104.     ptmp = PingCol + i;
  105.     tmp = ptmp[0]; ptmp[0] = ptmp[1]; ptmp[1] = tmp;
  106.     ptmp = (long *)PingWin + i;
  107.     tmp = ptmp[0]; ptmp[0] = ptmp[1]; ptmp[1] = tmp;
  108.     }
  109.     do_popmark();
  110. }
  111.  
  112. void
  113. do_purgemark()
  114. {
  115.     CurrDepth = 0;
  116. }
  117.  
  118. void
  119. do_ping()
  120. {
  121.     uword num = atoi(av[1]);
  122.  
  123.     if (num >= PINGDEPTH) {
  124.     title("ping: out of range");
  125.     return;
  126.     }
  127.     PingLine[num]= Ep->Line;
  128.     PingCol[num] = Ep->Column;
  129.     PingWin[num] = Ep;
  130.     title("Line marked");
  131. }
  132.  
  133. void
  134. do_pong()
  135. {
  136.     uword num = atoi(av[1]);
  137.     extern IBASE *IntuitionBase;
  138.  
  139.     text_sync();
  140.     if (num < 0 || num >= PINGDEPTH || !PingWin[num]) {
  141.     title("pong: range error or nothing marked");
  142.     return;
  143.     }
  144.     text_cursor(1);
  145.     text_switch(PingWin[num]->Win);
  146.     text_cursor(0);
  147.  
  148.     if (IntuitionBase->ActiveWindow != Ep->Win) {
  149.     WindowToFront(Ep->Win);
  150.     ActivateWindow(Ep->Win);
  151.     }
  152.     if ((Ep->Line = PingLine[num]) >= Ep->Lines) {
  153.     PingLine[num] = Ep->Line = Ep->Lines - 1;
  154.     }
  155.     Ep->Column = PingCol[num];
  156.     text_load();
  157.     text_sync();
  158. }
  159.  
  160. void
  161. do_undo()
  162. {
  163.     text_load();
  164.     text_redisplaycurrline();
  165. }
  166.  
  167.