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

  1. /* -------------------------- tvx_lex.c --------------------------- */
  2. #include "tvx_defs.ic"
  3.  
  4. /* -------------------------- GLOBALS GO HERE -------------------------------*/
  5. #define EXTERN
  6.  
  7. #include "tvx_glbl.ic"
  8.  
  9.    char clower(),cupper();
  10.  
  11. /* =============================>>> CHECKOS <<<============================= */
  12.   checkos()
  13.   {
  14.     /* check if ok operating system */
  15. #ifdef MSDOS
  16.     if ((bdos(0x30,0) & 0xff) < 2)        /* !!! cii-86 dependent */
  17.       {
  18.     remark("TVX requires MS-DOS 2.0 or later");
  19.     exit();
  20.       }
  21. #endif
  22.   }
  23.  
  24. /* =============================>>> STARTM <<<============================= */
  25.   startm()
  26.   {
  27.     prompt(START_IDM);
  28.     prompt(VERSION); prompt("Terminal: ");
  29.     remark(cversn);
  30.     remark("");
  31.     starthelp();
  32.   }
  33.  
  34. /* =============================>>> STARTHELP <<<============================= */
  35.   starthelp()        /* print start help message */
  36.   {
  37.     remark(START_HELPM); remark("");
  38.   }
  39.  
  40.  
  41. /* =============================>>> MEMORY <<<============================= */
  42.   memory()
  43.   { /* memory - print memory left */
  44.  
  45.     SLOW int nxt;
  46.     SLOW unsigned int tmp;
  47.  
  48.     char value[10],msg[85],*cp;
  49.  
  50.     if (bakflg)
  51.     return;            /* don't do this during logfile input */
  52.  
  53.     nxt=0;            /* where message goes */
  54.     cp = (*dest_file ? dest_file : orig_file);
  55.     strcopy(cp,max(strlen(cp)-36,0),msg,&nxt);    /* the file name */
  56.     if (nxt <= 14)
  57.      {
  58.        strcopy(VERSION,0,msg,&nxt); /* TVX */
  59.        strcopy(cversn,0,msg,&nxt);  /* terminal type */
  60.      }
  61.  
  62.     strcopy(" Free chars:",0,msg,&nxt);    /* add ' Free chars: ' */
  63.  
  64. #ifdef LASL
  65.     tmp = max(nxtsav - nxtchr - BUFFLIMIT,0);
  66. #else
  67.     tmp = nxtsav - nxtchr;
  68. #endif
  69.  
  70. #ifdef INT16
  71.     if (tmp > 30000)        /* handle "neg" size */
  72.       {
  73.     msg[nxt++] = '+';
  74.     tmp -= 30000;
  75.       }
  76. #endif
  77.     itoa(tmp,value);
  78.     strcopy(value,0,msg,&nxt);    /* the value */
  79.  
  80.     strcopy(" Line:",0,msg,&nxt);    /* add ' Line: ' */
  81.     itoa(curlin,value);
  82.     strcopy(value,0,msg,&nxt);
  83.     strcopy(" of ",0,msg,&nxt);
  84.     itoa(nxtlin-1,value);
  85.     strcopy(value,0,msg,&nxt);    /* add the count */
  86.  
  87.  
  88.     tverr(msg);     /* display line on screen */
  89.  }
  90.  
  91. /* =============================>>> SHOSET  <<<============================= */
  92.   shoset()
  93.   {  /* show repeat buffer, help if available */
  94.  
  95. #ifdef HELP
  96.     static char rp[2];
  97.     FAST int i;
  98.     SLOW char *cp, *msg;
  99.     SLOW int fields, oldtty, hnum;
  100.     SLOW unsigned tmp;
  101.  
  102. #ifdef TVX_CMDSET
  103. #ifdef FULLHELP
  104.     struct help_msg 
  105.       {
  106.     char *hmsg;
  107.     char Vmsg;
  108.       };
  109.  
  110.     static struct help_msg cmddes[] =    /* messages for help */
  111.       {
  112.     {"nApnd to sv buff", VSAPPEND},    {" Buffer beg     ",    VTOP},
  113.     {" File beg",         VFBEGIN},    {"nChange chars   ",    VCHANGE},
  114.     {"nDown line      ", VDOWNLINE},{"nDown column",    VDOWNCOL},
  115.     {" Buffer end     ", VBOTTOM},    {"nEdit rpt buffer",    VEDITRPT},
  116.     {"nFind",            VSEARCH},    {" Find cross-buff",    VNEXT},
  117.     {" Get save buffer", VGET},    {" Unkill lastline",    VUNKILL},
  118.     {"nHalf page      ", VHALFP},    {"nInsert (to ESC)",    VINSERT},
  119.     {" Jump back",         VJUMP},    {"nKill character ",    VDELNEXT},
  120.     {"nKill line      ", VKILLALL},    {"nLeft",        VLEFT},
  121.     {" Memory status  ", VMEMORY},    {"nNote location  ",    VNOTELOC},
  122.     {"nReset loc",         VRETNOTE},    {"nOpen line      ",    VOPENLINE},
  123.     {" Call Opr system", VSYSTEM},    {"nPage",        VFLIP},
  124.     {" Print screen   ", VPRINTS},    {"nRight          ",    VRIGHT},
  125.     {" Restore rpt buf", VSTORERPT},{"nSave lines     ",    VSAVE},
  126.     {"nTidy, fill text", VTIDY},    {" Abort",        VABORT},
  127.     {"nUp             ", VUPLINE},    {"nUp column      ",    VUPCOL},
  128.     {" Verify screen",   VVERIFY},    {"nWrite buffer   ",    VWPAGE},
  129.     {" Exit, end edit ", VQUIT},    {"nYank file",        VYANK},
  130.     {"nDel prev char  ", VDELLAST},    {"nFind again     ",    VSAGAIN},
  131.     {" Del last",         VREMOVE},    {" Change last    ",    VRMVINS},
  132.     {" Del to line beg", VKILLPREV},{" Del to line end",    VKILLREST},
  133.     {" Line begining  ", VBEGLINE},    {" Line end       ",    VENDLINE},
  134.     {"nWord right",         VMVWORD},    {"nWord left      ",    VMVBWORD},
  135.     {"nRepeat again   ", VXREPEAT},    {"nk Exec rpt k n times",VEXECRPT},
  136.     {"n p Set param p ", VSETPARS},    {" Help           ",    VHELP},
  137.     {" Insert find pat", VINSPAT},    {"nToggle case    ",    VFOLDCASE},
  138.     {"/",0}            /* last variable entry */
  139.       };
  140. #endif
  141. #endif
  142.  
  143.     if (bakflg)
  144.     return;            /* don't do this during logfile input */
  145.  
  146.     oldtty = ttymode;
  147.     ttymode = FALSE;
  148.     if (!oldtty)
  149.     tvclr();
  150.  
  151.     prompt("Parameter : cur val (1=y, 0=n)    Prev 16 cmds:");
  152.     for (hnum = 0,i = old_cindex ; hnum < 16 ; ++hnum)
  153.       {
  154.     shocout(old_cmds[i]);
  155.     i = ++i % 16;
  156.       }
  157.  
  158.     remark("");
  159.     prompt("A-Autoindent: "); wtint(autoin);
  160.     prompt("  C-Cut mode: "); wtint(cut_mode);
  161.     prompt("  E-Expand tabs: "); wtint(tabspc);
  162.     prompt("  T-TTY mode: "); wtint(ttymode); remark("");
  163.  
  164.     prompt("F-Find: ignore case: "); 
  165.     if (xcases)
  166.         tvcout('0');
  167.     else
  168.         tvcout('1');
  169.  
  170.     prompt("    M-Match wild cards: "); wtint(use_wild); remark("");
  171.     prompt("U-User wild card set: |");
  172.     for (cp = user_set ; *cp ; ++cp)
  173.       {
  174.     shocout(*cp);
  175.       }
  176.     remark("|");
  177.  
  178.     prompt("D disp line:"); wtint(dsplin); 
  179.     prompt("  S-Scroll window:"); wtint(scroll);
  180.     prompt("  V-Virtual window:"); wtint(tvlins); 
  181.     prompt("/"); wtint(tvhardlines);
  182.     prompt("  W-Wrap width:"); wtint(wraplm); remark("");
  183.     prompt("O-Output file: "); prompt(dest_file);
  184.     prompt("  (input file is: ");prompt(orig_file); remark(")");
  185.     remark("");
  186.  
  187.     prompt("Find: |");
  188.     for (cp = sbuff ; *cp ; ++cp)
  189.       {
  190.     shocout(*cp);
  191.       }
  192.     remark("|");
  193.     remark("");
  194.     prompt("Max chars: ");
  195.     tmp = mxbuff;
  196. #ifdef INT16
  197.     if (tmp > 30000)        /* handle "neg" size */
  198.       {
  199.     prompt("30000+");
  200.     tmp -= 30000;
  201.       }
  202. #endif
  203.     wtint(tmp); prompt("  Max lines: ");    wtint(mxline);
  204.     prompt("  Cur line: "); wtint(curlin);
  205.     if (usecz)
  206.     prompt("    ^Z for EOF");
  207.     remark("");
  208.     remark("");
  209.  
  210.     prompt("R-Repeat buffer: ");wtint(rptuse+1);
  211.     remark("   All repeat buffers : <contents>:");
  212.     for (i = 0 ; i < REPEATBUFS ; ++ i)
  213.       {
  214.     fields = 5;
  215.     shocout('#') ; shocout(i+'1') ; prompt(": <");
  216.     for (cp = &rptbuf[i][0] ; *cp ; ++cp)
  217.       {
  218.         shocout(*cp);
  219.         ++fields;        /* how many letters */
  220.         if (*cp < ' ')
  221.         ++fields;
  222.         if (fields >= (tvcols - 6))
  223.           {
  224.         prompt("+more+");
  225.         break;
  226.           }
  227.       }
  228.     remark(">");
  229.       }
  230.  
  231.     ttymode = oldtty;
  232.     memory();
  233.  
  234. #ifdef FULLHELP
  235.     tvxy(1,22);
  236.  
  237.     ask("Press space to exit, anything else for command list ",rp,1);
  238.  
  239.     if (*rp == ' ')
  240.       {
  241.     ttymode = oldtty;
  242.     verify(1);
  243.     return;
  244.       }
  245.  
  246.     if (!oldtty)
  247.     tvclr();
  248.  
  249. /* ------------------------------ TVX ----------------------------------- */
  250. #ifdef TVX_EM
  251.     remark("Commands (n => count allowed):");
  252. #endif
  253. #ifdef TVX0M_EM
  254.     remark("Commands (n => count allowed) (Non ^ cmds prefixed by ESC):");
  255. #endif
  256.  
  257. #ifdef TVX_CMDSET
  258.     for (hnum = fields = 0  ; ; ++hnum )
  259.       {
  260.     prompt("   ");
  261.     cp = cmddes[hnum].hmsg;
  262.     if (*cp == '/')    /* end of variable list */
  263.         break;
  264.     else
  265.         shocout(*cp);    /* show n or blank */
  266.     msg = ++cp;        /* where message is, skipping 'n' field */
  267.     while (*cp)        /* ship to lex value */
  268.         ++cp;
  269.     i = cmddes[hnum].Vmsg;        /* get the lexical index */
  270.     shocout(cupper(lexsym[i]));    /* show the command */
  271.     if (lexsym[i] >= ' ')
  272.         shocout(' ');    /* skip space for no '^' */
  273.  
  274.     shocout(' ');        /* space to separate */
  275.     prompt(msg);        /* and show the message */
  276.     if (++fields == 3)    /* bump fields, see if need newline */
  277.       {
  278.         fields = 0;
  279.         remark("");
  280.       }
  281.       }
  282.     if (fields != 0)
  283.     remark("");
  284. #endif        
  285. #ifdef TVX_EM
  286.     remark("   n<>$$:Rpt loop        @:Invoke cmd file      $:Escape");
  287. #endif
  288. #ifdef TVX0M_EM
  289.     remark("  $n<>$$:Rpt loop       $@:Invoke cmd file      $:Escape");
  290. #endif
  291.  
  292. /* ------------------------------ VI ----------------------------------- */
  293. #ifdef VI_EM
  294.     remark("Commands (n => count allowed):");
  295. remark("");
  296. remark("n^B:scrn up     n^D:half scrn   n^F:scrn dwn    ^G:status     ^L:refresh");
  297. remark("n^U:up half scr n!:tidy         n#p:ex rpt p n   $:line end    *:ins last pat");
  298. remark("/:search         =:help           ?:rev search  @:exec rpt lp");
  299. remark("A:apnd ln end   C:chng rest ln  D:del rest line  nG:Goto ln n  H:buff beg");
  300. remark("I:ins ln beg    J:join lines    nK:up: line beg  L:buff end    nM:ret to mark");
  301. remark("N:rev find nxt  nO:open above   P:put sv buf abv");
  302. remark("q:'tvx' prefix: q!:op system    qb:file begin    qu:limited undo"); 
  303. remark("nq:p:set par p nqe:ed rpt buf   qj:jump back     qp:put file   qy: yank file");
  304. remark("                qs:print scr    nqw:write buf   nqr:restore rpt q/:x-buff find");
  305. remark("nX:del prev ch  nY:apnd sv buf  Z:[Z:exit,A:abort]             ^:line begin");
  306. remark("a:append        nb:word left    c:chng [c,<sp>,^,$,/]      nd:del [d,<sp>,^,$,/]");
  307. remark("ni:insert       nh:left         nj:down in col   nk:up line in col");
  308. remark("nl:right        nm:mark loc     n:find next pat  no:open after");
  309. remark("p:put sv buf after              r:replace 1 chr  ns:substitute");
  310. remark("nw:word right   nx:delete chr   ny:yank to save buffer          n~:change case");
  311.     remark("");
  312. remark("n<>$$:Rpt loop  _:Invoke cmd file   $:Escape");
  313.     remark("'c/' and 'd/' are used to change/delete last thing found");
  314. #endif
  315.  
  316. /* ------------------------------ EMAX ----------------------------------- */
  317. #ifdef EMAX_EM
  318. remark("(n means count allowed: counts entered after <esc> or <ctrl-u>)");
  319. remark("");
  320. remark("^A:line beg    n^B:back chrs                 n^C:extended tvx commands:");
  321. remark("");
  322. remark("[n^A:apnd sv   ^B: file beg   n^C:chng chrs  n^E:Ed rpt bf   n^F:fill        ]");
  323. remark("[ ^G:no op    n^H:half scrn    ^J:jmp back    ^K:kill 'last'  n^N:next ln    ]");
  324. remark("[n^M:mark loc n^P:Prev ln      ^R:Restore rbf ^W:write buff    ;:search again]");
  325. remark("[n~:chng case  nG:Goto line    nH:Half pg up  nI:ins val n     L: Print scrn ]");
  326. remark("[nM:rtn 2 mrk  nP:Put sv bf     S:x buff find  U:unkill 1 ln nVp:set val(par)]");
  327. remark("[ R:Read file into sv buff      W:write sv buff to file   *:insert found pat ]");
  328. remark("");
  329. remark("n^D:del chr    ^E:line end    n^F:fwrd chr   n^H:del prev ch  n^K:kill line");
  330. remark(" ^L:repaint   n^N:next ln     n^O:open ln    n^P:prev ln       ^R:rev search");
  331. remark(" ^S:search     ^U:specify n  n^V:page dwn   ^X^C:abort edit");
  332. remark("^X^B:status  n^XE:ex. rpt bf  ^Y:yank sv bf   ^Z:write, exit");
  333. remark(" $%:cmd file   $!:op. sys.   n$#p:ex rpt p   n$(:rpt loop      $<:buff begin");
  334. remark(" $>:buff end   $?:help        n$B:back word  n$F:fwd word     n$V:page up");
  335. remark("");
  336. remark("$ = <esc>,  ')$$' ends repeat loops");
  337. #endif
  338.  
  339.  
  340. #ifdef GEMDOS
  341.     remark("Find wild cards:  {TVX command '(' toggles 25/50 line display}");
  342. #else
  343.     remark("Find wild cards:");
  344. #endif
  345. remark("^A-alphanumeric  ^D-digit  ^L-letter  ^O-other,(not-^A)  ^P-punctuation");
  346. remark("^X-any character ^U-user set  -- ^W-word of ^..  ^N-not in word of ^..");
  347.  
  348. #endif
  349.  
  350.     if (!oldtty)
  351.     tvxy(1,24);
  352.     ask("Press any key to resume ",rp,1);
  353.  
  354.     ttymode = oldtty;
  355.  
  356.     verify(1);
  357. #else                /* HELP not defined */
  358.     tverr(&rptbuf[rptuse][0]);
  359. #endif
  360.   }
  361.  
  362. /* =============================>>> SHOCOUT <<<============================= */
  363.   shocout(c)
  364.   char c;
  365.   {
  366.  
  367.     if (c < ' ')
  368.       {
  369.     ttwt('^'); ttwt(c + '@');
  370.       }
  371.     else
  372.     ttwt(c);
  373.   }
  374.  
  375. /* =============================>>> LEXGET <<<============================= */
  376.   lexget(chr)
  377.   char *chr;
  378.   {  /* lexget - get a character for lex, possibly from repeat buffer */
  379.  
  380.     SLOW char tmp;
  381. l10:
  382.     if (rptcnt[rptuse] > 0)    /* in a repeat buffer? */
  383.       {
  384.     *chr=rptbuf[rptuse][nxtrpt[rptuse]];    /* pick up from repeat buffer */
  385.     if (*chr == 0)     /* at end of rpt buff */
  386.       {
  387.         nxtrpt[rptuse] = 0;    /* start <> loop over */
  388.         if (--rptcnt[rptuse] == 0 && !echof)    /* all done with loop */
  389.           {
  390.         echof = TRUE;    /* turn on echo again */
  391.         newscr();    /* update screen after repeat */
  392.           }
  393.         goto l10;        /* loop again */
  394.       }
  395.     ++nxtrpt[rptuse];    /* bump to next char in loop */
  396.       }
  397.     else            /* not in loop, get from keyboard */
  398.       {
  399.     gkbd(&tmp);    /* picks up one character from the keyboard */
  400.     *chr = old_cmds[old_cindex] = tmp;
  401.     old_cindex = ++old_cindex % 16;
  402.       }
  403.   }
  404.  
  405. /* =============================>>> LEX    <<<============================= */
  406.   lex(lexval,lexcnt,lexchr,parsok)
  407.   int *lexval,*lexcnt,parsok;
  408.   char *lexchr;
  409.   { /* ##  lex - gets command input from terminal, and scans for
  410.        #  its lexical value.  Returns a count if given.  Also handles
  411.        #  repeat loops. */
  412.  
  413.     SLOW int count, lex_default;
  414.     FAST int i;
  415.     SLOW int neg, newln;
  416.  
  417.     static char chr,cmdchr,tchr;
  418. #ifdef EMAX_EM
  419.     SLOW char had_cu;
  420. #endif
  421.  
  422.     lex_default = TRUE;
  423.  
  424.     if (!parsok)        /* abort if error in <> */
  425.       {
  426.     if (rptcnt[rptuse] > 0)    /* in loop? */
  427.       {
  428.         newscr();    /* clear screen, send message */
  429.         tverrb("<> not complete ");
  430.       }
  431.     rptcnt[rptuse]=0;    /* abort loop if going */
  432.     nxtrpt[rptuse]=0;
  433.       }
  434. l10:
  435.     for (;;) 
  436.       {             /* need this loop to support <> */
  437.     count = 1;        /* default count is 1 */
  438.     lexget(&chr);        /* fetch a character */
  439. #ifdef EMAX_EM
  440.     had_cu = FALSE;        /* not ^U initially */
  441. CU_COUNT:
  442.     if (chr == 21)        /* ctrl-u count detect */
  443.       {
  444.         if (had_cu)
  445.         fixend();
  446.         count *= 4;        /* assume 4 by default */
  447.         tvmsg("Arg: ",FALSE); /* echo Arg: 4' */
  448.         wtint(count);
  449.         had_cu = TRUE;    /* remember we had control-u */
  450.         lex_default = FALSE; /* and not the default */
  451.         lexget(&chr);
  452.       }
  453. #endif
  454. #ifdef NOMODE_LEX
  455.     if ( ((chr & 0177) >= ' ' || chr == TAB || chr == CR)
  456.       && (chr & 0200) == 0)
  457.       {
  458. #ifdef EMAX_EM
  459.         if (had_cu)
  460.           {
  461.         had_cu = FALSE;
  462.         fixend();
  463.         if ((chr >= '0' && chr <= '9') || chr == '-')
  464.             goto EMAX_CNT;
  465.           }
  466.         for (i = 0 ; i < count ; ++i)    /* ^U times */
  467. #endif
  468.         ins_chr((int) chr);    /* simply insert the character */
  469.         continue;        /* get next character */
  470.       }
  471.     if (chr == escape_chr)    /* if an escape, simply get next char */
  472.         lexget(&chr);
  473. #endif
  474.  
  475.     if (rptcnt[rptuse]>0 && chr == loop_beg)    /* detect nesting */
  476.       {
  477.         nxtrpt[rptuse] = 0 ; rptcnt[rptuse] = 0 ; echof=TRUE;
  478.         newscr();    /* update anything so far */
  479.         tverrb("No loop nesting ");
  480.         continue;
  481.       }
  482.  
  483. #ifdef EMAX_EM
  484. EMAX_CNT:
  485. #endif
  486.     if ((chr>='0' && chr<='9') || chr=='-')    /* a number */
  487.       {
  488.         count = 0;  lex_default = FALSE;
  489.         neg = FALSE;    /* handle negative counts */
  490.         if (chr=='-')
  491.         neg=TRUE;
  492.         else 
  493.         count = chr-'0';    /* convert to int value */
  494.         for (;;) 
  495.           {
  496.         if (rptcnt[rptuse] > 0)    /* have to handle rptbuf special */
  497.           {
  498.             if ((chr=rptbuf[rptuse][nxtrpt[rptuse]]) == 0)
  499.             break;
  500.             ++nxtrpt[rptuse];
  501.           }
  502.         else 
  503.             lexget(&chr);
  504.         if (chr>='0' && chr<='9')    /* another number? */
  505.             count = count*10+chr-'0';
  506.         else            /* done with number */
  507.             break;
  508.           }
  509.         if (neg)            /* fix if it was negative */
  510.         count = min(-count ,-1);
  511.       }    /* end count arg if */
  512.  
  513. #ifdef EMAX_EM
  514.     if (chr == 21)        /* another ^U? */
  515.         goto CU_COUNT;
  516.     if (had_cu)
  517.         fixend();    /* count changes */
  518. #endif
  519.  
  520. #ifdef VI_EM
  521.     cmdchr = chr;        /* vi emulator is case sensitive */
  522. #else
  523.     cmdchr = clower(chr);    /* fold to one case */
  524. #endif
  525.     if (cmdchr == loop_beg)    /* starting a loop? */
  526.       {
  527.         lex_default = TRUE;            /* don't let lex count be def */
  528.         rptcnt[rptuse] = (count < 0) ? (-count) : count;    /* save count */
  529.         ins_mode = TRUE;            /* so ttymode works */
  530.         tvmsg("repeat[",FALSE);        /* echo 'repeat[k]: n<' */
  531.         wtint(rptuse+1); prompt("]: ");
  532.         wtint(rptcnt[rptuse]);
  533.  
  534.         tvcout(loop_beg);
  535. #ifdef SCR_BUF
  536.         ttflush();
  537. #endif
  538.         nxtrpt[rptuse]=0;    /* begin inserting at beginning */
  539.         newln = FALSE;    /* no new line echo yet */
  540.         do            /* fetch repeat chars until get > */
  541.           {
  542.         gkbd(&chr);    /* fetch a char */
  543.         if (chr==delkey)    /* allow editing */
  544.           {
  545.             if (nxtrpt[rptuse] > 0)    /* don't go past start */
  546.               {
  547.             --nxtrpt[rptuse];    /* wipe out last */
  548.             if ((tchr = rptbuf[rptuse][nxtrpt[rptuse]])==CR)
  549.               {
  550.                 ctrlch(CR);    /* going to newline */
  551.                 newln = TRUE;        /* new line now */
  552.               }
  553.             else if (!newln)
  554.               {
  555.                 tvcout(BACKSPACE);    /* back over character */
  556.                 tvcout(' ');
  557.                 tvcout(BACKSPACE);
  558.                 if (tchr < ' ' && tchr != 27)
  559.                   {
  560.                 tvcout(BACKSPACE);    /* back over char */
  561.                 tvcout(' ');
  562.                 tvcout(BACKSPACE);
  563.                   }
  564.               }
  565.             else        /* have passed new line start */
  566.               {
  567.                 ctrlch(rptbuf[rptuse][nxtrpt[rptuse]]);
  568.                 tvcout('\\');
  569.               }
  570.               }
  571.             else
  572.             tvcout(BELL);    /* trying to rubout too much */
  573. #ifdef SCR_BUF
  574.             ttflush();
  575. #endif
  576.             continue;
  577.           }
  578.         else        /* a control character detected */
  579.             ctrlch(chr);    /* echo */
  580. #ifdef SCR_BUF
  581.         ttflush();
  582. #endif
  583.  
  584.         rptbuf[rptuse][nxtrpt[rptuse]]=chr;    /* stuff in current rpt buff. */
  585.         ++nxtrpt[rptuse];    /* bump count */
  586.         if (nxtrpt[rptuse] >= 100)    /* only allow 100 chars! */
  587.           {
  588.             newscr();
  589.             tverrb("100 chars only");
  590.             nxtrpt[rptuse]=0 ; rptcnt[rptuse]=0;
  591.             ins_mode = FALSE;
  592.             goto l10;    /* bail out */
  593.           }
  594.           }
  595.         while (!( chr==ESC && rptbuf[rptuse][nxtrpt[rptuse]-2]==ESC &&
  596.           rptbuf[rptuse][nxtrpt[rptuse]-3]==loop_end));    /* end do loop */
  597.  
  598.         ins_mode = FALSE;        /* get ttymode right */
  599.  
  600.         if (rptcnt[rptuse] > 1)    /* positive count? */
  601.         echof = FALSE;    /* turn off echoing */
  602.         else if (newln)
  603.         verify();    /* need to fix up screen because of newline */
  604.         else        /* 0 or 1 count */
  605.           {
  606.         fixend();
  607.         tvhdln();    /* get back where we were */
  608.           }
  609.  
  610.         rptbuf[rptuse][nxtrpt[rptuse]-3] = 0;    /* mark with eos */
  611.         nxtrpt[rptuse]=0;    /* back for scan now */
  612.         continue;        /* now execute the loop */
  613.       }
  614. #ifdef VB
  615.     else if (cmdchr == lexsym[0])    /*$$$    indirect files! */
  616.       {
  617.         opnatf();
  618.         continue;
  619.       }
  620. #endif
  621.     for (i=0 ; synofr[i]!=0 ; ++i)
  622.       if (synofr[i]==cmdchr)
  623.          cmdchr=synoto[i];        /* allow synonyms */
  624.  
  625.     *lexval = UNKNOWN;    /* assume unknown command */
  626.     for (i = 1 ; i<= LEXVALUES ; ++i)    /* scan all possible cmds */
  627.         if (cmdchr == lexsym[i])    /* found it */
  628.           {
  629.         *lexval = i;
  630.         break;
  631.           }
  632.     *lexcnt = count;        /* return good stuff */
  633.     *lexchr = chr;
  634.     return (lex_default);        /* let know if gave back default */
  635.       }                    /* end of for(;;) */
  636.   }
  637. /* -------------------------- tvx_lex.c --------------------------- */
  638.