home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / VILE327.ZIP / VILE327.TAR / vile3.27 / wordmov.c < prev    next >
C/C++ Source or Header  |  1992-12-14  |  7KB  |  398 lines

  1. /* These routines report on transitions between word boundaries, both 
  2.  *    in the punctuated vi sense, and in the whitespace/darkspace
  3.  *    sense.  The transition is reported _after_ it has occurred.  You
  4.  *    need to back up to get to the char. before the transition.
  5.  *    Written for vile by Paul Fox, (c)1990
  6.  *
  7.  * $Log: wordmov.c,v $
  8.  * Revision 1.5  1992/05/16  12:00:31  pgf
  9.  * prototypes/ansi/void-int stuff/microsoftC
  10.  *
  11.  * Revision 1.4  1991/11/08  13:02:46  pgf
  12.  * ifdefed unneeded funcs
  13.  *
  14.  * Revision 1.3  1991/08/07  12:35:07  pgf
  15.  * added RCS log messages
  16.  *
  17.  * revision 1.2
  18.  * date: 1991/06/25 19:53:49;
  19.  * massive data structure restructure
  20.  * 
  21.  * revision 1.1
  22.  * date: 1990/09/21 10:26:27;
  23.  * initial vile RCS revision
  24.  */
  25.  
  26. #include    <stdio.h>
  27. #include "estruct.h"
  28. #include "edef.h"
  29.  
  30.  
  31. #define WASSPACE 0
  32. #define ISSPACE 0
  33. #define WASIDENT 1
  34. #define ISIDENT 1
  35. #define WASOTHER 2
  36. #define ISOTHER 2
  37. #define WASNL 3
  38. #define ISNL 3
  39.  
  40. static int ochartype;
  41.  
  42. void
  43. setchartype()
  44. {
  45.     ochartype = getchartype();
  46. }
  47.  
  48. int
  49. getchartype()
  50. {
  51.     register int    c;
  52.  
  53.     if (is_at_end_of_line(DOT))
  54.         return (ISNL);
  55.     else
  56.         c = char_at(DOT);
  57.     return (isspace(c) ? ISSPACE : 
  58.             ( isident(c) ? ISIDENT : ISOTHER ) );
  59. }
  60.  
  61.  
  62. int
  63. isnewwordf()
  64. {
  65.     register int    ret = FALSE;
  66.     register int    type;
  67.  
  68.     type = getchartype();
  69.  
  70.     switch (ochartype) {
  71.     case WASNL:
  72.     case WASSPACE:
  73.         switch (type) {
  74.         case ISNL:    if (doingopcmd) { ret = SORTOFTRUE; break;}
  75.         case ISSPACE: ret = FALSE;    break;
  76.         case ISIDENT:
  77.         case ISOTHER: ret = TRUE;    break;
  78.         }
  79.         break;
  80.     case WASIDENT:
  81.     case WASOTHER:
  82.         switch (type) {
  83.         case ISNL:    if (doingopcmd) { ret = SORTOFTRUE; break;}
  84.         case ISSPACE: if (doingopcmd && opcmd != OPDEL) 
  85.                         { ret = SORTOFTRUE; break;}
  86.         case ISIDENT:
  87.         case ISOTHER: ret = FALSE;    break;
  88.         }
  89.         break;
  90.     }
  91.     ochartype = type;
  92.     return (ret);
  93. }
  94.  
  95. int
  96. isnewwordb()
  97. {
  98.     register int    ret = FALSE;
  99.     register int    type;
  100.  
  101.     type = getchartype();
  102.  
  103.     switch (ochartype) {
  104.     case WASNL:
  105.     case WASSPACE:
  106.         ret = FALSE;    break;
  107.     case WASIDENT:
  108.         switch (type) {
  109.         case ISNL:
  110.         case ISSPACE: ret = TRUE;    break;
  111.         case ISIDENT:
  112.         case ISOTHER: ret = FALSE;    break;
  113.         }
  114.         break;
  115.     case WASOTHER:
  116.         switch (type) {
  117.         case ISNL:
  118.         case ISSPACE: ret = TRUE;    break;
  119.         case ISIDENT:
  120.         case ISOTHER: ret = FALSE;    break;
  121.         }
  122.         break;
  123.     }
  124.     ochartype = type;
  125.     return (ret);
  126. }
  127.  
  128. int
  129. isnewviwordf()
  130. {
  131.     register int    ret = FALSE;
  132.     register int    type;
  133.  
  134.     type = getchartype();
  135.  
  136.     switch (ochartype) {
  137.     case WASNL:
  138.     case WASSPACE:
  139.         switch (type) {
  140.         case ISNL:    if (doingopcmd) { ret = SORTOFTRUE; break;}
  141.         case ISSPACE: ret = FALSE;    break;
  142.         case ISIDENT:
  143.         case ISOTHER: ret = TRUE;    break;
  144.         }
  145.         break;
  146.     case WASIDENT:
  147.         switch (type) {
  148.         case ISNL:    if (doingopcmd) { ret = SORTOFTRUE; break;}
  149.         case ISSPACE: if (doingopcmd && opcmd != OPDEL) 
  150.                         { ret = SORTOFTRUE; break;}
  151.         case ISIDENT: ret = FALSE;    break;
  152.         case ISOTHER: ret = TRUE;    break;
  153.         }
  154.         break;
  155.     case WASOTHER:
  156.         switch (type) {
  157.         case ISNL:    if (doingopcmd) { ret = SORTOFTRUE; break;}
  158.         case ISSPACE: if (doingopcmd && opcmd != OPDEL) 
  159.                         { ret = SORTOFTRUE; break;}
  160.         case ISOTHER: ret = FALSE;    break;
  161.         case ISIDENT: ret = TRUE;    break;
  162.         }
  163.         break;
  164.     }
  165.     ochartype = type;
  166.     return (ret);
  167. }
  168.  
  169. int
  170. isnewviwordb()
  171. {
  172.     register int    ret = FALSE;
  173.     register int    type;
  174.  
  175.     type = getchartype();
  176.  
  177.     switch (ochartype) {
  178.     case WASNL:
  179.     case WASSPACE:
  180.         ret = FALSE;    break;
  181.     case WASIDENT:
  182.         switch (type) {
  183.         case ISNL:
  184.         case ISSPACE:
  185.         case ISOTHER: ret = TRUE;    break;
  186.         case ISIDENT: ret = FALSE;    break;
  187.         }
  188.         break;
  189.     case WASOTHER:
  190.         switch (type) {
  191.         case ISNL:
  192.         case ISSPACE:
  193.         case ISIDENT: ret = TRUE;    break;
  194.         case ISOTHER: ret = FALSE;    break;
  195.         }
  196.         break;
  197.     }
  198.     ochartype = type;
  199.     return (ret);
  200. }
  201.  
  202.  
  203. #ifdef NEEDED
  204. int
  205. isendwordb()
  206. {
  207.     register int    ret = FALSE;
  208.     register int    type;
  209.  
  210.     type = getchartype();
  211.  
  212.     switch (ochartype) {
  213.     case WASNL:
  214.     case WASSPACE:
  215.         switch (type) {
  216.         case ISNL:
  217.         case ISSPACE: ret = FALSE;    break;
  218.         case ISIDENT:
  219.         case ISOTHER: ret = TRUE;    break;
  220.         }
  221.         break;
  222.     case WASIDENT:
  223.     case WASOTHER:
  224.         ret = FALSE;    break;
  225.     }
  226.     ochartype = type;
  227.     return (ret);
  228. }
  229.  
  230. int
  231. isendviwordb()
  232. {
  233.     register int    ret = FALSE;
  234.     register int    type;
  235.  
  236.     type = getchartype();
  237.  
  238.     switch (ochartype) {
  239.     case WASNL:
  240.     case WASSPACE:
  241.         switch (type) {
  242.         case ISNL:
  243.         case ISSPACE: ret = FALSE;    break;
  244.         case ISOTHER:
  245.         case ISIDENT: ret = TRUE;    break;
  246.         }
  247.         break;
  248.     case WASIDENT:
  249.         switch (type) {
  250.         case ISNL:
  251.         case ISSPACE:
  252.         case ISOTHER: ret = TRUE;    break;
  253.         case ISIDENT: ret = FALSE;    break;
  254.         }
  255.         break;
  256.     case WASOTHER:
  257.         switch (type) {
  258.         case ISNL:
  259.         case ISSPACE:
  260.         case ISIDENT: ret = TRUE;    break;
  261.         case ISOTHER: ret = FALSE;    break;
  262.         }
  263.         break;
  264.     }
  265.     ochartype = type;
  266.     return (ret);
  267. }
  268. #endif /* NEEDED */
  269.  
  270. int
  271. isendwordf()
  272. {
  273.     register int    ret = FALSE;
  274.     register int    type;
  275.  
  276.     type = getchartype();
  277.  
  278.     switch (ochartype) {
  279.     case WASNL:
  280.     case WASSPACE:
  281.         ret = FALSE;    break;
  282.     case WASIDENT:
  283.         switch (type) {
  284.         case ISNL:
  285.         case ISSPACE:
  286.             if (doingopcmd) ret = SORTOFTRUE;
  287.             else ret = TRUE;
  288.             break;
  289.         case ISIDENT:
  290.         case ISOTHER: ret = FALSE;    break;
  291.         }
  292.         break;
  293.     case WASOTHER:
  294.         switch (type) {
  295.         case ISNL:
  296.         case ISSPACE:
  297.             if (doingopcmd) ret = SORTOFTRUE;
  298.             else ret = TRUE;
  299.             break;
  300.         case ISIDENT:
  301.         case ISOTHER: ret = FALSE;    break;
  302.         }
  303.         break;
  304.     }
  305.     ochartype = type;
  306.     return (ret);
  307. }
  308.  
  309. int
  310. isendviwordf()
  311. {
  312.     register int    ret = FALSE;
  313.     register int    type;
  314.  
  315.     type = getchartype();
  316.  
  317.     switch (ochartype) {
  318.     case WASNL:
  319.     case WASSPACE:
  320.         ret = FALSE;    break;
  321.     case WASIDENT:
  322.         switch (type) {
  323.         case ISNL:
  324.         case ISSPACE:
  325.         case ISOTHER:
  326.             if (doingopcmd) ret = SORTOFTRUE;
  327.             else ret = TRUE;
  328.             break;
  329.         case ISIDENT: ret = FALSE;    break;
  330.         }
  331.         break;
  332.     case WASOTHER:
  333.         switch (type) {
  334.         case ISNL:
  335.         case ISSPACE:
  336.         case ISIDENT:
  337.             if (doingopcmd) ret = SORTOFTRUE;
  338.             else ret = TRUE;
  339.             break;
  340.         case ISOTHER: ret = FALSE;    break;
  341.         }
  342.         break;
  343.     }
  344.     ochartype = type;
  345.     return (ret);
  346. }
  347.  
  348. #ifdef template
  349. int
  350. isANYTHING()
  351. {
  352.     register int    ret = FALSE;
  353.     register int    type;
  354.  
  355.     type = getchartype();
  356.  
  357.     switch (ochartype) {
  358.     case WASNL:
  359.     case WASSPACE:
  360.         switch (type) {
  361.         case ISNL:
  362.         case ISSPACE:
  363.             ret = FALSE;    break;
  364.         case ISIDENT:
  365.             ret = FALSE;    break;
  366.         case ISOTHER:
  367.             ret = FALSE;    break;
  368.         }
  369.         break;
  370.     case WASIDENT:
  371.         switch (type) {
  372.         case ISNL:
  373.         case ISSPACE:
  374.             ret = TRUE;    break;
  375.         case ISIDENT:
  376.             ret = FALSE;    break;
  377.         case ISOTHER:
  378.             ret = TRUE;    break;
  379.         }
  380.         break;
  381.     case WASOTHER:
  382.         switch (type) {
  383.         case ISNL:
  384.         case ISSPACE:
  385.             ret = TRUE;    break;
  386.         case ISIDENT:
  387.             ret = TRUE;    break;
  388.         case ISOTHER:
  389.             ret = FALSE;    break;
  390.         }
  391.         break;
  392.     }
  393.     ochartype = type;
  394.     return (ret);
  395. }
  396. #endif /* template */
  397.  
  398.