home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / editor / tvx_edit.arc / TVX_2.C < prev    next >
C/C++ Source or Header  |  1986-03-17  |  34KB  |  1,389 lines

  1. /* ========================================================================
  2.  
  3.     tvx_2.c - Part 2 of main TVX code 
  4.  
  5. ============================================================================ */
  6.  
  7. #include "tvx_defs.ic"        /* note tv_defs will #include stdio.h */
  8. #include "tvx_glbl.ic"
  9.  
  10. /* =============================>>> KILLIN <<<============================= */
  11.   killin(cnt)
  12.   int cnt;
  13.   { /* ##  killin - kill cnt lines */
  14.  
  15.     SLOW int i,lim;
  16.     SLOW int from,to,ityp,istrt;
  17.     SLOW int s_curlin, s_curchr, s_echo;
  18.  
  19.     if (cut_mode)        /* does kill "cut" */
  20.       {
  21.     s_echo = echof;
  22.     echof = FALSE;        /* turn off echo */
  23.     s_curlin = curlin;    /* save line */
  24.     save(cnt,FALSE);    /* save those lines */
  25.     curlin = s_curlin;
  26.     echof = s_echo;        /* restore things */
  27.       }
  28.  
  29.     if (cnt+curlin >= nxtlin || (curlin == nxtlin-1 && cnt >= 0))
  30.       {             /* special case: deleting rest of buffer */
  31.     svklin(nxtlin-1);
  32.     for (i = curlin ; i <= nxtlin-1 ; )
  33.         kline(*(lines+i++));
  34.     nxtlin = curlin--;
  35.     if (curlin > 0)
  36.       {
  37.         curchr = *(lines+curlin)+1;
  38.         newscr();
  39.       }
  40.     else
  41.       {
  42.         curchr = 0;
  43.         tvclr();
  44.       }
  45. #ifdef SCR_BUF
  46.     ttflush();
  47. #endif
  48.     return;
  49.       }
  50.  
  51.     if (cnt < 0)        /* negative kill */
  52.       {
  53.     cnt = min(-cnt,curlin-1);    /* all upwards? */
  54.     dwnlin(-cnt);        /* go up that far */
  55.       }
  56.  
  57.     if (cnt != 0)
  58.       {
  59.     range(cnt,&to,&from);    /* calculate the line numbers to kill */
  60.  
  61.     curlin=to;        /* remember new current line */
  62.  
  63.     svklin(from);    /* save one line */
  64.     for (i = to ; i <= from ; )        /* mark lines deleted */
  65.         kline(*(lines+i++));
  66.  
  67.     lim = min(nxtlin-1,mxline);
  68.     for (++from ; from <= lim ; )
  69.       {
  70.         *(lines+to++) = *(lines+from++);    /* copy next line number */
  71.       }
  72.  
  73.     nxtlin=to;
  74.     if (nxtlin == curlin)
  75.         --curlin;        /* don't go past end */
  76.     curchr = *(lines+curlin)+1;    /* remember new current character */
  77.  
  78.     if (cnt >= 0 && curlin+(tvlins-tvdlin) < nxtlin &&
  79.       tvdlin < tvlins)    /* killing down */
  80.       {
  81.         tvxy(1,tvy);    /* get to start of line */
  82.         ityp=min(tvlins-tvdlin+1,nxtlin-curlin);
  83.         if (cnt!=1 || !ckline[0])
  84.           {
  85.         tvescr();    /* erase the screen */
  86.         istrt=curlin;
  87.           }
  88.         else
  89.           {
  90.         sendcs(ckline);
  91.         istrt=curlin+ityp-1;
  92.         tvxy(1,tvlins);
  93.         ityp=1;
  94.           }
  95.         tvtype(istrt,ityp);
  96.         tvhdln();    /* home to display line */
  97.       }
  98.     else if ( cnt != 1)    /* neg and > 1 too complicated */
  99.         newscr();            /* kill up, just retype whole screen */
  100.     else if (nxtlin < tvlins)    /* top part of screen */
  101.       {
  102.         if (*ckline)        /* kill line defined */
  103.           {
  104.         tvxy(1,tvy);        /* get to start of line */
  105.         sendcs(ckline);        /* just need to kill the line */
  106.         tvhdln();
  107.           }
  108.         else
  109.         newscr();        /* rewrite it all */
  110.       }
  111.     else if (tvdlin < tvlins)    /* must be in last part of buffer */
  112.       {
  113.         if (*ckline && *ctopb)    /* kill line & topb defined */
  114.           {
  115.         tvxy(1,tvy);        /* get to start of line */
  116.         sendcs(ckline);        /* kill the line */
  117.         if (curlin-tvdlin > 0)    /* something to scroll */
  118.           {
  119.             tvtopb(1);        /* scroll down one line */
  120.             tvtype(curlin-tvdlin,1);    /* type the offscreen line */
  121.             tvdlin++;        /* will start display on next line */
  122.           }
  123.         tvhdln();
  124.           }
  125.         else
  126.         newscr();        /* rewrite it all */
  127.       }
  128.     else        /* if all else fails */
  129.         newscr();
  130.       }
  131. #ifdef SCR_BUF
  132.     ttflush();
  133. #endif
  134.   }
  135.  
  136. /* =============================>>> KLINE  <<<============================= */
  137.   kline(ptr)
  138.   BUFFINDEX ptr;
  139.   {  /* kline - kill off the line beginning at buff position ptr */
  140.  
  141.     SLOW BUFFINDEX i;
  142.  
  143.     for (i=ptr; *(buff+i) != ENDLINE ; )    /* insert GARBAGE to kill */
  144.     *(buff+i++) = GARBAGE;
  145.  
  146.     *(buff+i) = GARBAGE;        /* kill the endline */
  147.   }
  148.  
  149. /* =============================>>> KPREV  <<<============================= */
  150.   kprev()
  151.   { /* kprev - kill from cursor to beginning of line */
  152.  
  153.     FAST int chrs;
  154.  
  155.     svklin(curlin);                /* save one line */
  156.     chrs = curchr - *(lines+curlin) - 1;    /* how much to delete */
  157.     if (chrs > 0)
  158.     delnxt(-chrs);    /* won't cause a combine, so don't worry */
  159.   }
  160.  
  161. /* =============================>>> KREST  <<<============================= */
  162.   krest()
  163.   { /* krest - kill the rest of the line, not including cursor and ENDLINE */
  164.  
  165.     SLOW int chrs;
  166.     SLOW BUFFINDEX i;
  167.  
  168.     svklin(curlin);    /* save one line */
  169.     chrs=0;
  170.     for (i=curchr; *(buff+i)!=ENDLINE; ++i)
  171.     ++chrs;     /* count how much to delete */
  172.     if (chrs > 0)
  173.     delnxt(chrs);    /* won't cause combine, so don't worry */
  174.   }
  175.  
  176. /* =============================>>> NEATEN <<<============================= */
  177.   int neaten(count)
  178.   int count;
  179.   {  /* neaten - fill lines to current margin */
  180.  
  181.     SLOW int oldef, i;
  182.     SLOW BUFFINDEX linbeg;
  183.     SLOW int retval;
  184.  
  185.     retval = TRUE;
  186.     oldef = echof;
  187.     if (count > 1)
  188.     echof = FALSE;
  189.     if (wraplm <= 1 || curlin >= nxtlin-1)
  190.     goto l900;        /* work only if wrap limit turned on */
  191.  
  192.     for (i=1 ; i<=count ; ++i)
  193.       {
  194.     beglin();        /* start at beginning of line */
  195.     if (curlin >= nxtlin-1)
  196.         goto l900;
  197.  
  198.     /* don't neaten leading space, cr, period or tab */
  199.  
  200.     if (*(buff+curchr) == '.')
  201.       {
  202.         dwnlin(1);
  203.         continue;        /* skip dot commands */
  204.       }
  205.  
  206.     while (*(buff+curchr)== ' ' || *(buff+curchr)==ENDLINE
  207.       || *(buff+curchr) == 9)
  208.       {
  209.         right(1);    /* skip this line */
  210.       }
  211.  
  212.     do
  213.       {
  214.         if (*(buff+curchr) == ENDLINE)
  215.           {
  216.         if (tvx+leftmg < wraplm)    /* combine lines! */
  217.           {
  218.             linbeg = *(lines+curlin+1)+1;
  219.             /* pt to first char of next line */
  220.             if (*(buff+linbeg) == ' ' || *(buff+linbeg) == ENDLINE
  221.               || *(buff+linbeg) == 9 || *(buff+linbeg) == '.')
  222.               {
  223.             dwnlin(1);
  224.             break;    /* no more combining */
  225.               }
  226.             if (! neat1(1,32))
  227.             goto l990;
  228.             goto NEATNEXT;    /* tab over another word */
  229.           }
  230.         else
  231.           {
  232.             dwnlin(1);    /* no more combining on line */
  233.             break;
  234.           }
  235.           }
  236.  
  237. NEATNEXT:
  238.         if (*(buff+curchr-1)==' ' && tvx+leftmg >= wraplm)    /* change to cr */
  239.           {
  240.         if (! neat1(-1,CR))    /* delete the blank */
  241.             goto l990;
  242.         break;
  243.           }
  244.         wordr(1);
  245.       } /*# end of the repeat */
  246.     while (1);
  247.       } /*# end of the for     */
  248. l900:
  249.     echof = oldef;
  250.     if (oldef && count > 1)
  251.     newscr();
  252. #ifdef SCR_BUF
  253.     else
  254.     ttflush();
  255. #endif
  256.  
  257.     return (retval);
  258.  
  259. l990:                /* failure return */
  260.     retval = FALSE;
  261.     goto l900;
  262.   }
  263.  
  264. /* =============================>>> NEAT1  <<<============================= */
  265.   neat1(dir, val)
  266.   int dir, val;
  267.   {  /* change character dir to val */
  268.  
  269.     SLOW int oldwrp;
  270.  
  271.     oldwrp = wraplm;
  272.     wraplm = 0;
  273.     if (! delnxt(dir))
  274.     goto l900;
  275.     if (! ins_chr(val))
  276.     goto l900;
  277.     wraplm = oldwrp;
  278.     return (TRUE);
  279. l900:
  280.     wraplm = oldwrp;
  281.     return (FALSE);
  282.   }
  283.  
  284. /* =============================>>> NEWSCR <<<============================= */
  285.   newscr()
  286.   { /* newscr - retype entire screen, updating cursor position if necessary */
  287.  
  288.    SLOW int ibeg,cnt;
  289.  
  290.     if (tvlins != tvhardlines || nxtlin-1 <= tvlins)
  291.     /* two kinds of screen rewrite */
  292.     tvclr();            /* clear the screen and home */
  293.     else
  294.     tvxy(1,1);
  295.  
  296.     finddl(&ibeg,&cnt);     /* calculate where it will go */
  297.     tvtype(ibeg,cnt);        /* type it out */
  298.     tvhdln();            /* home to display line */
  299. #ifdef SCR_BUF
  300.     ttflush();
  301. #endif
  302.   }
  303.  
  304. /* =============================>>> OPENLN <<<============================= */
  305.   openln(cnt)
  306.   int cnt;
  307.   {  /* openln - open a new line */
  308.  
  309.     FAST int i;
  310.     SLOW int pcnt, oldauto;
  311.  
  312.     oldauto = autoin; autoin = FALSE;    /* don't allow autoindent */
  313.     pcnt = cnt >= 0 ? cnt : (-cnt);    /* only allow positive opens */
  314.     for (i=1; i<=pcnt; ++i)
  315.     ins_chr(CR);    /* insert right number of newlines */
  316.     dwnlin(-pcnt);    /* and goto beginning of the opened line */
  317.     endlin();
  318.     autoin = oldauto;
  319. #ifdef SCR_BUF
  320.     ttflush();
  321. #endif
  322.   }
  323.  
  324. /* =============================>>> RANGE  <<<============================= */
  325.   range(cnt,lbeg,lend)
  326.   int cnt,*lbeg,*lend;
  327.   { /* determine a legal line number range given cnt */
  328.  
  329.     if (cnt <= 0)
  330.       {
  331.     *lbeg=max(curlin+cnt,1);
  332.     *lend=curlin;
  333.     if (cnt < 0)
  334.        *lend = (*lend)-1;
  335.       }
  336.     else
  337.       {
  338.     *lbeg=curlin;
  339.     *lend=min(nxtlin-1,curlin+cnt-1);
  340.       }
  341.  }
  342.  
  343. /* =============================>>> RIGHT  <<<============================= */
  344.   right(cnt)
  345.   int cnt;
  346.   {  /* move cursor right cnt characters
  347.     newlines count as one character */
  348.  
  349.     FAST int change,i;
  350.  
  351.     change=0;            /* nochange yet */
  352.     if (cnt > 0)
  353.       {
  354.     for (i = 1 ; i <= cnt ; ++i)
  355.       {
  356.         if (*(buff+curchr)==ENDLINE)
  357.           {
  358.         if (curlin+1 >= nxtlin)
  359.             break;        /* don't go beyond end! */
  360.         ++curlin;
  361.         ++change;        /* we've gone down one line */
  362.         curchr = *(lines+curlin)+1;
  363.           }
  364.         else
  365.         ++curchr;
  366.       }
  367.       }
  368.     else if (cnt < 0)
  369.       {
  370.     cnt=(-cnt);
  371.     for (i = 1 ; i <= cnt ; ++i)
  372.       {
  373.         --curchr;
  374.         if (*(buff+curchr) == BEGLINE)
  375.           {
  376.         if (curlin > 1)
  377.           {
  378.             --curlin;
  379.             --change;
  380.             for (curchr = *(lines+curlin) ; *(buff+curchr)!=ENDLINE ;
  381.               ++curchr)
  382.             ;    /* bump curchr to end of the line */
  383.           }
  384.         else
  385.           {
  386.             ++curchr;
  387.             break;
  388.           }
  389.           }
  390.       }
  391.       }
  392.     if (change != 0)        /* don't do unnecessary change */
  393.     update(change);
  394.     tvhdln();
  395. #ifdef SCR_BUF
  396.     ttflush();
  397. #endif
  398.   }
  399.  
  400. /* =============================>>> SEARCH <<<============================= */
  401.   search(lexcnt,iarg)
  402.   int lexcnt,iarg;
  403.   { /* search - search down in buffer for a pattern */
  404.  
  405.     SLOW char chr,c0,c1,c2;
  406.     static int slines;
  407.     SLOW int oldx,oldy,oldlin;
  408.     SLOW int change, searchv, lininc, newln, fold_wild;
  409.     SLOW int l,lbeg,is;
  410.     SLOW BUFFINDEX ib, bbeg, oldpos, nbbeg;
  411.     FAST int i;
  412.  
  413.     SLOW int how_match, set_len;    /* how wild card matching happens */
  414.     char *cp, *s_getset();
  415.     SLOW int w_len,inset,extra_len;        /* length of match */
  416.  
  417.     static int lastsb = 0;
  418.  
  419.     lininc = (lexcnt >= 0 ) ? 1 : (-1);
  420.     searchv = FALSE;
  421.     newln = FALSE;        /* haven't rubbed out 2nd line */
  422.  
  423.     oldpos = curchr;        /* need to remember for -f */
  424.     oldx = tvx ; oldy = tvy ; oldlin = curlin;
  425.  
  426.     ins_mode = TRUE;        /* so ttymode can echo right */
  427.  
  428.     if (! iarg)
  429.     goto l100;        /* get arg form search buffer */
  430.  
  431.     tvmsg("Find?",FALSE);
  432.  
  433.     if (! grptch(&chr))
  434.     goto l9000;
  435.  
  436.     slines=1;            /* only one line so far */
  437.     for (i = 0; chr != ESC && i < 100; ++i)    /* read in the pattern */
  438.       {
  439.     if (chr == delkey && rptcnt[rptuse] <= 0) /* edit interactive input */
  440.       {
  441.         --i;        /* adjust i for for loop ++i */
  442.         if (i >= 0)        /* wipe out chars on screen */
  443.           {
  444.         if (sbuff[i] == 0)    /* newline */
  445.           {
  446.              --slines; ctrlch(CR); newln = TRUE;
  447.           }
  448.         else
  449.           {
  450.             if (newln)
  451.               {
  452.             tvcout('\\');
  453.             ctrlch(sbuff[i]);
  454.               }
  455.             else
  456.               {
  457.             tvcout(BACKSPACE);
  458.             tvcout(' ');
  459.             tvcout(BACKSPACE);
  460.             if (sbuff[i] < ' ' && sbuff[i] != 27)
  461.               {
  462.                 tvcout(BACKSPACE);
  463.                 tvcout(' ');
  464.                 tvcout(BACKSPACE);
  465.               }
  466.               }
  467.           }
  468.         --i;        /* wipe the character */
  469.           }
  470. #ifdef SCR_BUF
  471.         ttflush();
  472. #endif
  473.         gkbd(&chr);        /* get new char */
  474.         continue;
  475.       }
  476.     sbuff[i]=chr;        /* stuff it away */
  477.     if (chr == LF)
  478.       {
  479. #ifdef USELF
  480.         tvcout(chr);    /*$$$ to ignore lfs in cr/lf systems */
  481. #endif
  482.       }
  483.     else if (chr == CR)
  484.       {
  485.         if (rptcnt[rptuse] <= 0)
  486.         ctrlch(chr);
  487.         ++slines;
  488.         sbuff[i]=0;    /* end of a line */
  489.       }
  490.     else
  491.         ctrlch(chr);    /* echo character, handline control chars */
  492.  
  493. #ifdef SCR_BUF
  494.         ttflush();
  495. #endif
  496. /*# fetch the next character */
  497.     if (! grptch(&chr))
  498.         goto l9000;
  499.       }
  500.  
  501.     tvcout('$');    /* echo the escape */
  502.     tvxy(oldx,oldy);    /* return to old location */
  503.  
  504.     if (i>0)            /* we got a new pattern */
  505.       {
  506.     lastsb=i-1;        /* last valid character */
  507.     sbuff[i] = 0;        /* make sure an EOS */
  508.       }
  509.     fixend();
  510.  
  511. l100:
  512.     extra_len = 0;
  513.     if (lininc < 0)
  514.     endlin();
  515.     bbeg = curchr;        /* start from current character first time */
  516.     c0 = sbuff[0];        /* initial char of pattern */
  517.     if (!xcases)            /* get initial character of pattern */
  518.     c0 = (c0 >= 'A' && c0 <= 'Z') ? c0+' ' : c0;
  519.  
  520.     for (l = curlin ; l < nxtlin && l ; l += lininc)  /* l is same as l != 0 */
  521.       {
  522.     if ( !c0 )        /* !c0 same as c0 == 0 */
  523.       {
  524.         if (lastsb == 0)    /* matching cr only? */
  525.           {
  526.         dwnlin(1);    /* go down one line */
  527.         newscr();    /* screen needs updating */
  528.         goto l8000;
  529.           }
  530.         else
  531.           {
  532.         for (ib = bbeg; *(buff+ib); ++ib)
  533.             ;
  534.         goto l1000;
  535.           }
  536.       }
  537.  
  538. l900:
  539.     if (c0 < ' ')    /* save time, check if might be w.c. once */
  540.       {
  541.         ib = bbeg;
  542.         if (*(buff+ib))
  543.         goto l1000;
  544.       }
  545.  
  546.     for (ib=bbeg; *(buff+ib); ++ib)    /* search current line */
  547.       {
  548.         c2 = *(buff+ib);    /* next char of buffer */
  549.         if (!xcases)
  550.         c2 = (c2 >= 'A' && c2 <= 'Z') ? c2+' ' : c2;
  551.     
  552.         if (c2 != c0)
  553.         continue;        /* first characters don't match */
  554.         else if (lastsb == 0)
  555.           {         /* one character pattern */
  556.         curchr = ib+1;
  557.         curlin = l;
  558.         goto l5000;    /* successful match */
  559.           }
  560.         else
  561.           {
  562.         if ((c1 = sbuff[1]) < ' ')    /* possible wild? */
  563.             goto l1000;
  564.         c2 = *(buff+ib+1);
  565.         if (! xcases)    /* fold to lower case */
  566.           {
  567.             c1 = (c1 >= 'A' && c1 <= 'Z') ? c1+' ' : c1;
  568.             c2 = (c2 >= 'A' && c2 <= 'Z') ? c2+' ' : c2; /* clower */
  569.           }
  570.         if ( c1 != c2 )
  571.             continue;    /* first two don't match */
  572.         else
  573.             goto l1000;    /* first two match, so possibility */
  574.           }
  575.       }
  576.  
  577. /*    # fall thru => no match on this line */
  578. l950:
  579.     bbeg = *(lines+l+lininc)+1;    /* next beginning character */
  580.     continue;            /* go check next line */
  581.                     
  582. l1000:                /* we have two characters matching! */
  583.     nbbeg = ib;        /* beginning of possible match in buff */
  584.     lbeg = l;         /* current line we are searching */
  585.     how_match = 1;        /* assume exact match */
  586.     for (is = -1 ; ++is <= lastsb ; )
  587.       {
  588.         if ((c1 = sbuff[is]) < ' ')        /* possible wild card */
  589.           {
  590.         if (c1 == W_span)
  591.           {
  592.             extra_len--;
  593.             how_match = 2;        /* span match */
  594.             continue;            /* keep scanning search pat */
  595.           }
  596.         else if (c1 == W_skip)        /* skip? */
  597.           {
  598.             extra_len--;
  599.             how_match = 0;        /* skip match */
  600.             continue;            /* keep scanning search pat */
  601.           }
  602.         else if ((cp = s_getset(c1,&set_len,&fold_wild)) == NULL)    /* not wild */
  603.             goto NOT_WILD;        /* continue normally */
  604.          
  605.     /* ok, to here, then have possible wild card match */
  606.     
  607.         w_len = 0;
  608.  
  609.         for ( ; ; )
  610.           {
  611.             chr = *(buff + nbbeg);    /* pick up char */
  612.             if (fold_wild)        /* fold if not user */
  613.             chr = clower(chr);
  614.             if (chr == ENDLINE)        /* break on end of line */
  615.             break;            /* get out */
  616.     
  617.             inset = s_inset(chr,cp,set_len);    /* see if in set */
  618.             if ((how_match > 0 && inset) || (how_match == 0 && !inset))
  619.               {
  620.             nbbeg++;         /* bump to next char */
  621.             ++w_len;
  622.             if (how_match == 1)
  623.                     break;        /* only once on mode 1 */
  624.               }
  625.             else
  626.             break;
  627.           }
  628.  
  629.         if (w_len <= 0)
  630.           {
  631.             ++bbeg;     /* this part of line doesn't match */
  632.             extra_len = 0;
  633.             if (c0 == 0)
  634.             goto l950;
  635.             else
  636.             goto l900;    /* try rest of current line */
  637.           }
  638.  
  639.     /* to here, then exit from wild card match */
  640.         extra_len += w_len - 1;
  641.         how_match = 1;            /* back to 1 again */
  642.         continue;        /* leave cursor on 1st unmatched */
  643.           }
  644.  
  645. NOT_WILD:
  646.         c2 = *(buff+nbbeg);
  647.         if (! xcases)    /* fold to lower case */
  648.           {
  649.         c1 = (c1 >= 'A' && c1 <= 'Z') ? c1+' ' : c1;
  650.         c2 = (c2 >= 'A' && c2 <= 'Z') ? c2+' ' : c2; /* clower */
  651.           }
  652.  
  653.         if ( c1 != c2 )
  654.           {
  655.         extra_len = 0;
  656.         ++bbeg;     /* this part of line doesn't match */
  657.         if (c0 == 0)
  658.             goto l950;
  659.         else
  660.             goto l900;    /* try rest of current line */
  661.           }
  662.  
  663.     /* regular matched sequence */
  664.  
  665.         if (*(buff+nbbeg)==0 && lbeg+1 < nxtlin)
  666.           {
  667.         ++lbeg;
  668.         nbbeg = *(lines+lbeg)+1;    /* point to next character */
  669.           }
  670.         else
  671.         ++nbbeg;
  672.       }
  673.  
  674. /*#  fall through => found the pattern */
  675.     curlin = lbeg;
  676.     curchr = nbbeg;
  677.  
  678. l5000:
  679.     change = curlin-oldlin;    /* compute real line change */
  680.     if ((slines > 1 && iarg) || tvdlin == tvlins || newln)
  681.         newscr();
  682.     else
  683.         update(change);
  684.     goto l8000;
  685.       }
  686.     curchr = oldpos;        /* reset things */
  687.     tvxy(oldx, oldy);
  688.     if (slines > 1 && iarg)
  689.     newscr();        /* patch up screen */
  690.     pat_buff[0] = 0;
  691.     tverrb("Not found ");    /* announce failure a little */
  692.     goto l9000;
  693.  
  694. l8000:                /* success return */
  695.     oldlen = lastsb+1+extra_len;        /* remember the length */
  696.     save_pat();        /* save the find pattern */
  697.     savlen = (-1);            /* haven't saved lines */
  698.     searchv = TRUE;
  699.  
  700. l9000:
  701.     ins_mode = FALSE;
  702. #ifdef SCR_BUF
  703.     ttflush();
  704. #endif
  705.     return (searchv);
  706.   }
  707.  
  708. /* =============================>>> S_GETSET <<<============================= */
  709.   char *s_getset(wildchr,set_len,fold)
  710.   char wildchr;        /* wild card character */
  711.   int *set_len, *fold;        /* length of set, fold flag */
  712.   {
  713.     static char sets[] =        /* possible sets */
  714.       {
  715.     'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
  716.     'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
  717.     'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
  718.     '4', '5', '6', '7', '8', '9', '.', ',', '?', '!',
  719.     '[', ']', '{', '}', '(', ')', '<', '>', '\'','"',
  720.     '+', '-', '/', '*', '=', '@', '#', '$', '%', '^',
  721.     '&', '_', '~', '`', '|', '\\', ' ', 9, ';', ':', 0
  722.       };
  723.  
  724.     struct wild_set
  725.       {
  726.     char wch;
  727.     int s_start, s_len;
  728.       };
  729.  
  730.     static struct wild_set wild_cards[] =
  731.       {
  732.     { W_letter,  0, 26 },    /* ^L is a letter, starts at 0, 26 long */
  733.     { W_digit, 26, 10 },    /* ^D is digit, starts at 26, 10 long */
  734.     { W_alpha,  0, 36 },    /* ^A is alpha numeric, start at 0, 36 long */
  735.     { W_punc, 36,  4 },    /* ^P is punctuation, at 36, 4 long */
  736.     { W_anything,  0, 70 },    /* ^X is any thing, whole set */
  737.     { W_others, 36, 34 },    /* ^O is non-alphanum, start at 36, 32 long */
  738.     { 0 ,  0,  0 }    /* end of set */
  739.       };
  740.  
  741.     SLOW int i;
  742.     
  743.     *fold = FALSE;        /* assume won't fold */
  744.     if (!use_wild)
  745.     return NULL;        /* not there if not using! */
  746.  
  747.     for (i = 0 ; wild_cards[i].wch ; ++i)    /* scan list */
  748.       {
  749.     if (wildchr == wild_cards[i].wch)    /* found the one we want */
  750.       {
  751.         *set_len = wild_cards[i].s_len;
  752.         *fold = TRUE;
  753.         return (&sets[ wild_cards[i].s_start ]);
  754.       }
  755.       }
  756.     if (wildchr == W_user)
  757.       {
  758.     *set_len = strlen(user_set);
  759.     return user_set;
  760.       }
  761.     else
  762.     return NULL;
  763.  
  764.   }
  765.   
  766. /* =============================>>> S_inset <<<============================= */
  767.   s_inset(c2,cp,set_len)
  768.   char c2, *cp;
  769.   int set_len;
  770.   {
  771.     FAST int i;
  772.  
  773.     for (i = 0 ; i < set_len ; ++i)
  774.     if (c2 == *(cp+i))
  775.         return TRUE;
  776.     return FALSE;
  777.   }
  778.   
  779. /* =============================>>> SETPAR <<<============================= */
  780.   setpar(val,chr)
  781.   int val;
  782.   char chr;
  783.   { /* setpar - reset varoius parameters
  784.         syntax for setpar is [val]:<let>, where [val] is the new value
  785.         of the parameter, : is the setpar command, and <let> is the
  786.         letter of the parameter to set. */
  787.  
  788.     chr = clower(chr);
  789.  
  790.     switch (chr)
  791.       {
  792.        case 'a':        /* set auto indent */
  793.          autoin = val > 0;
  794.         break;
  795.  
  796.     case 'c':        /* cut mode */
  797.          cut_mode = val > 0;
  798.         break;
  799.  
  800.        case 'e':        /* expand tabs */
  801.          tabspc = max(val,0);
  802.         verify(1);        /* need to redisplay */
  803.         break;
  804.  
  805.     case 'd':        /* display line */
  806.         if (val < 1 || val > tvlins)
  807.         tverrb("Bad par val");
  808.         else
  809.           {
  810.         dsplin=val;
  811.         verify(1);
  812.           }
  813.         break;
  814.  
  815.        case 'f':        /* set find mode */
  816.         xcases = val <= 0;
  817.         break;
  818.  
  819.     case 'm':        /* match wild cards */
  820.         use_wild = val;
  821.         break;
  822.  
  823.     case 'o':
  824.         if (rdonly)
  825.           {
  826.         tverrb("Can't :o, R/O");
  827.         break;
  828.           }
  829.         tvclr();
  830.         ask("New output file name: ",dest_file,FNAMESIZE);
  831.         if (*dest_file)
  832.         rdonly = FALSE;
  833.         verify(1);
  834.         break;
  835.  
  836.     case 's':        /* scroll lines */
  837.         if (val < 0 || val > dsplin-1)
  838.         tverrb("Bad par val");
  839.         else
  840.         scroll=val;
  841.         break;
  842.  
  843.     case 't':        /* tty mode */
  844.         tvclr();
  845.         ttymode = val;
  846.         ttynext = 1000;
  847.         verify(1);
  848.         break;
  849.  
  850.     case 'r':        /* change repeat buffer in use */
  851.         if (val < 1 || val > REPEATBUFS)
  852.         tverrb("Bad par val");
  853.         else
  854.         rptuse=val-1;    /* adjust for 0 index int */
  855.         break;
  856.  
  857.     case 'u':
  858.         tvclr();
  859.         ask("Enter user wild card set: ",user_set,39);
  860.         verify(1);
  861.         break;
  862.  
  863.     case 'v':        /* virtual window size */
  864.         if (val < 3 || val > tvhardlines)
  865.         tverrb("Bad par val");
  866.         else
  867.           {
  868.         tvlins = val;            /* set to new display line */
  869.         ddline = (tvlins / 2) + 1;    /* fix home line */
  870.         setdscrl();            /* set scroll value */
  871.         dsplin = ddline;        /* reset these */
  872.         scroll = dscrl;
  873.         verify(1);            /* update the screen */
  874.           }
  875.         break;
  876.  
  877.     case 'w':        /* change wrap width */
  878.         wraplm=val;
  879.         break;
  880.  
  881.     default:
  882.         tverrb("Bad par name");
  883.       }
  884. #ifdef SCR_BUF
  885.     ttflush();
  886. #endif
  887.   }
  888.  
  889. /* =============================>>> SNEXT  <<<============================= */
  890.   snext(lexcnt,iarg)
  891.   int lexcnt,iarg;
  892.   { /* snext - find a text pattern across page boundaries */
  893.  
  894.     SLOW int ihow,pagout;
  895.  
  896.     if (lexcnt < 0)
  897.       {
  898.     tverrb("Search fails");
  899.     return (FALSE);
  900.       }
  901.     
  902.     ihow=iarg;            /* make a local copy */
  903.     pagout=FALSE;
  904.     for(;;)
  905.       {
  906.     if (! search(lexcnt,ihow))
  907.       {
  908.         wtpage(1);        /* write out current page */
  909.         ihow=FALSE;        /* don't reread search pattern */
  910.         pagout=TRUE;
  911.         if (! rdpage())
  912.           {
  913.         tvclr();    /* no more text */
  914.         tverrb("Search fails");
  915.         return (FALSE);
  916.           }
  917.       }
  918.     else            /* found it */
  919.       {
  920.         if (pagout)
  921.         newscr();
  922. #ifdef SCR_BUF
  923.         else
  924.         ttflush();
  925. #endif
  926.         return (TRUE);
  927.       }
  928.       }
  929.   }
  930.  
  931. /* =============================>>> STORE_RPT <<<============================= */
  932.   store_rpt(dummy)
  933.   int dummy;
  934.   {    /* start at current cursor position, insert into repeat buffer
  935.        identified until find >$$ or exceed size limit, deleting as it goes */
  936.  
  937.     SLOW char chr;
  938.     SLOW int saved, i, val;
  939.  
  940.     beglin();        /* start by moving to beginning of current line */
  941.  
  942.     if ((chr = *(buff+curchr)) != '#')    /* get current char, which must be # */
  943.       {
  944.     tverrb("Not a valid rpt buff");
  945.     return (FALSE);    
  946.       }
  947.     val = *(buff+curchr+1)-'0';        /* pick up buffer number */
  948.  
  949.     if (!chk_rpt_nr(val))
  950.     return FALSE;
  951.  
  952.     delnxt(4);                /* delete the #n:< */
  953.  
  954.     --val;        /* change to relative */
  955.  
  956.     saved = 0;                /* no previous chars */
  957.     for (i = 0 ;  ; ++i)
  958.       {
  959.     chr = *(buff+curchr);        /* get the character */
  960.  
  961.     if (chr == ESC && i > 1 && rptbuf[val][i-1] == ESC &&
  962.         rptbuf[val][i-2] == loop_end)
  963.       {
  964.         rptbuf[val][i-2] = 0;    /* set to 0 */
  965.         nxtrpt[val] = 0;
  966.         delnxt(2);            /* delete the 27 and following CR */
  967. #ifdef SCR_BUF
  968.         ttflush();
  969. #endif
  970.         return TRUE;
  971.       }
  972.     if (++saved > 99)
  973.       {
  974.         tverrb("Only 100 chars in rpt");
  975.         return FALSE;
  976.       }
  977.     if (chr == ENDLINE)
  978.         chr = CR;
  979.     rptbuf[val][i] = chr;            /* save the char */
  980.     delnxt(1);            /* and delete it */
  981.       }
  982.   }
  983.  
  984. /* =============================>>> SVKLIN <<<============================= */
  985.   svklin(lin)
  986.   int lin;
  987.   { /* svklin - save one line that will be killed */
  988.  
  989.     SLOW BUFFINDEX from,to;
  990.  
  991.     to=0;
  992.     for (from= *(lines+lin)+1; *(buff+from)!=ENDLINE; ++from)
  993.       {
  994.     unkbuf[to]= *(buff+from);    /* put it in unkill buffer */
  995.     to = min(130,to+1);
  996.       }
  997.     unkbuf[to]=0;
  998.   }
  999.  
  1000. /* =============================>>> TOPPAG <<<============================= */
  1001.   toppag()
  1002.   { /* toppag - move cursor to top of the page */
  1003.  
  1004.     curlin=1;
  1005.     curchr = *(lines+1)+1;        /* first char of buffer */
  1006.     newscr();
  1007.   }
  1008.  
  1009. /* =============================>>> TVIDEFS <<<============================= */
  1010.   tvidefs()
  1011.   { /* initialize these AFTER opening, defaults set by -c */
  1012.  
  1013.     dsplin=ddline;
  1014.     scroll=dscrl;
  1015.     xcases=dxcase;
  1016.   }
  1017.  
  1018. /* =============================>>> TVINIT <<<============================= */
  1019.   tvinit()
  1020.   { /* perform initializations needed for tv edit */
  1021.  
  1022.     FAST BUFFINDEX i;
  1023.     FAST char *chrp;
  1024.     SLOW char *lim;
  1025.     char *malloc();
  1026.  
  1027. #ifdef MSDOS
  1028.     BUFFINDEX coreleft();        /* !!! cii-86 dependent */
  1029. #endif
  1030.  
  1031. /*    This is a time eater if a big buffer -- if your loader inits
  1032.     mem to some known value, it might be possible to change GARBAGE
  1033.     to that value (be sure no other conflicts, like EOS == 0)     */
  1034.  
  1035. /* try for maximum size buffer */
  1036.  
  1037. #ifndef GEMDOS
  1038.     if ((lines = (BUFFINDEX *) malloc((MAXLINE+1)*sizeof(BUFFINDEX)))
  1039.        == NULL)        /* line pointer array */
  1040.     exit(1);
  1041. #else
  1042. if ((lines=(BUFFINDEX *)malloc((unsigned int)((MAXLINE+1)*sizeof(BUFFINDEX))) )
  1043.        == NULL)        /* line pointer array */
  1044.     exit(1);
  1045. #endif
  1046.  
  1047. #ifdef UNIX
  1048.     for (mxbuff=MAXBUFF ; (buff = malloc(mxbuff+2))==NULL ; mxbuff -= 1000)
  1049.     ;            /* text buffer pointer */
  1050. #endif
  1051. #ifdef OSCPM
  1052.     for (mxbuff=MAXBUFF ; (buff = malloc(mxbuff+2))==NULL ; mxbuff -= 1000)
  1053.     ;            /* text buffer pointer */
  1054. #endif
  1055. #ifdef GEMDOS
  1056.     for (mxbuff = 60000L ; (buff = malloc((unsigned int) (mxbuff+2)))==NULL
  1057.       ; mxbuff -= 1000L)
  1058.     ;            /* text buffer pointer */
  1059. #endif
  1060. #ifdef MSDOS            /* *** Cii-86 C compiler dependent! */
  1061.  
  1062.     /* cii-86 requires you to manually leave some memory left over
  1063.        for the I/O routines to use.  'coreleft' does this. Sigh. */
  1064.  
  1065.     if ((mxbuff = (coreleft() - 5000) ) > MAXBUFF)
  1066.     mxbuff = MAXBUFF;
  1067.     for ( ; (buff = malloc(mxbuff+2))==NULL ; mxbuff -= 1000)
  1068.     ;            /* text buffer pointer */
  1069. #endif
  1070.  
  1071.     mxline = MAXLINE;
  1072.  
  1073.     lim = buff + mxbuff;
  1074.     for (chrp = buff ; chrp <= lim ; *chrp++ = GARBAGE )
  1075.     ;    /* mark as all garbage */
  1076.  
  1077.     curlin =            /* init some stuff */
  1078.     oldlen =
  1079.     curchr = 0;
  1080.  
  1081.     xoutcm = leftmg = nxtlin = nxtchr = tvdlin = 1;
  1082.     *(buff+mxbuff) = ENDLINE;    /* needs to be ENDLINE for save buffer */
  1083.     nxtsav=mxbuff;        /* point to end of the buffer */
  1084.  
  1085.     pat_buff[0] = 0;        /* null pattern buffer */
  1086.  
  1087.  
  1088.     savlin = savlen = (-1);
  1089.     for (i = 0 ; i < REPEATBUFS ; ++i)
  1090.       {              /* fix repeat buffers to initial state */
  1091.     rptbuf[i][0] = rptcnt[i]= nxtrpt[i] = rptbuf[i][1] = 0;
  1092.       }
  1093.     rptuse=0;            /* start with first repeat buff */
  1094.     bakflg = FALSE;
  1095.     ineof =
  1096.     echof = TRUE;
  1097.   }
  1098.  
  1099. /* =============================>>> TVERR  <<<============================= */
  1100.   tverr(str)
  1101.   char str[];
  1102.   { /* tverr -    display an error message on the last line of the screen
  1103.                always writes on screen, returns to old position */
  1104.  
  1105.     SLOW int oldx,oldy,oldxot,oldech;
  1106.  
  1107.     waserr = TRUE;
  1108.     oldx=tvx ; oldy=tvy ; oldxot=xoutcm ; oldech=echof;
  1109.  
  1110.     ttynext = 1000;        /* force new read */
  1111.  
  1112.     echof = TRUE;            /* always echo! */
  1113.     tvmsg(str,TRUE);         /* print the message part */
  1114.     tvxy(oldx,oldy);
  1115.     xoutcm=oldxot;
  1116.     echof=oldech;        /* restore to what it was */
  1117. #ifdef SCR_BUF
  1118.     ttflush();
  1119. #endif
  1120.   }
  1121.  
  1122. /* =============================>>> TVERRB <<<============================= */
  1123.   tverrb(str)
  1124.   char str[];
  1125.   { /* tverrb - display an error message on the last line of the screen
  1126.               always writes on screen, returns to old position */
  1127.  
  1128.     sendcs(cerrbg);
  1129.     tverr(str);
  1130.     sendcs(cerred);
  1131. #ifdef SCR_BUF
  1132.     ttflush();
  1133. #endif
  1134.   }
  1135.  
  1136. /* =============================>>> TVHDLN <<<============================= */
  1137.   tvhdln()
  1138.   { /* tvhdln - home to display line */
  1139.  
  1140.     SLOW int xf;
  1141.     xf = findx();
  1142.     tvxy(xf,tvdlin);
  1143.   }
  1144.  
  1145. /* =============================>>> TVMSG  <<<============================= */
  1146.   tvmsg(str,intty)
  1147.   char str[];
  1148.   int intty;
  1149.   { /* tvmsg - display a message on the last line of the screen */
  1150.  
  1151.     FAST int i;
  1152.     SLOW int oldtty;
  1153.  
  1154.     tvxy(1,tvhardlines);
  1155.     tvelin();
  1156.     
  1157.     oldtty = ttymode;
  1158.     if (ttymode && intty)
  1159.       {
  1160.     ttymode = FALSE;
  1161.     prompt(">");
  1162.       }
  1163.  
  1164.     for (i=0; str[i]; ctrlch(str[i++]))
  1165.     ;
  1166.  
  1167.     if (oldtty)        /* end with < if was ttymode */
  1168.     remark("<");
  1169.  
  1170.     ttymode = oldtty;
  1171. #ifdef SCR_BUF
  1172.     ttflush();
  1173. #endif
  1174.   }
  1175.  
  1176. /* =============================>>> TVTYLN <<<============================= */
  1177.   tvtyln(chrptr)
  1178.   BUFFINDEX chrptr;
  1179.   { /* tvtyln - type a line on the screen without cr/lf */
  1180.  
  1181. #ifdef ULBD
  1182.     FAST BUFFINDEX i;
  1183.  
  1184.     if (cundlb[0] || cboldb[0])    /* check for underline/bold */
  1185.       {
  1186.     for (i = *(lines+curlin)+1 ; *(buff+i)!=ENDLINE ; ++i)
  1187.         if (*(buff+i)==TOGUNDERLINE || *(buff+i)==TOGBOLD)
  1188.           {
  1189.         tvxy(1,tvy);
  1190.         xoutcm=1;
  1191.         tvplin(*(lines+curlin)+1);
  1192.         return;
  1193.           }
  1194.       }
  1195. #endif
  1196.     xoutcm=tvx;
  1197.     tvplin(chrptr);
  1198. #ifdef SCR_BUF
  1199.     ttflush();
  1200. #endif
  1201.   }
  1202.  
  1203. /* =============================>>> UNKILL <<<============================= */
  1204.   int unkill()
  1205.   { /* unkill the single last line killed */
  1206.  
  1207.     SLOW char chrval;
  1208.     FAST int i;
  1209.  
  1210.     openln(1);        /* put the CR 1st - makes update pretty */
  1211.     for (i=0; unkbuf[i]; ++i)
  1212.       {
  1213.     chrval = unkbuf[i];
  1214.     if (! ins_chr(chrval))    /* unkill slowly by using insert */
  1215.       {
  1216.         return (FALSE);
  1217.       }
  1218.       }
  1219.     dwnlin(1);        /* back to where we were */
  1220.     return (TRUE);
  1221.   }
  1222.  
  1223. /* =============================>>> UPDATE <<<============================= */
  1224.   update(change)
  1225.   int change;
  1226.   { /* update - update the screen when line position has changed
  1227.         will not be used if any alterations have been made */
  1228.  
  1229.     SLOW int abschg,bscrol;
  1230.  
  1231.     if (! echof)
  1232.     return;
  1233.     abschg =  change;
  1234.  
  1235.     bscrol = (ctopb[0]==0) ? 0 : scroll;
  1236.  
  1237.     if (change < 0)            /* have to scroll screen down */
  1238.       {
  1239.     abschg = (-change);
  1240.     if (tvdlin-abschg < 1)
  1241.         newscr();
  1242.     else if (curlin < tvdlin)    /* won't fit exactly */
  1243.       {
  1244.         if (tvdlin >= dsplin-scroll && abschg!=1)
  1245.           {
  1246.         tvclr();        /* clear the screen */
  1247.         tvtype(1,tvlins);    /* type out a screen */
  1248.           }
  1249.         tvdlin=curlin;
  1250.       }
  1251.     else if (tvdlin-abschg >= dsplin-scroll)
  1252.         tvdlin -= abschg;
  1253.     else
  1254.       {
  1255.         if (tvdlin > dsplin-scroll)
  1256.           {             /* moving up from below display line */
  1257.         abschg=dsplin-scroll-(tvdlin-abschg);
  1258.         tvdlin=dsplin-scroll;    /* update */
  1259.           }
  1260.         if (ctopb[0]==0)        /* can't do reverse linefeeds */
  1261.         newscr();        /* no choice, redraw screen */
  1262.         else
  1263.           {
  1264.         tvtopb(abschg);        /* make blank lines at top */
  1265.         tvtype(curlin-tvdlin+1,abschg);    /* fill in */
  1266.           }
  1267.       }
  1268.       }
  1269.     else if (change > 0)        /* have to scroll screen up */
  1270.     if ((tvdlin+change>tvlins && tvdlin<dsplin+bscrol) || change>=tvlins)
  1271.         newscr();
  1272.     else if (tvdlin < dsplin+bscrol || nxtlin-1 <= tvlins)
  1273.         if (tvdlin+change > dsplin+bscrol && nxtlin-1 > tvlins)
  1274.         newscr();
  1275.         else
  1276.         tvdlin += change;
  1277.     else if (nxtlin-curlin<=tvlins-tvdlin)    /* on bottom part */
  1278.       {
  1279.         if (tvdlin<=dsplin+bscrol && abschg!=1)
  1280.           {
  1281.         tvclr();        /* rewrite whole screen */
  1282.         tvtype(nxtlin-tvlins,tvlins);
  1283.           }
  1284.         tvdlin=min(tvlins,nxtlin-1)-(nxtlin-curlin)+1;
  1285.       }
  1286.     else
  1287.       {
  1288.         tvbotb(abschg);        /* make room */
  1289.         tvxy(1,tvlins-abschg+1);    /* home to right line */
  1290.         tvtype(curlin+tvlins-tvdlin-abschg+1,abschg);  /* fix up screen */
  1291.         if (tvdlin < dsplin+bscrol)
  1292.         tvdlin=dsplin;
  1293.       }
  1294.     tvhdln();
  1295. #ifdef SCR_BUF
  1296.     ttflush();
  1297. #endif
  1298.   }
  1299.  
  1300. /* =============================>>> WORDR  <<<============================= */
  1301.   wordr(cnt)
  1302.   int cnt;
  1303.   {  /* wordr - move cursor over words */
  1304.  
  1305.     SLOW int lim,words,incr,lenmov;
  1306.  
  1307.     lenmov=0;
  1308.     if (cnt<0)
  1309.       {
  1310.     incr = (-1);        /* change */
  1311.     lim = (-cnt);
  1312.       }
  1313.     else if (cnt == 0)
  1314.       {
  1315.     incr = -1;
  1316.     lim = 0;
  1317.       }
  1318.     else 
  1319.       {
  1320.     incr = 1; 
  1321.     lim = cnt;
  1322.       }
  1323.  
  1324.     for (words=1; words<=lim; ++words)
  1325.       {
  1326.     if ((*(buff+curchr)==ENDLINE && incr>0) ||
  1327.         (*(buff+curchr-1)==BEGLINE && incr<0) )
  1328.       {
  1329.         if (curlin+incr==nxtlin || curlin+incr<1)
  1330.         break;        /* at a buffer limit, so quit */
  1331.         dwnlin(incr);    /* move up or down */
  1332.         lenmov += incr;
  1333.         if (cnt<0)
  1334.         endlin();
  1335.         continue;        /* move to next word */
  1336.       }
  1337.  
  1338. /* ok, first, skip over word characters */
  1339.     while (wrdchr(*(buff+curchr)))
  1340.       {
  1341.         if (*(buff+curchr-1)==BEGLINE && incr<=0)
  1342.         goto l100;
  1343.         else
  1344.           {
  1345.         curchr += incr;
  1346.         lenmov += incr;
  1347.           }
  1348.       }
  1349.  
  1350. /* now skip over remaining non word chars */
  1351.     while (! wrdchr(*(buff+curchr)))
  1352.        {
  1353.         if ((*(buff+curchr)==ENDLINE && incr>0) || (*(buff+curchr-1)==BEGLINE &&
  1354.           incr<0))
  1355.         break;
  1356.         else
  1357.           {
  1358.         curchr += incr;
  1359.         lenmov += incr;
  1360.           }
  1361.       }
  1362. l100: ;
  1363.       }
  1364.  
  1365.     if (incr < 0)        /* move cursor to beginning of word */
  1366.     while (wrdchr(*(buff+curchr-1)))
  1367.       {
  1368.         curchr += incr;
  1369.         lenmov += incr;
  1370.       }
  1371.     tvhdln();
  1372. #ifdef SCR_BUF
  1373.     ttflush();
  1374. #endif
  1375.     oldlen = lenmov ; savlen=(-1) ;
  1376.   }
  1377.  
  1378. /* =============================>>> WRDCHR <<<============================= */
  1379.   int wrdchr(chr)
  1380.   char chr;
  1381.   { /* wrdchr - determine if a character is a "word" type character */
  1382.  
  1383.     if ((chr>='a' && chr <= 'z') || (chr >= 'A' && chr <= 'Z') ||
  1384.       (chr >= '0' && chr <= '9'))
  1385.     return (TRUE);
  1386.     else
  1387.      return (FALSE);
  1388.   }
  1389.