home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3492 < prev    next >
Encoding:
Internet Message Format  |  1991-06-20  |  54.5 KB

  1. From: pgf@cayman.COM (Paul Fox)
  2. Newsgroups: alt.sources
  3. Subject: Vile 02/17 - vi feel-alike (multi-window)
  4. Message-ID: <4521@cayman.COM>
  5. Date: 7 Jun 91 22:09:10 GMT
  6.  
  7. #!/bin/sh
  8. # this is vileshar.02 (part 2 of Vile)
  9. # do not concatenate these parts, unpack them in order with /bin/sh
  10. # file bind.c continued
  11. #
  12. if test ! -r _shar_seq_.tmp; then
  13.     echo 'Please unpack part 1 first!'
  14.     exit 1
  15. fi
  16. (read Scheck
  17.  if test "$Scheck" != 2; then
  18.     echo Please unpack part "$Scheck" next!
  19.     exit 1
  20.  else
  21.     exit 0
  22.  fi
  23. ) < _shar_seq_.tmp || exit 1
  24. echo 'x - continuing file bind.c'
  25. sed 's/^X//' << 'SHAR_EOF' >> 'bind.c' &&
  26. X        if (nptr->n_cmd == cfp) {
  27. X            return(nptr->n_name);
  28. X        }
  29. X    }
  30. X    return NULL;
  31. }
  32. X
  33. #if NEEDED
  34. /* translate a function pointer to its associated flags */
  35. fnc2flags(func)
  36. CMDFUNC *cfp;    /* ptr to the requested function to bind to */
  37. {
  38. X    register NTAB *nptr;    /* pointer into the name binding table */
  39. X
  40. X    /* skim through the table, looking for a match */
  41. X    nptr = nametbl;
  42. X    while (nptr->n_cmd != NULL) {
  43. X        if (nptr->n_cmd == cfp) {
  44. X            return nptr->n_flags;
  45. X        }
  46. X        ++nptr;
  47. X    }
  48. X    return NONE;
  49. }
  50. #endif
  51. X
  52. X
  53. /* engl2fnc: match name to a function in the names table
  54. X    translate english name to function pointer
  55. X          return any match or NULL if none
  56. X */
  57. CMDFUNC *
  58. engl2fnc(fname)
  59. char *fname;    /* name to attempt to match */
  60. {
  61. X    register NTAB *nptr;    /* pointer to entry in name binding table */
  62. X
  63. X    /* scan through the table, returning any match */
  64. X    nptr = nametbl;
  65. X    while (nptr->n_cmd != NULL) {
  66. X        if (strcmp(fname, nptr->n_name) == 0) {
  67. X            return nptr->n_cmd;
  68. X        }
  69. X        ++nptr;
  70. X    }
  71. X    return NULL;
  72. }
  73. X
  74. /* prc2kcod: translate printable code to 10 bit keycode */
  75. int 
  76. prc2kcod(k)
  77. char *k;        /* name of key to translate to Command key form */
  78. {
  79. X    register int c;    /* key sequence to return */
  80. X
  81. X    /* parse it up */
  82. X    c = 0;
  83. X
  84. X    /* first, the CTLA prefix */
  85. X    if (*k == '^' && *(k+1) == toalpha(cntl_a) && *(k+2) == '-') {
  86. X        c = CTLA;
  87. X        k += 3;
  88. X    }
  89. X
  90. X    /* next the function prefix */
  91. X    if (*k == 'F' && *(k+1) == 'N' && *(k+2) == '-') {
  92. X        c |= SPEC;
  93. X        k += 3;
  94. X    }
  95. X
  96. X    /* control-x as well... (but not with FN) */
  97. X    if (*k == '^' && *(k+1) == toalpha(cntl_x) && 
  98. X                *(k+2) == '-' && !(c & SPEC)) {
  99. X        c |= CTLX;
  100. X        k += 3;
  101. X    }
  102. X
  103. X    /* a control char? */
  104. X    if (*k == '^' && *(k+1) != 0) {
  105. X        ++k;
  106. X        c |= *k;
  107. X        if (islower(c)) c = toupper(c);
  108. X        c = tocntrl(c);
  109. X    } else if (!strcmp(k,"<sp>")) {
  110. X        c |= ' ';
  111. X    } else if (!strcmp(k,"<tab>")) {
  112. X        c |= '\t';
  113. X    } else {
  114. X        c |= *k;
  115. X    }
  116. X    return c;
  117. }
  118. X
  119. #if ! SMALLER
  120. X
  121. /* translate printable code (like "M-r") to english command name */
  122. char *
  123. prc2engl(skey)    /* string key name to binding name.... */
  124. char *skey;    /* name of keey to get binding for */
  125. {
  126. X    char *bindname;
  127. X
  128. X    bindname = fnc2engl(kcod2fnc(prc2kcod(skey)));
  129. X    if (bindname == NULL)
  130. X        bindname = "ERROR";
  131. X
  132. X    return bindname;
  133. }
  134. #endif
  135. X
  136. /* get an english command name from the user. Command completion means
  137. X * that pressing a <SPACE> will attempt to complete an unfinished command
  138. X * name if it is unique.
  139. X */
  140. char *
  141. kbd_engl()
  142. {
  143. X    int status;
  144. X    char *buf;
  145. X
  146. X
  147. X    status = kbd_engl_stat(&buf);
  148. X    if (status == SORTOFTRUE) /* something was tungetc'ed */
  149. X        (void)tgetc();
  150. X    if (status == TRUE)
  151. X        return buf;
  152. X    return NULL;
  153. }
  154. X
  155. /* *bufp only valid if return is TRUE */
  156. kbd_engl_stat(bufp)
  157. char **bufp;
  158. {
  159. #if    ST520 & LATTICE
  160. #define register        
  161. #endif
  162. X    register int c;
  163. X    register int cpos;    /* current column on screen output */
  164. X    register char *sp;    /* pointer to string for output */
  165. X    register NTAB *nbp;    /* first ptr to entry in name binding table */
  166. X    register NTAB *cnbp;    /* current ptr to entry in name binding table */
  167. X    register NTAB *lnbp;    /* last ptr to entry in name binding table */
  168. X    static char buf[NLINE]; /* buffer to hold tentative command name */
  169. X
  170. X    cpos = 0;
  171. X
  172. X    *bufp = NULL;
  173. X
  174. X    /* if we are executing a command line just get the next arg and return */
  175. X    if (clexec) {
  176. X        if (macarg(buf) != TRUE) {
  177. X            return FALSE;
  178. X        }
  179. X        *bufp = buf;
  180. X        return TRUE;
  181. X    }
  182. X
  183. X    lineinput = TRUE;
  184. X
  185. X    /* build a name string from the keyboard */
  186. X    while (TRUE) {
  187. X        c = tgetc();
  188. X
  189. X        if (cpos == 0) {
  190. X            if (isbackspace(c) ||
  191. X                c == kcod2key(abortc) ||
  192. X                c == kcod2key(killc) ||
  193. X                c == '\r' ||
  194. X                islinespecchar(c) ) {
  195. X                tungetc(c);
  196. X                return SORTOFTRUE;
  197. X            }
  198. X        }
  199. X
  200. X        if (c == '\r') {
  201. X            buf[cpos] = 0;
  202. X            lineinput = FALSE;
  203. X            *bufp = buf;
  204. X            return TRUE;
  205. X
  206. X        } else if (c == kcod2key(abortc)) {    /* Bell, abort */
  207. X            buf[0] = '\0';
  208. X            lineinput = FALSE;
  209. X            return FALSE;
  210. X
  211. X        } else if (isbackspace(c)) {
  212. X            TTputc('\b');
  213. X            TTputc(' ');
  214. X            TTputc('\b');
  215. X            --ttcol;
  216. X            --cpos;
  217. X            TTflush();
  218. X
  219. X        } else if (c == kcod2key(killc)) {    /* ^U, kill */
  220. X            while (cpos != 0) {
  221. X                TTputc('\b');
  222. X                TTputc(' ');
  223. X                TTputc('\b');
  224. X                --cpos;
  225. X                --ttcol;
  226. X            }
  227. X            TTflush();
  228. X            tungetc(c);
  229. X            return SORTOFTRUE;
  230. X
  231. X        } /* else... */
  232. /* the following mess causes the command to terminate if:
  233. X    we've got a space
  234. X        -or-
  235. X    we're in the first few chars and we're switching from punctuation
  236. X    to alphanumerics, or vice-versa.  oh yeah -- '!' is considered
  237. X    alphanumeric today.
  238. X    All this allows things like:
  239. X        : e#
  240. X        : !ls
  241. X        : q!
  242. X    to work properly.
  243. X    If we pass this "if" with c != ' ', then c is ungotten below,
  244. X    so it can be picked up by the commands argument getter later.
  245. */
  246. X        else if (c == ' ' || (cpos > 0 && cpos < 3 &&
  247. X                 ((!ispunct(c) &&  ispunct(buf[cpos-1])) ||
  248. X       ((c != '!' && ispunct(c)) &&
  249. X            (buf[cpos-1] == '!' || !ispunct(buf[cpos-1]))) )
  250. X                          )
  251. X            ) {
  252. /* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
  253. X    /* attempt a completion */
  254. X    buf[cpos] = 0;        /* terminate it for us */
  255. X    nbp = nametbl;    /* scan for matches */
  256. X    while (nbp->n_cmd != NULL) {
  257. X        if (strncmp(buf, nbp->n_name, strlen(buf)) == 0) {
  258. X            /* a possible match! exact? no more than one? */
  259. X            if (strcmp(buf, nbp->n_name) == 0 || /* exact? */
  260. X                (nbp + 1)->n_cmd == NULL ||
  261. X                strncmp(buf, (nbp+1)->n_name, strlen(buf)) != 0)
  262. X            {
  263. X                /* exact or only one like it.  print it */
  264. X                sp = nbp->n_name + cpos;
  265. X                while (*sp)
  266. X                    TTputc(*sp++);
  267. X                TTflush();
  268. X                if (c != ' ')  /* put it back */
  269. X                    tungetc(c);
  270. X                lineinput = FALSE;
  271. X                /* return nbp->n_name; */
  272. X                strncpy(buf,nbp->n_name,NLINE);
  273. X                *bufp = buf;
  274. X                return TRUE;
  275. X            } else {
  276. /* << << << << << << << << << << << << << << << << << */
  277. X    /* try for a partial match against the list */
  278. X
  279. X    /* first scan down until we no longer match the current input */
  280. X    lnbp = (nbp + 1);
  281. X    while ((lnbp+1)->n_cmd != NULL) {
  282. X        if (strncmp(buf, (lnbp+1)->n_name, strlen(buf)) != 0)
  283. X            break;
  284. X        ++lnbp;
  285. X    }
  286. X
  287. X    /* and now, attempt to partial complete the string, char at a time */
  288. X    while (TRUE) {
  289. X        /* add the next char in */
  290. X        buf[cpos] = nbp->n_name[cpos];
  291. X
  292. X        /* scan through the candidates */
  293. X        cnbp = nbp + 1;
  294. X        while (cnbp <= lnbp) {
  295. X            if (cnbp->n_name[cpos] != buf[cpos])
  296. X                goto onward;
  297. X            ++cnbp;
  298. X        }
  299. X
  300. X        /* add the character */
  301. X        TTputc(buf[cpos++]);
  302. X    }
  303. /* << << << << << << << << << << << << << << << << << */
  304. X            }
  305. X        }
  306. X        ++nbp;
  307. X    }
  308. X
  309. X    /* no match.....beep and onward */
  310. X    TTbeep();
  311. onward:;
  312. X    TTflush();
  313. /* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
  314. X        } else {
  315. X            if (cpos < NLINE-1 && isprint(c)) {
  316. X                buf[cpos++] = c;
  317. X                TTputc(c);
  318. X            }
  319. X
  320. X            ++ttcol;
  321. X            TTflush();
  322. X        }
  323. X    }
  324. }
  325. X
  326. SHAR_EOF
  327. echo 'File bind.c is complete' &&
  328. chmod 0444 bind.c ||
  329. echo 'restore of bind.c failed'
  330. Wc_c="`wc -c < 'bind.c'`"
  331. test 21479 -eq "$Wc_c" ||
  332.     echo 'bind.c: original size 21479, current size' "$Wc_c"
  333. # ============= buffer.c ==============
  334. echo 'x - extracting buffer.c (Text)'
  335. sed 's/^X//' << 'SHAR_EOF' > 'buffer.c' &&
  336. /*
  337. X * Buffer management.
  338. X * Some of the functions are internal,
  339. X * and some are actually attached to user
  340. X * keys. Like everyone else, they set hints
  341. X * for the display system.
  342. X */
  343. #include        <stdio.h>
  344. #include    "estruct.h"
  345. #include        "edef.h"
  346. X
  347. static lastlookup = -1;
  348. X
  349. /* c is either first character of a filename, or an index into buffer list */
  350. char *
  351. hist_lookup(c)
  352. {
  353. X    register BUFFER *bp;
  354. X    static char buf[NBUFN];
  355. X    buf[0] = '\0';
  356. X
  357. X    if (curbp != bheadp)
  358. X        mlwrite("BUG: hist_lookup: curbp != bheadp");
  359. X        
  360. X    bp = curbp->b_bufp; /* always skip the current */
  361. X    while (bp != NULL) {
  362. X        if (!(bp->b_flag & (BFINVS|BFSCRTCH)) && (--c == 0))
  363. X            break;
  364. X        bp = bp->b_bufp;
  365. X    }
  366. X    if (bp)
  367. X        return bp->b_bname;
  368. X    return NULL;
  369. }
  370. X
  371. hist_show()
  372. {
  373. X    int i;
  374. X    char line[NLINE];
  375. X    BUFFER *bp;
  376. X    
  377. X    if (curbp != bheadp)
  378. X        mlwrite("BUG: hist_show: curbp != bheadp");
  379. X    
  380. X    strcpy(line,"");
  381. X    for (i = 0, bp = curbp->b_bufp; i < 10 && bp != NULL; bp = bp->b_bufp) {
  382. X        if (!(bp->b_flag & (BFINVS|BFSCRTCH))) {
  383. X            strcat(line, "  %d");
  384. X            if (bp->b_flag & BFCHG)
  385. X                strcat(line, "* ");
  386. X            else
  387. X                strcat(line, " ");
  388. X            strcat(line, bp->b_bname);
  389. X            i++;
  390. X        }
  391. X    }
  392. X    if (strcmp(line,"")) {
  393. X        mlwrite(line,1,2,3,4,5,6,7,8,9,10);
  394. X        return TRUE;
  395. X    } else {
  396. X        return FALSE;
  397. X    }
  398. }
  399. X
  400. histbuff(f,n)
  401. {
  402. X    register int thiscmd, c;
  403. X        register BUFFER *bp;
  404. X    char *bufn;
  405. X
  406. X    if (curbp->b_bufp == NULL) {
  407. X        TTbeep();
  408. X        mlwrite("No other buffers.");
  409. X        return(FALSE);
  410. X    }
  411. X
  412. X    if (f == FALSE) {
  413. X        hist_show();
  414. X        thiscmd = lastcmd;
  415. X        c = kbd_seq();
  416. X        mlerase();
  417. X        if (c == thiscmd) {
  418. X            c = 1;
  419. X        } else if (isdigit(c)) {
  420. X            c = c - '0';
  421. X        } else {
  422. X            tungetc(c);
  423. X            return FALSE;
  424. X        }
  425. X    } else {
  426. X        c = n;
  427. X    }
  428. X    
  429. X    bufn = hist_lookup(c);
  430. X    if (bufn == NULL) {
  431. X        TTbeep();
  432. X        mlwrite("No such buffer.");
  433. X        return FALSE;
  434. X    }
  435. X    /* first assume its a buffer name, then a file name */
  436. X        if ((bp=bfind(bufn, NO_CREAT, 0)) == NULL)
  437. X        return getfile(bufn,TRUE);
  438. X    else {
  439. X        return swbuffer(bp);
  440. X    }
  441. }
  442. X
  443. altbuff(f,n)
  444. {
  445. X    return(histbuff(TRUE,1));
  446. }
  447. X
  448. /*
  449. X * Attach a buffer to a window. The
  450. X * values of dot and mark come from the buffer
  451. X * if the use count is 0. Otherwise, they come
  452. X * from some other window.
  453. X */
  454. usebuffer(f, n)
  455. {
  456. X        register BUFFER *bp;
  457. X        register int    s;
  458. X        char            bufn[NBUFN];
  459. X
  460. X    bufn[0] = 0;
  461. X        if ((s=mlreply("Use buffer: ", bufn, NBUFN)) != TRUE)
  462. X                return s;
  463. X        if ((bp=bfind(bufn, OK_CREAT, 0)) == NULL)
  464. X                return FALSE;
  465. X    return swbuffer(bp);
  466. }
  467. X
  468. nextbuffer(f, n)    /* switch to the next buffer in the buffer list */
  469. int f, n;    /* default flag, numeric argument */
  470. {
  471. X    register BUFFER *bp;    /* eligable buffer to switch to*/
  472. X    register BUFFER *stopatbp;    /* eligable buffer to switch to*/
  473. X    
  474. X    stopatbp = NULL;
  475. X    while (stopatbp != bheadp) {
  476. X        /* get the last buffer in the list */
  477. X        for (bp = bheadp; bp->b_bufp != stopatbp; bp = bp->b_bufp)
  478. X            ;
  479. X        /* if that one's invisible, back up and try again */
  480. X        if (bp->b_flag & BFINVS)
  481. X            stopatbp = bp;
  482. X        else
  483. X            return swbuffer(bp);
  484. X    }
  485. X    /* we're back to the top -- they were all invisible */
  486. X    return swbuffer(stopatbp);
  487. X    
  488. }
  489. X
  490. X
  491. swbuffer(bp)    /* make buffer BP current */
  492. register BUFFER *bp;
  493. {
  494. X        register WINDOW *wp;
  495. X
  496. X    if (curbp == bp)  /* no switching to be done */
  497. X        return TRUE;
  498. X
  499. X        if (curbp) {
  500. X            /* if we'll have to take over this window, and it's the last */
  501. X        if (bp->b_nwnd == 0 && --curbp->b_nwnd == 0) {
  502. X            undispbuff(curbp,curwp);
  503. X        }
  504. X        }
  505. X    make_current(bp);
  506. X    
  507. X    /* get it already on the screen if possible */
  508. X        if (bp->b_nwnd > 0)  { /* then it's on the screen somewhere */
  509. X            register WINDOW *wp;
  510. X            int nw;
  511. X        for (wp = wheadp, nw= 1;
  512. X             wp->w_bufp != bp && wp->w_wndp != NULL;
  513. X                     nw++, wp = wp->w_wndp)
  514. X            ;
  515. X        if (!wp)
  516. X            mlwrite("BUG: swbuffer: wp still NULL");
  517. X        curwp = wp;
  518. X        upmode();
  519. X        return TRUE;
  520. X    }
  521. X    
  522. X    /* oh well, suck it into this window */
  523. X        curwp->w_bufp  = bp;
  524. X        curwp->w_linep = bp->b_linep;           /* For macros, ignored. */
  525. X        curwp->w_flag |= WFMODE|WFFORCE|WFHARD; /* Quite nasty.         */
  526. X        if (bp->b_nwnd++ == 0) {                /* First use.           */
  527. X                curwp->w_dotp  = bp->b_dotp;
  528. X                curwp->w_doto  = bp->b_doto;
  529. X                curwp->w_mkp = bp->b_markp;
  530. X                curwp->w_mko = bp->b_marko;
  531. X                curwp->w_ldmkp = bp->b_ldmkp;
  532. X                curwp->w_ldmko = bp->b_ldmko;
  533. X                curwp->w_sideways = bp->b_sideways;
  534. X        }
  535. X    if (bp->b_active != TRUE) {        /* buffer not active yet*/
  536. X        /* read it in and activate it */
  537. X        (void)readin(bp->b_fname, TRUE, bp, TRUE);
  538. X        curwp->w_dotp = lforw(bp->b_linep);
  539. X        curwp->w_doto = 0;
  540. X        bp->b_active = TRUE;
  541. X    }
  542. #if     NeWS
  543. X        newsreportmodes() ;
  544. #endif
  545. X        return TRUE;
  546. }
  547. X
  548. X
  549. undispbuff(bp,wp)
  550. register BUFFER *bp;
  551. register WINDOW *wp;
  552. {
  553. X    /* get rid of it completely if it's a scratch buffer,
  554. X        or it's empty and unmodified */
  555. X    if ( (bp->b_flag & BFSCRTCH) || ( !(bp->b_flag & BFCHG) && 
  556. X                lforw(bp->b_linep) == bp->b_linep ) ) {
  557. X        (void)zotbuf(bp);
  558. X    } else {  /* otherwise just adjust it off the screen */
  559. X        bp->b_dotp  = wp->w_dotp;
  560. X        bp->b_doto  = wp->w_doto;
  561. X        bp->b_markp = wp->w_mkp;
  562. X        bp->b_marko = wp->w_mko;
  563. X        bp->b_ldmkp = wp->w_ldmkp;
  564. X        bp->b_ldmko = wp->w_ldmko;
  565. X        bp->b_sideways = wp->w_sideways;
  566. X    }
  567. }
  568. X
  569. /* bring nbp to the top of the list, where curbp _always_ lives */
  570. make_current(nbp)
  571. BUFFER *nbp;
  572. {
  573. X    register BUFFER *bp;
  574. X    
  575. X    if (nbp == bheadp) {    /* already at the head */
  576. X        curbp = bheadp;
  577. X        return;
  578. X    }
  579. X        
  580. X    /* remove nbp from the list */
  581. X    for (bp = bheadp; bp->b_bufp != nbp; bp = bp->b_bufp)
  582. X        ;
  583. X    bp->b_bufp = nbp->b_bufp;
  584. X    
  585. X    /* put it at the head */
  586. X    nbp->b_bufp = bheadp;
  587. X    
  588. X    bheadp = nbp;
  589. X    curbp = nbp;
  590. }
  591. X
  592. /*
  593. X * Dispose of a buffer, by name.
  594. X * Ask for the name. Look it up (don't get too
  595. X * upset if it isn't there at all!). Get quite upset
  596. X * if the buffer is being displayed. Clear the buffer (ask
  597. X * if the buffer has been changed). Then free the header
  598. X * line and the buffer header.
  599. X */
  600. killbuffer(f, n)
  601. {
  602. X    register BUFFER *bp;
  603. X        register int    s;
  604. X        char bufn[NBUFN];
  605. X
  606. X    bufn[0] = 0;
  607. X        if ((s=mlreply("Kill buffer: ", bufn, NBUFN)) != TRUE)
  608. X                return(s);
  609. X        if ((bp=bfind(bufn, NO_CREAT, 0)) == NULL) { /* Easy if unknown.     */
  610. X            mlwrite("No such buffer");
  611. X                return FALSE;
  612. X        }
  613. X    if(bp->b_flag & BFINVS)        /* Deal with special buffers    */
  614. X            return (TRUE);        /* by doing nothing.    */
  615. X    s = zotbuf(bp);
  616. X    if (s == TRUE)
  617. X                mlwrite("Buffer %s gone", bufn);
  618. X    return s;
  619. }
  620. X
  621. zotbuf(bp)    /* kill the buffer pointed to by bp */
  622. register BUFFER *bp;
  623. {
  624. X        register BUFFER *bp1;
  625. X        register BUFFER *bp2;
  626. X        register int    s;
  627. X
  628. X        if (bp->b_nwnd != 0) {                  /* Error if on screen.  */
  629. X                mlwrite("Buffer is being displayed");
  630. X                return (FALSE);
  631. X        }
  632. X        if ((s=bclear(bp)) != TRUE)             /* Blow text away.      */
  633. X                return (s);
  634. X                
  635. X        lfree(bp->b_linep);             /* Release header line. */
  636. X        bp1 = NULL;                             /* Find the header.     */
  637. X        bp2 = bheadp;
  638. X        while (bp2 != bp) {
  639. X                bp1 = bp2;
  640. X                bp2 = bp2->b_bufp;
  641. X        }
  642. X        bp2 = bp2->b_bufp;                      /* Next one in chain.   */
  643. X        if (bp1 == NULL)                        /* Unlink it.           */
  644. X                bheadp = bp2;
  645. X        else
  646. X                bp1->b_bufp = bp2;
  647. X        free((char *) bp);                      /* Release buffer block */
  648. X        return (TRUE);
  649. }
  650. X
  651. namebuffer(f,n)        /*    Rename the current buffer    */
  652. int f, n;        /* default Flag & Numeric arg */
  653. {
  654. X    register BUFFER *bp;    /* pointer to scan through all buffers */
  655. X    static char bufn[NBUFN];    /* buffer to hold buffer name */
  656. X    char *prompt = "New name for buffer: ";
  657. X
  658. X    /* prompt for and get the new buffer name */
  659. ask:    if (mlreply(prompt, bufn, NBUFN) != TRUE)
  660. X        return(FALSE);
  661. X
  662. X    /* and check for duplicates */
  663. X    bp = bheadp;
  664. X    while (bp != NULL) {
  665. X        if (bp != curbp) {
  666. X            /* if the names the same */
  667. X            if (strcmp(bufn, bp->b_bname) == 0) {
  668. X                prompt = "That name's been used.  New name: ";
  669. X                goto ask;  /* try again */
  670. X            }
  671. X        }
  672. X        bp = bp->b_bufp;    /* onward */
  673. X    }
  674. X
  675. X    strcpy(curbp->b_bname, bufn);    /* copy buffer name to structure */
  676. X    curwp->w_flag |= WFMODE;    /* make mode line replot */
  677. X    mlerase();
  678. X    return(TRUE);
  679. }
  680. X
  681. /* create or find a window, and stick this buffer in it.  when 
  682. X    done, we own the window and the buffer, but they are _not_
  683. X    necessarily curwp and curbp */
  684. popupbuff(bp)
  685. BUFFER *bp;
  686. {
  687. X        register WINDOW *wp;
  688. X
  689. X    if (!curbp) {
  690. X        curbp = bp;  /* possibly at startup time */
  691. X        curwp->w_bufp = curbp;
  692. X                ++curbp->b_nwnd;
  693. X    } else if (bp->b_nwnd == 0) {              /* Not on screen yet.   */
  694. X                if ((wp = wpopup()) == NULL)
  695. X                        return FALSE;
  696. X                if (--wp->w_bufp->b_nwnd == 0)
  697. X                    undispbuff(wp->w_bufp,wp);
  698. X                wp->w_bufp  = bp;
  699. X                ++bp->b_nwnd;
  700. X        }
  701. X        wp = wheadp;
  702. X        while (wp != NULL) {
  703. X                if (wp->w_bufp == bp) {
  704. X                        wp->w_linep = lforw(bp->b_linep);
  705. X                        wp->w_dotp  = lforw(bp->b_linep);
  706. X                        wp->w_doto  = 0;
  707. X                        wp->w_mkp = NULL;
  708. X                        wp->w_mko = 0;
  709. X                        wp->w_ldmkp = NULL;
  710. X                        wp->w_ldmko = 0;
  711. X                        wp->w_sideways = 0;
  712. X                        wp->w_flag |= WFMODE|WFHARD;
  713. X                
  714. X                }
  715. X                wp = wp->w_wndp;
  716. X        }
  717. X        return TRUE;
  718. }
  719. X
  720. /*
  721. X    List all of the active buffers.  First update the special
  722. X    buffer that holds the list.  Next make sure at least 1
  723. X    window is displaying the buffer list, splitting the screen
  724. X    if this is what it takes.  Lastly, repaint all of the
  725. X    windows that are displaying the list.
  726. X    A numeric argument forces it to list invisable buffers as
  727. X    well.
  728. */
  729. togglelistbuffers(f, n)
  730. {
  731. X        register WINDOW *wp;
  732. X        register BUFFER *bp;
  733. X    int s;
  734. X
  735. X    /* if it doesn't exist, create it */
  736. X    if ((bp = bfind("[List]", NO_CREAT, BFSCRTCH)) == NULL)
  737. X        return listbuffers(f,n);
  738. X
  739. X    /* if it does exist, delete the window, which in turn 
  740. X        will kill the BFSCRTCH buffer */
  741. X        wp = wheadp;
  742. X    s = TRUE;
  743. X        while (wp != NULL && s) {
  744. X                if (wp->w_bufp == bp) {
  745. X            s = delwp(wp);
  746. X                    break;
  747. X        }
  748. X                wp = wp->w_wndp;
  749. X    }
  750. X    return s;
  751. }
  752. X
  753. listbuffers(f, n)
  754. {
  755. X        register BUFFER *bp;
  756. X        register int    s;
  757. X
  758. X    /* create the buffer list buffer   */
  759. X    bp = bfind("[List]", OK_CREAT, BFSCRTCH);
  760. X    if (bp == NULL)
  761. X        return FALSE;
  762. X    
  763. X        if ((s=bclear(bp)) != TRUE) /* clear old text (?) */
  764. X                return (s);
  765. X    bp->b_flag |= BFSCRTCH;
  766. X        s = makelist(f,bp);
  767. X    if (!s || popupbuff(bp) == FALSE) {
  768. X        mlwrite("[Sorry, can't list. ]");
  769. X        zotbuf(bp);
  770. X                return (FALSE);
  771. X        }
  772. X        sprintf(bp->b_fname, "       %s   %s",prognam,version);
  773. X        bp->b_flag &= ~BFCHG;               /* Don't complain!      */
  774. X        bp->b_active = TRUE;
  775. X
  776. X        return TRUE;
  777. }
  778. X
  779. /*
  780. X * This routine rebuilds the
  781. X * text in the buffer
  782. X * that holds the buffer list. It is called
  783. X * by the list buffers command. Return TRUE
  784. X * if everything works. Return FALSE if there
  785. X * is an error (if there is no memory). Iflag
  786. X * indicates whether to list hidden buffers.
  787. X */
  788. /* returns no. of lines in list */
  789. int
  790. makelist(iflag,blistp)
  791. int iflag;    /* list hidden buffer flag */
  792. BUFFER *blistp;
  793. {
  794. X        register char   *cp1;
  795. X        register char   *cp2;
  796. X        register int    c;
  797. X        register BUFFER *bp;
  798. X        register LINE   *lp;
  799. X        register int    s;
  800. X    register int    i;
  801. X        long nbytes;        /* # of bytes in current buffer */
  802. X    int nbuf = 0;    /* no. of buffers */
  803. X        int nlines = 0;  /* no. of lines in list */
  804. X        char b[10];
  805. X        char line[NFILEN+NBUFN+30];
  806. X        static char dashes[] =
  807. X            "-------------------------------------------------";
  808. X    int footnote = FALSE;
  809. X
  810. X    sprintf(line,"    %-*s %7s %-*s %s",
  811. X            NUMMODES,"Modes","Size",NBUFN,"Buffer name","Contents");
  812. X        if(addline(blistp,line, -1) == FALSE)
  813. X                return (FALSE);
  814. X        nlines++;
  815. X                
  816. X    /* put some spaces into the separator line... */
  817. X    dashes[3] = dashes[NUMMODES+4] = dashes[NUMMODES+4+8] = 
  818. X        dashes[NUMMODES+4+8+NBUFN+1] = ' ';
  819. X        if (addline(blistp,dashes, -1) == FALSE)
  820. X                return (FALSE);
  821. X        nlines++;
  822. X
  823. X        bp = bheadp;                            /* For all buffers      */
  824. X
  825. X    /* output the list of buffers */
  826. X        while (bp != NULL) {
  827. X        /* skip invisible buffers and ourself if iflag is false */
  828. X                if (((bp->b_flag&(BFINVS|BFSCRTCH)) != 0) && (iflag != TRUE)) {
  829. X                        bp = bp->b_bufp;
  830. X                        continue;
  831. X                }
  832. X
  833. X
  834. X                cp1 = &line[0];                 /* Start at left edge   */
  835. X        /* output status of ACTIVE flag (has the file been read in? */
  836. X                if (bp->b_active == TRUE) {   /* if activated       */
  837. X                    if ((bp->b_flag&BFCHG) != 0) {    /* if changed     */
  838. X                            *cp1++ = 'm';
  839. X                footnote = TRUE;
  840. X                    } else {
  841. X                            *cp1++ = ' ';
  842. X            }
  843. X        } else {
  844. X                        *cp1++ = 'u';
  845. X            footnote = TRUE;
  846. X        }
  847. X
  848. X        sprintf(cp1,"%2d ",nbuf++);
  849. X
  850. X                cp1 = &line[strlen(line)];
  851. X
  852. X        /* output the mode codes */
  853. X        for (i = 0; i < NUMMODES; i++) {
  854. X            if (bp->b_mode & (1 << i))
  855. X                *cp1++ = modecode[i];
  856. X            else
  857. X                *cp1++ = '.';
  858. X        }
  859. X                *cp1++ = ' ';                   /* Gap.                 */
  860. X                nbytes = 0L;                    /* Count bytes in buf.  */
  861. X                lp = lforw(bp->b_linep);
  862. X                while (lp != bp->b_linep) {
  863. X                        nbytes += (long)llength(lp)+1L;
  864. X                        lp = lforw(lp);
  865. X                }
  866. X        sprintf(cp1,"%7ld %-*s %s",nbytes,
  867. X            NBUFN, bp->b_bname, bp->b_fname);
  868. X                if (addline(blistp,line,-1) == FALSE)
  869. X                        return (FALSE);
  870. X            nlines++;
  871. X                bp = bp->b_bufp;
  872. X        }
  873. X
  874. X    if (footnote == TRUE) {
  875. X            if (addline(blistp,
  876. X                "('m' means modified, 'u' means unread)",-1)
  877. X                                 == FALSE) {
  878. X            return FALSE;
  879. X        }
  880. X            nlines++;
  881. X    }
  882. X
  883. X    /* build line to report global mode settings */
  884. X    sprintf(line,"    ");
  885. X    cp1 = &line[4];
  886. X
  887. X    /* output the mode codes */
  888. X    for (i = 0; i < NUMMODES; i++)
  889. X        if (gmode & (1 << i))
  890. X            *cp1++ = modecode[i];
  891. X        else
  892. X            *cp1++ = '.';
  893. X    strcpy(cp1, "    are the global modes");
  894. X    if (addline(blistp,line,-1) == FALSE)
  895. X        return(FALSE);
  896. X
  897. X    sprintf(line," tabstop = %d; fillcol = %d", TABVAL, fillcol);
  898. X    if (addline(blistp,line,-1) == FALSE)
  899. X        return(FALSE);
  900. X
  901. X    sprintf(line," lazy filename matching is %s",
  902. X                    (othmode & OTH_LAZY) ? "on":"off");
  903. X    if (addline(blistp,line,-1) == FALSE)
  904. X        return(FALSE);
  905. X
  906. X    nlines++;
  907. X
  908. X        return (nlines);
  909. }
  910. X
  911. ltoa(buf, width, num)
  912. char   buf[];
  913. int    width;
  914. long   num;
  915. {
  916. X        buf[width] = 0;                         /* End of string.       */
  917. X        while (num >= 10) {                     /* Conditional digits.  */
  918. X                buf[--width] = (int)(num%10L) + '0';
  919. X                num /= 10L;
  920. X        }
  921. X        buf[--width] = (int)num + '0';          /* Always 1 digit.      */
  922. X        while (width != 0)                      /* Pad with blanks.     */
  923. X                buf[--width] = ' ';
  924. }
  925. X
  926. /*
  927. X * The argument "text" points to
  928. X * a string. Append this line to the
  929. X * buffer. Handcraft the EOL
  930. X * on the end. Return TRUE if it worked and
  931. X * FALSE if you ran out of room.
  932. X */
  933. addline(bp,text,len)
  934. register BUFFER *bp;
  935. char    *text;
  936. int len;
  937. {
  938. X        register LINE   *lp;
  939. X        register int    i;
  940. X        register int    ntext;
  941. X
  942. X        ntext = (len < 0) ? strlen(text) : len;
  943. X        if ((lp=lalloc(ntext)) == NULL)
  944. X                return (FALSE);
  945. X        for (i=0; i<ntext; ++i)
  946. X                lputc(lp, i, text[i]);
  947. X        bp->b_linep->l_bp->l_fp = lp;       /* Hook onto the end    */
  948. X        lp->l_bp = bp->b_linep->l_bp;
  949. X        bp->b_linep->l_bp = lp;
  950. X        lp->l_fp = bp->b_linep;
  951. X        if (bp->b_dotp == bp->b_linep)  /* If "." is at the end */
  952. X                bp->b_dotp = lp;            /* move it to new line  */
  953. X        return (TRUE);
  954. }
  955. X
  956. /*
  957. X * Look through the list of
  958. X * buffers. Return TRUE if there
  959. X * are any changed buffers. Buffers
  960. X * that hold magic internal stuff are
  961. X * not considered; who cares if the
  962. X * list of buffer names is hacked.
  963. X * Return FALSE if no buffers
  964. X * have been changed.
  965. X */
  966. anycb()
  967. {
  968. X        register BUFFER *bp;
  969. X    register int cnt = 0;
  970. X
  971. X        bp = bheadp;
  972. X        while (bp != NULL) {
  973. X                if ((bp->b_flag&BFINVS)==0 && (bp->b_flag&BFCHG)!=0)
  974. X            cnt++;
  975. X                bp = bp->b_bufp;
  976. X        }
  977. X        return (cnt);
  978. }
  979. X
  980. /*
  981. X * Find a buffer, by name. Return a pointer
  982. X * to the BUFFER structure associated with it.
  983. X * If the buffer is not found
  984. X * and the "cflag" is OK_CREAT, create it. The "bflag" is
  985. X * the settings for the flags in in buffer.
  986. X */
  987. BUFFER  *
  988. bfind(bname, cflag, bflag)
  989. char   *bname;
  990. {
  991. X        register BUFFER *bp;
  992. X        register LINE   *lp;
  993. X    register BUFFER *lastb = NULL;    /* buffer to insert after */
  994. X
  995. X        bp = bheadp;
  996. X        while (bp != NULL) {
  997. X                if (strncmp(bname, bp->b_bname, NBUFN) == 0)
  998. X                        return (bp);
  999. X                lastb = bp;
  1000. X                bp = bp->b_bufp;
  1001. X        }
  1002. X    if (cflag == NO_CREAT)    /* don't create it */
  1003. X        return NULL;
  1004. X    
  1005. X        if ((bp=(BUFFER *)malloc(sizeof(BUFFER))) == NULL)
  1006. X                return (NULL);
  1007. X        if ((lp=lalloc(0)) == NULL) {
  1008. X                free((char *) bp);
  1009. X                return (NULL);
  1010. X        }
  1011. X
  1012. X    /* and set up the other buffer fields */
  1013. X    bp->b_active = FALSE;
  1014. X        bp->b_dotp  = lp;
  1015. X        bp->b_doto  = 0;
  1016. X        bp->b_markp = NULL;
  1017. X        bp->b_marko = 0;
  1018. X        bp->b_ldmkp = NULL;
  1019. X        bp->b_ldmko = 0;
  1020. X        bp->b_nmmarks = NULL;
  1021. X        bp->b_flag  = bflag;
  1022. X    bp->b_mode  = gmode & ~(MDCMOD|MDDOS); /* handled in readin() */
  1023. X        bp->b_nwnd  = 0;
  1024. X        bp->b_sideways = 0;
  1025. X        bp->b_linep = lp;
  1026. X        strcpy(bp->b_fname, "");
  1027. X        strcpy(bp->b_bname, bname);
  1028. #if    CRYPT
  1029. X    bp->b_key[0] = 0;
  1030. #endif
  1031. X    bp->b_udstks[0] = bp->b_udstks[1] = NULL;
  1032. X    bp->b_udstkindx = 0;
  1033. X        bp->b_ulinep = NULL;
  1034. X        lp->l_fp = lp;
  1035. X        lp->l_bp = lp;
  1036. X        
  1037. X    /* append at the end */
  1038. X    if (lastb)
  1039. X            lastb->b_bufp = bp;
  1040. X    else
  1041. X        bheadp = bp;
  1042. X        bp->b_bufp = NULL;
  1043. X
  1044. X        return (bp);
  1045. }
  1046. X
  1047. /*
  1048. X * This routine blows away all of the text
  1049. X * in a buffer. If the buffer is marked as changed
  1050. X * then we ask if it is ok to blow it away; this is
  1051. X * to save the user the grief of losing text. The
  1052. X * window chain is nearly always wrong if this gets
  1053. X * called; the caller must arrange for the updates
  1054. X * that are required. Return TRUE if everything
  1055. X * looks good.
  1056. X */
  1057. bclear(bp)
  1058. register BUFFER *bp;
  1059. {
  1060. X        register LINE   *lp;
  1061. X        register int    s;
  1062. X
  1063. X        if ((bp->b_flag&(BFINVS|BFSCRTCH)) == 0 /* Not invisible or scratch */
  1064. X                && (bp->b_flag&BFCHG) != 0 ) {      /* Something changed    */
  1065. X        char ques[50];
  1066. X        strcpy(ques,"Discard changes to ");
  1067. X        strcat(ques,bp->b_bname);
  1068. X            if (mlyesno(ques) != TRUE)
  1069. X                    return FALSE;
  1070. X    }
  1071. X        bp->b_flag  &= ~BFCHG;                  /* Not changed          */
  1072. X    freeundostacks(bp);    /* do this before removing lines */
  1073. X        while ((lp=lforw(bp->b_linep)) != bp->b_linep) {
  1074. X                lremove(bp,lp);
  1075. X                lfree(lp);
  1076. X    }
  1077. X        bp->b_dotp  = bp->b_linep;              /* Fix "."              */
  1078. X        bp->b_doto  = 0;
  1079. X        bp->b_markp = NULL;                     /* Invalidate "mark"    */
  1080. X        bp->b_marko = 0;
  1081. X        bp->b_ldmkp = NULL;                     /* Invalidate "mark"    */
  1082. X        bp->b_ldmko = 0;
  1083. X    if (bp->b_nmmarks != NULL) { /* free the named marks */
  1084. X        free((char *)(bp->b_nmmarks));
  1085. X        bp->b_nmmarks = NULL;
  1086. X    }
  1087. X        return (TRUE);
  1088. }
  1089. X
  1090. unmark(f, n)    /* unmark the current buffers change flag */
  1091. int f, n;    /* unused command arguments */
  1092. {
  1093. X    curbp->b_flag &= ~BFCHG;
  1094. X    curwp->w_flag |= WFMODE;
  1095. X    return(TRUE);
  1096. }
  1097. SHAR_EOF
  1098. chmod 0444 buffer.c ||
  1099. echo 'restore of buffer.c failed'
  1100. Wc_c="`wc -c < 'buffer.c'`"
  1101. test 20200 -eq "$Wc_c" ||
  1102.     echo 'buffer.c: original size 20200, current size' "$Wc_c"
  1103. # ============= buglist ==============
  1104. echo 'x - extracting buglist (Text)'
  1105. sed 's/^X//' << 'SHAR_EOF' > 'buglist' &&
  1106. X
  1107. X    (E means enhancement, L,M,H are low, medium, high priority)
  1108. ----------------------
  1109. X
  1110. H    the gotoeop motion and regions interract wrongly.  For instance,
  1111. X    using ^W} to write the rest of the paragraph to a file writes
  1112. X    the wrong number of characters.
  1113. X
  1114. H    when reading the output of a shell command, it's far too slow -- should
  1115. X    read as much as possible, put it into the buffer, and _then_ update
  1116. X    [ This has been fixed for BSD -- other implementations not yet ]
  1117. X
  1118. M    output doesn't flush properly after a shell escape
  1119. X
  1120. M    longnames cause severe portability constraint -- does the shortnames
  1121. X    stuff take care of this?  I can't test it...
  1122. X
  1123. M    :k, to set a mark, won't work as ":ka" or ":kb".  Must use ":k a"
  1124. X
  1125. M    :set all should be made to work (fix help)
  1126. X
  1127. L    formatregion sometimes appends a space to the last line, for instance
  1128. X    when a paragraph is reformatted
  1129. X
  1130. L    dos-style is set even when file is majority unix-lines?
  1131. X
  1132. L    why does file reading seem so slow?
  1133. X
  1134. L    why is searching so slow?
  1135. X
  1136. L    with two window displayed, hitting * twice makes one go away.
  1137. X    perhaps popup should _always_ split a window, rather than sometimes
  1138. X    taking over an existing one.  but then we'd have to remember who we
  1139. X    split, so we could give the space back to the donor.
  1140. X
  1141. E    patterns as addresses do not work, e.g. ":/str1/,/str2/d".  They're
  1142. X    hard to parse the way things are set up right now.  We could accumulate
  1143. X    the whole commandline, and then parse it, the way real vi does, but we'd
  1144. X    lose the "prompt and display last response" behavior.
  1145. X
  1146. E    In vi, the join command is supposed to act either on a region (from
  1147. X    the command line, as in ":13,15j"), or it should take a simple
  1148. X    count, from vi mode, as in "3j".  Right now vile _only_ does the
  1149. X    simple count form of the command.
  1150. X
  1151. E    should add an option to support file locking, rather than the
  1152. X    current ifdef stuff -- but this is only useful if we match the
  1153. X    GNU locking protocol, which I'm not inclined to do
  1154. X
  1155. E    Wow. the scrsearch functions could become region based -- as in "search for
  1156. X    the next occrence of the region", which would usually be a word.  And
  1157. X    the ^A/ version could become "a/ (search for teh contents of buffer a),
  1158. X    if you know what I mean.
  1159. X
  1160. E    need a "file newer than buffer" warning.  Should stat the file, and
  1161. X    store it's mod time, compare to current when going back to that window,
  1162. X    after performing some shell command.  e.g., if you're editing a file
  1163. X    that is created by a script you're testing, then you want to be warned
  1164. X    that the file is out of date after doing a test run of the script.
  1165. X
  1166. E    should be able to refer to remote tags file, and have paths
  1167. X    contained there be relative to _its_ location, rather than the current
  1168. X    directory.
  1169. X
  1170. E    add a command-line expansion character to be the list of files
  1171. X    mentioned in "tags"
  1172. X
  1173. E    should there be a "significant-length" for tags?
  1174. X
  1175. E    another mode, which will "!get -p" an SCCS or RCS file if 
  1176. X    the clear-text file isn't found
  1177. X
  1178. E    add _another_ mode, similar to the above, which will do a caseless 
  1179. X    match against filenames mentioned in tags
  1180. X
  1181. E    it would be nice if ^X!! reran the last command into [Output]
  1182. X
  1183. E    add support for sh or C comments to formatregion() code
  1184. X
  1185. E    why can't I kill a displayed buffer?  simply bring up the previous.
  1186. X    
  1187. E    g should become a region command.  Then it could take ranges, as
  1188. X    it should, and could also become an operator command.
  1189. X
  1190. E    add C comments to CFENCE matching code
  1191. X
  1192. E    add C ifdefs to CFENCE matching code
  1193. X
  1194. E    adjust window size of popups based on length of buffer.  currently
  1195. X    popups get half the window they're splitting, no matter what
  1196. X
  1197. E    collapse command execution code to as few places as possible.
  1198. X    Its currently spread through main(), execute(), operator(),
  1199. X    docmd(), and usekreg().
  1200. X    
  1201. E    mlreply line should ideally be a one line buffer, so editing
  1202. X    and history can be done on it.
  1203. X
  1204. E    BSD interrupt processing is botched during a read() of the keyboard.
  1205. X    The read doesn't return -1 as it does under sysV (USG).
  1206. X    So you can bang on ^C all day and nothing will happen.
  1207. X    [I'm not sure this is true anymore  -pgf]
  1208. X    
  1209. E    This editor does not virtualize buffers out to disk.  It is quite 
  1210. X    a memory hog.  But isn't that what /dev/swap is for?  But
  1211. X    seriously, I haven't even come close to testing it for
  1212. X    memory-full conditions.  Some malloc() packages give 95%
  1213. X    warnings -- perhaps something like that should be done for
  1214. X    safety.
  1215. X
  1216. E    to make the code shrink, could probably try to eliminate
  1217. X    sprintf and its brethren.  mlwrite already does format
  1218. X    expansion, it could probably be turned into a doprnt-like
  1219. X    beast, and that used as a basis for our own sprintf,fprintf
  1220. X    How does one write [sfp]printf and doprnt using varargs?
  1221. X
  1222. E    likewise for scanf
  1223. X
  1224. E    marks should perhaps be linked onto lines.  this would make a lot
  1225. X        of things a lot easier, since a mark would travel with the
  1226. X        line, instead of having to be moved when the line is
  1227. X        reallocated etc.  the U line could be treated as a special
  1228. X        mark.  The "copied" flag needed by undo could be a special
  1229. X        sort of mark as well.  Implementation of the "tag stack"
  1230. X    would be aided by this as well.
  1231. X
  1232. E    there is currently no way to change working directories -- it's
  1233. X    not clear whether that should be a global thing, or perhaps
  1234. X    a per-buffer notion.
  1235. X
  1236. E    there is code (in imdying()) that attempts to save unwritten buffers
  1237. X    on hangups.  It is fairly crude, having been written quickly
  1238. X    in self-defense during debugging.  It should be examined and
  1239. X    fixed.
  1240. X
  1241. E    :e and :n should be able to deal with multiple filenames resulting
  1242. X    from filename globbing.  vi has this problem too.  At least
  1243. X    vile lets you choose to choose the first such name.  if should show
  1244. X    you the first name, so you know whether to accept it or not.
  1245. X
  1246. E    ^W should erase word in input mode, and killc should erase line 
  1247. X    in input mode.  (but only back to where the input started, if it
  1248. X    started on this line.  right now we have no record of that, hence
  1249. X    you can backspace past the insert point)
  1250. X
  1251. E    All code should pass lint.  This won't be easy... :-)
  1252. X    
  1253. SHAR_EOF
  1254. chmod 0444 buglist ||
  1255. echo 'restore of buglist failed'
  1256. Wc_c="`wc -c < 'buglist'`"
  1257. test 6009 -eq "$Wc_c" ||
  1258.     echo 'buglist: original size 6009, current size' "$Wc_c"
  1259. # ============= cmdtbl ==============
  1260. echo 'x - extracting cmdtbl (Text)'
  1261. sed 's/^X//' << 'SHAR_EOF' > 'cmdtbl' &&
  1262. X
  1263. # This file contains all of the editor's command and key linkages.
  1264. #
  1265. # It should be processed by the "mktbls" program, which produces the
  1266. #  headers #included by main.c
  1267. #
  1268. # All that is necessary to add a new function to the editor is to add
  1269. #  an entry to this file, write the function, make sure it's in the
  1270. #  makefile, and rebuild.  (This is not to be confused with adding a
  1271. #  new key binding, which can be done with the rebind command if it
  1272. #  was compiled in.)
  1273. #
  1274. # If you want to know which keyboard bindings are already taken, look
  1275. #  at nebind.h, after you build it.
  1276. #
  1277. # The entries are functions within the editor.  They _must_ match the
  1278. #  functions' names.  On the same line as the name is the set of flags
  1279. #  describing that function.
  1280. # Also accompanying each function is a list of english names  for the 
  1281. #  command, in double quotes, and a list of keys bound to the command,
  1282. #  in single quotes.  These are the default key bindings -- they can change
  1283. #  at runtime.  English names must be all lowercase.
  1284. # Any function, name, or key may be followed by a conditional, i.e. the
  1285. #  name of a preprocessor #define which must be defined non-zero for that
  1286. #  line to become part of the editor.  If a function name is made conditional,
  1287. #  the names and keys listed with it will be conditional also.
  1288. # The names and keys must be preceded by a tab character.
  1289. # Blank lines must be completely empty.
  1290. # For convenience only, this table is kept in roughly alphabetical order, 
  1291. #  by first character of function name.
  1292. #
  1293. # For example, consider the following entry:
  1294. #
  1295. #     somefunc    ABS|MOTION        BSD|DOS
  1296. #        "funkycom"
  1297. #        '^X-F'
  1298. #        'FN-2'                DOS
  1299. #
  1300. # This says that somefunc() is an absolute motion command, that it should
  1301. #  only be included in the editor if we're running BSD or DOS, that its
  1302. #  english name as one would type on the command line is "funkycom", and
  1303. #  that it is bound to ^X-F, and also to function key 2 under DOS.
  1304. #
  1305. # Function flags have the following meanings:
  1306. #    REDO means the dotcmd command recorder should be halted, so that
  1307. #        the command can be redone.
  1308. #    UNDO means the undo stacks should be cleared, in preparation for
  1309. #        an undoable command.
  1310. #    OPER means the command is an "operator", that is, it acts on a region
  1311. #        demarcated by the current cursor postion and the cursor position
  1312. #        following a subsequent motion command.
  1313. #    MOTION means this command moves dot, and specifically is compatible
  1314. #        with the operator commands.
  1315. #    FL only occurs with MOTION, means that if the motion is an argument
  1316. #        to an operator, the operation should affect Full Lines
  1317. #    ABS only occurs with MOTION, means that the motion is absolute,
  1318. #        i.e. not relative to the current postion or screen.  It causes
  1319. #        the "lastdotmark", ldmark to be set to dot before the move
  1320. #        takes place.
  1321. #    GOAL signifies a motion that will attempt to retain the 
  1322. #        current column postition after the motion.
  1323. #    GLOBOK says the function can follow a global command
  1324. #        (e.g. the 'd' in "g/pattern/d")
  1325. #
  1326. #    This file was designed and constructed by Paul Fox for vile, (c)1990
  1327. #
  1328. #    The flags given in parentheses are "ex" flags, related to what
  1329. #        kind of line-range arguments the command can take.  Not all are
  1330. #        currently used or implemented, but they were defined in the command
  1331. #        table for the Steve Kirkendall's elvis editor, so I included them
  1332. #        here for completeness.
  1333. X
  1334. altbuff        NONE
  1335. X    "alternate-buffer"        !FEWNAMES
  1336. X    '^^'
  1337. append        REDO|UNDO
  1338. X    "appendchar"            !FEWNAMES
  1339. X    'a'
  1340. appendeol    REDO|UNDO
  1341. X    "append-eol"            !FEWNAMES
  1342. X    'A'
  1343. apro        NONE            APROP|REBIND
  1344. X    "apropos"
  1345. backchar    MOTION
  1346. X    "backward-character"        !FEWNAMES
  1347. X    'h'
  1348. X    '^H'
  1349. backdelchar    REDO|UNDO
  1350. X    "delete-previous-character"    !FEWNAMES
  1351. X    'X'
  1352. backhunt    ABS|MOTION        !SMALLER
  1353. X    "hunt-backward"
  1354. backhpage    NONE
  1355. X    "previous-half-page"        !FEWNAMES
  1356. X    '^U'
  1357. backline    GOAL|MOTION|FL
  1358. X    "previous-line"            !FEWNAMES
  1359. X    'k'
  1360. backbline    MOTION|FL
  1361. X    "previous-line-at-bol"        !FEWNAMES
  1362. X    '-'
  1363. backpage    MOTION
  1364. X    "previous-page"            !FEWNAMES
  1365. X    '^B'
  1366. backword    MOTION
  1367. X    "previous-word"            !FEWNAMES
  1368. X    'B'
  1369. backviword    MOTION
  1370. X    "previous-punc-word"        !FEWNAMES
  1371. X    'b'
  1372. backsearch    ABS|MOTION
  1373. X    "search-reverse"        !FEWNAMES
  1374. X    '?'
  1375. bcsrch        MOTION
  1376. X    "backward-char-scan"        !FEWNAMES
  1377. X    'F'
  1378. bcsrch_to    MOTION
  1379. X    "backward-char-scan-to"        !FEWNAMES
  1380. X    'T'
  1381. bindkey        NONE            REBIND
  1382. X    "bind-key"
  1383. X    "rebind-key"
  1384. bktoshell    NONE            UNIX&&defined(SIGTSTP)
  1385. X    "suspend-emacs"            !FEWNAMES
  1386. X    '^Z'
  1387. cntl_xf        NONE
  1388. X    "cntl_x-prefix"            !FEWNAMES
  1389. X    '^X'
  1390. chgchar        REDO|UNDO
  1391. X    "change-char"            !FEWNAMES
  1392. X    's'
  1393. chgline        REDO|UNDO
  1394. X    "change-line"            !FEWNAMES
  1395. X    'S'
  1396. chgtoeol    REDO|UNDO
  1397. X    "change-to-end-of-line"        !FEWNAMES
  1398. X    'C'
  1399. clrmes        NONE
  1400. X    "clear-message-line"        !FEWNAMES
  1401. consearch    ABS|MOTION
  1402. X    "continue-search"        !FEWNAMES
  1403. X    'n'
  1404. opercopy        OPER|(RANGE|EXTRA)
  1405. X    "copy"
  1406. X    "c"
  1407. ctlxlp        NONE
  1408. X    "begin-macro"            !FEWNAMES
  1409. X    '^X-('
  1410. ctlxrp        NONE
  1411. X    "end-macro"            !FEWNAMES
  1412. X    '^X-)'
  1413. ctlxe        REDO
  1414. X    "execute-macro"            !FEWNAMES
  1415. X    '^X-&'
  1416. cbuf1        REDO
  1417. X    "execute-macro-1"        !FEWNAMES
  1418. X    'FN-1'                TERMCAP
  1419. cbuf2        REDO
  1420. X    "execute-macro-2"        !FEWNAMES
  1421. X    'FN-2'                TERMCAP
  1422. cbuf3        REDO
  1423. X    "execute-macro-3"        !FEWNAMES
  1424. X    'FN-3'                TERMCAP
  1425. cbuf4        REDO
  1426. X    "execute-macro-4"        !FEWNAMES
  1427. X    'FN-4'                TERMCAP
  1428. cbuf5        REDO
  1429. X    "execute-macro-5"        !FEWNAMES
  1430. X    'FN-5'                TERMCAP
  1431. cbuf6        REDO
  1432. X    "execute-macro-6"        !FEWNAMES
  1433. X    'FN-6'                TERMCAP
  1434. cbuf7        REDO
  1435. X    "execute-macro-7"        !FEWNAMES
  1436. X    'FN-7'                TERMCAP
  1437. cbuf8        REDO
  1438. X    "execute-macro-8"        !FEWNAMES
  1439. X    'FN-8'                TERMCAP
  1440. cbuf9        REDO
  1441. X    "execute-macro-9"        !FEWNAMES
  1442. X    'FN-9'                TERMCAP
  1443. cbuf10        REDO
  1444. X    "execute-macro-10"        !FEWNAMES
  1445. cbuf11        REDO            !SMALLER
  1446. X    "execute-macro-11"        !FEWNAMES
  1447. cbuf12        REDO            !SMALLER
  1448. X    "execute-macro-12"        !FEWNAMES
  1449. cbuf13        REDO            !SMALLER
  1450. X    "execute-macro-13"        !FEWNAMES
  1451. cbuf14        REDO            !SMALLER
  1452. X    "execute-macro-14"        !FEWNAMES
  1453. cbuf15        REDO            !SMALLER
  1454. X    "execute-macro-15"        !FEWNAMES
  1455. cbuf16        REDO            !SMALLER
  1456. X    "execute-macro-16"        !FEWNAMES
  1457. cbuf17        REDO            !SMALLER
  1458. X    "execute-macro-17"        !FEWNAMES
  1459. cbuf18        REDO            !SMALLER
  1460. X    "execute-macro-18"        !FEWNAMES
  1461. cbuf19        REDO            !SMALLER
  1462. X    "execute-macro-19"        !FEWNAMES
  1463. cbuf20        REDO            !SMALLER
  1464. X    "execute-macro-20"        !FEWNAMES
  1465. cbuf21        REDO            !SMALLER
  1466. X    "execute-macro-21"        !FEWNAMES
  1467. cbuf22        REDO            !SMALLER
  1468. X    "execute-macro-22"        !FEWNAMES
  1469. cbuf23        REDO            !SMALLER
  1470. X    "execute-macro-23"        !FEWNAMES
  1471. cbuf24        REDO            !SMALLER
  1472. X    "execute-macro-24"        !FEWNAMES
  1473. cbuf25        REDO            !SMALLER
  1474. X    "execute-macro-25"        !FEWNAMES
  1475. cbuf26        REDO            !SMALLER
  1476. X    "execute-macro-26"        !FEWNAMES
  1477. cbuf27        REDO            !SMALLER
  1478. X    "execute-macro-27"        !FEWNAMES
  1479. cbuf28        REDO            !SMALLER
  1480. X    "execute-macro-28"        !FEWNAMES
  1481. cbuf29        REDO            !SMALLER
  1482. X    "execute-macro-29"        !FEWNAMES
  1483. cbuf30        REDO            !SMALLER
  1484. X    "execute-macro-30"        !FEWNAMES
  1485. cbuf31        REDO            !SMALLER
  1486. X    "execute-macro-31"        !FEWNAMES
  1487. cbuf32        REDO            !SMALLER
  1488. X    "execute-macro-32"        !FEWNAMES
  1489. cbuf33        REDO            !SMALLER
  1490. X    "execute-macro-33"        !FEWNAMES
  1491. cbuf34        REDO            !SMALLER
  1492. X    "execute-macro-34"        !FEWNAMES
  1493. cbuf35        REDO            !SMALLER
  1494. X    "execute-macro-35"        !FEWNAMES
  1495. cbuf36        REDO            !SMALLER
  1496. X    "execute-macro-36"        !FEWNAMES
  1497. cbuf37        REDO            !SMALLER
  1498. X    "execute-macro-37"        !FEWNAMES
  1499. cbuf38        REDO            !SMALLER
  1500. X    "execute-macro-38"        !FEWNAMES
  1501. cbuf39        REDO            !SMALLER
  1502. X    "execute-macro-39"        !FEWNAMES
  1503. cbuf40        REDO            !SMALLER
  1504. X    "execute-macro-40"        !FEWNAMES
  1505. delwind        NONE
  1506. X    "delete-window"            !FEWNAMES
  1507. X    '^K'
  1508. X    '^X-0'
  1509. deblank        REDO|UNDO        AEDIT
  1510. X    "delete-blank-lines"        !FEWNAMES
  1511. X    '^A-o'
  1512. delgmode    NONE
  1513. X    "delete-global-mode"        !FEWNAMES
  1514. X    "setgno"
  1515. X    "unsetg"
  1516. delmode        NONE|(EXRCOK|EXTRA)
  1517. X    "delete-mode"            !FEWNAMES
  1518. X    "setno"
  1519. X    "unset"
  1520. deltoeol    REDO|UNDO
  1521. X    "delete-to-end-of-line"        !FEWNAMES
  1522. X    'D'
  1523. desbind        NONE            REBIND
  1524. X    "describe-bindings"
  1525. deskey        NONE            REBIND
  1526. X    "describe-key"
  1527. detab        REDO|UNDO        AEDIT
  1528. X    "detab-line"            !FEWNAMES
  1529. X    '^A- '
  1530. dotcmdplay    NONE
  1531. X    "repeat-last-cmd"        !FEWNAMES
  1532. X    '.'
  1533. execbuf        NONE            !SMALLER
  1534. X    "execute-buffer"        !FEWNAMES
  1535. execcmd        NONE            NEVER
  1536. X    "execute-command-line"        !FEWNAMES
  1537. execfile    NONE            !SMALLER
  1538. X    "execute-file"            !FEWNAMES
  1539. execproc    REDO            PROC
  1540. X    "execute-procedure"        !FEWNAMES
  1541. X    "run"
  1542. enlargewind    NONE
  1543. X    "grow-window"            !FEWNAMES
  1544. X    'V'
  1545. entab        REDO|UNDO        AEDIT
  1546. X    "entab-line"            !FEWNAMES
  1547. X    '^A-^I'
  1548. esc        NONE
  1549. X    "abort-command"            !FEWNAMES
  1550. X    '^['
  1551. fcsrch        MOTION
  1552. X    "forward-char-scan"        !FEWNAMES
  1553. X    'f'
  1554. fcsrch_to    MOTION
  1555. X    "forward-char-scan-to"        !FEWNAMES
  1556. X    't'
  1557. filefind    NONE|(BANG|FILE1|PLUS)
  1558. X    "e"
  1559. X    "E"
  1560. X    "edit-file"            !FEWNAMES
  1561. X    "find-file"            !FEWNAMES
  1562. X    '^X-e'
  1563. filename    NONE|(NAMEDF)
  1564. X    "change-file-name"        !FEWNAMES
  1565. X    "f"
  1566. X    "file"
  1567. X    "filename"
  1568. fileread    NONE
  1569. X    "e!"
  1570. X    "replace-with-file"        !FEWNAMES
  1571. filesave    NONE            !SMALLER
  1572. X    "save-file"
  1573. filewrite    NONE
  1574. #    "w"
  1575. #    "W"
  1576. X    "write-file"            !FEWNAMES
  1577. filter        REDO|UNDO
  1578. X    "|"
  1579. X    "filter-buffer"            !FEWNAMES
  1580. finderr        NONE            FINDERR
  1581. X    "find-next-error"        !FEWNAMES
  1582. X    '^X-^X'
  1583. firstnonwhite    MOTION
  1584. X    "first-nonwhite"        !FEWNAMES
  1585. X    '^'
  1586. fisearch    NONE            ISRCH
  1587. X    "incremental-search"        !FEWNAMES
  1588. X    '^X-S'
  1589. flipchar    REDO|UNDO
  1590. X    "flip-character"        !FEWNAMES
  1591. X    '~'
  1592. fnclabel    NONE            FLABEL
  1593. X    "label-function-key"        !FEWNAMES
  1594. X    "label-fkey"
  1595. forwdelchar    REDO|UNDO
  1596. X    "delete-next-character"        !FEWNAMES
  1597. X    'x'
  1598. forwhpage    NONE
  1599. X    "next-half-page"        !FEWNAMES
  1600. X    '^D'
  1601. forwchar    MOTION
  1602. X    "forward-character"        !FEWNAMES
  1603. X    ' '
  1604. X    'l'
  1605. forwpage    MOTION
  1606. X    "next-page"            !FEWNAMES
  1607. X    '^F'
  1608. forwline    GOAL|MOTION|FL
  1609. X    "next-line"            !FEWNAMES
  1610. X    'j'
  1611. X    '^J'
  1612. forwbline    MOTION|FL
  1613. X    "next-line-at-bol"        !FEWNAMES
  1614. X    '+'
  1615. X    '^M'
  1616. forwword    MOTION
  1617. X    "next-word"            !FEWNAMES
  1618. X    'W'
  1619. forwviword    MOTION
  1620. X    "next-punc-word"        !FEWNAMES
  1621. X    'w'
  1622. forwendw    MOTION
  1623. X    "next-word-end"            !FEWNAMES
  1624. X    'E'
  1625. forwviendw    MOTION
  1626. X    "next-punc-word-end"        !FEWNAMES
  1627. X    'e'
  1628. forwhunt    ABS|MOTION        !SMALLER
  1629. X    "hunt-forward"            !FEWNAMES
  1630. forwsearch    ABS|MOTION
  1631. X    "search-forward"        !FEWNAMES
  1632. X    '/'
  1633. getfence    ABS|MOTION        CFENCE
  1634. X    "goto-matching-fence"        !FEWNAMES
  1635. X    '%'
  1636. globals        NONE            GLOBALS
  1637. X    "og"
  1638. # this function is for internal use only, for the operator commands
  1639. godotplus    MOTION|FL
  1640. X
  1641. # this function is for internal use only, for ex commands
  1642. gomark        MOTION|FL|(RANGE)
  1643. X
  1644. gotobop        ABS|MOTION        WORDPRO
  1645. X    "previous-paragraph"        !FEWNAMES
  1646. X    '{'
  1647. gotoeop        ABS|MOTION        WORDPRO
  1648. X    "next-paragraph"        !FEWNAMES
  1649. X    '}'
  1650. gotobob        ABS|MOTION        !SMALLER
  1651. X    "beginning-of-file"        !FEWNAMES
  1652. gotoeob        ABS|MOTION        !SMALLER
  1653. X    "end-of-file"            !FEWNAMES
  1654. gotobol        MOTION
  1655. X    "beginning-of-line"        !FEWNAMES
  1656. X    '0'
  1657. gotoeol        MOTION|GOAL
  1658. X    "end-of-line"            !FEWNAMES
  1659. X    '$'
  1660. gotobos        MOTION|FL
  1661. X    "beginning-of-screen"        !FEWNAMES
  1662. X    'H'
  1663. gotomos        MOTION|FL
  1664. X    "middle-of-screen"        !FEWNAMES
  1665. X    'M'
  1666. gotoeos        MOTION|FL
  1667. X    "end-of-screen"            !FEWNAMES
  1668. X    'L'
  1669. gotobosec    ABS|MOTION        WORDPRO
  1670. X    "previous-section"        !FEWNAMES
  1671. X    '['
  1672. gotoeosec    ABS|MOTION        WORDPRO
  1673. X    "next-section"            !FEWNAMES
  1674. X    ']'
  1675. gototag        NONE|(BANG|WORD1)        TAGS
  1676. X    "ta"
  1677. X    "tag"
  1678. X    "find-tag"            !FEWNAMES
  1679. X    '^]'
  1680. gotocol        MOTION
  1681. X    "goto-column"            !FEWNAMES
  1682. X    '|'
  1683. gotoline    ABS|MOTION|FL|(RANGE)
  1684. X    "goto-line"            !FEWNAMES
  1685. X    'G'
  1686. # golinenmmark and goexactnmmark are special cases--    
  1687. #     no ABS even though they are absolute, since these are the commands
  1688. #    that maintain the last-dot-mark
  1689. golinenmmark    MOTION|FL
  1690. X    "goto-named-mark"        !FEWNAMES
  1691. #  single quote -- can't use '''
  1692. X    '\047'
  1693. goexactnmmark    MOTION
  1694. X    "goto-named-mark-exact"        !FEWNAMES
  1695. X    '`'
  1696. help        NONE
  1697. X    "h"
  1698. X    "help"
  1699. X    '^A-h'
  1700. X    '^X-h'
  1701. histbuff    NONE
  1702. X    "historical-buffer"        !FEWNAMES
  1703. X    '_'
  1704. X    "_"
  1705. insert        REDO|UNDO
  1706. X    "insertchar"            !FEWNAMES
  1707. X    'i'
  1708. insertbol    REDO|UNDO
  1709. X    "insert-bol"            !FEWNAMES
  1710. X    'I'
  1711. insfiletop        REDO|UNDO    BEFORE
  1712. X    "R"
  1713. X    "insert-file-at-top"            !FEWNAMES
  1714. insfile        REDO|UNDO|GLOBOK|(FROM|ZERO|NAMEDF)
  1715. X    "r"
  1716. X    "insert-file"            !FEWNAMES
  1717. X    '^R'
  1718. insspace    REDO|UNDO        !SMALLER
  1719. X    "insert-space"            !FEWNAMES
  1720. istring        REDO|UNDO        !SMALLER
  1721. X    "insert-string"
  1722. join        REDO|UNDO
  1723. X    "join-lines"            !FEWNAMES
  1724. X    'J'
  1725. killbuffer    NONE
  1726. X    "delete-buffer"            !FEWNAMES
  1727. X    "kill-buffer"            !FEWNAMES
  1728. X    "ki"
  1729. showlength    NONE
  1730. X    "buffer-length"            !FEWNAMES
  1731. X    "="
  1732. lastnonwhite    MOTION            !SMALLER
  1733. X    "last-nonwhite"            !FEWNAMES
  1734. listbuffers    NONE
  1735. X    "list-buffers"            !FEWNAMES
  1736. X    '^A-*'
  1737. lineputafter    REDO|UNDO|GLOBOK|(FROM|ZERO|WORD1)
  1738. X    "put-as-lines-after"        !FEWNAMES
  1739. X    "put"
  1740. X    '^X-p'
  1741. lineputbefore    REDO|UNDO|GLOBOK|(FROM|WORD1)
  1742. X    "put-as-lines-before"        !FEWNAMES
  1743. X    "Put"
  1744. X    '^X-P'
  1745. lineundo    NONE
  1746. X    "undo-line-changes"        !FEWNAMES
  1747. X    'U'
  1748. map        NONE|(EXRCOK|BANG|EXTRA)
  1749. X    "map"
  1750. cntl_af        NONE
  1751. X    "cntl_a-prefix"
  1752. X    '^A'
  1753. opermove    OPER|(RANGE|EXTRA)
  1754. X    "move"
  1755. X    "m"
  1756. mvdnnxtwind    NONE
  1757. X    "move-next-window-down"        !FEWNAMES
  1758. X    '^A-^E'
  1759. mvupnxtwind    NONE
  1760. X    "move-next-window-up"        !FEWNAMES
  1761. X    '^A-^Y'
  1762. mvdnwind    GOAL
  1763. X    "move-window-down"        !FEWNAMES
  1764. X    '^E'
  1765. mvupwind    GOAL
  1766. X    "move-window-up"        !FEWNAMES
  1767. X    '^Y'
  1768. mvrightwind    GOAL
  1769. X    "move-window-right"        !FEWNAMES
  1770. X    '^X-^R'
  1771. mvleftwind    GOAL
  1772. X    "move-window-left"        !FEWNAMES
  1773. X    '^X-^L'
  1774. nextbuffer    NONE|(BANG|NAMEDFS)
  1775. X    "n"
  1776. X    "next-buffer"            !FEWNAMES
  1777. namebuffer    NONE
  1778. X    "rename-buffer"
  1779. newline        REDO|UNDO        !SMALLER
  1780. X    "newline"
  1781. newlength    NONE
  1782. X    "screen-rows"
  1783. newwidth    NONE
  1784. X    "screen-columns"
  1785. nextwind    NONE
  1786. X    "next-window"            !FEWNAMES
  1787. X    '^N'
  1788. nullproc    NONE
  1789. X    "nop"                !FEWNAMES
  1790. X    '^Q'
  1791. X    '^S'
  1792. onamedcmd    NONE
  1793. X    "execute-named-command-old"    !FEWNAMES
  1794. X    '^A-:'
  1795. namedcmd    NONE
  1796. X    "execute-named-command"        !FEWNAMES
  1797. X    ":"
  1798. X    ':'
  1799. ex    NONE|(BANG|FILE1)
  1800. X    "ex"
  1801. operchg        OPER|REDO|UNDO
  1802. X    "change-til"            !FEWNAMES
  1803. X    'c'
  1804. operlinechg    OPER|REDO|UNDO|(RANGE)
  1805. X    "change-lines-til"        !FEWNAMES
  1806. X    "ch"
  1807. X    '^X-c'
  1808. operdel        OPER|REDO|UNDO
  1809. X    "delete-til"            !FEWNAMES
  1810. X    'd'
  1811. operlinedel    OPER|REDO|UNDO|GLOBOK|(RANGE+WORD1)
  1812. X    "delete-lines-til"        !FEWNAMES
  1813. X    "d"
  1814. X    '^X-d'
  1815. operfilter    OPER|REDO|UNDO|(EXRCOK|RANGE|NAMEDFS|DFLNONE|NL)
  1816. X    "filter-til"            !FEWNAMES
  1817. X    "!"
  1818. X    '!'
  1819. operformat    OPER|REDO|UNDO|(RANGE)        WORDPRO
  1820. X    "format-til"            !FEWNAMES
  1821. X    '^A-f'
  1822. X    '^A-j'
  1823. operflip    OPER|REDO|UNDO|GLOBOK|(RANGE)
  1824. X    "flip-til"            !FEWNAMES
  1825. X    "~"
  1826. X    '^A-~'
  1827. # RANGE commented out, since it's not done.... 
  1828. operglobals    OPER|(/*RANGE|*/BANG|EXTRA|DFLALL)    GLOBALS
  1829. X    "global"
  1830. X    "g"
  1831. opervglobals    OPER|(RANGE|BANG|EXTRA|DFLALL)    GLOBALS
  1832. X    "vglobal"
  1833. X    "v"
  1834. operlower    OPER|REDO|UNDO|GLOBOK|(RANGE)
  1835. X    "lower-til"            !FEWNAMES
  1836. X    "L"
  1837. X    '^A-l'
  1838. operlist    OPER|GLOBOK|(RANGE)        GLOBALS
  1839. X    "list-lines-til"        !FEWNAMES
  1840. X    "l"
  1841. operprint    OPER|GLOBOK|(RANGE)        GLOBALS
  1842. X    "print-lines-til"        !FEWNAMES
  1843. X    "p"
  1844. operupper    OPER|REDO|UNDO|GLOBOK|(RANGE)
  1845. X    "upper-til"            !FEWNAMES
  1846. X    "U"
  1847. X    '^A-u'
  1848. operlshift    OPER|REDO|UNDO|GLOBOK|(RANGE)
  1849. X    "shift-left-til"        !FEWNAMES
  1850. X    "<"
  1851. X    '<'
  1852. operrshift    OPER|REDO|UNDO|GLOBOK|(RANGE)
  1853. X    "shift-right-til"        !FEWNAMES
  1854. X    ">"
  1855. X    '>'
  1856. opersubst    OPER|REDO|UNDO|GLOBOK|(RANGE|EXTRA)
  1857. X    "substitute"            !FEWNAMES
  1858. X    "s"
  1859. X    '^X-s'
  1860. operyank    OPER
  1861. X    "yank-til"            !FEWNAMES
  1862. X    'y'
  1863. operlineyank    OPER|(RANGE|WORD1)
  1864. X    "yank-lines-til"        !FEWNAMES
  1865. X    "y"
  1866. X    '^X-y'
  1867. openup        REDO|UNDO|(FROM)
  1868. X    "open-line-above"        !FEWNAMES
  1869. X    "insert"
  1870. X    "i"
  1871. X    'O'
  1872. opendown    REDO|UNDO|(FROM|ZERO)
  1873. X    "open-line-below"        !FEWNAMES
  1874. X    "append"
  1875. X    "a"
  1876. X    'o'
  1877. operwrite    OPER|(RANGE|BANG|FILE1|DFLALL)
  1878. X    "w"
  1879. X    "W"
  1880. X    "write-til"            !FEWNAMES
  1881. X    '^W'
  1882. overwrite    REDO|UNDO
  1883. X    "overwrite"            !FEWNAMES
  1884. X    'R'
  1885. onlywind    NONE
  1886. X    "delete-other-windows"        !FEWNAMES
  1887. X    '^O'
  1888. X    '^X-1'
  1889. poswind        NONE
  1890. X    "position-window"        !FEWNAMES
  1891. X    'z'
  1892. prevwind    NONE
  1893. X    "previous-window"        !FEWNAMES
  1894. X    '^P'
  1895. pipecmd        NONE
  1896. X    "pipe-command"            !FEWNAMES
  1897. X    '^X-!'
  1898. putafter    REDO|UNDO
  1899. X    "put-after"            !FEWNAMES
  1900. X    'p'
  1901. putbefore    REDO|UNDO
  1902. X    "put-before"            !FEWNAMES
  1903. X    'P'
  1904. quit        NONE|(BANG)
  1905. X    "q"
  1906. X    "Q"
  1907. X    "exit"
  1908. X    'Q'
  1909. X    '^X-^C'
  1910. quithard    NONE
  1911. X    "q!"
  1912. quickexit    NONE|(BANG|NL)
  1913. X    "x"
  1914. X    "xit"
  1915. X    "quick-exit"            !FEWNAMES
  1916. X    'Z'
  1917. quote        REDO|UNDO
  1918. X    "quote-character"        !FEWNAMES
  1919. X    '^V'
  1920. refresh        NONE
  1921. X    "clear-and-redraw"        !FEWNAMES
  1922. X    '^L'
  1923. reposition    NONE            !SMALLER
  1924. X    "redraw-display"
  1925. rep_csrch    MOTION
  1926. X    "repeat-char-scan"        !FEWNAMES
  1927. X    ';'
  1928. replacechar    REDO|UNDO
  1929. X    "replace-character"        !FEWNAMES
  1930. X    'r'
  1931. respawn        NONE
  1932. X    "!!"
  1933. X    "rerun-shell-command"        !FEWNAMES
  1934. resize        NONE            !SMALLER
  1935. X    "resize-window"
  1936. restwnd        NONE            !SMALLER
  1937. X    "restore-window"
  1938. rev_csrch    MOTION
  1939. X    "reverse-char-scan"        !FEWNAMES
  1940. X    ','
  1941. risearch    NONE            ISRCH
  1942. X    "reverse-incremental-search"    !FEWNAMES
  1943. X    '^X-R'
  1944. revsearch    ABS|MOTION
  1945. X    "reverse-search"        !FEWNAMES
  1946. X    'N'
  1947. scrforwsearch    ABS|MOTION
  1948. X    "screen-search-forward"        !FEWNAMES
  1949. X    '^X-/'
  1950. scrbacksearch    ABS|MOTION
  1951. X    "screen-search-reverse"        !FEWNAMES
  1952. X    '^X-?'
  1953. scrsearchpat    NONE
  1954. X    "screen-search-pattern-grab"    !FEWNAMES
  1955. X    '^A-/'
  1956. settab        NONE
  1957. X    "handle-tab"            !FEWNAMES
  1958. X    "set-tab"
  1959. X    '^X-t'
  1960. spawncli    NONE
  1961. X    "sh"
  1962. X    "shell"
  1963. X    "i-shell"            !FEWNAMES
  1964. savewnd        NONE            !SMALLER
  1965. X    "save-window"
  1966. scrnextup    NONE
  1967. X    "scroll-next-up"        !FEWNAMES
  1968. X    '^A-^U'
  1969. scrnextdw    NONE
  1970. X    "scroll-next-down"        !FEWNAMES
  1971. X    '^A-^D'
  1972. setfillcol    NONE
  1973. X    "set-fill-column"
  1974. X    '^X-f'
  1975. setkey        NONE            CRYPT
  1976. X    "set-crypt-key"
  1977. X    '^X-X'
  1978. setmode        NONE|(EXRCOK|EXTRA)
  1979. X    "set"
  1980. X    "set-mode"            !FEWNAMES
  1981. setgmode    NONE
  1982. X    "setg"
  1983. X    "set-global-mode"
  1984. setnmmark    NONE|(FROM+WORD1)
  1985. X    "set-named-mark"        !FEWNAMES
  1986. X    "k"
  1987. X    'm'
  1988. setvar        NONE            !SMALLER
  1989. X    "setv"
  1990. X    "set-variable"
  1991. setvmalloc    NONE            VMALLOC
  1992. X    "vmalloc"
  1993. X    '^X-v'
  1994. showcpos    NONE
  1995. X    "position"        !FEWNAMES
  1996. X    '^G'
  1997. X    '^X-='
  1998. showmodes    NONE
  1999. X    "modes"
  2000. X    "show-modes"
  2001. X    "setall"
  2002. showgmodes    NONE
  2003. X    "gmodes"
  2004. X    "show-global-modes"
  2005. X    "setgall"
  2006. showversion    NONE|(EXRCOK)
  2007. X    "version"
  2008. shrinkwind    NONE
  2009. X    "shrink-window"            !FEWNAMES
  2010. X    'v'
  2011. source        NONE|(EXRCOK|NAMEDF)
  2012. X    "source"
  2013. spawn        NONE
  2014. #    "!"
  2015. X    "shell-command"            !FEWNAMES
  2016. splitwind    NONE
  2017. X    "split-current-window"        !FEWNAMES
  2018. X    '^T'
  2019. X    '^X-2'
  2020. storemac    NONE
  2021. X    "store-macro"
  2022. storeproc    NONE            PROC
  2023. X    "store-procedure"
  2024. subst_again    REDO|UNDO|GLOBOK|(RANGE|EXTRA)
  2025. X    "substitute-again"        !FEWNAMES
  2026. X    "&"
  2027. opertransf    OPER|(RANGE+EXTRA)
  2028. X    "t"
  2029. togglelistbuffers    NONE
  2030. X    "*"
  2031. X    "toggle-buffer-list"        !FEWNAMES
  2032. X    '*'
  2033. trimline        REDO|UNDO|GLOBOK
  2034. X    "trim-line"            !FEWNAMES
  2035. X    "trim"
  2036. X    '^A-t'
  2037. twiddle        REDO|UNDO        !SMALLER
  2038. X    "transpose-characters"        !FEWNAMES
  2039. unbindkey    NONE            REBIND
  2040. X    "unbind-key"
  2041. undo        NONE
  2042. X    "undo-change"            !FEWNAMES
  2043. X    'u'
  2044. unarg        NONE
  2045. X    "universal-argument"        !FEWNAMES
  2046. X    'K'
  2047. unimpl        NONE
  2048. X    "unimplemented-command"        !FEWNAMES
  2049. X    '('
  2050. X    ')'
  2051. unmark        NONE
  2052. X    "unmark-buffer"
  2053. unmap        NONE|(EXRCOK|BANG|EXTRA)
  2054. X    "unmap"
  2055. untagpop    NONE            TAGS
  2056. X    "untag-pop"            !FEWNAMES
  2057. X    '^X-^]'
  2058. upscreen    NONE            !SMALLER
  2059. X    "update-screen"
  2060. usebuffer    NONE
  2061. X    "b"
  2062. X    "buffer"
  2063. X    "select-buffer"            !FEWNAMES
  2064. usekreg        REDO
  2065. X    "use-named-kill-register"    !FEWNAMES
  2066. X    '"'
  2067. visual        NONE
  2068. X    "visual"
  2069. vglobals    NONE            GLOBALS
  2070. X    "ov"
  2071. viewfile    NONE
  2072. X    "view-file"
  2073. writequit    NONE|(NL)
  2074. X    "wq"
  2075. X    "Wq"
  2076. X    "WQ"
  2077. X    "write-file-and-quit"        !FEWNAMES
  2078. wrapword    REDO|UNDO        !SMALLER
  2079. X    "wrap-word"
  2080. writemsg    NONE            !SMALLER
  2081. X    "write-message"
  2082. yankline    NONE
  2083. X    "yank-line"            !FEWNAMES
  2084. X    'Y'
  2085. X
  2086. SHAR_EOF
  2087. chmod 0444 cmdtbl ||
  2088. echo 'restore of cmdtbl failed'
  2089. Wc_c="`wc -c < 'cmdtbl'`"
  2090. test 17753 -eq "$Wc_c" ||
  2091.     echo 'cmdtbl: original size 17753, current size' "$Wc_c"
  2092. # ============= crypt.c ==============
  2093. echo 'x - extracting crypt.c (Text)'
  2094. sed 's/^X//' << 'SHAR_EOF' > 'crypt.c' &&
  2095. /*    Crypt:    Encryption routines for MicroEMACS
  2096. X        written by Dana Hoggatt and Daniel Lawrence
  2097. */
  2098. X
  2099. #include    <stdio.h>
  2100. #include    "estruct.h"
  2101. #include    "edef.h"
  2102. X
  2103. #if    CRYPT
  2104. setkey(f, n)    /* reset encryption key of current buffer */
  2105. X
  2106. int f;        /* default flag */
  2107. int n;        /* numeric argument */
  2108. X
  2109. {
  2110. X    register int status;    /* return status */
  2111. X    int odisinp;        /* original vlaue of disinp */
  2112. X    char key[NPAT];        /* new encryption string */
  2113. X
  2114. X    /* turn command input echo off */
  2115. X    odisinp = disinp;
  2116. X    disinp = FALSE;
  2117. X
  2118. X    /* get the string to use as an encrytion string */
  2119. X    key[0] = 0;
  2120. X    status = mlreply("Encryption String: ", key, NPAT - 1);
  2121. X    disinp = odisinp;
  2122. X        if (status != TRUE)
  2123. X                return(status);
  2124. X
  2125. X    /* and encrypt it */
  2126. X    crypt((char *)NULL, 0);
  2127. X    crypt(key, strlen(key));
  2128. X
  2129. X    /* and save it off */
  2130. X    strcpy(curbp->b_key, key);
  2131. X    mlwrite(" ");        /* clear it off the bottom line */
  2132. X    return(TRUE);
  2133. }
  2134. X
  2135. /**********
  2136. X *
  2137. X *    crypt - in place encryption/decryption of a buffer
  2138. X *
  2139. X *    (C) Copyright 1986, Dana L. Hoggatt
  2140. X *    1216, Beck Lane, Lafayette, IN
  2141. X *
  2142. X *    When consulting directly with the author of this routine, 
  2143. X *    please refer to this routine as the "DLH-POLY-86-B CIPHER".  
  2144. X *
  2145. X *    This routine was written for Dan Lawrence, for use in V3.8 of
  2146. X *    MicroEMACS, a public domain text/program editor.  
  2147. X *
  2148. X *    I kept the following goals in mind when preparing this function:
  2149. X *
  2150. X *        1.    All printable characters were to be encrypted back
  2151. X *        into the printable range, control characters and
  2152. X *        high-bit characters were to remain unaffected.  this
  2153. X *        way, encrypted would still be just as cheap to 
  2154. X *        transmit down a 7-bit data path as they were before.
  2155. X *
  2156. X *        2.    The encryption had to be portable.  The encrypted 
  2157. SHAR_EOF
  2158. true || echo 'restore of crypt.c failed'
  2159. echo 'End of Vile part 2'
  2160. echo 'File crypt.c is continued in part 3'
  2161. echo 3 > _shar_seq_.tmp
  2162. exit 0
  2163. -- 
  2164.         paul fox, pgf@cayman.com, (617)494-1999
  2165.         Cayman Systems, 26 Landsdowne St., Cambridge, MA 02139
  2166.