home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume1 / 8706 / 14 < prev    next >
Internet Message Format  |  1993-09-02  |  57KB

  1. From mipos3!intelca!oliveb!pyramid!uccba!hal!ncoast!allbery Fri Jun 19 14:07:06 PDT 1987
  2. Article 13 of comp.sources.misc:
  3. Path: td2cad!mipos3!intelca!oliveb!pyramid!uccba!hal!ncoast!allbery
  4. >From: davidsen@steinmetz.UUCP (William E. Davidsen Jr)
  5. Newsgroups: comp.sources.misc
  6. Subject: memacs 3.8i 2 of 11
  7. Message-ID: <2657@ncoast.UUCP>
  8. Date: 15 Jun 87 18:57:43 GMT
  9. Sender: allbery@ncoast.UUCP
  10. Lines: 2107
  11. Approved: allbery@ncoast.UUCP
  12. X-Archive: comp.sources.misc/8706/14
  13.  
  14. :
  15. #!/bin/sh
  16. # shar+ created from directory /usr2/davidsen/emacs38i
  17. # 13:42 on Thu Jun 11, 1987 by davidsen
  18. echo 'x - diffs (text)'
  19. sed << 'E!O!F' 's/^X//' > diffs
  20. Xchanges to MicroEMACS v3.8i
  21. X
  22. XSorry I couldn't do a context diff on the system with the source. These
  23. Xconsist of the name of the module, the reason for the change, given as
  24. Xcomments, and the actual diffs. These represent some changes I found
  25. Xuseful. With the exception of the change to the 'word' logic, these will
  26. Xdo nothing but eliminate compiler warnings.
  27. X----------------------------------------------------------------
  28. Xestruct.h
  29. X# This change is to keep the VAX C compiler from complaining about
  30. X# undefining 'abs'. It complains on every compile, and on the link
  31. X# once per module. Enough!
  32. X269a270
  33. X> #ifdef abs
  34. X270a272
  35. X> #endif
  36. X
  37. Xtermio.c
  38. X# this avoids a message from the BSD compiler about "statement
  39. X# not reached"
  40. X462c462
  41. X< #endif
  42. X---
  43. X> #else
  44. X463a464
  45. X> #endif
  46. Xword.c
  47. X# This causes emacs to treat words the way vi does. Delete word now has
  48. X# the following logic:
  49. X# - if the cursor is in a word, delete the word and all following
  50. X# whitespace
  51. X# - if the cursor is not in a word delete characters up to the next word
  52. X# 
  53. X# This matters for expressions like "abc/(def+ghi)", where the original
  54. X# logic would delete from 'a' in 'abc' to 'd' in 'def', dropping the
  55. X# operators on the way. With this change the word deleted is 'abc' only,
  56. Xprobably what is intended.
  57. X255,258c255,267
  58. X<         while (inword() != FALSE) {
  59. X<             if (forwchar(FALSE,1) == FALSE)
  60. X<                 return(FALSE);
  61. X<             ++size;
  62. X---
  63. X>         if (inword()) {
  64. X>             while (inword() != FALSE) {
  65. X>                 if (forwchar(FALSE,1) == FALSE)
  66. X>                     return(FALSE);
  67. X>                 ++size;
  68. X>             }
  69. X>     
  70. X>                     while ((iswhite()) &&
  71. X>                     (curwp->w_doto != llength(curwp->w_dotp))) {
  72. X>                             if (forwchar(FALSE, 1) == FALSE)
  73. X>                                     return (FALSE);
  74. X>                             ++size;
  75. X>                     }
  76. X260,266c269,276
  77. X< 
  78. X<                 while ((inword() == FALSE) &&
  79. X<                 (curwp->w_doto != llength(curwp->w_dotp))) {
  80. X<                         if (forwchar(FALSE, 1) == FALSE)
  81. X<                                 return (FALSE);
  82. X<                         ++size;
  83. X<                 }
  84. X---
  85. X>         else {
  86. X>             while ((inword() == FALSE) &&
  87. X>                     (curwp->w_doto != llength(curwp->w_dotp))) {
  88. X>                 if (forwchar(FALSE,1) == FALSE)
  89. X>                     return(FALSE);
  90. X>                 ++size;
  91. X>             }
  92. X>         }
  93. X340a351,366
  94. X>         return (FALSE);
  95. X> }
  96. X> 
  97. X> /*
  98. X>  *  return TRUE if the current character is whitespace,
  99. X>  *  else return FALSE.
  100. X>  */
  101. X> 
  102. X> iswhite()
  103. X> {
  104. X>         register int    c;
  105. X> 
  106. X>         if (curwp->w_doto == llength(curwp->w_dotp))
  107. X>                 return (FALSE);
  108. X>         c = lgetc(curwp->w_dotp, curwp->w_doto);
  109. X>     if (c == ' ' || c == '\t') return (TRUE);
  110. E!O!F
  111. newsize=`wc -c < diffs`
  112. if [ $newsize -ne 2630 ]
  113. then echo "File diffs was $newsize bytes, 2630 expected"
  114. fi
  115. echo 'x - display.c (text)'
  116. sed << 'E!O!F' 's/^X//' > display.c
  117. X/*
  118. X * The functions in this file handle redisplay. There are two halves, the
  119. X * ones that update the virtual display screen, and the ones that make the
  120. X * physical display screen the same as the virtual display screen. These
  121. X * functions use hints that are left in the windows by the commands.
  122. X *
  123. X */
  124. X
  125. X#include        <stdio.h>
  126. X#include    "estruct.h"
  127. X#include        "edef.h"
  128. X
  129. Xtypedef struct  VIDEO {
  130. X        int    v_flag;                 /* Flags */
  131. X#if    COLOR
  132. X    int    v_fcolor;        /* current forground color */
  133. X    int    v_bcolor;        /* current background color */
  134. X    int    v_rfcolor;        /* requested forground color */
  135. X    int    v_rbcolor;        /* requested background color */
  136. X#endif
  137. X        char    v_text[1];              /* Screen data. */
  138. X}       VIDEO;
  139. X
  140. X#define VFCHG   0x0001                  /* Changed flag            */
  141. X#define    VFEXT    0x0002            /* extended (beyond column 80)    */
  142. X#define    VFREV    0x0004            /* reverse video status        */
  143. X#define    VFREQ    0x0008            /* reverse video request    */
  144. X#define    VFCOL    0x0010            /* color change requested    */
  145. X
  146. XVIDEO   **vscreen;                      /* Virtual screen. */
  147. X#if    MEMMAP == 0
  148. XVIDEO   **pscreen;                      /* Physical screen. */
  149. X#endif
  150. X
  151. X/*
  152. X * Initialize the data structures used by the display code. The edge vectors
  153. X * used to access the screens are set up. The operating system's terminal I/O
  154. X * channel is set up. All the other things get initialized at compile time.
  155. X * The original window has "WFCHG" set, so that it will get completely
  156. X * redrawn on the first call to "update".
  157. X */
  158. Xvtinit()
  159. X{
  160. X    register int i;
  161. X    register VIDEO *vp;
  162. X    char *malloc();
  163. X
  164. X    TTopen();        /* open the screen */
  165. X    TTkopen();        /* open the keyboard */
  166. X    TTrev(FALSE);
  167. X    vscreen = (VIDEO **) malloc(term.t_mrow*sizeof(VIDEO *));
  168. X
  169. X    if (vscreen == NULL)
  170. X        exit(1);
  171. X
  172. X#if    MEMMAP == 0
  173. X    pscreen = (VIDEO **) malloc(term.t_mrow*sizeof(VIDEO *));
  174. X
  175. X    if (pscreen == NULL)
  176. X        exit(1);
  177. X#endif
  178. X
  179. X    for (i = 0; i < term.t_mrow; ++i)
  180. X        {
  181. X        vp = (VIDEO *) malloc(sizeof(VIDEO)+term.t_mcol);
  182. X
  183. X        if (vp == NULL)
  184. X            exit(1);
  185. X
  186. X    vp->v_flag = 0;
  187. X#if    COLOR
  188. X    vp->v_rfcolor = 7;
  189. X    vp->v_rbcolor = 0;
  190. X#endif
  191. X        vscreen[i] = vp;
  192. X#if    MEMMAP == 0
  193. X        vp = (VIDEO *) malloc(sizeof(VIDEO)+term.t_mcol);
  194. X
  195. X        if (vp == NULL)
  196. X            exit(1);
  197. X
  198. X    vp->v_flag = 0;
  199. X        pscreen[i] = vp;
  200. X#endif
  201. X        }
  202. X}
  203. X
  204. X/*
  205. X * Clean up the virtual terminal system, in anticipation for a return to the
  206. X * operating system. Move down to the last line and clear it out (the next
  207. X * system prompt will be written in the line). Shut down the channel to the
  208. X * terminal.
  209. X */
  210. Xvttidy()
  211. X{
  212. X    mlerase();
  213. X    movecursor(term.t_nrow, 0);
  214. X    TTflush();
  215. X    TTclose();
  216. X    TTkclose();
  217. X}
  218. X
  219. X/*
  220. X * Set the virtual cursor to the specified row and column on the virtual
  221. X * screen. There is no checking for nonsense values; this might be a good
  222. X * idea during the early stages.
  223. X */
  224. Xvtmove(row, col)
  225. X{
  226. X    vtrow = row;
  227. X    vtcol = col;
  228. X}
  229. X
  230. X/* Write a character to the virtual screen. The virtual row and
  231. X   column are updated. If we are not yet on left edge, don't print
  232. X   it yet. If the line is too long put a "$" in the last column.
  233. X   This routine only puts printing characters into the virtual
  234. X   terminal buffers. Only column overflow is checked.
  235. X*/
  236. X
  237. Xvtputc(c)
  238. X
  239. Xint c;
  240. X
  241. X{
  242. X    register VIDEO *vp;    /* ptr to line being updated */
  243. X
  244. X    vp = vscreen[vtrow];
  245. X
  246. X    if (c == '\t') {
  247. X        do {
  248. X            vtputc(' ');
  249. X        } while (((vtcol + taboff)&0x07) != 0);
  250. X    } else if (vtcol >= term.t_ncol) {
  251. X        ++vtcol;
  252. X        vp->v_text[term.t_ncol - 1] = '$';
  253. X    } else if (c < 0x20 || c == 0x7F) {
  254. X        vtputc('^');
  255. X        vtputc(c ^ 0x40);
  256. X    } else {
  257. X        if (vtcol >= 0)
  258. X            vp->v_text[vtcol] = c;
  259. X        ++vtcol;
  260. X    }
  261. X}
  262. X
  263. X/*
  264. X * Erase from the end of the software cursor to the end of the line on which
  265. X * the software cursor is located.
  266. X */
  267. Xvteeol()
  268. X{
  269. X    register VIDEO      *vp;
  270. X
  271. X    vp = vscreen[vtrow];
  272. X    while (vtcol < term.t_ncol)
  273. X        vp->v_text[vtcol++] = ' ';
  274. X}
  275. X
  276. X/* upscreen:    user routine to force a screen update
  277. X        always finishes complete update        */
  278. X
  279. Xupscreen(f, n)
  280. X
  281. X{
  282. X    update(TRUE);
  283. X    return(TRUE);
  284. X}
  285. X
  286. X/*
  287. X * Make sure that the display is right. This is a three part process. First,
  288. X * scan through all of the windows looking for dirty ones. Check the framing,
  289. X * and refresh the screen. Second, make sure that "currow" and "curcol" are
  290. X * correct for the current window. Third, make the virtual and physical
  291. X * screens the same.
  292. X */
  293. Xupdate(force)
  294. X
  295. Xint force;    /* force update past type ahead? */
  296. X
  297. X{
  298. X    register WINDOW *wp;
  299. X
  300. X#if    TYPEAH
  301. X    if (force == FALSE && typahead())
  302. X        return(TRUE);
  303. X#endif
  304. X#if    VISMAC == 0
  305. X    if (force == FALSE && kbdmode == PLAY)
  306. X        return(TRUE);
  307. X#endif
  308. X
  309. X    /* update any windows that need refreshing */
  310. X    wp = wheadp;
  311. X    while (wp != NULL) {
  312. X        if (wp->w_flag) {
  313. X            /* if the window has changed, service it */
  314. X            reframe(wp);    /* check the framing */
  315. X            if ((wp->w_flag & ~WFMODE) == WFEDIT)
  316. X                updone(wp);    /* update EDITed line */
  317. X            else if (wp->w_flag & ~WFMOVE)
  318. X                updall(wp);    /* update all lines */
  319. X            if (wp->w_flag & WFMODE)
  320. X                modeline(wp);    /* update modeline */
  321. X            wp->w_flag = 0;
  322. X            wp->w_force = 0;
  323. X        }
  324. X        /* on to the next window */
  325. X        wp = wp->w_wndp;
  326. X    }
  327. X
  328. X    /* recalc the current hardware cursor location */
  329. X    updpos();
  330. X
  331. X#if    MEMMAP
  332. X    /* update the cursor and flush the buffers */
  333. X    movecursor(currow, curcol - lbound);
  334. X#endif
  335. X
  336. X    /* check for lines to de-extend */
  337. X    upddex();
  338. X
  339. X    /* if screen is garbage, re-plot it */
  340. X    if (sgarbf != FALSE)
  341. X        updgar();
  342. X
  343. X    /* update the virtual screen to the physical screen */
  344. X    updupd(force);
  345. X
  346. X    /* update the cursor and flush the buffers */
  347. X    movecursor(currow, curcol - lbound);
  348. X    TTflush();
  349. X    return(TRUE);
  350. X}
  351. X
  352. X/*    reframe:    check to see if the cursor is on in the window
  353. X            and re-frame it if needed or wanted        */
  354. X
  355. Xreframe(wp)
  356. X
  357. XWINDOW *wp;
  358. X
  359. X{
  360. X    register LINE *lp;
  361. X    register int i;
  362. X
  363. X    /* if not a requested reframe, check for a needed one */
  364. X    if ((wp->w_flag & WFFORCE) == 0) {
  365. X        lp = wp->w_linep;
  366. X        for (i = 0; i < wp->w_ntrows; i++) {
  367. X
  368. X            /* if the line is in the window, no reframe */
  369. X            if (lp == wp->w_dotp)
  370. X                return(TRUE);
  371. X
  372. X            /* if we are at the end of the file, reframe */
  373. X            if (lp == wp->w_bufp->b_linep)
  374. X                break;
  375. X
  376. X            /* on to the next line */
  377. X            lp = lforw(lp);
  378. X        }
  379. X    }
  380. X
  381. X    /* reaching here, we need a window refresh */
  382. X    i = wp->w_force;
  383. X
  384. X    /* how far back to reframe? */
  385. X    if (i > 0) {        /* only one screen worth of lines max */
  386. X        if (--i >= wp->w_ntrows)
  387. X            i = wp->w_ntrows - 1;
  388. X    } else if (i < 0) {    /* negative update???? */
  389. X        i += wp->w_ntrows;
  390. X        if (i < 0)
  391. X            i = 0;
  392. X    } else
  393. X        i = wp->w_ntrows / 2;
  394. X
  395. X    /* backup to new line at top of window */
  396. X    lp = wp->w_dotp;
  397. X    while (i != 0 && lback(lp) != wp->w_bufp->b_linep) {
  398. X        --i;
  399. X        lp = lback(lp);
  400. X    }
  401. X
  402. X    /* and reset the current line at top of window */
  403. X    wp->w_linep = lp;
  404. X    wp->w_flag |= WFHARD;
  405. X    wp->w_flag &= ~WFFORCE;
  406. X    return(TRUE);
  407. X}
  408. X
  409. X/*    updone:    update the current line    to the virtual screen        */
  410. X
  411. Xupdone(wp)
  412. X
  413. XWINDOW *wp;    /* window to update current line in */
  414. X
  415. X{
  416. X    register LINE *lp;    /* line to update */
  417. X    register int sline;    /* physical screen line to update */
  418. X    register int i;
  419. X
  420. X    /* search down the line we want */
  421. X    lp = wp->w_linep;
  422. X    sline = wp->w_toprow;
  423. X    while (lp != wp->w_dotp) {
  424. X        ++sline;
  425. X        lp = lforw(lp);
  426. X    }
  427. X
  428. X    /* and update the virtual line */
  429. X    vscreen[sline]->v_flag |= VFCHG;
  430. X    vscreen[sline]->v_flag &= ~VFREQ;
  431. X    vtmove(sline, 0);
  432. X    for (i=0; i < llength(lp); ++i)
  433. X        vtputc(lgetc(lp, i));
  434. X#if    COLOR
  435. X    vscreen[sline]->v_rfcolor = wp->w_fcolor;
  436. X    vscreen[sline]->v_rbcolor = wp->w_bcolor;
  437. X#endif
  438. X    vteeol();
  439. X}
  440. X
  441. X/*    updall:    update all the lines in a window on the virtual screen */
  442. X
  443. Xupdall(wp)
  444. X
  445. XWINDOW *wp;    /* window to update lines in */
  446. X
  447. X{
  448. X    register LINE *lp;    /* line to update */
  449. X    register int sline;    /* physical screen line to update */
  450. X    register int i;
  451. X
  452. X    /* search down the lines, updating them */
  453. X    lp = wp->w_linep;
  454. X    sline = wp->w_toprow;
  455. X    while (sline < wp->w_toprow + wp->w_ntrows) {
  456. X
  457. X        /* and update the virtual line */
  458. X        vscreen[sline]->v_flag |= VFCHG;
  459. X        vscreen[sline]->v_flag &= ~VFREQ;
  460. X        vtmove(sline, 0);
  461. X        if (lp != wp->w_bufp->b_linep) {
  462. X            /* if we are not at the end */
  463. X            for (i=0; i < llength(lp); ++i)
  464. X                vtputc(lgetc(lp, i));
  465. X            lp = lforw(lp);
  466. X        }
  467. X
  468. X        /* on to the next one */
  469. X#if    COLOR
  470. X        vscreen[sline]->v_rfcolor = wp->w_fcolor;
  471. X        vscreen[sline]->v_rbcolor = wp->w_bcolor;
  472. X#endif
  473. X        vteeol();
  474. X        ++sline;
  475. X    }
  476. X
  477. X}
  478. X
  479. X/*    updpos:    update the position of the hardware cursor and handle extended
  480. X        lines. This is the only update for simple moves.    */
  481. X
  482. Xupdpos()
  483. X
  484. X{
  485. X    register LINE *lp;
  486. X    register int c;
  487. X    register int i;
  488. X
  489. X    /* find the current row */
  490. X    lp = curwp->w_linep;
  491. X    currow = curwp->w_toprow;
  492. X    while (lp != curwp->w_dotp) {
  493. X        ++currow;
  494. X        lp = lforw(lp);
  495. X    }
  496. X
  497. X    /* find the current column */
  498. X    curcol = 0;
  499. X    i = 0;
  500. X    while (i < curwp->w_doto) {
  501. X        c = lgetc(lp, i++);
  502. X        if (c == '\t')
  503. X            curcol |= 0x07;
  504. X        else
  505. X            if (c < 0x20 || c == 0x7f)
  506. X                ++curcol;
  507. X
  508. X        ++curcol;
  509. X    }
  510. X
  511. X    /* if extended, flag so and update the virtual line image */
  512. X    if (curcol >=  term.t_ncol - 1) {
  513. X        vscreen[currow]->v_flag |= (VFEXT | VFCHG);
  514. X        updext();
  515. X    } else
  516. X        lbound = 0;
  517. X}
  518. X
  519. X/*    upddex:    de-extend any line that derserves it        */
  520. X
  521. Xupddex()
  522. X
  523. X{
  524. X    register WINDOW *wp;
  525. X    register LINE *lp;
  526. X    register int i,j;
  527. X
  528. X    wp = wheadp;
  529. X
  530. X    while (wp != NULL) {
  531. X        lp = wp->w_linep;
  532. X        i = wp->w_toprow;
  533. X
  534. X        while (i < wp->w_toprow + wp->w_ntrows) {
  535. X            if (vscreen[i]->v_flag & VFEXT) {
  536. X                if ((wp != curwp) || (lp != wp->w_dotp) ||
  537. X                   (curcol < term.t_ncol - 1)) {
  538. X                    vtmove(i, 0);
  539. X                    for (j = 0; j < llength(lp); ++j)
  540. X                        vtputc(lgetc(lp, j));
  541. X                    vteeol();
  542. X
  543. X                    /* this line no longer is extended */
  544. X                    vscreen[i]->v_flag &= ~VFEXT;
  545. X                    vscreen[i]->v_flag |= VFCHG;
  546. X                }
  547. X            }
  548. X            lp = lforw(lp);
  549. X            ++i;
  550. X        }
  551. X        /* and onward to the next window */
  552. X        wp = wp->w_wndp;
  553. X    }
  554. X}
  555. X
  556. X/*    updgar:    if the screen is garbage, clear the physical screen and
  557. X        the virtual screen and force a full update        */
  558. X
  559. Xupdgar()
  560. X
  561. X{
  562. X    register char *txt;
  563. X    register int i,j;
  564. X
  565. X    for (i = 0; i < term.t_nrow; ++i) {
  566. X        vscreen[i]->v_flag |= VFCHG;
  567. X#if    REVSTA
  568. X        vscreen[i]->v_flag &= ~VFREV;
  569. X#endif
  570. X#if    COLOR
  571. X        vscreen[i]->v_fcolor = gfcolor;
  572. X        vscreen[i]->v_bcolor = gbcolor;
  573. X#endif
  574. X#if    MEMMAP == 0
  575. X        txt = pscreen[i]->v_text;
  576. X        for (j = 0; j < term.t_ncol; ++j)
  577. X            txt[j] = ' ';
  578. X#endif
  579. X    }
  580. X
  581. X    movecursor(0, 0);         /* Erase the screen. */
  582. X    (*term.t_eeop)();
  583. X    sgarbf = FALSE;             /* Erase-page clears */
  584. X    mpresf = FALSE;             /* the message area. */
  585. X#if    COLOR
  586. X    mlerase();            /* needs to be cleared if colored */
  587. X#endif
  588. X}
  589. X
  590. X/*    updupd:    update the physical screen from the virtual screen    */
  591. X
  592. Xupdupd(force)
  593. X
  594. Xint force;    /* forced update flag */
  595. X
  596. X{
  597. X    register VIDEO *vp1;
  598. X    register int i;
  599. X
  600. X    for (i = 0; i < term.t_nrow; ++i) {
  601. X        vp1 = vscreen[i];
  602. X
  603. X        /* for each line that needs to be updated*/
  604. X        if ((vp1->v_flag & VFCHG) != 0) {
  605. X#if    TYPEAH
  606. X            if (force == FALSE && typahead())
  607. X                return(TRUE);
  608. X#endif
  609. X#if    MEMMAP
  610. X            updateline(i, vp1);
  611. X#else
  612. X            updateline(i, vp1, pscreen[i]);
  613. X#endif
  614. X        }
  615. X    }
  616. X    return(TRUE);
  617. X}
  618. X
  619. X/*    updext: update the extended line which the cursor is currently
  620. X        on at a column greater than the terminal width. The line
  621. X        will be scrolled right or left to let the user see where
  622. X        the cursor is
  623. X                                */
  624. X
  625. Xupdext()
  626. X
  627. X{
  628. X    register int rcursor;    /* real cursor location */
  629. X    register LINE *lp;    /* pointer to current line */
  630. X    register int j;        /* index into line */
  631. X
  632. X    /* calculate what column the real cursor will end up in */
  633. X    rcursor = ((curcol - term.t_ncol) % term.t_scrsiz) + term.t_margin;
  634. X    taboff = lbound = curcol - rcursor + 1;
  635. X
  636. X    /* scan through the line outputing characters to the virtual screen */
  637. X    /* once we reach the left edge                    */
  638. X    vtmove(currow, -lbound);    /* start scanning offscreen */
  639. X    lp = curwp->w_dotp;        /* line to output */
  640. X    for (j=0; j<llength(lp); ++j)    /* until the end-of-line */
  641. X        vtputc(lgetc(lp, j));
  642. X
  643. X    /* truncate the virtual line, restore tab offset */
  644. X    vteeol();
  645. X    taboff = 0;
  646. X
  647. X    /* and put a '$' in column 1 */
  648. X    vscreen[currow]->v_text[0] = '$';
  649. X}
  650. X
  651. X/*
  652. X * Update a single line. This does not know how to use insert or delete
  653. X * character sequences; we are using VT52 functionality. Update the physical
  654. X * row and column variables. It does try an exploit erase to end of line. The
  655. X * RAINBOW version of this routine uses fast video.
  656. X */
  657. X#if    MEMMAP
  658. X/*    UPDATELINE specific code for the IBM-PC and other compatables */
  659. X
  660. Xupdateline(row, vp1)
  661. X
  662. Xint row;        /* row of screen to update */
  663. Xstruct VIDEO *vp1;    /* virtual screen image */
  664. X
  665. X{
  666. X#if    COLOR
  667. X    scwrite(row, vp1->v_text, vp1->v_rfcolor, vp1->v_rbcolor);
  668. X    vp1->v_fcolor = vp1->v_rfcolor;
  669. X    vp1->v_bcolor = vp1->v_rbcolor;
  670. X#else
  671. X    if (vp1->v_flag & VFREQ)
  672. X        scwrite(row, vp1->v_text, 0, 7);
  673. X    else
  674. X        scwrite(row, vp1->v_text, 7, 0);
  675. X#endif
  676. X    vp1->v_flag &= ~(VFCHG | VFCOL);    /* flag this line as changed */
  677. X
  678. X}
  679. X
  680. X#else
  681. X
  682. Xupdateline(row, vp1, vp2)
  683. X
  684. Xint row;        /* row of screen to update */
  685. Xstruct VIDEO *vp1;    /* virtual screen image */
  686. Xstruct VIDEO *vp2;    /* physical screen image */
  687. X
  688. X{
  689. X#if RAINBOW
  690. X/*    UPDATELINE specific code for the DEC rainbow 100 micro    */
  691. X
  692. X    register char *cp1;
  693. X    register char *cp2;
  694. X    register int nch;
  695. X
  696. X    /* since we don't know how to make the rainbow do this, turn it off */
  697. X    flags &= (~VFREV & ~VFREQ);
  698. X
  699. X    cp1 = &vp1->v_text[0];                    /* Use fast video. */
  700. X    cp2 = &vp2->v_text[0];
  701. X    putline(row+1, 1, cp1);
  702. X    nch = term.t_ncol;
  703. X
  704. X    do
  705. X        {
  706. X        *cp2 = *cp1;
  707. X        ++cp2;
  708. X        ++cp1;
  709. X        }
  710. X    while (--nch);
  711. X    *flags &= ~VFCHG;
  712. X#else
  713. X/*    UPDATELINE code for all other versions        */
  714. X
  715. X    register char *cp1;
  716. X    register char *cp2;
  717. X    register char *cp3;
  718. X    register char *cp4;
  719. X    register char *cp5;
  720. X    register int nbflag;    /* non-blanks to the right flag? */
  721. X    int rev;        /* reverse video flag */
  722. X    int req;        /* reverse video request flag */
  723. X
  724. X
  725. X    /* set up pointers to virtual and physical lines */
  726. X    cp1 = &vp1->v_text[0];
  727. X    cp2 = &vp2->v_text[0];
  728. X
  729. X#if    COLOR
  730. X    TTforg(vp1->v_rfcolor);
  731. X    TTbacg(vp1->v_rbcolor);
  732. X#endif
  733. X
  734. X#if    REVSTA | COLOR
  735. X    /* if we need to change the reverse video status of the
  736. X       current line, we need to re-write the entire line     */
  737. X    rev = (vp1->v_flag & VFREV) == VFREV;
  738. X    req = (vp1->v_flag & VFREQ) == VFREQ;
  739. X    if ((rev != req)
  740. X#if    COLOR
  741. X        || (vp1->v_fcolor != vp1->v_rfcolor) || (vp1->v_bcolor != vp1->v_rbcolor)
  742. X#endif
  743. X#if    HP150
  744. X    /* the HP150 has some reverse video problems */
  745. X        || req || rev
  746. X#endif
  747. X            ) {
  748. X        movecursor(row, 0);    /* Go to start of line. */
  749. X        /* set rev video if needed */
  750. X        if (rev != req)
  751. X            (*term.t_rev)(req);
  752. X
  753. X        /* scan through the line and dump it to the screen and
  754. X           the virtual screen array                */
  755. X        cp3 = &vp1->v_text[term.t_ncol];
  756. X        while (cp1 < cp3) {
  757. X            TTputc(*cp1);
  758. X            ++ttcol;
  759. X            *cp2++ = *cp1++;
  760. X        }
  761. X        /* turn rev video off */
  762. X        if (rev != req)
  763. X            (*term.t_rev)(FALSE);
  764. X
  765. X        /* update the needed flags */
  766. X        vp1->v_flag &= ~VFCHG;
  767. X        if (req)
  768. X            vp1->v_flag |= VFREV;
  769. X        else
  770. X            vp1->v_flag &= ~VFREV;
  771. X#if    COLOR
  772. X        vp1->v_fcolor = vp1->v_rfcolor;
  773. X        vp1->v_bcolor = vp1->v_rbcolor;
  774. X#endif
  775. X        return(TRUE);
  776. X    }
  777. X#endif
  778. X
  779. X    /* advance past any common chars at the left */
  780. X    while (cp1 != &vp1->v_text[term.t_ncol] && cp1[0] == cp2[0]) {
  781. X        ++cp1;
  782. X        ++cp2;
  783. X    }
  784. X
  785. X/* This can still happen, even though we only call this routine on changed
  786. X * lines. A hard update is always done when a line splits, a massive
  787. X * change is done, or a buffer is displayed twice. This optimizes out most
  788. X * of the excess updating. A lot of computes are used, but these tend to
  789. X * be hard operations that do a lot of update, so I don't really care.
  790. X */
  791. X    /* if both lines are the same, no update needs to be done */
  792. X    if (cp1 == &vp1->v_text[term.t_ncol]) {
  793. X         vp1->v_flag &= ~VFCHG;        /* flag this line is changed */
  794. X        return(TRUE);
  795. X    }
  796. X
  797. X    /* find out if there is a match on the right */
  798. X    nbflag = FALSE;
  799. X    cp3 = &vp1->v_text[term.t_ncol];
  800. X    cp4 = &vp2->v_text[term.t_ncol];
  801. X
  802. X    while (cp3[-1] == cp4[-1]) {
  803. X        --cp3;
  804. X        --cp4;
  805. X        if (cp3[0] != ' ')        /* Note if any nonblank */
  806. X            nbflag = TRUE;        /* in right match. */
  807. X    }
  808. X
  809. X    cp5 = cp3;
  810. X
  811. X    /* Erase to EOL ? */
  812. X    if (nbflag == FALSE && eolexist == TRUE && (req != TRUE)) {
  813. X        while (cp5!=cp1 && cp5[-1]==' ')
  814. X            --cp5;
  815. X
  816. X        if (cp3-cp5 <= 3)        /* Use only if erase is */
  817. X            cp5 = cp3;        /* fewer characters. */
  818. X    }
  819. X
  820. X    movecursor(row, cp1 - &vp1->v_text[0]);    /* Go to start of line. */
  821. X#if    REVSTA
  822. X    TTrev(rev);
  823. X#endif
  824. X
  825. X    while (cp1 != cp5) {        /* Ordinary. */
  826. X        TTputc(*cp1);
  827. X        ++ttcol;
  828. X        *cp2++ = *cp1++;
  829. X    }
  830. X
  831. X    if (cp5 != cp3) {        /* Erase. */
  832. X        TTeeol();
  833. X        while (cp1 != cp3)
  834. X            *cp2++ = *cp1++;
  835. X    }
  836. X#if    REVSTA
  837. X    TTrev(FALSE);
  838. X#endif
  839. X    vp1->v_flag &= ~VFCHG;        /* flag this line as updated */
  840. X    return(TRUE);
  841. X#endif
  842. X}
  843. X#endif
  844. X
  845. X/*
  846. X * Redisplay the mode line for the window pointed to by the "wp". This is the
  847. X * only routine that has any idea of how the modeline is formatted. You can
  848. X * change the modeline format by hacking at this routine. Called by "update"
  849. X * any time there is a dirty window.
  850. X */
  851. Xmodeline(wp)
  852. X    WINDOW *wp;
  853. X{
  854. X    register char *cp;
  855. X    register int c;
  856. X    register int n;        /* cursor position count */
  857. X    register BUFFER *bp;
  858. X    register i;            /* loop index */
  859. X    register lchar;        /* character to draw line in buffer with */
  860. X    register firstm;        /* is this the first mode? */
  861. X    char tline[NLINE];        /* buffer for part of mode line */
  862. X
  863. X    n = wp->w_toprow+wp->w_ntrows;          /* Location. */
  864. X    vscreen[n]->v_flag |= VFCHG | VFREQ | VFCOL;/* Redraw next time. */
  865. X#if    COLOR
  866. X    vscreen[n]->v_rfcolor = 0;            /* black on */
  867. X    vscreen[n]->v_rbcolor = 7;            /* white.....*/
  868. X#endif
  869. X    vtmove(n, 0);                           /* Seek to right line. */
  870. X    if (wp == curwp)                /* mark the current buffer */
  871. X    lchar = '=';
  872. X    else
  873. X#if    REVSTA
  874. X    if (revexist)
  875. X        lchar = ' ';
  876. X    else
  877. X#endif
  878. X        lchar = '-';
  879. X
  880. X    vtputc(lchar);
  881. X    bp = wp->w_bufp;
  882. X
  883. X    if ((bp->b_flag&BFCHG) != 0)                /* "*" if changed. */
  884. X        vtputc('*');
  885. X    else
  886. X        vtputc(lchar);
  887. X
  888. X    n  = 2;
  889. X    strcpy(tline, " ");                /* Buffer name. */
  890. X    strcat(tline, PROGNAME);
  891. X    strcat(tline, " ");
  892. X    strcat(tline, VERSION);
  893. X    strcat(tline, " (");
  894. X
  895. X    /* display the modes */
  896. X
  897. X    firstm = TRUE;
  898. X    for (i = 0; i < NUMMODES; i++)    /* add in the mode flags */
  899. X        if (wp->w_bufp->b_mode & (1 << i)) {
  900. X            if (firstm != TRUE)
  901. X                strcat(tline, " ");
  902. X            firstm = FALSE;
  903. X            strcat(tline, modename[i]);
  904. X        }
  905. X    strcat(tline,") ");
  906. X
  907. X    cp = &tline[0];
  908. X    while ((c = *cp++) != 0)
  909. X        {
  910. X        vtputc(c);
  911. X        ++n;
  912. X        }
  913. X
  914. X#if 0
  915. X    vtputc(lchar);
  916. X    vtputc((wp->w_flag&WFCOLR) != 0  ? 'C' : lchar);
  917. X    vtputc((wp->w_flag&WFMODE) != 0  ? 'M' : lchar);
  918. X    vtputc((wp->w_flag&WFHARD) != 0  ? 'H' : lchar);
  919. X    vtputc((wp->w_flag&WFEDIT) != 0  ? 'E' : lchar);
  920. X    vtputc((wp->w_flag&WFMOVE) != 0  ? 'V' : lchar);
  921. X    vtputc((wp->w_flag&WFFORCE) != 0 ? 'F' : lchar);
  922. X    vtputc(lchar);
  923. X    n += 8;
  924. X#endif
  925. X
  926. X    vtputc(lchar);
  927. X    vtputc(lchar);
  928. X    vtputc(' ');
  929. X    n += 3;
  930. X    cp = &bp->b_bname[0];
  931. X
  932. X    while ((c = *cp++) != 0)
  933. X        {
  934. X        vtputc(c);
  935. X        ++n;
  936. X        }
  937. X
  938. X    vtputc(' ');
  939. X    vtputc(lchar);
  940. X    vtputc(lchar);
  941. X    n += 3;
  942. X
  943. X    if (bp->b_fname[0] != 0)            /* File name. */
  944. X        {
  945. X    vtputc(' ');
  946. X    ++n;
  947. X        cp = "File: ";
  948. X
  949. X        while ((c = *cp++) != 0)
  950. X            {
  951. X            vtputc(c);
  952. X            ++n;
  953. X            }
  954. X
  955. X        cp = &bp->b_fname[0];
  956. X
  957. X        while ((c = *cp++) != 0)
  958. X            {
  959. X            vtputc(c);
  960. X            ++n;
  961. X            }
  962. X
  963. X        vtputc(' ');
  964. X        ++n;
  965. X        }
  966. X
  967. X    while (n < term.t_ncol)             /* Pad to full width. */
  968. X        {
  969. X        vtputc(lchar);
  970. X        ++n;
  971. X        }
  972. X}
  973. X
  974. Xupmode()    /* update all the mode lines */
  975. X
  976. X{
  977. X    register WINDOW *wp;
  978. X
  979. X    wp = wheadp;
  980. X    while (wp != NULL) {
  981. X        wp->w_flag |= WFMODE;
  982. X        wp = wp->w_wndp;
  983. X    }
  984. X}
  985. X
  986. X/*
  987. X * Send a command to the terminal to move the hardware cursor to row "row"
  988. X * and column "col". The row and column arguments are origin 0. Optimize out
  989. X * random calls. Update "ttrow" and "ttcol".
  990. X */
  991. Xmovecursor(row, col)
  992. X    {
  993. X    if (row!=ttrow || col!=ttcol)
  994. X        {
  995. X        ttrow = row;
  996. X        ttcol = col;
  997. X        TTmove(row, col);
  998. X        }
  999. X    }
  1000. X
  1001. X/*
  1002. X * Erase the message line. This is a special routine because the message line
  1003. X * is not considered to be part of the virtual screen. It always works
  1004. X * immediately; the terminal buffer is flushed via a call to the flusher.
  1005. X */
  1006. Xmlerase()
  1007. X    {
  1008. X    int i;
  1009. X    
  1010. X    movecursor(term.t_nrow, 0);
  1011. X    if (discmd == FALSE)
  1012. X        return;
  1013. X
  1014. X#if    COLOR
  1015. X     TTforg(7);
  1016. X     TTbacg(0);
  1017. X#endif
  1018. X    if (eolexist == TRUE)
  1019. X        TTeeol();
  1020. X    else {
  1021. X        for (i = 0; i < term.t_ncol - 1; i++)
  1022. X            TTputc(' ');
  1023. X        movecursor(term.t_nrow, 1);    /* force the move! */
  1024. X        movecursor(term.t_nrow, 0);
  1025. X    }
  1026. X    TTflush();
  1027. X    mpresf = FALSE;
  1028. X    }
  1029. X
  1030. X/*
  1031. X * Write a message into the message line. Keep track of the physical cursor
  1032. X * position. A small class of printf like format items is handled. Assumes the
  1033. X * stack grows down; this assumption is made by the "++" in the argument scan
  1034. X * loop. Set the "message line" flag TRUE.
  1035. X */
  1036. X
  1037. Xmlwrite(fmt, arg)
  1038. X
  1039. Xchar *fmt;    /* format string for output */
  1040. Xchar *arg;    /* pointer to first argument to print */
  1041. X
  1042. X{
  1043. X    register int c;        /* current char in format string */
  1044. X    register char *ap;    /* ptr to current data field */
  1045. X
  1046. X    /* if we are not currently echoing on the command line, abort this */
  1047. X    if (discmd == FALSE) {
  1048. X        movecursor(term.t_nrow, 0);
  1049. X        return;
  1050. X    }
  1051. X
  1052. X#if    COLOR
  1053. X    /* set up the proper colors for the command line */
  1054. X    TTforg(7);
  1055. X    TTbacg(0);
  1056. X#endif
  1057. X
  1058. X    /* if we can not erase to end-of-line, do it manually */
  1059. X    if (eolexist == FALSE) {
  1060. X        mlerase();
  1061. X        TTflush();
  1062. X    }
  1063. X
  1064. X    movecursor(term.t_nrow, 0);
  1065. X    ap = (char *) &arg;
  1066. X    while ((c = *fmt++) != 0) {
  1067. X        if (c != '%') {
  1068. X            TTputc(c);
  1069. X            ++ttcol;
  1070. X        } else {
  1071. X            c = *fmt++;
  1072. X            switch (c) {
  1073. X                case 'd':
  1074. X                    mlputi(*(int *)ap, 10);
  1075. X                    ap += sizeof(int);
  1076. X                    break;
  1077. X
  1078. X                case 'o':
  1079. X                    mlputi(*(int *)ap,  8);
  1080. X                    ap += sizeof(int);
  1081. X                    break;
  1082. X
  1083. X                case 'x':
  1084. X                    mlputi(*(int *)ap, 16);
  1085. X                    ap += sizeof(int);
  1086. X                    break;
  1087. X
  1088. X                case 'D':
  1089. X                    mlputli(*(long *)ap, 10);
  1090. X                    ap += sizeof(long);
  1091. X                    break;
  1092. X
  1093. X                case 's':
  1094. X                    mlputs(*(char **)ap);
  1095. X                    ap += sizeof(char *);
  1096. X                    break;
  1097. X
  1098. X                case 'f':
  1099. X                    mlputf(*(int *)ap);
  1100. X                    ap += sizeof(int);
  1101. X                    break;
  1102. X
  1103. X                default:
  1104. X                    TTputc(c);
  1105. X                    ++ttcol;
  1106. X            }
  1107. X        }
  1108. X    }
  1109. X
  1110. X    /* if we can, erase to the end of screen */
  1111. X    if (eolexist == TRUE)
  1112. X        TTeeol();
  1113. X    TTflush();
  1114. X    mpresf = TRUE;
  1115. X}
  1116. X
  1117. X/*
  1118. X * Write out a string. Update the physical cursor position. This assumes that
  1119. X * the characters in the string all have width "1"; if this is not the case
  1120. X * things will get screwed up a little.
  1121. X */
  1122. Xmlputs(s)
  1123. X    char *s;
  1124. X    {
  1125. X    register int c;
  1126. X
  1127. X    while ((c = *s++) != 0)
  1128. X        {
  1129. X        TTputc(c);
  1130. X        ++ttcol;
  1131. X        }
  1132. X    }
  1133. X
  1134. X/*
  1135. X * Write out an integer, in the specified radix. Update the physical cursor
  1136. X * position.
  1137. X */
  1138. Xmlputi(i, r)
  1139. X    {
  1140. X    register int q;
  1141. X    static char hexdigits[] = "0123456789ABCDEF";
  1142. X
  1143. X    if (i < 0)
  1144. X        {
  1145. X        i = -i;
  1146. X        TTputc('-');
  1147. X        }
  1148. X
  1149. X    q = i/r;
  1150. X
  1151. X    if (q != 0)
  1152. X        mlputi(q, r);
  1153. X
  1154. X    TTputc(hexdigits[i%r]);
  1155. X    ++ttcol;
  1156. X    }
  1157. X
  1158. X/*
  1159. X * do the same except as a long integer.
  1160. X */
  1161. Xmlputli(l, r)
  1162. X    long l;
  1163. X    {
  1164. X    register long q;
  1165. X
  1166. X    if (l < 0)
  1167. X        {
  1168. X        l = -l;
  1169. X        TTputc('-');
  1170. X        }
  1171. X
  1172. X    q = l/r;
  1173. X
  1174. X    if (q != 0)
  1175. X        mlputli(q, r);
  1176. X
  1177. X    TTputc((int)(l%r)+'0');
  1178. X    ++ttcol;
  1179. X    }
  1180. X
  1181. X/*
  1182. X *    write out a scaled integer with two decimal places
  1183. X */
  1184. X
  1185. Xmlputf(s)
  1186. X
  1187. Xint s;    /* scaled integer to output */
  1188. X
  1189. X{
  1190. X    int i;    /* integer portion of number */
  1191. X    int f;    /* fractional portion of number */
  1192. X
  1193. X    /* break it up */
  1194. X    i = s / 100;
  1195. X    f = s % 100;
  1196. X
  1197. X    /* send out the integer portion */
  1198. X    mlputi(i, 10);
  1199. X    TTputc('.');
  1200. X    TTputc((f / 10) + '0');
  1201. X    TTputc((f % 10) + '0');
  1202. X    ttcol += 3;
  1203. X}    
  1204. X
  1205. X#if RAINBOW
  1206. X
  1207. Xputline(row, col, buf)
  1208. X    int row, col;
  1209. X    char buf[];
  1210. X    {
  1211. X    int n;
  1212. X
  1213. X    n = strlen(buf);
  1214. X    if (col + n - 1 > term.t_ncol)
  1215. X        n = term.t_ncol - col + 1;
  1216. X    Put_Data(row, col, n, buf);
  1217. X    }
  1218. X#endif
  1219. X
  1220. E!O!F
  1221. newsize=`wc -c < display.c`
  1222. if [ $newsize -ne 23827 ]
  1223. then echo "File display.c was $newsize bytes, 23827 expected"
  1224. fi
  1225. echo 'x - dolock.c (text)'
  1226. sed << 'E!O!F' 's/^X//' > dolock.c
  1227. X#if    0
  1228. X/*    dolock:    MDBS specific Unix 4.2BSD file locking mechinism
  1229. X        this is not to be distributed generally        */
  1230. X
  1231. X#include    <mdbs.h>
  1232. X#include    <mdbsio.h>
  1233. X#include    <sys/types.h>
  1234. X#include    <sys/stat.h>
  1235. X
  1236. X/* included by port.h: mdbs.h, mdbsio.h, sys/types.h, sys/stat.h */
  1237. X
  1238. X
  1239. X#ifndef bsdunix
  1240. Xchar *dolock(){return(NULL);}
  1241. Xchar *undolock(){return(NULL);}
  1242. X#else
  1243. X
  1244. X#include <pwd.h>
  1245. X#include <errno.h>
  1246. X
  1247. Xextern int errno;
  1248. X
  1249. X#define LOCKDIR ".xlk"
  1250. X
  1251. X#define LOCKMSG "LOCK ERROR -- "
  1252. X#define LOCKMSZ sizeof(LOCKMSG)
  1253. X#define LOCKERR(s) { strcat(lmsg,s); oldumask = umask(oldumask); return(lmsg); }
  1254. X
  1255. X/**********************
  1256. X *
  1257. X * dolock -- lock the file fname
  1258. X *
  1259. X * if successful, returns NULL 
  1260. X * if file locked, returns username of person locking the file
  1261. X * if other error, returns "LOCK ERROR: explanation"
  1262. X *
  1263. X * Jon Reid, 2/19/86
  1264. X *
  1265. X *********************/
  1266. X
  1267. XBOOL parent = FALSE;
  1268. XBOOL tellall = FALSE;
  1269. X
  1270. Xchar *gtname(filespec)        /* get name component of unix-style filespec */
  1271. Xchar *filespec;
  1272. X{
  1273. X    char *rname, *rindex();
  1274. X
  1275. X    rname = rindex(filespec,'/');
  1276. X
  1277. X    if (rname != NULL)
  1278. X        return(rname);
  1279. X    else
  1280. X        return(filespec);
  1281. X}
  1282. X
  1283. Xchar *getpath(filespec)
  1284. Xchar *filespec;
  1285. X{
  1286. X    char rbuff[LFILEN];
  1287. X    char *rname, *rindex();
  1288. X
  1289. X    strcpy(rbuff,filespec);
  1290. X    rname = rindex(rbuff,'/');
  1291. X
  1292. X    if (rname == NULL)
  1293. X        return(NULL);
  1294. X    else
  1295. X    {
  1296. X        *(++rname) = '\0';
  1297. X        return(rbuff);
  1298. X    }
  1299. X
  1300. X}
  1301. X
  1302. Xchar *dolock(fname)
  1303. X    char *fname;
  1304. X{
  1305. X    static char lockname[LFILEN] = LOCKDIR;
  1306. X    static char username[12];
  1307. X    static char lmsg[40] = LOCKMSG;
  1308. X    char *pathfmt;
  1309. X    struct stat statblk;
  1310. X    struct passwd *pblk;
  1311. X    long pid, getpid();
  1312. X    FILE *lf, *fopen();
  1313. X    int oldumask;
  1314. X
  1315. X    oldumask = umask(0);    /* maximum access allowed to lock files */
  1316. X
  1317. X
  1318. X      if (*fname != '/')
  1319. X       pathfmt = "./%s%s";
  1320. X      else
  1321. X       pathfmt = "%s/%s";
  1322. X      sprintf(lockname,pathfmt,getpath(fname), LOCKDIR);
  1323. X
  1324. X      if (tellall) printf("checking for existence of %s\n",lockname);
  1325. X
  1326. X      if (stat(lockname,&statblk))
  1327. X      {
  1328. X         if (tellall) printf("making directory %s\n",lockname);
  1329. X         mkdir(lockname,0777); 
  1330. X      }
  1331. X
  1332. X      sprintf(lockname,"%s/%s",lockname,gtname(fname));
  1333. X
  1334. X      if (tellall) printf("checking for existence of %s\n",lockname);
  1335. X
  1336. X      if (stat(lockname,&statblk))
  1337. X      {
  1338. Xmakelock:      if (tellall) printf("creating %s\n",lockname);
  1339. X
  1340. X        if ((lf = fopen(lockname,FOP_TW)) == NULL)
  1341. X          LOCKERR("could not create lock file")
  1342. X            else
  1343. X          {
  1344. X            if (parent)
  1345. X             pid = getppid();    /* parent pid */
  1346. X            else
  1347. X             pid = getpid();    /* current pid */
  1348. X
  1349. X             if (tellall)
  1350. X              printf("pid is %ld\n",pid); 
  1351. X
  1352. X             fprintf(lf,"%ld",pid); /* write pid to lock file */
  1353. X
  1354. X            fclose(lf);
  1355. X            oldumask = umask(oldumask);
  1356. X            return(NULL);
  1357. X        }
  1358. X      }
  1359. X      else
  1360. X      {
  1361. X        if (tellall) printf("reading lock file %s\n",lockname);
  1362. X        if ((lf = fopen(lockname,FOP_TR)) == NULL)
  1363. X          LOCKERR("could not read lock file")
  1364. X            else
  1365. X          {
  1366. X            fscanf(lf,"%ld",&pid); /* contains current pid */
  1367. X            fclose(lf);
  1368. X            if (tellall)
  1369. X             printf("pid in %s is %ld\n",lockname, pid);
  1370. X            if (tellall)
  1371. X             printf("signaling process %ld\n", pid);
  1372. X            if (kill(pid,0))
  1373. X                switch (errno)
  1374. X                {
  1375. X                  case ESRCH:    /* process not found */
  1376. X                        goto makelock;
  1377. X                        break;
  1378. X                  case EPERM:    /* process exists, not yours */
  1379. X                         if (tellall) 
  1380. X                         puts("process exists");
  1381. X                        break;
  1382. X                  default:
  1383. X                    LOCKERR("kill was bad")
  1384. X                    break;
  1385. X                }
  1386. X            else
  1387. X             if (tellall) puts("kill was good; process exists");
  1388. X        }
  1389. X        if ((pblk = getpwuid(statblk.st_uid)) == NULL)
  1390. X          sprintf(username,"uid %d",atoi(statblk.st_uid));
  1391. X        else
  1392. X          strcpy(username,pblk->pw_name);
  1393. X
  1394. X        oldumask = umask(oldumask);
  1395. X        return(username);
  1396. X      }
  1397. X}
  1398. X
  1399. X/**********************
  1400. X *
  1401. X * undolock -- unlock the file fname
  1402. X *
  1403. X * if successful, returns NULL 
  1404. X * if other error, returns "LOCK ERROR: explanation"
  1405. X *
  1406. X * Jon Reid, 2/19/86
  1407. X *
  1408. X *********************/
  1409. X
  1410. Xchar *undolock(fname)
  1411. X    char *fname;
  1412. X{
  1413. X    static char lockname[LFILEN] = LOCKDIR;
  1414. X    static char lmsg[40] = LOCKMSG;
  1415. X    char *pathfmt;
  1416. X
  1417. X      if (*fname != '/')
  1418. X       pathfmt = "./%s%s";
  1419. X      else
  1420. X       pathfmt = "%s/%s";
  1421. X      sprintf(lockname,pathfmt,getpath(fname), LOCKDIR);
  1422. X
  1423. X      sprintf(lockname,"%s/%s",lockname,gtname(fname));
  1424. X
  1425. X      if (tellall) printf("attempting to unlink %s\n",lockname);
  1426. X
  1427. X      if (unlink(lockname))
  1428. X      { 
  1429. X        strcat(lmsg,"could not remove lock file"); 
  1430. X        return(lmsg); 
  1431. X      }
  1432. X      else
  1433. X            return(NULL);
  1434. X}
  1435. X
  1436. X#endif bsdunix
  1437. X
  1438. X/******************
  1439. X * end dolock module
  1440. X *******************/
  1441. X
  1442. X#else
  1443. Xdolhello()
  1444. X{
  1445. X}
  1446. X#endif
  1447. X
  1448. E!O!F
  1449. newsize=`wc -c < dolock.c`
  1450. if [ $newsize -ne 4348 ]
  1451. then echo "File dolock.c was $newsize bytes, 4348 expected"
  1452. fi
  1453. echo 'x - ebind.h (text)'
  1454. sed << 'E!O!F' 's/^X//' > ebind.h
  1455. X/*    EBIND:        Initial default key to function bindings for
  1456. X            MicroEMACS 3.7
  1457. X*/
  1458. X
  1459. X/*
  1460. X * Command table.
  1461. X * This table  is *roughly* in ASCII order, left to right across the
  1462. X * characters of the command. This explains the funny location of the
  1463. X * control-X commands.
  1464. X */
  1465. XKEYTAB  keytab[NBINDS] = {
  1466. X    {CTRL|'A',        gotobol},
  1467. X    {CTRL|'B',        backchar},
  1468. X    {CTRL|'C',        insspace},
  1469. X    {CTRL|'D',        forwdel},
  1470. X    {CTRL|'E',        gotoeol},
  1471. X    {CTRL|'F',        forwchar},
  1472. X    {CTRL|'G',        ctrlg},
  1473. X    {CTRL|'H',        backdel},
  1474. X    {CTRL|'I',        tab},
  1475. X    {CTRL|'J',        indent},
  1476. X    {CTRL|'K',        killtext},
  1477. X    {CTRL|'L',        refresh},
  1478. X    {CTRL|'M',        newline},
  1479. X    {CTRL|'N',        forwline},
  1480. X    {CTRL|'O',        openline},
  1481. X    {CTRL|'P',        backline},
  1482. X    {CTRL|'Q',        quote},
  1483. X    {CTRL|'R',        backsearch},
  1484. X    {CTRL|'S',        forwsearch},
  1485. X    {CTRL|'T',        twiddle},
  1486. X    {CTRL|'U',        unarg},
  1487. X    {CTRL|'V',        forwpage},
  1488. X    {CTRL|'W',        killregion},
  1489. X    {CTRL|'X',        cex},
  1490. X    {CTRL|'Y',        yank},
  1491. X    {CTRL|'Z',        backpage},
  1492. X    {CTRL|']',        meta},
  1493. X    {CTLX|CTRL|'B',        listbuffers},
  1494. X    {CTLX|CTRL|'C',        quit},          /* Hard quit.           */
  1495. X#if    AEDIT
  1496. X    {CTLX|CTRL|'D',        detab},
  1497. X    {CTLX|CTRL|'E',        entab},
  1498. X#endif
  1499. X    {CTLX|CTRL|'F',        filefind},
  1500. X    {CTLX|CTRL|'I',        insfile},
  1501. X    {CTLX|CTRL|'L',        lowerregion},
  1502. X    {CTLX|CTRL|'M',        delmode},
  1503. X    {CTLX|CTRL|'N',        mvdnwind},
  1504. X    {CTLX|CTRL|'O',        deblank},
  1505. X    {CTLX|CTRL|'P',        mvupwind},
  1506. X    {CTLX|CTRL|'R',        fileread},
  1507. X    {CTLX|CTRL|'S',        filesave},
  1508. X#if    AEDIT
  1509. X    {CTLX|CTRL|'T',        trim},
  1510. X#endif
  1511. X    {CTLX|CTRL|'U',        upperregion},
  1512. X    {CTLX|CTRL|'V',        viewfile},
  1513. X    {CTLX|CTRL|'W',        filewrite},
  1514. X    {CTLX|CTRL|'X',        swapmark},
  1515. X    {CTLX|CTRL|'Z',        shrinkwind},
  1516. X    {CTLX|'?',        deskey},
  1517. X    {CTLX|'!',        spawn},
  1518. X    {CTLX|'@',        pipecmd},
  1519. X    {CTLX|'#',        filter},
  1520. X    {CTLX|'=',        showcpos},
  1521. X    {CTLX|'(',        ctlxlp},
  1522. X    {CTLX|')',        ctlxrp},
  1523. X    {CTLX|'^',        enlargewind},
  1524. X    {CTLX|'0',        delwind},
  1525. X    {CTLX|'1',        onlywind},
  1526. X    {CTLX|'2',        splitwind},
  1527. X    {CTLX|'A',        setvar},
  1528. X    {CTLX|'B',        usebuffer},
  1529. X    {CTLX|'C',        spawncli},
  1530. X#if    BSD
  1531. X    {CTLX|'D',        bktoshell},
  1532. X#endif
  1533. X    {CTLX|'E',        ctlxe},
  1534. X    {CTLX|'F',        setfillcol},
  1535. X    {CTLX|'K',        killbuffer},
  1536. X    {CTLX|'M',        setmode},
  1537. X    {CTLX|'N',        filename},
  1538. X    {CTLX|'O',        nextwind},
  1539. X    {CTLX|'P',        prevwind},
  1540. X#if    ISRCH
  1541. X    {CTLX|'R',        risearch},
  1542. X    {CTLX|'S',        fisearch},
  1543. X#endif
  1544. X    {CTLX|'W',        resize},
  1545. X    {CTLX|'X',        nextbuffer},
  1546. X    {CTLX|'Z',        enlargewind},
  1547. X#if    WORDPRO
  1548. X    {META|CTRL|'C',        wordcount},
  1549. X#endif
  1550. X#if    PROC
  1551. X    {META|CTRL|'E',        execproc},
  1552. X#endif
  1553. X#if    CFENCE
  1554. X    {META|CTRL|'F',        getfence},
  1555. X#endif
  1556. X    {META|CTRL|'H',        delbword},
  1557. X    {META|CTRL|'K',        unbindkey},
  1558. X    {META|CTRL|'L',        reposition},
  1559. X    {META|CTRL|'M',        delgmode},
  1560. X    {META|CTRL|'N',        namebuffer},
  1561. X    {META|CTRL|'R',        qreplace},
  1562. X    {META|CTRL|'S',        newsize},
  1563. X    {META|CTRL|'T',        newwidth},
  1564. X    {META|CTRL|'V',        scrnextdw},
  1565. X#if    WORDPRO
  1566. X    {META|CTRL|'W',        killpara},
  1567. X#endif
  1568. X    {META|CTRL|'Z',        scrnextup},
  1569. X    {META|' ',        setmark},
  1570. X    {META|'?',        help},
  1571. X    {META|'!',        reposition},
  1572. X    {META|'.',        setmark},
  1573. X    {META|'>',        gotoeob},
  1574. X    {META|'<',        gotobob},
  1575. X    {META|'~',        unmark},
  1576. X#if    APROP
  1577. X    {META|'A',        apro},
  1578. X#endif
  1579. X    {META|'B',        backword},
  1580. X    {META|'C',        capword},
  1581. X    {META|'D',        delfword},
  1582. X#if    CRYPT
  1583. X    {META|'E',        setkey},
  1584. X#endif
  1585. X    {META|'F',        forwword},
  1586. X    {META|'G',        gotoline},
  1587. X    {META|'K',        bindtokey},
  1588. X    {META|'L',        lowerword},
  1589. X    {META|'M',        setgmode},
  1590. X#if    WORDPRO
  1591. X    {META|'N',        gotoeop},
  1592. X    {META|'P',        gotobop},
  1593. X    {META|'Q',        fillpara},
  1594. X#endif
  1595. X    {META|'R',        sreplace},
  1596. X#if    BSD
  1597. X    {META|'S',        bktoshell},
  1598. X#endif
  1599. X    {META|'U',        upperword},
  1600. X    {META|'V',        backpage},
  1601. X    {META|'W',        copyregion},
  1602. X    {META|'X',        namedcmd},
  1603. X    {META|'Z',        quickexit},
  1604. X    {META|0x7F,              delbword},
  1605. X
  1606. X#if    MSDOS & (HP150 == 0) & (WANGPC == 0) & (HP110 == 0)
  1607. X    {SPEC|CTRL|'_',        forwhunt},
  1608. X    {SPEC|CTRL|'S',        backhunt},
  1609. X    {SPEC|71,        gotobob},
  1610. X    {SPEC|72,        backline},
  1611. X    {SPEC|73,        backpage},
  1612. X    {SPEC|75,        backchar},
  1613. X    {SPEC|77,        forwchar},
  1614. X    {SPEC|79,        gotoeob},
  1615. X    {SPEC|80,        forwline},
  1616. X    {SPEC|81,        forwpage},
  1617. X    {SPEC|82,        insspace},
  1618. X    {SPEC|83,        forwdel},
  1619. X    {SPEC|115,        backword},
  1620. X    {SPEC|116,        forwword},
  1621. X#if    WORDPRO
  1622. X    {SPEC|132,        gotobop},
  1623. X    {SPEC|118,        gotoeop},
  1624. X#endif
  1625. X    {SPEC|84,        cbuf1},
  1626. X    {SPEC|85,        cbuf2},
  1627. X    {SPEC|86,        cbuf3},
  1628. X    {SPEC|87,        cbuf4},
  1629. X    {SPEC|88,        cbuf5},
  1630. X    {SPEC|89,        cbuf6},
  1631. X    {SPEC|90,        cbuf7},
  1632. X    {SPEC|91,        cbuf8},
  1633. X    {SPEC|92,        cbuf9},
  1634. X    {SPEC|93,        cbuf10},
  1635. X#endif
  1636. X
  1637. X#if    HP150
  1638. X    {SPEC|32,        backline},
  1639. X    {SPEC|33,        forwline},
  1640. X    {SPEC|35,        backchar},
  1641. X    {SPEC|34,        forwchar},
  1642. X    {SPEC|44,        gotobob},
  1643. X    {SPEC|46,        forwpage},
  1644. X    {SPEC|47,        backpage},
  1645. X    {SPEC|82,        nextwind},
  1646. X    {SPEC|68,        openline},
  1647. X    {SPEC|69,        killtext},
  1648. X    {SPEC|65,        forwdel},
  1649. X    {SPEC|64,        ctlxe},
  1650. X    {SPEC|67,        refresh},
  1651. X    {SPEC|66,        reposition},
  1652. X    {SPEC|83,        help},
  1653. X    {SPEC|81,        deskey},
  1654. X#endif
  1655. X
  1656. X#if    HP110
  1657. X    {SPEC|0x4b,        backchar},
  1658. X    {SPEC|0x4d,        forwchar},
  1659. X    {SPEC|0x48,        backline},
  1660. X    {SPEC|0x50,        forwline},
  1661. X    {SPEC|0x43,        help},
  1662. X    {SPEC|0x73,        backword},
  1663. X    {SPEC|0x74,        forwword},
  1664. X    {SPEC|0x49,        backpage},
  1665. X    {SPEC|0x51,        forwpage},
  1666. X    {SPEC|84,        cbuf1},
  1667. X    {SPEC|85,        cbuf2},
  1668. X    {SPEC|86,        cbuf3},
  1669. X    {SPEC|87,        cbuf4},
  1670. X    {SPEC|88,        cbuf5},
  1671. X    {SPEC|89,        cbuf6},
  1672. X    {SPEC|90,        cbuf7},
  1673. X    {SPEC|91,        cbuf8},
  1674. X#endif
  1675. X
  1676. X#if    AMIGA
  1677. X    {SPEC|'?',        help},
  1678. X    {SPEC|'A',        backline},
  1679. X    {SPEC|'B',        forwline},
  1680. X    {SPEC|'C',        forwchar},
  1681. X    {SPEC|'D',        backchar},
  1682. X    {SPEC|'T',        backpage},
  1683. X    {SPEC|'S',        forwpage},
  1684. X    {SPEC|'a',        backword},
  1685. X    {SPEC|'`',        forwword},
  1686. X    {SPEC|'P',        cbuf1},
  1687. X    {SPEC|'Q',        cbuf2},
  1688. X    {SPEC|'R',        cbuf3},
  1689. X    {SPEC|'S',        cbuf4},
  1690. X    {SPEC|'T',        cbuf5},
  1691. X    {SPEC|'U',        cbuf6},
  1692. X    {SPEC|'V',        cbuf7},
  1693. X    {SPEC|'W',        cbuf8},
  1694. X    {SPEC|'X',        cbuf9},
  1695. X    {SPEC|'Y',        cbuf10},
  1696. X    {127,            forwdel},
  1697. X#endif
  1698. X
  1699. X#if    ST520
  1700. X    {SPEC|'b',        help},
  1701. X    {SPEC|'H',        backline},
  1702. X    {SPEC|'P',        forwline},
  1703. X    {SPEC|'M',        forwchar},
  1704. X    {SPEC|'K',        backchar},
  1705. X    {SPEC|'t',        setmark},
  1706. X    {SPEC|'a',        yank},
  1707. X    {SPEC|'R',        insspace},
  1708. X    {SPEC|'G',        gotobob},
  1709. X    {127,            forwdel},
  1710. X    {SPEC|84,        cbuf1},
  1711. X    {SPEC|85,        cbuf2},
  1712. X    {SPEC|86,        cbuf3},
  1713. X    {SPEC|87,        cbuf4},
  1714. X    {SPEC|88,        cbuf5},
  1715. X    {SPEC|89,        cbuf6},
  1716. X    {SPEC|90,        cbuf7},
  1717. X    {SPEC|91,        cbuf8},
  1718. X    {SPEC|92,        cbuf9},
  1719. X    {SPEC|93,        cbuf10},
  1720. X#endif
  1721. X
  1722. X#if  WANGPC
  1723. X    SPEC|0xE0,              quit,           /* Cancel */
  1724. X    SPEC|0xE1,              help,           /* Help */
  1725. X    SPEC|0xF1,              help,           /* ^Help */
  1726. X    SPEC|0xE3,              ctrlg,          /* Print */
  1727. X    SPEC|0xF3,              ctrlg,          /* ^Print */
  1728. X    SPEC|0xC0,              backline,       /* North */
  1729. X    SPEC|0xD0,              gotobob,        /* ^North */
  1730. X    SPEC|0xC1,              forwchar,       /* East */
  1731. X    SPEC|0xD1,              gotoeol,        /* ^East */
  1732. X    SPEC|0xC2,              forwline,       /* South */
  1733. X    SPEC|0xD2,              gotobop,        /* ^South */
  1734. X    SPEC|0xC3,              backchar,       /* West */
  1735. X    SPEC|0xD3,              gotobol,        /* ^West */
  1736. X    SPEC|0xC4,              ctrlg,          /* Home */
  1737. X    SPEC|0xD4,              gotobob,        /* ^Home */
  1738. X    SPEC|0xC5,              filesave,       /* Execute */
  1739. X    SPEC|0xD5,              ctrlg,          /* ^Execute */
  1740. X    SPEC|0xC6,              insfile,        /* Insert */
  1741. X    SPEC|0xD6,              ctrlg,          /* ^Insert */
  1742. X    SPEC|0xC7,              forwdel,        /* Delete */
  1743. X    SPEC|0xD7,              killregion,     /* ^Delete */
  1744. X    SPEC|0xC8,              backpage,       /* Previous */
  1745. X    SPEC|0xD8,              prevwind,       /* ^Previous */
  1746. X    SPEC|0xC9,              forwpage,       /* Next */
  1747. X    SPEC|0xD9,              nextwind,       /* ^Next */
  1748. X    SPEC|0xCB,              ctrlg,          /* Erase */
  1749. X    SPEC|0xDB,              ctrlg,          /* ^Erase */
  1750. X    SPEC|0xDC,              ctrlg,          /* ^Tab */
  1751. X    SPEC|0xCD,              ctrlg,          /* BackTab */
  1752. X    SPEC|0xDD,              ctrlg,          /* ^BackTab */
  1753. X    SPEC|0x80,              ctrlg,          /* Indent */
  1754. X    SPEC|0x90,              ctrlg,          /* ^Indent */
  1755. X    SPEC|0x81,              ctrlg,          /* Page */
  1756. X    SPEC|0x91,              ctrlg,          /* ^Page */
  1757. X    SPEC|0x82,              ctrlg,          /* Center */
  1758. X    SPEC|0x92,              ctrlg,          /* ^Center */
  1759. X    SPEC|0x83,              ctrlg,          /* DecTab */
  1760. X    SPEC|0x93,              ctrlg,          /* ^DecTab */
  1761. X    SPEC|0x84,              ctrlg,          /* Format */
  1762. X    SPEC|0x94,              ctrlg,          /* ^Format */
  1763. X    SPEC|0x85,              ctrlg,          /* Merge */
  1764. X    SPEC|0x95,              ctrlg,          /* ^Merge */
  1765. X    SPEC|0x86,              setmark,        /* Note */
  1766. X    SPEC|0x96,              ctrlg,          /* ^Note */
  1767. X    SPEC|0x87,              ctrlg,          /* Stop */
  1768. X    SPEC|0x97,              ctrlg,          /* ^Stop */
  1769. X    SPEC|0x88,              forwsearch,     /* Srch */
  1770. X    SPEC|0x98,              backsearch,     /* ^Srch */
  1771. X    SPEC|0x89,              sreplace,       /* Replac */
  1772. X    SPEC|0x99,              qreplace,       /* ^Replac */
  1773. X    SPEC|0x8A,              ctrlg,          /* Copy */
  1774. X    SPEC|0x9A,              ctrlg,          /* ^Copy */
  1775. X    SPEC|0x8B,              ctrlg,          /* Move */
  1776. X    SPEC|0x9B,              ctrlg,          /* ^Move */
  1777. X    SPEC|0x8C,              namedcmd,       /* Command */
  1778. X    SPEC|0x9C,              spawn,          /* ^Command */
  1779. X    SPEC|0x8D,              ctrlg,          /* ^ */
  1780. X    SPEC|0x9D,              ctrlg,          /* ^^ */
  1781. X    SPEC|0x8E,              ctrlg,          /* Blank */
  1782. X    SPEC|0x9E,              ctrlg,          /* ^Blank */
  1783. X    SPEC|0x8F,              gotoline,       /* GoTo */
  1784. X    SPEC|0x9F,              usebuffer,      /* ^GoTo */
  1785. X#endif
  1786. X    {0x7F,            backdel},
  1787. X
  1788. X    /* special internal bindings */
  1789. X    SPEC|META|'W',        wrapword,    /* called on word wrap */
  1790. X
  1791. X    {0,            NULL}
  1792. X};
  1793. X
  1794. X#if RAINBOW
  1795. X
  1796. X#include "rainbow.h"
  1797. X
  1798. X/*
  1799. X * Mapping table from the LK201 function keys to the internal EMACS character.
  1800. X */
  1801. X
  1802. Xshort lk_map[][2] = {
  1803. X    Up_Key,                         CTRL+'P',
  1804. X    Down_Key,                       CTRL+'N',
  1805. X    Left_Key,                       CTRL+'B',
  1806. X    Right_Key,                      CTRL+'F',
  1807. X    Shift+Left_Key,                 META+'B',
  1808. X    Shift+Right_Key,                META+'F',
  1809. X    Control+Left_Key,               CTRL+'A',
  1810. X    Control+Right_Key,              CTRL+'E',
  1811. X    Prev_Scr_Key,                   META+'V',
  1812. X    Next_Scr_Key,                   CTRL+'V',
  1813. X    Shift+Up_Key,                   META+'<',
  1814. X    Shift+Down_Key,                 META+'>',
  1815. X    Cancel_Key,                     CTRL+'G',
  1816. X    Find_Key,                       CTRL+'S',
  1817. X    Shift+Find_Key,                 CTRL+'R',
  1818. X    Insert_Key,                     CTRL+'Y',
  1819. X    Options_Key,                    CTRL+'D',
  1820. X    Shift+Options_Key,              META+'D',
  1821. X    Remove_Key,                     CTRL+'W',
  1822. X    Shift+Remove_Key,               META+'W',
  1823. X    Select_Key,                     CTRL+'@',
  1824. X    Shift+Select_Key,               CTLX+CTRL+'X',
  1825. X    Interrupt_Key,                  CTRL+'U',
  1826. X    Keypad_PF2,                     META+'L',
  1827. X    Keypad_PF3,                     META+'C',
  1828. X    Keypad_PF4,                     META+'U',
  1829. X    Shift+Keypad_PF2,               CTLX+CTRL+'L',
  1830. X    Shift+Keypad_PF4,               CTLX+CTRL+'U',
  1831. X    Keypad_1,                       CTLX+'1',
  1832. X    Keypad_2,                       CTLX+'2',
  1833. X    Do_Key,                         CTLX+'E',
  1834. X    Keypad_4,                       CTLX+CTRL+'B',
  1835. X    Keypad_5,                       CTLX+'B',
  1836. X    Keypad_6,                       CTLX+'K',
  1837. X    Resume_Key,                     META+'!',
  1838. X    Control+Next_Scr_Key,           CTLX+'N',
  1839. X    Control+Prev_Scr_Key,           CTLX+'P',
  1840. X    Control+Up_Key,                 CTLX+CTRL+'P',
  1841. X    Control+Down_Key,               CTLX+CTRL+'N',
  1842. X    Help_Key,                       CTLX+'=',
  1843. X    Shift+Do_Key,                   CTLX+'(',
  1844. X    Control+Do_Key,                 CTLX+')',
  1845. X    Keypad_0,                       CTLX+'Z',
  1846. X    Shift+Keypad_0,                 CTLX+CTRL+'Z',
  1847. X    Main_Scr_Key,                   CTRL+'C',
  1848. X    Keypad_Enter,                   CTLX+'!',
  1849. X    Exit_Key,                       CTLX+CTRL+'C',
  1850. X    Shift+Exit_Key,                 CTRL+'Z'
  1851. X};
  1852. X
  1853. X#define lk_map_size     (sizeof(lk_map)/2)
  1854. X#endif
  1855. X
  1856. E!O!F
  1857. newsize=`wc -c < ebind.h`
  1858. if [ $newsize -ne 11535 ]
  1859. then echo "File ebind.h was $newsize bytes, 11535 expected"
  1860. fi
  1861. echo 'x - edef.h (text)'
  1862. sed << 'E!O!F' 's/^X//' > edef.h
  1863. X/*    EDEF:        Global variable definitions for
  1864. X            MicroEMACS 3.2
  1865. X
  1866. X            written by Dave G. Conroy
  1867. X            modified by Steve Wilhite, George Jones
  1868. X            greatly modified by Daniel Lawrence
  1869. X*/
  1870. X
  1871. X/* some global fuction declarations */
  1872. X
  1873. Xchar *malloc();
  1874. Xchar *strcpy();
  1875. Xchar *strcat();
  1876. Xchar *strncpy();
  1877. Xchar *itoa();
  1878. Xchar *getval();
  1879. Xchar *gtenv();
  1880. Xchar *gtusr();
  1881. Xchar *gtfun();
  1882. Xchar *token();
  1883. Xchar *ltos();
  1884. Xchar *flook();
  1885. Xchar *mkupper();
  1886. Xchar *mklower();
  1887. Xunsigned int getckey();
  1888. X
  1889. X#ifdef    maindef
  1890. X
  1891. X/* for MAIN.C */
  1892. X
  1893. X/* initialized global definitions */
  1894. X
  1895. Xint     fillcol = 72;                   /* Current fill column          */
  1896. Xshort   kbdm[NKBDM];            /* Macro                        */
  1897. Xchar    *execstr = NULL;        /* pointer to string to execute    */
  1898. Xchar    golabel[NPAT] = "";        /* current line to go to    */
  1899. Xint    execlevel = 0;            /* execution IF level        */
  1900. Xint    eolexist = TRUE;        /* does clear to EOL exist    */
  1901. Xint    revexist = FALSE;        /* does reverse video exist?    */
  1902. Xint    flickcode = FALSE;        /* do flicker supression?    */
  1903. Xchar    *modename[] = {            /* name of modes        */
  1904. X    "WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER",
  1905. X    "MAGIC", "CRYPT", "ASAVE"};
  1906. Xchar    modecode[] = "WCSEVOMYA";    /* letters to represent modes    */
  1907. Xint    gmode = 0;            /* global editor mode        */
  1908. Xint    gfcolor = 7;            /* global forgrnd color (white)    */
  1909. Xint    gbcolor    = 0;            /* global backgrnd color (black)*/
  1910. Xint    gasave = 256;            /* global ASAVE size        */
  1911. Xint    gacount = 256;            /* count until next ASAVE    */
  1912. Xint     sgarbf  = TRUE;                 /* TRUE if screen is garbage    */
  1913. Xint     mpresf  = FALSE;                /* TRUE if message in last line */
  1914. Xint    clexec    = FALSE;        /* command line execution flag    */
  1915. Xint    mstore    = FALSE;        /* storing text to macro flag    */
  1916. Xint    discmd    = TRUE;            /* display command flag        */
  1917. Xint    disinp    = TRUE;            /* display input characters    */
  1918. Xstruct    BUFFER *bstore = NULL;        /* buffer to store macro text to*/
  1919. Xint     vtrow   = 0;                    /* Row location of SW cursor */
  1920. Xint     vtcol   = 0;                    /* Column location of SW cursor */
  1921. Xint     ttrow   = HUGE;                 /* Row location of HW cursor */
  1922. Xint     ttcol   = HUGE;                 /* Column location of HW cursor */
  1923. Xint    lbound    = 0;            /* leftmost column of current line
  1924. X                       being displayed */
  1925. Xint    taboff    = 0;            /* tab offset for display    */
  1926. Xint    metac = CTRL | '[';        /* current meta character */
  1927. Xint    ctlxc = CTRL | 'X';        /* current control X prefix char */
  1928. Xint    reptc = CTRL | 'U';        /* current universal repeat char */
  1929. Xint    abortc = CTRL | 'G';        /* current abort command char    */
  1930. X
  1931. Xint    quotec = 0x11;            /* quote char during mlreply() */
  1932. Xchar    *cname[] = {            /* names of colors        */
  1933. X    "BLACK", "RED", "GREEN", "YELLOW", "BLUE",
  1934. X    "MAGENTA", "CYAN", "WHITE"};
  1935. XKILL *kbufp  = NULL;        /* current kill buffer chunk pointer    */
  1936. XKILL *kbufh  = NULL;        /* kill buffer header pointer        */
  1937. Xint kused = KBLOCK;        /* # of bytes used in kill buffer    */
  1938. XWINDOW *swindow = NULL;        /* saved window pointer            */
  1939. Xint cryptflag = FALSE;        /* currently encrypting?        */
  1940. Xshort    *kbdptr;        /* current position in keyboard buf */
  1941. Xshort    *kbdend = &kbdm[0];    /* ptr to end of the keyboard */
  1942. Xint    kbdmode = STOP;        /* current keyboard macro mode    */
  1943. Xint    kbdrep = 0;        /* number of repetitions    */
  1944. Xint    restflag = FALSE;    /* restricted use?        */
  1945. Xint    lastkey = 0;        /* last keystoke        */
  1946. Xint    seed = 0;        /* random number seed        */
  1947. Xlong    envram = 0l;    /* # of bytes current in use by malloc */
  1948. Xint    macbug = FALSE;        /* macro debuging flag        */
  1949. Xchar    errorm[] = "ERROR";    /* error literal        */
  1950. Xchar    truem[] = "TRUE";    /* true literal            */
  1951. Xchar    falsem[] = "FALSE";    /* false litereal        */
  1952. Xint    cmdstatus = TRUE;    /* last command status        */
  1953. Xchar    palstr[49] = "";    /* palette string        */
  1954. X
  1955. X/* uninitialized global definitions */
  1956. X
  1957. Xint     currow;                 /* Cursor row                   */
  1958. Xint     curcol;                 /* Cursor column                */
  1959. Xint     thisflag;               /* Flags, this command          */
  1960. Xint     lastflag;               /* Flags, last command          */
  1961. Xint     curgoal;                /* Goal for C-P, C-N            */
  1962. XWINDOW  *curwp;                 /* Current window               */
  1963. XBUFFER  *curbp;                 /* Current buffer               */
  1964. XWINDOW  *wheadp;                /* Head of list of windows      */
  1965. XBUFFER  *bheadp;                /* Head of list of buffers      */
  1966. XBUFFER  *blistp;                /* Buffer for C-X C-B           */
  1967. X
  1968. XBUFFER  *bfind();               /* Lookup a buffer by name      */
  1969. XWINDOW  *wpopup();              /* Pop up window creation       */
  1970. XLINE    *lalloc();              /* Allocate a line              */
  1971. Xchar    sres[NBUFN];        /* current screen resolution    */
  1972. X
  1973. Xchar    pat[NPAT];                      /* Search pattern        */
  1974. Xchar    tap[NPAT];            /* Reversed pattern array.    */
  1975. Xchar    rpat[NPAT];            /* replacement pattern        */
  1976. X
  1977. X/* The variable matchlen holds the length of the matched
  1978. X * string - used by the replace functions.
  1979. X * The variable patmatch holds the string that satisfies
  1980. X * the search command.
  1981. X * The variables matchline and matchoff hold the line and
  1982. X * offset position of the start of match.
  1983. X */
  1984. Xunsigned int    matchlen = 0;
  1985. Xunsigned int    mlenold  = 0;
  1986. Xchar        *patmatch = NULL;
  1987. XLINE        *matchline = NULL;
  1988. Xint        matchoff = 0;
  1989. X
  1990. X#if    MAGIC
  1991. X/*
  1992. X * The variable magical determines if there are actual
  1993. X * metacharacters in the string - if not, then we don't
  1994. X * have to use the slower MAGIC mode search functions.
  1995. X */
  1996. Xshort int    magical = FALSE;
  1997. XMC        mcpat[NPAT];        /* the magic pattern        */
  1998. XMC        tapcm[NPAT];        /* the reversed magic pattern    */
  1999. X
  2000. X#endif
  2001. X
  2002. X#else
  2003. X
  2004. X/* for all the other .C files */
  2005. X
  2006. X/* initialized global external declarations */
  2007. X
  2008. Xextern  int     fillcol;                /* Fill column                  */
  2009. Xextern  short   kbdm[];                 /* Holds kayboard macro data    */
  2010. Xextern  char    pat[];                  /* Search pattern               */
  2011. Xextern    char    rpat[];            /* Replacement pattern        */
  2012. Xextern    char    *execstr;        /* pointer to string to execute    */
  2013. Xextern    char    golabel[];        /* current line to go to    */
  2014. Xextern    int    execlevel;        /* execution IF level        */
  2015. Xextern    int    eolexist;        /* does clear to EOL exist?    */
  2016. Xextern    int    revexist;        /* does reverse video exist?    */
  2017. Xextern    int    flickcode;        /* do flicker supression?    */
  2018. Xextern    char *modename[];        /* text names of modes        */
  2019. Xextern    char    modecode[];        /* letters to represent modes    */
  2020. Xextern    KEYTAB keytab[];        /* key bind to functions table    */
  2021. Xextern    NBIND names[];            /* name to function table    */
  2022. Xextern    int    gmode;            /* global editor mode        */
  2023. Xextern    int    gfcolor;        /* global forgrnd color (white)    */
  2024. Xextern    int    gbcolor;        /* global backgrnd color (black)*/
  2025. Xextern    int    gasave;            /* global ASAVE size        */
  2026. Xextern    int    gacount;        /* count until next ASAVE    */
  2027. Xextern  int     sgarbf;                 /* State of screen unknown      */
  2028. Xextern  int     mpresf;                 /* Stuff in message line        */
  2029. Xextern    int    clexec;            /* command line execution flag    */
  2030. Xextern    int    mstore;            /* storing text to macro flag    */
  2031. Xextern    int    discmd;            /* display command flag        */
  2032. Xextern    int    disinp;            /* display input characters    */
  2033. Xextern    struct    BUFFER *bstore;        /* buffer to store macro text to*/
  2034. Xextern    int     vtrow;                  /* Row location of SW cursor */
  2035. Xextern    int     vtcol;                  /* Column location of SW cursor */
  2036. Xextern    int     ttrow;                  /* Row location of HW cursor */
  2037. Xextern    int     ttcol;                  /* Column location of HW cursor */
  2038. Xextern    int    lbound;            /* leftmost column of current line
  2039. X                       being displayed */
  2040. Xextern    int    taboff;            /* tab offset for display    */
  2041. Xextern    int    metac;            /* current meta character */
  2042. Xextern    int    ctlxc;            /* current control X prefix char */
  2043. Xextern    int    reptc;            /* current universal repeat char */
  2044. Xextern    int    abortc;            /* current abort command char    */
  2045. X
  2046. Xextern    int    quotec;            /* quote char during mlreply() */
  2047. Xextern    char    *cname[];        /* names of colors        */
  2048. Xextern KILL *kbufp;            /* current kill buffer chunk pointer */
  2049. Xextern KILL *kbufh;            /* kill buffer header pointer    */
  2050. Xextern int kused;            /* # of bytes used in KB        */
  2051. Xextern WINDOW *swindow;            /* saved window pointer        */
  2052. Xextern int cryptflag;            /* currently encrypting?    */
  2053. Xextern    short    *kbdptr;        /* current position in keyboard buf */
  2054. Xextern    short    *kbdend;        /* ptr to end of the keyboard */
  2055. Xextern    int kbdmode;            /* current keyboard macro mode    */
  2056. Xextern    int kbdrep;            /* number of repetitions    */
  2057. Xextern    int restflag;            /* restricted use?        */
  2058. Xextern    int lastkey;            /* last keystoke        */
  2059. Xextern    int seed;            /* random number seed        */
  2060. Xextern    long envram;        /* # of bytes current in use by malloc */
  2061. Xextern    int    macbug;            /* macro debuging flag        */
  2062. Xextern    char    errorm[];        /* error literal        */
  2063. Xextern    char    truem[];        /* true literal            */
  2064. Xextern    char    falsem[];        /* false litereal        */
  2065. Xextern    int    cmdstatus;        /* last command status        */
  2066. Xextern    char    palstr[];        /* palette string        */
  2067. X
  2068. X/* uninitialized global external declarations */
  2069. X
  2070. Xextern  int     currow;                 /* Cursor row                   */
  2071. Xextern  int     curcol;                 /* Cursor column                */
  2072. Xextern  int     thisflag;               /* Flags, this command          */
  2073. Xextern  int     lastflag;               /* Flags, last command          */
  2074. Xextern  int     curgoal;                /* Goal for C-P, C-N            */
  2075. Xextern  WINDOW  *curwp;                 /* Current window               */
  2076. Xextern  BUFFER  *curbp;                 /* Current buffer               */
  2077. Xextern  WINDOW  *wheadp;                /* Head of list of windows      */
  2078. Xextern  BUFFER  *bheadp;                /* Head of list of buffers      */
  2079. Xextern  BUFFER  *blistp;                /* Buffer for C-X C-B           */
  2080. X
  2081. Xextern  BUFFER  *bfind();               /* Lookup a buffer by name      */
  2082. Xextern  WINDOW  *wpopup();              /* Pop up window creation       */
  2083. Xextern  LINE    *lalloc();              /* Allocate a line              */
  2084. Xextern    char    sres[NBUFN];        /* current screen resolution    */
  2085. Xextern    char    pat[];                  /* Search pattern        */
  2086. Xextern    char    tap[];            /* Reversed pattern array.    */
  2087. Xextern    char    rpat[];            /* replacement pattern        */
  2088. X
  2089. Xextern    unsigned int    matchlen;    /* length of found string    */
  2090. Xextern    unsigned int    mlenold;    /* previous length of found str    */
  2091. Xextern    char    *patmatch;        /* the found string        */
  2092. Xextern    LINE    *matchline;        /* line pointer to found string    */
  2093. Xextern    int    matchoff;        /* offset to the found string    */
  2094. X
  2095. X#if    MAGIC
  2096. X
  2097. Xextern    short int    magical;    /* meta-characters in pattern?    */
  2098. Xextern    MC        mcpat[];    /* the magic pattern        */
  2099. Xextern    MC        tapcm[];    /* the reversed magic pattern    */
  2100. X
  2101. X#endif
  2102. X
  2103. X#endif
  2104. X
  2105. X/* terminal table defined only in TERM.C */
  2106. X
  2107. X#ifndef    termdef
  2108. Xextern  TERM    term;                   /* Terminal information.        */
  2109. X#endif
  2110. X
  2111. X
  2112. E!O!F
  2113. newsize=`wc -c < edef.h`
  2114. if [ $newsize -ne 10634 ]
  2115. then echo "File edef.h was $newsize bytes, 10634 expected"
  2116. fi
  2117.     bill davidsen        (wedu@ge-crd.arpa)
  2118.   {chinet | philabs | sesimo}!steinmetz!crdos1!davidsen
  2119. "Stupidity, like virtue, is its own reward" -me
  2120.  
  2121.  
  2122.