[comp.sources.misc] memacs 3.8i 2 of 11

allbery@ncoast.UUCP (06/15/87)

:
#!/bin/sh
# shar+ created from directory /usr2/davidsen/emacs38i
# 13:42 on Thu Jun 11, 1987 by davidsen
echo 'x - diffs (text)'
sed << 'E!O!F' 's/^X//' > diffs
Xchanges to MicroEMACS v3.8i
X
XSorry I couldn't do a context diff on the system with the source. These
Xconsist of the name of the module, the reason for the change, given as
Xcomments, and the actual diffs. These represent some changes I found
Xuseful. With the exception of the change to the 'word' logic, these will
Xdo nothing but eliminate compiler warnings.
X----------------------------------------------------------------
Xestruct.h
X# This change is to keep the VAX C compiler from complaining about
X# undefining 'abs'. It complains on every compile, and on the link
X# once per module. Enough!
X269a270
X> #ifdef abs
X270a272
X> #endif
X
Xtermio.c
X# this avoids a message from the BSD compiler about "statement
X# not reached"
X462c462
X< #endif
X---
X> #else
X463a464
X> #endif
Xword.c
X# This causes emacs to treat words the way vi does. Delete word now has
X# the following logic:
X# - if the cursor is in a word, delete the word and all following
X# whitespace
X# - if the cursor is not in a word delete characters up to the next word
X# 
X# This matters for expressions like "abc/(def+ghi)", where the original
X# logic would delete from 'a' in 'abc' to 'd' in 'def', dropping the
X# operators on the way. With this change the word deleted is 'abc' only,
Xprobably what is intended.
X255,258c255,267
X< 		while (inword() != FALSE) {
X< 			if (forwchar(FALSE,1) == FALSE)
X< 				return(FALSE);
X< 			++size;
X---
X> 		if (inword()) {
X> 			while (inword() != FALSE) {
X> 				if (forwchar(FALSE,1) == FALSE)
X> 					return(FALSE);
X> 				++size;
X> 			}
X> 	
X> 	                while ((iswhite()) &&
X> 					(curwp->w_doto != llength(curwp->w_dotp))) {
X> 	                        if (forwchar(FALSE, 1) == FALSE)
X> 	                                return (FALSE);
X> 	                        ++size;
X> 	                }
X260,266c269,276
X< 
X<                 while ((inword() == FALSE) &&
X< 				(curwp->w_doto != llength(curwp->w_dotp))) {
X<                         if (forwchar(FALSE, 1) == FALSE)
X<                                 return (FALSE);
X<                         ++size;
X<                 }
X---
X> 		else {
X> 			while ((inword() == FALSE) &&
X> 					(curwp->w_doto != llength(curwp->w_dotp))) {
X> 				if (forwchar(FALSE,1) == FALSE)
X> 					return(FALSE);
X> 				++size;
X> 			}
X> 		}
X340a351,366
X>         return (FALSE);
X> }
X> 
X> /*
X>  *  return TRUE if the current character is whitespace,
X>  *  else return FALSE.
X>  */
X> 
X> iswhite()
X> {
X>         register int    c;
X> 
X>         if (curwp->w_doto == llength(curwp->w_dotp))
X>                 return (FALSE);
X>         c = lgetc(curwp->w_dotp, curwp->w_doto);
X> 	if (c == ' ' || c == '\t') return (TRUE);
E!O!F
newsize=`wc -c < diffs`
if [ $newsize -ne 2630 ]
then echo "File diffs was $newsize bytes, 2630 expected"
fi
echo 'x - display.c (text)'
sed << 'E!O!F' 's/^X//' > display.c
X/*
X * The functions in this file handle redisplay. There are two halves, the
X * ones that update the virtual display screen, and the ones that make the
X * physical display screen the same as the virtual display screen. These
X * functions use hints that are left in the windows by the commands.
X *
X */
X
X#include        <stdio.h>
X#include	"estruct.h"
X#include        "edef.h"
X
Xtypedef struct  VIDEO {
X        int	v_flag;                 /* Flags */
X#if	COLOR
X	int	v_fcolor;		/* current forground color */
X	int	v_bcolor;		/* current background color */
X	int	v_rfcolor;		/* requested forground color */
X	int	v_rbcolor;		/* requested background color */
X#endif
X        char    v_text[1];              /* Screen data. */
X}       VIDEO;
X
X#define VFCHG   0x0001                  /* Changed flag			*/
X#define	VFEXT	0x0002			/* extended (beyond column 80)	*/
X#define	VFREV	0x0004			/* reverse video status		*/
X#define	VFREQ	0x0008			/* reverse video request	*/
X#define	VFCOL	0x0010			/* color change requested	*/
X
XVIDEO   **vscreen;                      /* Virtual screen. */
X#if	MEMMAP == 0
XVIDEO   **pscreen;                      /* Physical screen. */
X#endif
X
X/*
X * Initialize the data structures used by the display code. The edge vectors
X * used to access the screens are set up. The operating system's terminal I/O
X * channel is set up. All the other things get initialized at compile time.
X * The original window has "WFCHG" set, so that it will get completely
X * redrawn on the first call to "update".
X */
Xvtinit()
X{
X    register int i;
X    register VIDEO *vp;
X    char *malloc();
X
X    TTopen();		/* open the screen */
X    TTkopen();		/* open the keyboard */
X    TTrev(FALSE);
X    vscreen = (VIDEO **) malloc(term.t_mrow*sizeof(VIDEO *));
X
X    if (vscreen == NULL)
X        exit(1);
X
X#if	MEMMAP == 0
X    pscreen = (VIDEO **) malloc(term.t_mrow*sizeof(VIDEO *));
X
X    if (pscreen == NULL)
X        exit(1);
X#endif
X
X    for (i = 0; i < term.t_mrow; ++i)
X        {
X        vp = (VIDEO *) malloc(sizeof(VIDEO)+term.t_mcol);
X
X        if (vp == NULL)
X            exit(1);
X
X	vp->v_flag = 0;
X#if	COLOR
X	vp->v_rfcolor = 7;
X	vp->v_rbcolor = 0;
X#endif
X        vscreen[i] = vp;
X#if	MEMMAP == 0
X        vp = (VIDEO *) malloc(sizeof(VIDEO)+term.t_mcol);
X
X        if (vp == NULL)
X            exit(1);
X
X	vp->v_flag = 0;
X        pscreen[i] = vp;
X#endif
X        }
X}
X
X/*
X * Clean up the virtual terminal system, in anticipation for a return to the
X * operating system. Move down to the last line and clear it out (the next
X * system prompt will be written in the line). Shut down the channel to the
X * terminal.
X */
Xvttidy()
X{
X    mlerase();
X    movecursor(term.t_nrow, 0);
X    TTflush();
X    TTclose();
X    TTkclose();
X}
X
X/*
X * Set the virtual cursor to the specified row and column on the virtual
X * screen. There is no checking for nonsense values; this might be a good
X * idea during the early stages.
X */
Xvtmove(row, col)
X{
X    vtrow = row;
X    vtcol = col;
X}
X
X/* Write a character to the virtual screen. The virtual row and
X   column are updated. If we are not yet on left edge, don't print
X   it yet. If the line is too long put a "$" in the last column.
X   This routine only puts printing characters into the virtual
X   terminal buffers. Only column overflow is checked.
X*/
X
Xvtputc(c)
X
Xint c;
X
X{
X	register VIDEO *vp;	/* ptr to line being updated */
X
X	vp = vscreen[vtrow];
X
X	if (c == '\t') {
X		do {
X			vtputc(' ');
X		} while (((vtcol + taboff)&0x07) != 0);
X	} else if (vtcol >= term.t_ncol) {
X		++vtcol;
X		vp->v_text[term.t_ncol - 1] = '$';
X	} else if (c < 0x20 || c == 0x7F) {
X		vtputc('^');
X		vtputc(c ^ 0x40);
X	} else {
X		if (vtcol >= 0)
X			vp->v_text[vtcol] = c;
X		++vtcol;
X	}
X}
X
X/*
X * Erase from the end of the software cursor to the end of the line on which
X * the software cursor is located.
X */
Xvteeol()
X{
X    register VIDEO      *vp;
X
X    vp = vscreen[vtrow];
X    while (vtcol < term.t_ncol)
X        vp->v_text[vtcol++] = ' ';
X}
X
X/* upscreen:	user routine to force a screen update
X		always finishes complete update		*/
X
Xupscreen(f, n)
X
X{
X	update(TRUE);
X	return(TRUE);
X}
X
X/*
X * Make sure that the display is right. This is a three part process. First,
X * scan through all of the windows looking for dirty ones. Check the framing,
X * and refresh the screen. Second, make sure that "currow" and "curcol" are
X * correct for the current window. Third, make the virtual and physical
X * screens the same.
X */
Xupdate(force)
X
Xint force;	/* force update past type ahead? */
X
X{
X	register WINDOW *wp;
X
X#if	TYPEAH
X	if (force == FALSE && typahead())
X		return(TRUE);
X#endif
X#if	VISMAC == 0
X	if (force == FALSE && kbdmode == PLAY)
X		return(TRUE);
X#endif
X
X	/* update any windows that need refreshing */
X	wp = wheadp;
X	while (wp != NULL) {
X		if (wp->w_flag) {
X			/* if the window has changed, service it */
X			reframe(wp);	/* check the framing */
X			if ((wp->w_flag & ~WFMODE) == WFEDIT)
X				updone(wp);	/* update EDITed line */
X			else if (wp->w_flag & ~WFMOVE)
X				updall(wp);	/* update all lines */
X			if (wp->w_flag & WFMODE)
X				modeline(wp);	/* update modeline */
X			wp->w_flag = 0;
X			wp->w_force = 0;
X		}
X		/* on to the next window */
X		wp = wp->w_wndp;
X	}
X
X	/* recalc the current hardware cursor location */
X	updpos();
X
X#if	MEMMAP
X	/* update the cursor and flush the buffers */
X	movecursor(currow, curcol - lbound);
X#endif
X
X	/* check for lines to de-extend */
X	upddex();
X
X	/* if screen is garbage, re-plot it */
X	if (sgarbf != FALSE)
X		updgar();
X
X	/* update the virtual screen to the physical screen */
X	updupd(force);
X
X	/* update the cursor and flush the buffers */
X	movecursor(currow, curcol - lbound);
X	TTflush();
X	return(TRUE);
X}
X
X/*	reframe:	check to see if the cursor is on in the window
X			and re-frame it if needed or wanted		*/
X
Xreframe(wp)
X
XWINDOW *wp;
X
X{
X	register LINE *lp;
X	register int i;
X
X	/* if not a requested reframe, check for a needed one */
X	if ((wp->w_flag & WFFORCE) == 0) {
X		lp = wp->w_linep;
X		for (i = 0; i < wp->w_ntrows; i++) {
X
X			/* if the line is in the window, no reframe */
X			if (lp == wp->w_dotp)
X				return(TRUE);
X
X			/* if we are at the end of the file, reframe */
X			if (lp == wp->w_bufp->b_linep)
X				break;
X
X			/* on to the next line */
X			lp = lforw(lp);
X		}
X	}
X
X	/* reaching here, we need a window refresh */
X	i = wp->w_force;
X
X	/* how far back to reframe? */
X	if (i > 0) {		/* only one screen worth of lines max */
X		if (--i >= wp->w_ntrows)
X			i = wp->w_ntrows - 1;
X	} else if (i < 0) {	/* negative update???? */
X		i += wp->w_ntrows;
X		if (i < 0)
X			i = 0;
X	} else
X		i = wp->w_ntrows / 2;
X
X	/* backup to new line at top of window */
X	lp = wp->w_dotp;
X	while (i != 0 && lback(lp) != wp->w_bufp->b_linep) {
X		--i;
X		lp = lback(lp);
X	}
X
X	/* and reset the current line at top of window */
X	wp->w_linep = lp;
X	wp->w_flag |= WFHARD;
X	wp->w_flag &= ~WFFORCE;
X	return(TRUE);
X}
X
X/*	updone:	update the current line	to the virtual screen		*/
X
Xupdone(wp)
X
XWINDOW *wp;	/* window to update current line in */
X
X{
X	register LINE *lp;	/* line to update */
X	register int sline;	/* physical screen line to update */
X	register int i;
X
X	/* search down the line we want */
X	lp = wp->w_linep;
X	sline = wp->w_toprow;
X	while (lp != wp->w_dotp) {
X		++sline;
X		lp = lforw(lp);
X	}
X
X	/* and update the virtual line */
X	vscreen[sline]->v_flag |= VFCHG;
X	vscreen[sline]->v_flag &= ~VFREQ;
X	vtmove(sline, 0);
X	for (i=0; i < llength(lp); ++i)
X		vtputc(lgetc(lp, i));
X#if	COLOR
X	vscreen[sline]->v_rfcolor = wp->w_fcolor;
X	vscreen[sline]->v_rbcolor = wp->w_bcolor;
X#endif
X	vteeol();
X}
X
X/*	updall:	update all the lines in a window on the virtual screen */
X
Xupdall(wp)
X
XWINDOW *wp;	/* window to update lines in */
X
X{
X	register LINE *lp;	/* line to update */
X	register int sline;	/* physical screen line to update */
X	register int i;
X
X	/* search down the lines, updating them */
X	lp = wp->w_linep;
X	sline = wp->w_toprow;
X	while (sline < wp->w_toprow + wp->w_ntrows) {
X
X		/* and update the virtual line */
X		vscreen[sline]->v_flag |= VFCHG;
X		vscreen[sline]->v_flag &= ~VFREQ;
X		vtmove(sline, 0);
X		if (lp != wp->w_bufp->b_linep) {
X			/* if we are not at the end */
X			for (i=0; i < llength(lp); ++i)
X				vtputc(lgetc(lp, i));
X			lp = lforw(lp);
X		}
X
X		/* on to the next one */
X#if	COLOR
X		vscreen[sline]->v_rfcolor = wp->w_fcolor;
X		vscreen[sline]->v_rbcolor = wp->w_bcolor;
X#endif
X		vteeol();
X		++sline;
X	}
X
X}
X
X/*	updpos:	update the position of the hardware cursor and handle extended
X		lines. This is the only update for simple moves.	*/
X
Xupdpos()
X
X{
X	register LINE *lp;
X	register int c;
X	register int i;
X
X	/* find the current row */
X	lp = curwp->w_linep;
X	currow = curwp->w_toprow;
X	while (lp != curwp->w_dotp) {
X		++currow;
X		lp = lforw(lp);
X	}
X
X	/* find the current column */
X	curcol = 0;
X	i = 0;
X	while (i < curwp->w_doto) {
X		c = lgetc(lp, i++);
X		if (c == '\t')
X			curcol |= 0x07;
X		else
X			if (c < 0x20 || c == 0x7f)
X				++curcol;
X
X		++curcol;
X	}
X
X	/* if extended, flag so and update the virtual line image */
X	if (curcol >=  term.t_ncol - 1) {
X		vscreen[currow]->v_flag |= (VFEXT | VFCHG);
X		updext();
X	} else
X		lbound = 0;
X}
X
X/*	upddex:	de-extend any line that derserves it		*/
X
Xupddex()
X
X{
X	register WINDOW *wp;
X	register LINE *lp;
X	register int i,j;
X
X	wp = wheadp;
X
X	while (wp != NULL) {
X		lp = wp->w_linep;
X		i = wp->w_toprow;
X
X		while (i < wp->w_toprow + wp->w_ntrows) {
X			if (vscreen[i]->v_flag & VFEXT) {
X				if ((wp != curwp) || (lp != wp->w_dotp) ||
X				   (curcol < term.t_ncol - 1)) {
X					vtmove(i, 0);
X					for (j = 0; j < llength(lp); ++j)
X						vtputc(lgetc(lp, j));
X					vteeol();
X
X					/* this line no longer is extended */
X					vscreen[i]->v_flag &= ~VFEXT;
X					vscreen[i]->v_flag |= VFCHG;
X				}
X			}
X			lp = lforw(lp);
X			++i;
X		}
X		/* and onward to the next window */
X		wp = wp->w_wndp;
X	}
X}
X
X/*	updgar:	if the screen is garbage, clear the physical screen and
X		the virtual screen and force a full update		*/
X
Xupdgar()
X
X{
X	register char *txt;
X	register int i,j;
X
X	for (i = 0; i < term.t_nrow; ++i) {
X		vscreen[i]->v_flag |= VFCHG;
X#if	REVSTA
X		vscreen[i]->v_flag &= ~VFREV;
X#endif
X#if	COLOR
X		vscreen[i]->v_fcolor = gfcolor;
X		vscreen[i]->v_bcolor = gbcolor;
X#endif
X#if	MEMMAP == 0
X		txt = pscreen[i]->v_text;
X		for (j = 0; j < term.t_ncol; ++j)
X			txt[j] = ' ';
X#endif
X	}
X
X	movecursor(0, 0);		 /* Erase the screen. */
X	(*term.t_eeop)();
X	sgarbf = FALSE;			 /* Erase-page clears */
X	mpresf = FALSE;			 /* the message area. */
X#if	COLOR
X	mlerase();			/* needs to be cleared if colored */
X#endif
X}
X
X/*	updupd:	update the physical screen from the virtual screen	*/
X
Xupdupd(force)
X
Xint force;	/* forced update flag */
X
X{
X	register VIDEO *vp1;
X	register int i;
X
X	for (i = 0; i < term.t_nrow; ++i) {
X		vp1 = vscreen[i];
X
X		/* for each line that needs to be updated*/
X		if ((vp1->v_flag & VFCHG) != 0) {
X#if	TYPEAH
X			if (force == FALSE && typahead())
X				return(TRUE);
X#endif
X#if	MEMMAP
X			updateline(i, vp1);
X#else
X			updateline(i, vp1, pscreen[i]);
X#endif
X		}
X	}
X	return(TRUE);
X}
X
X/*	updext: update the extended line which the cursor is currently
X		on at a column greater than the terminal width. The line
X		will be scrolled right or left to let the user see where
X		the cursor is
X								*/
X
Xupdext()
X
X{
X	register int rcursor;	/* real cursor location */
X	register LINE *lp;	/* pointer to current line */
X	register int j;		/* index into line */
X
X	/* calculate what column the real cursor will end up in */
X	rcursor = ((curcol - term.t_ncol) % term.t_scrsiz) + term.t_margin;
X	taboff = lbound = curcol - rcursor + 1;
X
X	/* scan through the line outputing characters to the virtual screen */
X	/* once we reach the left edge					*/
X	vtmove(currow, -lbound);	/* start scanning offscreen */
X	lp = curwp->w_dotp;		/* line to output */
X	for (j=0; j<llength(lp); ++j)	/* until the end-of-line */
X		vtputc(lgetc(lp, j));
X
X	/* truncate the virtual line, restore tab offset */
X	vteeol();
X	taboff = 0;
X
X	/* and put a '$' in column 1 */
X	vscreen[currow]->v_text[0] = '$';
X}
X
X/*
X * Update a single line. This does not know how to use insert or delete
X * character sequences; we are using VT52 functionality. Update the physical
X * row and column variables. It does try an exploit erase to end of line. The
X * RAINBOW version of this routine uses fast video.
X */
X#if	MEMMAP
X/*	UPDATELINE specific code for the IBM-PC and other compatables */
X
Xupdateline(row, vp1)
X
Xint row;		/* row of screen to update */
Xstruct VIDEO *vp1;	/* virtual screen image */
X
X{
X#if	COLOR
X	scwrite(row, vp1->v_text, vp1->v_rfcolor, vp1->v_rbcolor);
X	vp1->v_fcolor = vp1->v_rfcolor;
X	vp1->v_bcolor = vp1->v_rbcolor;
X#else
X	if (vp1->v_flag & VFREQ)
X		scwrite(row, vp1->v_text, 0, 7);
X	else
X		scwrite(row, vp1->v_text, 7, 0);
X#endif
X	vp1->v_flag &= ~(VFCHG | VFCOL);	/* flag this line as changed */
X
X}
X
X#else
X
Xupdateline(row, vp1, vp2)
X
Xint row;		/* row of screen to update */
Xstruct VIDEO *vp1;	/* virtual screen image */
Xstruct VIDEO *vp2;	/* physical screen image */
X
X{
X#if RAINBOW
X/*	UPDATELINE specific code for the DEC rainbow 100 micro	*/
X
X    register char *cp1;
X    register char *cp2;
X    register int nch;
X
X    /* since we don't know how to make the rainbow do this, turn it off */
X    flags &= (~VFREV & ~VFREQ);
X
X    cp1 = &vp1->v_text[0];                    /* Use fast video. */
X    cp2 = &vp2->v_text[0];
X    putline(row+1, 1, cp1);
X    nch = term.t_ncol;
X
X    do
X        {
X        *cp2 = *cp1;
X        ++cp2;
X        ++cp1;
X        }
X    while (--nch);
X    *flags &= ~VFCHG;
X#else
X/*	UPDATELINE code for all other versions		*/
X
X	register char *cp1;
X	register char *cp2;
X	register char *cp3;
X	register char *cp4;
X	register char *cp5;
X	register int nbflag;	/* non-blanks to the right flag? */
X	int rev;		/* reverse video flag */
X	int req;		/* reverse video request flag */
X
X
X	/* set up pointers to virtual and physical lines */
X	cp1 = &vp1->v_text[0];
X	cp2 = &vp2->v_text[0];
X
X#if	COLOR
X	TTforg(vp1->v_rfcolor);
X	TTbacg(vp1->v_rbcolor);
X#endif
X
X#if	REVSTA | COLOR
X	/* if we need to change the reverse video status of the
X	   current line, we need to re-write the entire line     */
X	rev = (vp1->v_flag & VFREV) == VFREV;
X	req = (vp1->v_flag & VFREQ) == VFREQ;
X	if ((rev != req)
X#if	COLOR
X	    || (vp1->v_fcolor != vp1->v_rfcolor) || (vp1->v_bcolor != vp1->v_rbcolor)
X#endif
X#if	HP150
X	/* the HP150 has some reverse video problems */
X	    || req || rev
X#endif
X			) {
X		movecursor(row, 0);	/* Go to start of line. */
X		/* set rev video if needed */
X		if (rev != req)
X			(*term.t_rev)(req);
X
X		/* scan through the line and dump it to the screen and
X		   the virtual screen array				*/
X		cp3 = &vp1->v_text[term.t_ncol];
X		while (cp1 < cp3) {
X			TTputc(*cp1);
X			++ttcol;
X			*cp2++ = *cp1++;
X		}
X		/* turn rev video off */
X		if (rev != req)
X			(*term.t_rev)(FALSE);
X
X		/* update the needed flags */
X		vp1->v_flag &= ~VFCHG;
X		if (req)
X			vp1->v_flag |= VFREV;
X		else
X			vp1->v_flag &= ~VFREV;
X#if	COLOR
X		vp1->v_fcolor = vp1->v_rfcolor;
X		vp1->v_bcolor = vp1->v_rbcolor;
X#endif
X		return(TRUE);
X	}
X#endif
X
X	/* advance past any common chars at the left */
X	while (cp1 != &vp1->v_text[term.t_ncol] && cp1[0] == cp2[0]) {
X		++cp1;
X		++cp2;
X	}
X
X/* This can still happen, even though we only call this routine on changed
X * lines. A hard update is always done when a line splits, a massive
X * change is done, or a buffer is displayed twice. This optimizes out most
X * of the excess updating. A lot of computes are used, but these tend to
X * be hard operations that do a lot of update, so I don't really care.
X */
X	/* if both lines are the same, no update needs to be done */
X	if (cp1 == &vp1->v_text[term.t_ncol]) {
X 		vp1->v_flag &= ~VFCHG;		/* flag this line is changed */
X		return(TRUE);
X	}
X
X	/* find out if there is a match on the right */
X	nbflag = FALSE;
X	cp3 = &vp1->v_text[term.t_ncol];
X	cp4 = &vp2->v_text[term.t_ncol];
X
X	while (cp3[-1] == cp4[-1]) {
X		--cp3;
X		--cp4;
X		if (cp3[0] != ' ')		/* Note if any nonblank */
X			nbflag = TRUE;		/* in right match. */
X	}
X
X	cp5 = cp3;
X
X	/* Erase to EOL ? */
X	if (nbflag == FALSE && eolexist == TRUE && (req != TRUE)) {
X		while (cp5!=cp1 && cp5[-1]==' ')
X			--cp5;
X
X		if (cp3-cp5 <= 3)		/* Use only if erase is */
X			cp5 = cp3;		/* fewer characters. */
X	}
X
X	movecursor(row, cp1 - &vp1->v_text[0]);	/* Go to start of line. */
X#if	REVSTA
X	TTrev(rev);
X#endif
X
X	while (cp1 != cp5) {		/* Ordinary. */
X		TTputc(*cp1);
X		++ttcol;
X		*cp2++ = *cp1++;
X	}
X
X	if (cp5 != cp3) {		/* Erase. */
X		TTeeol();
X		while (cp1 != cp3)
X			*cp2++ = *cp1++;
X	}
X#if	REVSTA
X	TTrev(FALSE);
X#endif
X	vp1->v_flag &= ~VFCHG;		/* flag this line as updated */
X	return(TRUE);
X#endif
X}
X#endif
X
X/*
X * Redisplay the mode line for the window pointed to by the "wp". This is the
X * only routine that has any idea of how the modeline is formatted. You can
X * change the modeline format by hacking at this routine. Called by "update"
X * any time there is a dirty window.
X */
Xmodeline(wp)
X    WINDOW *wp;
X{
X    register char *cp;
X    register int c;
X    register int n;		/* cursor position count */
X    register BUFFER *bp;
X    register i;			/* loop index */
X    register lchar;		/* character to draw line in buffer with */
X    register firstm;		/* is this the first mode? */
X    char tline[NLINE];		/* buffer for part of mode line */
X
X    n = wp->w_toprow+wp->w_ntrows;      	/* Location. */
X    vscreen[n]->v_flag |= VFCHG | VFREQ | VFCOL;/* Redraw next time. */
X#if	COLOR
X    vscreen[n]->v_rfcolor = 0;			/* black on */
X    vscreen[n]->v_rbcolor = 7;			/* white.....*/
X#endif
X    vtmove(n, 0);                       	/* Seek to right line. */
X    if (wp == curwp)				/* mark the current buffer */
X	lchar = '=';
X    else
X#if	REVSTA
X	if (revexist)
X		lchar = ' ';
X	else
X#endif
X		lchar = '-';
X
X    vtputc(lchar);
X    bp = wp->w_bufp;
X
X    if ((bp->b_flag&BFCHG) != 0)                /* "*" if changed. */
X        vtputc('*');
X    else
X        vtputc(lchar);
X
X    n  = 2;
X    strcpy(tline, " ");				/* Buffer name. */
X    strcat(tline, PROGNAME);
X    strcat(tline, " ");
X    strcat(tline, VERSION);
X    strcat(tline, " (");
X
X    /* display the modes */
X
X	firstm = TRUE;
X	for (i = 0; i < NUMMODES; i++)	/* add in the mode flags */
X		if (wp->w_bufp->b_mode & (1 << i)) {
X			if (firstm != TRUE)
X				strcat(tline, " ");
X			firstm = FALSE;
X			strcat(tline, modename[i]);
X		}
X	strcat(tline,") ");
X
X    cp = &tline[0];
X    while ((c = *cp++) != 0)
X        {
X        vtputc(c);
X        ++n;
X        }
X
X#if 0
X    vtputc(lchar);
X    vtputc((wp->w_flag&WFCOLR) != 0  ? 'C' : lchar);
X    vtputc((wp->w_flag&WFMODE) != 0  ? 'M' : lchar);
X    vtputc((wp->w_flag&WFHARD) != 0  ? 'H' : lchar);
X    vtputc((wp->w_flag&WFEDIT) != 0  ? 'E' : lchar);
X    vtputc((wp->w_flag&WFMOVE) != 0  ? 'V' : lchar);
X    vtputc((wp->w_flag&WFFORCE) != 0 ? 'F' : lchar);
X    vtputc(lchar);
X    n += 8;
X#endif
X
X    vtputc(lchar);
X    vtputc(lchar);
X    vtputc(' ');
X    n += 3;
X    cp = &bp->b_bname[0];
X
X    while ((c = *cp++) != 0)
X        {
X        vtputc(c);
X        ++n;
X        }
X
X    vtputc(' ');
X    vtputc(lchar);
X    vtputc(lchar);
X    n += 3;
X
X    if (bp->b_fname[0] != 0)            /* File name. */
X        {
X	vtputc(' ');
X	++n;
X        cp = "File: ";
X
X        while ((c = *cp++) != 0)
X            {
X            vtputc(c);
X            ++n;
X            }
X
X        cp = &bp->b_fname[0];
X
X        while ((c = *cp++) != 0)
X            {
X            vtputc(c);
X            ++n;
X            }
X
X        vtputc(' ');
X        ++n;
X        }
X
X    while (n < term.t_ncol)             /* Pad to full width. */
X        {
X        vtputc(lchar);
X        ++n;
X        }
X}
X
Xupmode()	/* update all the mode lines */
X
X{
X	register WINDOW *wp;
X
X	wp = wheadp;
X	while (wp != NULL) {
X		wp->w_flag |= WFMODE;
X		wp = wp->w_wndp;
X	}
X}
X
X/*
X * Send a command to the terminal to move the hardware cursor to row "row"
X * and column "col". The row and column arguments are origin 0. Optimize out
X * random calls. Update "ttrow" and "ttcol".
X */
Xmovecursor(row, col)
X    {
X    if (row!=ttrow || col!=ttcol)
X        {
X        ttrow = row;
X        ttcol = col;
X        TTmove(row, col);
X        }
X    }
X
X/*
X * Erase the message line. This is a special routine because the message line
X * is not considered to be part of the virtual screen. It always works
X * immediately; the terminal buffer is flushed via a call to the flusher.
X */
Xmlerase()
X    {
X    int i;
X    
X    movecursor(term.t_nrow, 0);
X    if (discmd == FALSE)
X    	return;
X
X#if	COLOR
X     TTforg(7);
X     TTbacg(0);
X#endif
X    if (eolexist == TRUE)
X	    TTeeol();
X    else {
X        for (i = 0; i < term.t_ncol - 1; i++)
X            TTputc(' ');
X        movecursor(term.t_nrow, 1);	/* force the move! */
X        movecursor(term.t_nrow, 0);
X    }
X    TTflush();
X    mpresf = FALSE;
X    }
X
X/*
X * Write a message into the message line. Keep track of the physical cursor
X * position. A small class of printf like format items is handled. Assumes the
X * stack grows down; this assumption is made by the "++" in the argument scan
X * loop. Set the "message line" flag TRUE.
X */
X
Xmlwrite(fmt, arg)
X
Xchar *fmt;	/* format string for output */
Xchar *arg;	/* pointer to first argument to print */
X
X{
X	register int c;		/* current char in format string */
X	register char *ap;	/* ptr to current data field */
X
X	/* if we are not currently echoing on the command line, abort this */
X	if (discmd == FALSE) {
X		movecursor(term.t_nrow, 0);
X		return;
X	}
X
X#if	COLOR
X	/* set up the proper colors for the command line */
X	TTforg(7);
X	TTbacg(0);
X#endif
X
X	/* if we can not erase to end-of-line, do it manually */
X	if (eolexist == FALSE) {
X		mlerase();
X		TTflush();
X	}
X
X	movecursor(term.t_nrow, 0);
X	ap = (char *) &arg;
X	while ((c = *fmt++) != 0) {
X		if (c != '%') {
X			TTputc(c);
X			++ttcol;
X		} else {
X			c = *fmt++;
X			switch (c) {
X				case 'd':
X					mlputi(*(int *)ap, 10);
X					ap += sizeof(int);
X					break;
X
X				case 'o':
X					mlputi(*(int *)ap,  8);
X					ap += sizeof(int);
X					break;
X
X				case 'x':
X					mlputi(*(int *)ap, 16);
X					ap += sizeof(int);
X					break;
X
X				case 'D':
X					mlputli(*(long *)ap, 10);
X					ap += sizeof(long);
X					break;
X
X				case 's':
X					mlputs(*(char **)ap);
X					ap += sizeof(char *);
X					break;
X
X				case 'f':
X					mlputf(*(int *)ap);
X					ap += sizeof(int);
X					break;
X
X				default:
X					TTputc(c);
X					++ttcol;
X			}
X		}
X	}
X
X	/* if we can, erase to the end of screen */
X	if (eolexist == TRUE)
X		TTeeol();
X	TTflush();
X	mpresf = TRUE;
X}
X
X/*
X * Write out a string. Update the physical cursor position. This assumes that
X * the characters in the string all have width "1"; if this is not the case
X * things will get screwed up a little.
X */
Xmlputs(s)
X    char *s;
X    {
X    register int c;
X
X    while ((c = *s++) != 0)
X        {
X        TTputc(c);
X        ++ttcol;
X        }
X    }
X
X/*
X * Write out an integer, in the specified radix. Update the physical cursor
X * position.
X */
Xmlputi(i, r)
X    {
X    register int q;
X    static char hexdigits[] = "0123456789ABCDEF";
X
X    if (i < 0)
X        {
X        i = -i;
X        TTputc('-');
X        }
X
X    q = i/r;
X
X    if (q != 0)
X        mlputi(q, r);
X
X    TTputc(hexdigits[i%r]);
X    ++ttcol;
X    }
X
X/*
X * do the same except as a long integer.
X */
Xmlputli(l, r)
X    long l;
X    {
X    register long q;
X
X    if (l < 0)
X        {
X        l = -l;
X        TTputc('-');
X        }
X
X    q = l/r;
X
X    if (q != 0)
X        mlputli(q, r);
X
X    TTputc((int)(l%r)+'0');
X    ++ttcol;
X    }
X
X/*
X *	write out a scaled integer with two decimal places
X */
X
Xmlputf(s)
X
Xint s;	/* scaled integer to output */
X
X{
X	int i;	/* integer portion of number */
X	int f;	/* fractional portion of number */
X
X	/* break it up */
X	i = s / 100;
X	f = s % 100;
X
X	/* send out the integer portion */
X	mlputi(i, 10);
X	TTputc('.');
X	TTputc((f / 10) + '0');
X	TTputc((f % 10) + '0');
X	ttcol += 3;
X}	
X
X#if RAINBOW
X
Xputline(row, col, buf)
X    int row, col;
X    char buf[];
X    {
X    int n;
X
X    n = strlen(buf);
X    if (col + n - 1 > term.t_ncol)
X        n = term.t_ncol - col + 1;
X    Put_Data(row, col, n, buf);
X    }
X#endif
X
E!O!F
newsize=`wc -c < display.c`
if [ $newsize -ne 23827 ]
then echo "File display.c was $newsize bytes, 23827 expected"
fi
echo 'x - dolock.c (text)'
sed << 'E!O!F' 's/^X//' > dolock.c
X#if	0
X/*	dolock:	MDBS specific Unix 4.2BSD file locking mechinism
X		this is not to be distributed generally		*/
X
X#include	<mdbs.h>
X#include	<mdbsio.h>
X#include	<sys/types.h>
X#include	<sys/stat.h>
X
X/* included by port.h: mdbs.h, mdbsio.h, sys/types.h, sys/stat.h */
X
X
X#ifndef bsdunix
Xchar *dolock(){return(NULL);}
Xchar *undolock(){return(NULL);}
X#else
X
X#include <pwd.h>
X#include <errno.h>
X
Xextern int errno;
X
X#define LOCKDIR ".xlk"
X
X#define LOCKMSG "LOCK ERROR -- "
X#define LOCKMSZ sizeof(LOCKMSG)
X#define LOCKERR(s) { strcat(lmsg,s); oldumask = umask(oldumask); return(lmsg); }
X
X/**********************
X *
X * dolock -- lock the file fname
X *
X * if successful, returns NULL 
X * if file locked, returns username of person locking the file
X * if other error, returns "LOCK ERROR: explanation"
X *
X * Jon Reid, 2/19/86
X *
X *********************/
X
XBOOL parent = FALSE;
XBOOL tellall = FALSE;
X
Xchar *gtname(filespec)		/* get name component of unix-style filespec */
Xchar *filespec;
X{
X	char *rname, *rindex();
X
X	rname = rindex(filespec,'/');
X
X	if (rname != NULL)
X		return(rname);
X	else
X		return(filespec);
X}
X
Xchar *getpath(filespec)
Xchar *filespec;
X{
X	char rbuff[LFILEN];
X	char *rname, *rindex();
X
X	strcpy(rbuff,filespec);
X	rname = rindex(rbuff,'/');
X
X	if (rname == NULL)
X		return(NULL);
X	else
X	{
X		*(++rname) = '\0';
X		return(rbuff);
X	}
X
X}
X
Xchar *dolock(fname)
X	char *fname;
X{
X	static char lockname[LFILEN] = LOCKDIR;
X	static char username[12];
X	static char lmsg[40] = LOCKMSG;
X	char *pathfmt;
X	struct stat statblk;
X	struct passwd *pblk;
X	long pid, getpid();
X	FILE *lf, *fopen();
X	int oldumask;
X
X	oldumask = umask(0);	/* maximum access allowed to lock files */
X
X
X	  if (*fname != '/')
X	   pathfmt = "./%s%s";
X	  else
X	   pathfmt = "%s/%s";
X	  sprintf(lockname,pathfmt,getpath(fname), LOCKDIR);
X
X	  if (tellall) printf("checking for existence of %s\n",lockname);
X
X	  if (stat(lockname,&statblk))
X	  {
X		 if (tellall) printf("making directory %s\n",lockname);
X		 mkdir(lockname,0777); 
X	  }
X
X	  sprintf(lockname,"%s/%s",lockname,gtname(fname));
X
X	  if (tellall) printf("checking for existence of %s\n",lockname);
X
X	  if (stat(lockname,&statblk))
X	  {
Xmakelock:  	if (tellall) printf("creating %s\n",lockname);
X
X		if ((lf = fopen(lockname,FOP_TW)) == NULL)
X		  LOCKERR("could not create lock file")
X	        else
X	  	{
X			if (parent)
X			 pid = getppid();	/* parent pid */
X			else
X			 pid = getpid();	/* current pid */
X
X			 if (tellall)
X			  printf("pid is %ld\n",pid); 
X
X			 fprintf(lf,"%ld",pid); /* write pid to lock file */
X
X			fclose(lf);
X			oldumask = umask(oldumask);
X			return(NULL);
X		}
X	  }
X	  else
X	  {
X		if (tellall) printf("reading lock file %s\n",lockname);
X		if ((lf = fopen(lockname,FOP_TR)) == NULL)
X		  LOCKERR("could not read lock file")
X	        else
X	  	{
X			fscanf(lf,"%ld",&pid); /* contains current pid */
X			fclose(lf);
X			if (tellall)
X			 printf("pid in %s is %ld\n",lockname, pid);
X			if (tellall)
X			 printf("signaling process %ld\n", pid);
X			if (kill(pid,0))
X				switch (errno)
X				{
X				  case ESRCH:	/* process not found */
X						goto makelock;
X						break;
X				  case EPERM:	/* process exists, not yours */
X			 			if (tellall) 
X						 puts("process exists");
X						break;
X				  default:
X					LOCKERR("kill was bad")
X					break;
X				}
X			else
X			 if (tellall) puts("kill was good; process exists");
X		}
X		if ((pblk = getpwuid(statblk.st_uid)) == NULL)
X		  sprintf(username,"uid %d",atoi(statblk.st_uid));
X		else
X		  strcpy(username,pblk->pw_name);
X
X		oldumask = umask(oldumask);
X		return(username);
X	  }
X}
X
X/**********************
X *
X * undolock -- unlock the file fname
X *
X * if successful, returns NULL 
X * if other error, returns "LOCK ERROR: explanation"
X *
X * Jon Reid, 2/19/86
X *
X *********************/
X
Xchar *undolock(fname)
X	char *fname;
X{
X	static char lockname[LFILEN] = LOCKDIR;
X	static char lmsg[40] = LOCKMSG;
X	char *pathfmt;
X
X	  if (*fname != '/')
X	   pathfmt = "./%s%s";
X	  else
X	   pathfmt = "%s/%s";
X	  sprintf(lockname,pathfmt,getpath(fname), LOCKDIR);
X
X	  sprintf(lockname,"%s/%s",lockname,gtname(fname));
X
X	  if (tellall) printf("attempting to unlink %s\n",lockname);
X
X	  if (unlink(lockname))
X	  { 
X		strcat(lmsg,"could not remove lock file"); 
X		return(lmsg); 
X	  }
X	  else
X	  	  return(NULL);
X}
X
X#endif bsdunix
X
X/******************
X * end dolock module
X *******************/
X
X#else
Xdolhello()
X{
X}
X#endif
X
E!O!F
newsize=`wc -c < dolock.c`
if [ $newsize -ne 4348 ]
then echo "File dolock.c was $newsize bytes, 4348 expected"
fi
echo 'x - ebind.h (text)'
sed << 'E!O!F' 's/^X//' > ebind.h
X/*	EBIND:		Initial default key to function bindings for
X			MicroEMACS 3.7
X*/
X
X/*
X * Command table.
X * This table  is *roughly* in ASCII order, left to right across the
X * characters of the command. This explains the funny location of the
X * control-X commands.
X */
XKEYTAB  keytab[NBINDS] = {
X	{CTRL|'A',		gotobol},
X	{CTRL|'B',		backchar},
X	{CTRL|'C',		insspace},
X	{CTRL|'D',		forwdel},
X	{CTRL|'E',		gotoeol},
X	{CTRL|'F',		forwchar},
X	{CTRL|'G',		ctrlg},
X	{CTRL|'H',		backdel},
X	{CTRL|'I',		tab},
X	{CTRL|'J',		indent},
X	{CTRL|'K',		killtext},
X	{CTRL|'L',		refresh},
X	{CTRL|'M',		newline},
X	{CTRL|'N',		forwline},
X	{CTRL|'O',		openline},
X	{CTRL|'P',		backline},
X	{CTRL|'Q',		quote},
X	{CTRL|'R',		backsearch},
X	{CTRL|'S',		forwsearch},
X	{CTRL|'T',		twiddle},
X	{CTRL|'U',		unarg},
X	{CTRL|'V',		forwpage},
X	{CTRL|'W',		killregion},
X	{CTRL|'X',		cex},
X	{CTRL|'Y',		yank},
X	{CTRL|'Z',		backpage},
X	{CTRL|']',		meta},
X	{CTLX|CTRL|'B',		listbuffers},
X	{CTLX|CTRL|'C',		quit},          /* Hard quit.           */
X#if	AEDIT
X	{CTLX|CTRL|'D',		detab},
X	{CTLX|CTRL|'E',		entab},
X#endif
X	{CTLX|CTRL|'F',		filefind},
X	{CTLX|CTRL|'I',		insfile},
X	{CTLX|CTRL|'L',		lowerregion},
X	{CTLX|CTRL|'M',		delmode},
X	{CTLX|CTRL|'N',		mvdnwind},
X	{CTLX|CTRL|'O',		deblank},
X	{CTLX|CTRL|'P',		mvupwind},
X	{CTLX|CTRL|'R',		fileread},
X	{CTLX|CTRL|'S',		filesave},
X#if	AEDIT
X	{CTLX|CTRL|'T',		trim},
X#endif
X	{CTLX|CTRL|'U',		upperregion},
X	{CTLX|CTRL|'V',		viewfile},
X	{CTLX|CTRL|'W',		filewrite},
X	{CTLX|CTRL|'X',		swapmark},
X	{CTLX|CTRL|'Z',		shrinkwind},
X	{CTLX|'?',		deskey},
X	{CTLX|'!',		spawn},
X	{CTLX|'@',		pipecmd},
X	{CTLX|'#',		filter},
X	{CTLX|'=',		showcpos},
X	{CTLX|'(',		ctlxlp},
X	{CTLX|')',		ctlxrp},
X	{CTLX|'^',		enlargewind},
X	{CTLX|'0',		delwind},
X	{CTLX|'1',		onlywind},
X	{CTLX|'2',		splitwind},
X	{CTLX|'A',		setvar},
X	{CTLX|'B',		usebuffer},
X	{CTLX|'C',		spawncli},
X#if	BSD
X	{CTLX|'D',		bktoshell},
X#endif
X	{CTLX|'E',		ctlxe},
X	{CTLX|'F',		setfillcol},
X	{CTLX|'K',		killbuffer},
X	{CTLX|'M',		setmode},
X	{CTLX|'N',		filename},
X	{CTLX|'O',		nextwind},
X	{CTLX|'P',		prevwind},
X#if	ISRCH
X	{CTLX|'R',		risearch},
X	{CTLX|'S',		fisearch},
X#endif
X	{CTLX|'W',		resize},
X	{CTLX|'X',		nextbuffer},
X	{CTLX|'Z',		enlargewind},
X#if	WORDPRO
X	{META|CTRL|'C',		wordcount},
X#endif
X#if	PROC
X	{META|CTRL|'E',		execproc},
X#endif
X#if	CFENCE
X	{META|CTRL|'F',		getfence},
X#endif
X	{META|CTRL|'H',		delbword},
X	{META|CTRL|'K',		unbindkey},
X	{META|CTRL|'L',		reposition},
X	{META|CTRL|'M',		delgmode},
X	{META|CTRL|'N',		namebuffer},
X	{META|CTRL|'R',		qreplace},
X	{META|CTRL|'S',		newsize},
X	{META|CTRL|'T',		newwidth},
X	{META|CTRL|'V',		scrnextdw},
X#if	WORDPRO
X	{META|CTRL|'W',		killpara},
X#endif
X	{META|CTRL|'Z',		scrnextup},
X	{META|' ',		setmark},
X	{META|'?',		help},
X	{META|'!',		reposition},
X	{META|'.',		setmark},
X	{META|'>',		gotoeob},
X	{META|'<',		gotobob},
X	{META|'~',		unmark},
X#if	APROP
X	{META|'A',		apro},
X#endif
X	{META|'B',		backword},
X	{META|'C',		capword},
X	{META|'D',		delfword},
X#if	CRYPT
X	{META|'E',		setkey},
X#endif
X	{META|'F',		forwword},
X	{META|'G',		gotoline},
X	{META|'K',		bindtokey},
X	{META|'L',		lowerword},
X	{META|'M',		setgmode},
X#if	WORDPRO
X	{META|'N',		gotoeop},
X	{META|'P',		gotobop},
X	{META|'Q',		fillpara},
X#endif
X	{META|'R',		sreplace},
X#if	BSD
X	{META|'S',		bktoshell},
X#endif
X	{META|'U',		upperword},
X	{META|'V',		backpage},
X	{META|'W',		copyregion},
X	{META|'X',		namedcmd},
X	{META|'Z',		quickexit},
X	{META|0x7F,              delbword},
X
X#if	MSDOS & (HP150 == 0) & (WANGPC == 0) & (HP110 == 0)
X	{SPEC|CTRL|'_',		forwhunt},
X	{SPEC|CTRL|'S',		backhunt},
X	{SPEC|71,		gotobob},
X	{SPEC|72,		backline},
X	{SPEC|73,		backpage},
X	{SPEC|75,		backchar},
X	{SPEC|77,		forwchar},
X	{SPEC|79,		gotoeob},
X	{SPEC|80,		forwline},
X	{SPEC|81,		forwpage},
X	{SPEC|82,		insspace},
X	{SPEC|83,		forwdel},
X	{SPEC|115,		backword},
X	{SPEC|116,		forwword},
X#if	WORDPRO
X	{SPEC|132,		gotobop},
X	{SPEC|118,		gotoeop},
X#endif
X	{SPEC|84,		cbuf1},
X	{SPEC|85,		cbuf2},
X	{SPEC|86,		cbuf3},
X	{SPEC|87,		cbuf4},
X	{SPEC|88,		cbuf5},
X	{SPEC|89,		cbuf6},
X	{SPEC|90,		cbuf7},
X	{SPEC|91,		cbuf8},
X	{SPEC|92,		cbuf9},
X	{SPEC|93,		cbuf10},
X#endif
X
X#if	HP150
X	{SPEC|32,		backline},
X	{SPEC|33,		forwline},
X	{SPEC|35,		backchar},
X	{SPEC|34,		forwchar},
X	{SPEC|44,		gotobob},
X	{SPEC|46,		forwpage},
X	{SPEC|47,		backpage},
X	{SPEC|82,		nextwind},
X	{SPEC|68,		openline},
X	{SPEC|69,		killtext},
X	{SPEC|65,		forwdel},
X	{SPEC|64,		ctlxe},
X	{SPEC|67,		refresh},
X	{SPEC|66,		reposition},
X	{SPEC|83,		help},
X	{SPEC|81,		deskey},
X#endif
X
X#if	HP110
X	{SPEC|0x4b,		backchar},
X	{SPEC|0x4d,		forwchar},
X	{SPEC|0x48,		backline},
X	{SPEC|0x50,		forwline},
X	{SPEC|0x43,		help},
X	{SPEC|0x73,		backword},
X	{SPEC|0x74,		forwword},
X	{SPEC|0x49,		backpage},
X	{SPEC|0x51,		forwpage},
X	{SPEC|84,		cbuf1},
X	{SPEC|85,		cbuf2},
X	{SPEC|86,		cbuf3},
X	{SPEC|87,		cbuf4},
X	{SPEC|88,		cbuf5},
X	{SPEC|89,		cbuf6},
X	{SPEC|90,		cbuf7},
X	{SPEC|91,		cbuf8},
X#endif
X
X#if	AMIGA
X	{SPEC|'?',		help},
X	{SPEC|'A',		backline},
X	{SPEC|'B',		forwline},
X	{SPEC|'C',		forwchar},
X	{SPEC|'D',		backchar},
X	{SPEC|'T',		backpage},
X	{SPEC|'S',		forwpage},
X	{SPEC|'a',		backword},
X	{SPEC|'`',		forwword},
X	{SPEC|'P',		cbuf1},
X	{SPEC|'Q',		cbuf2},
X	{SPEC|'R',		cbuf3},
X	{SPEC|'S',		cbuf4},
X	{SPEC|'T',		cbuf5},
X	{SPEC|'U',		cbuf6},
X	{SPEC|'V',		cbuf7},
X	{SPEC|'W',		cbuf8},
X	{SPEC|'X',		cbuf9},
X	{SPEC|'Y',		cbuf10},
X	{127,			forwdel},
X#endif
X
X#if	ST520
X	{SPEC|'b',		help},
X	{SPEC|'H',		backline},
X	{SPEC|'P',		forwline},
X	{SPEC|'M',		forwchar},
X	{SPEC|'K',		backchar},
X	{SPEC|'t',		setmark},
X	{SPEC|'a',		yank},
X	{SPEC|'R',		insspace},
X	{SPEC|'G',		gotobob},
X	{127,			forwdel},
X	{SPEC|84,		cbuf1},
X	{SPEC|85,		cbuf2},
X	{SPEC|86,		cbuf3},
X	{SPEC|87,		cbuf4},
X	{SPEC|88,		cbuf5},
X	{SPEC|89,		cbuf6},
X	{SPEC|90,		cbuf7},
X	{SPEC|91,		cbuf8},
X	{SPEC|92,		cbuf9},
X	{SPEC|93,		cbuf10},
X#endif
X
X#if  WANGPC
X	SPEC|0xE0,              quit,           /* Cancel */
X	SPEC|0xE1,              help,           /* Help */
X	SPEC|0xF1,              help,           /* ^Help */
X	SPEC|0xE3,              ctrlg,          /* Print */
X	SPEC|0xF3,              ctrlg,          /* ^Print */
X	SPEC|0xC0,              backline,       /* North */
X	SPEC|0xD0,              gotobob,        /* ^North */
X	SPEC|0xC1,              forwchar,       /* East */
X	SPEC|0xD1,              gotoeol,        /* ^East */
X	SPEC|0xC2,              forwline,       /* South */
X	SPEC|0xD2,              gotobop,        /* ^South */
X	SPEC|0xC3,              backchar,       /* West */
X	SPEC|0xD3,              gotobol,        /* ^West */
X	SPEC|0xC4,              ctrlg,          /* Home */
X	SPEC|0xD4,              gotobob,        /* ^Home */
X	SPEC|0xC5,              filesave,       /* Execute */
X	SPEC|0xD5,              ctrlg,          /* ^Execute */
X	SPEC|0xC6,              insfile,        /* Insert */
X	SPEC|0xD6,              ctrlg,          /* ^Insert */
X	SPEC|0xC7,              forwdel,        /* Delete */
X	SPEC|0xD7,              killregion,     /* ^Delete */
X	SPEC|0xC8,              backpage,       /* Previous */
X	SPEC|0xD8,              prevwind,       /* ^Previous */
X	SPEC|0xC9,              forwpage,       /* Next */
X	SPEC|0xD9,              nextwind,       /* ^Next */
X	SPEC|0xCB,              ctrlg,          /* Erase */
X	SPEC|0xDB,              ctrlg,          /* ^Erase */
X	SPEC|0xDC,              ctrlg,          /* ^Tab */
X	SPEC|0xCD,              ctrlg,          /* BackTab */
X	SPEC|0xDD,              ctrlg,          /* ^BackTab */
X	SPEC|0x80,              ctrlg,          /* Indent */
X	SPEC|0x90,              ctrlg,          /* ^Indent */
X	SPEC|0x81,              ctrlg,          /* Page */
X	SPEC|0x91,              ctrlg,          /* ^Page */
X	SPEC|0x82,              ctrlg,          /* Center */
X	SPEC|0x92,              ctrlg,          /* ^Center */
X	SPEC|0x83,              ctrlg,          /* DecTab */
X	SPEC|0x93,              ctrlg,          /* ^DecTab */
X	SPEC|0x84,              ctrlg,          /* Format */
X	SPEC|0x94,              ctrlg,          /* ^Format */
X	SPEC|0x85,              ctrlg,          /* Merge */
X	SPEC|0x95,              ctrlg,          /* ^Merge */
X	SPEC|0x86,              setmark,        /* Note */
X	SPEC|0x96,              ctrlg,          /* ^Note */
X	SPEC|0x87,              ctrlg,          /* Stop */
X	SPEC|0x97,              ctrlg,          /* ^Stop */
X	SPEC|0x88,              forwsearch,     /* Srch */
X	SPEC|0x98,              backsearch,     /* ^Srch */
X	SPEC|0x89,              sreplace,       /* Replac */
X	SPEC|0x99,              qreplace,       /* ^Replac */
X	SPEC|0x8A,              ctrlg,          /* Copy */
X	SPEC|0x9A,              ctrlg,          /* ^Copy */
X	SPEC|0x8B,              ctrlg,          /* Move */
X	SPEC|0x9B,              ctrlg,          /* ^Move */
X	SPEC|0x8C,              namedcmd,       /* Command */
X	SPEC|0x9C,              spawn,          /* ^Command */
X	SPEC|0x8D,              ctrlg,          /* ^ */
X	SPEC|0x9D,              ctrlg,          /* ^^ */
X	SPEC|0x8E,              ctrlg,          /* Blank */
X	SPEC|0x9E,              ctrlg,          /* ^Blank */
X	SPEC|0x8F,              gotoline,       /* GoTo */
X	SPEC|0x9F,              usebuffer,      /* ^GoTo */
X#endif
X 
X	{0x7F,			backdel},
X
X	/* special internal bindings */
X	SPEC|META|'W',		wrapword,	/* called on word wrap */
X
X	{0,			NULL}
X};
X
X#if RAINBOW
X
X#include "rainbow.h"
X
X/*
X * Mapping table from the LK201 function keys to the internal EMACS character.
X */
X
Xshort lk_map[][2] = {
X	Up_Key,                         CTRL+'P',
X	Down_Key,                       CTRL+'N',
X	Left_Key,                       CTRL+'B',
X	Right_Key,                      CTRL+'F',
X	Shift+Left_Key,                 META+'B',
X	Shift+Right_Key,                META+'F',
X	Control+Left_Key,               CTRL+'A',
X	Control+Right_Key,              CTRL+'E',
X	Prev_Scr_Key,                   META+'V',
X	Next_Scr_Key,                   CTRL+'V',
X	Shift+Up_Key,                   META+'<',
X	Shift+Down_Key,                 META+'>',
X	Cancel_Key,                     CTRL+'G',
X	Find_Key,                       CTRL+'S',
X	Shift+Find_Key,                 CTRL+'R',
X	Insert_Key,                     CTRL+'Y',
X	Options_Key,                    CTRL+'D',
X	Shift+Options_Key,              META+'D',
X	Remove_Key,                     CTRL+'W',
X	Shift+Remove_Key,               META+'W',
X	Select_Key,                     CTRL+'@',
X	Shift+Select_Key,               CTLX+CTRL+'X',
X	Interrupt_Key,                  CTRL+'U',
X	Keypad_PF2,                     META+'L',
X	Keypad_PF3,                     META+'C',
X	Keypad_PF4,                     META+'U',
X	Shift+Keypad_PF2,               CTLX+CTRL+'L',
X	Shift+Keypad_PF4,               CTLX+CTRL+'U',
X	Keypad_1,                       CTLX+'1',
X	Keypad_2,                       CTLX+'2',
X	Do_Key,                         CTLX+'E',
X	Keypad_4,                       CTLX+CTRL+'B',
X	Keypad_5,                       CTLX+'B',
X	Keypad_6,                       CTLX+'K',
X	Resume_Key,                     META+'!',
X	Control+Next_Scr_Key,           CTLX+'N',
X	Control+Prev_Scr_Key,           CTLX+'P',
X	Control+Up_Key,                 CTLX+CTRL+'P',
X	Control+Down_Key,               CTLX+CTRL+'N',
X	Help_Key,                       CTLX+'=',
X	Shift+Do_Key,                   CTLX+'(',
X	Control+Do_Key,                 CTLX+')',
X	Keypad_0,                       CTLX+'Z',
X	Shift+Keypad_0,                 CTLX+CTRL+'Z',
X	Main_Scr_Key,                   CTRL+'C',
X	Keypad_Enter,                   CTLX+'!',
X	Exit_Key,                       CTLX+CTRL+'C',
X	Shift+Exit_Key,                 CTRL+'Z'
X};
X
X#define lk_map_size     (sizeof(lk_map)/2)
X#endif
X
E!O!F
newsize=`wc -c < ebind.h`
if [ $newsize -ne 11535 ]
then echo "File ebind.h was $newsize bytes, 11535 expected"
fi
echo 'x - edef.h (text)'
sed << 'E!O!F' 's/^X//' > edef.h
X/*	EDEF:		Global variable definitions for
X			MicroEMACS 3.2
X
X			written by Dave G. Conroy
X			modified by Steve Wilhite, George Jones
X			greatly modified by Daniel Lawrence
X*/
X
X/* some global fuction declarations */
X
Xchar *malloc();
Xchar *strcpy();
Xchar *strcat();
Xchar *strncpy();
Xchar *itoa();
Xchar *getval();
Xchar *gtenv();
Xchar *gtusr();
Xchar *gtfun();
Xchar *token();
Xchar *ltos();
Xchar *flook();
Xchar *mkupper();
Xchar *mklower();
Xunsigned int getckey();
X
X#ifdef	maindef
X
X/* for MAIN.C */
X
X/* initialized global definitions */
X
Xint     fillcol = 72;                   /* Current fill column          */
Xshort   kbdm[NKBDM];			/* Macro                        */
Xchar	*execstr = NULL;		/* pointer to string to execute	*/
Xchar	golabel[NPAT] = "";		/* current line to go to	*/
Xint	execlevel = 0;			/* execution IF level		*/
Xint	eolexist = TRUE;		/* does clear to EOL exist	*/
Xint	revexist = FALSE;		/* does reverse video exist?	*/
Xint	flickcode = FALSE;		/* do flicker supression?	*/
Xchar	*modename[] = {			/* name of modes		*/
X	"WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER",
X	"MAGIC", "CRYPT", "ASAVE"};
Xchar	modecode[] = "WCSEVOMYA";	/* letters to represent modes	*/
Xint	gmode = 0;			/* global editor mode		*/
Xint	gfcolor = 7;			/* global forgrnd color (white)	*/
Xint	gbcolor	= 0;			/* global backgrnd color (black)*/
Xint	gasave = 256;			/* global ASAVE size		*/
Xint	gacount = 256;			/* count until next ASAVE	*/
Xint     sgarbf  = TRUE;                 /* TRUE if screen is garbage	*/
Xint     mpresf  = FALSE;                /* TRUE if message in last line */
Xint	clexec	= FALSE;		/* command line execution flag	*/
Xint	mstore	= FALSE;		/* storing text to macro flag	*/
Xint	discmd	= TRUE;			/* display command flag		*/
Xint	disinp	= TRUE;			/* display input characters	*/
Xstruct	BUFFER *bstore = NULL;		/* buffer to store macro text to*/
Xint     vtrow   = 0;                    /* Row location of SW cursor */
Xint     vtcol   = 0;                    /* Column location of SW cursor */
Xint     ttrow   = HUGE;                 /* Row location of HW cursor */
Xint     ttcol   = HUGE;                 /* Column location of HW cursor */
Xint	lbound	= 0;			/* leftmost column of current line
X					   being displayed */
Xint	taboff	= 0;			/* tab offset for display	*/
Xint	metac = CTRL | '[';		/* current meta character */
Xint	ctlxc = CTRL | 'X';		/* current control X prefix char */
Xint	reptc = CTRL | 'U';		/* current universal repeat char */
Xint	abortc = CTRL | 'G';		/* current abort command char	*/
X
Xint	quotec = 0x11;			/* quote char during mlreply() */
Xchar	*cname[] = {			/* names of colors		*/
X	"BLACK", "RED", "GREEN", "YELLOW", "BLUE",
X	"MAGENTA", "CYAN", "WHITE"};
XKILL *kbufp  = NULL;		/* current kill buffer chunk pointer	*/
XKILL *kbufh  = NULL;		/* kill buffer header pointer		*/
Xint kused = KBLOCK;		/* # of bytes used in kill buffer	*/
XWINDOW *swindow = NULL;		/* saved window pointer			*/
Xint cryptflag = FALSE;		/* currently encrypting?		*/
Xshort	*kbdptr;		/* current position in keyboard buf */
Xshort	*kbdend = &kbdm[0];	/* ptr to end of the keyboard */
Xint	kbdmode = STOP;		/* current keyboard macro mode	*/
Xint	kbdrep = 0;		/* number of repetitions	*/
Xint	restflag = FALSE;	/* restricted use?		*/
Xint	lastkey = 0;		/* last keystoke		*/
Xint	seed = 0;		/* random number seed		*/
Xlong	envram = 0l;	/* # of bytes current in use by malloc */
Xint	macbug = FALSE;		/* macro debuging flag		*/
Xchar	errorm[] = "ERROR";	/* error literal		*/
Xchar	truem[] = "TRUE";	/* true literal			*/
Xchar	falsem[] = "FALSE";	/* false litereal		*/
Xint	cmdstatus = TRUE;	/* last command status		*/
Xchar	palstr[49] = "";	/* palette string		*/
X
X/* uninitialized global definitions */
X
Xint     currow;                 /* Cursor row                   */
Xint     curcol;                 /* Cursor column                */
Xint     thisflag;               /* Flags, this command          */
Xint     lastflag;               /* Flags, last command          */
Xint     curgoal;                /* Goal for C-P, C-N            */
XWINDOW  *curwp;                 /* Current window               */
XBUFFER  *curbp;                 /* Current buffer               */
XWINDOW  *wheadp;                /* Head of list of windows      */
XBUFFER  *bheadp;                /* Head of list of buffers      */
XBUFFER  *blistp;                /* Buffer for C-X C-B           */
X
XBUFFER  *bfind();               /* Lookup a buffer by name      */
XWINDOW  *wpopup();              /* Pop up window creation       */
XLINE    *lalloc();              /* Allocate a line              */
Xchar	sres[NBUFN];		/* current screen resolution	*/
X
Xchar    pat[NPAT];                      /* Search pattern		*/
Xchar	tap[NPAT];			/* Reversed pattern array.	*/
Xchar	rpat[NPAT];			/* replacement pattern		*/
X
X/* The variable matchlen holds the length of the matched
X * string - used by the replace functions.
X * The variable patmatch holds the string that satisfies
X * the search command.
X * The variables matchline and matchoff hold the line and
X * offset position of the start of match.
X */
Xunsigned int	matchlen = 0;
Xunsigned int	mlenold  = 0;
Xchar		*patmatch = NULL;
XLINE		*matchline = NULL;
Xint		matchoff = 0;
X
X#if	MAGIC
X/*
X * The variable magical determines if there are actual
X * metacharacters in the string - if not, then we don't
X * have to use the slower MAGIC mode search functions.
X */
Xshort int	magical = FALSE;
XMC		mcpat[NPAT];		/* the magic pattern		*/
XMC		tapcm[NPAT];		/* the reversed magic pattern	*/
X
X#endif
X
X#else
X
X/* for all the other .C files */
X
X/* initialized global external declarations */
X
Xextern  int     fillcol;                /* Fill column                  */
Xextern  short   kbdm[];                 /* Holds kayboard macro data    */
Xextern  char    pat[];                  /* Search pattern               */
Xextern	char	rpat[];			/* Replacement pattern		*/
Xextern	char	*execstr;		/* pointer to string to execute	*/
Xextern	char	golabel[];		/* current line to go to	*/
Xextern	int	execlevel;		/* execution IF level		*/
Xextern	int	eolexist;		/* does clear to EOL exist?	*/
Xextern	int	revexist;		/* does reverse video exist?	*/
Xextern	int	flickcode;		/* do flicker supression?	*/
Xextern	char *modename[];		/* text names of modes		*/
Xextern	char	modecode[];		/* letters to represent modes	*/
Xextern	KEYTAB keytab[];		/* key bind to functions table	*/
Xextern	NBIND names[];			/* name to function table	*/
Xextern	int	gmode;			/* global editor mode		*/
Xextern	int	gfcolor;		/* global forgrnd color (white)	*/
Xextern	int	gbcolor;		/* global backgrnd color (black)*/
Xextern	int	gasave;			/* global ASAVE size		*/
Xextern	int	gacount;		/* count until next ASAVE	*/
Xextern  int     sgarbf;                 /* State of screen unknown      */
Xextern  int     mpresf;                 /* Stuff in message line        */
Xextern	int	clexec;			/* command line execution flag	*/
Xextern	int	mstore;			/* storing text to macro flag	*/
Xextern	int	discmd;			/* display command flag		*/
Xextern	int	disinp;			/* display input characters	*/
Xextern	struct	BUFFER *bstore;		/* buffer to store macro text to*/
Xextern	int     vtrow;                  /* Row location of SW cursor */
Xextern	int     vtcol;                  /* Column location of SW cursor */
Xextern	int     ttrow;                  /* Row location of HW cursor */
Xextern	int     ttcol;                  /* Column location of HW cursor */
Xextern	int	lbound;			/* leftmost column of current line
X					   being displayed */
Xextern	int	taboff;			/* tab offset for display	*/
Xextern	int	metac;			/* current meta character */
Xextern	int	ctlxc;			/* current control X prefix char */
Xextern	int	reptc;			/* current universal repeat char */
Xextern	int	abortc;			/* current abort command char	*/
X
Xextern	int	quotec;			/* quote char during mlreply() */
Xextern	char	*cname[];		/* names of colors		*/
Xextern KILL *kbufp;			/* current kill buffer chunk pointer */
Xextern KILL *kbufh;			/* kill buffer header pointer	*/
Xextern int kused;			/* # of bytes used in KB        */
Xextern WINDOW *swindow;			/* saved window pointer		*/
Xextern int cryptflag;			/* currently encrypting?	*/
Xextern	short	*kbdptr;		/* current position in keyboard buf */
Xextern	short	*kbdend;		/* ptr to end of the keyboard */
Xextern	int kbdmode;			/* current keyboard macro mode	*/
Xextern	int kbdrep;			/* number of repetitions	*/
Xextern	int restflag;			/* restricted use?		*/
Xextern	int lastkey;			/* last keystoke		*/
Xextern	int seed;			/* random number seed		*/
Xextern	long envram;		/* # of bytes current in use by malloc */
Xextern	int	macbug;			/* macro debuging flag		*/
Xextern	char	errorm[];		/* error literal		*/
Xextern	char	truem[];		/* true literal			*/
Xextern	char	falsem[];		/* false litereal		*/
Xextern	int	cmdstatus;		/* last command status		*/
Xextern	char	palstr[];		/* palette string		*/
X
X/* uninitialized global external declarations */
X
Xextern  int     currow;                 /* Cursor row                   */
Xextern  int     curcol;                 /* Cursor column                */
Xextern  int     thisflag;               /* Flags, this command          */
Xextern  int     lastflag;               /* Flags, last command          */
Xextern  int     curgoal;                /* Goal for C-P, C-N            */
Xextern  WINDOW  *curwp;                 /* Current window               */
Xextern  BUFFER  *curbp;                 /* Current buffer               */
Xextern  WINDOW  *wheadp;                /* Head of list of windows      */
Xextern  BUFFER  *bheadp;                /* Head of list of buffers      */
Xextern  BUFFER  *blistp;                /* Buffer for C-X C-B           */
X
Xextern  BUFFER  *bfind();               /* Lookup a buffer by name      */
Xextern  WINDOW  *wpopup();              /* Pop up window creation       */
Xextern  LINE    *lalloc();              /* Allocate a line              */
Xextern	char	sres[NBUFN];		/* current screen resolution	*/
Xextern	char    pat[];                  /* Search pattern		*/
Xextern	char	tap[];			/* Reversed pattern array.	*/
Xextern	char	rpat[];			/* replacement pattern		*/
X
Xextern	unsigned int	matchlen;	/* length of found string	*/
Xextern	unsigned int	mlenold;	/* previous length of found str	*/
Xextern	char	*patmatch;		/* the found string		*/
Xextern	LINE	*matchline;		/* line pointer to found string	*/
Xextern	int	matchoff;		/* offset to the found string	*/
X
X#if	MAGIC
X
Xextern	short int	magical;	/* meta-characters in pattern?	*/
Xextern	MC		mcpat[];	/* the magic pattern		*/
Xextern	MC		tapcm[];	/* the reversed magic pattern	*/
X
X#endif
X
X#endif
X
X/* terminal table defined only in TERM.C */
X
X#ifndef	termdef
Xextern  TERM    term;                   /* Terminal information.        */
X#endif
X
X
E!O!F
newsize=`wc -c < edef.h`
if [ $newsize -ne 10634 ]
then echo "File edef.h was $newsize bytes, 10634 expected"
fi
	bill davidsen		(wedu@ge-crd.arpa)
  {chinet | philabs | sesimo}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me