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