[comp.windows.open-look] update to NeWS version of elvis

mh@roger.imsd.contel.com (Mike Hoegeman) (01/19/91)

Here is a shar file which is an update to my NeWS version of elvis
which i posted a week or so ago. This update allows pasting from the
xview shelf selection buffer. Just paste from the named buffer x 

e.g. this..
		"xp
or this..
		"xP

To get whatever is in the xview shelf selection. I found myself wanting
to paste stuff from xview into elvis. I found it was pretty easy to do
so I put it in. A note: If you are in dumb tty mode you'll get a "can't
paste from xview" on the message line. Cutting to xview is not present
as it is somewhat more involved but I'll get around to it eventually.

-mike hoegeman, mh@roger.imsd.contel.com

p.s. You may have to tweak around with the makefile a bit


----------------------------------CUT HERE------------------------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	cut.c
#	Makefile
#	config.h
#	ow.c
#	ow_xv.c
#	wconfig.h
#	CHANGE_NOTES
# This archive created: Fri Jan 18 13:26:42 1991
export PATH; PATH=/bin:$PATH
if test -f 'cut.c'
then
	echo shar: will not over-write existing file "'cut.c'"
else
cat << \SHAR_EOF > 'cut.c'
/* cut.c */

/* Author:
 *	Steve Kirkendall
 *	14407 SW Teal Blvd. #C
 *	Beaverton, OR 97005
 *	kirkenda@cs.pdx.edu
 */


/* This file contains function which manipulate the cut buffers. */

#include "config.h"
#include "vi.h"
#if TURBOC
#include <process.h>		/* needed for getpid */
#endif
#if TOS
#include <osbind.h>
#define	rename(a,b)	Frename(0,a,b)
#endif

# define NANNONS	9	/* number of annonymous buffers */

static struct cutbuf
{
	short	*phys;	/* pointer to an array of #s of BLKs containing text */
	int	nblks;	/* number of blocks in phys[] array */
	int	start;	/* offset into first block of start of cut */
	int	end;	/* offset into last block of end of cut */
	int	fd;	/* fd of tmp file, or -1 to use tmpfd */
	char	lnmode;	/* boolean: line-mode cut? (as opposed to char-mode) */
}
	named[27],	/* cut buffers "a through "z and ". */
	annon[NANNONS];	/* annonymous cut buffers */

static char	cbname;	/* name chosen for next cut/paste operation */


#ifndef NO_RECYCLE
/* This function builds a list of all blocks needed in the current tmp file
 * for the contents of cut buffers.
 * !!! WARNING: if you have more than ~450000 bytes of text in all of the
 * cut buffers, then this will fail disastrously, because buffer overflow
 * is *not* allowed for.
 */
int cutneeds(need)
	BLK		*need;	/* this is where we deposit the list */
{
	struct cutbuf	*cb;	/* used to count through cut buffers */
	int		i;	/* used to count through blocks of a cut buffer */
	int		n;	/* total number of blocks in list */

	n = 0;

	/* first the named buffers... */
	for (cb = named; cb < &named[27]; cb++)
	{
		if (cb->fd > 0)
			continue;

		for (i = cb->nblks; i-- > 0; )
		{
			need->n[n++] = cb->phys[i];
		}
	}

	/* then the anonymous buffers */
	for (cb = annon; cb < &annon[NANNONS]; cb++)
	{
		if (cb->fd > 0)
			continue;

		for (i = cb->nblks; i-- > 0; )
		{
			need->n[n++] = cb->phys[i];
		}
	}

	return n;
}
#endif

/* This function frees a cut buffer */
static void cutfree(buf)
	struct cutbuf	*buf;
{
	char	cutfname[50];
	int	i;

	/* return immediately if the buffer is already empty */
	if (buf->nblks <= 0)
	{
		return;
	}

	/* else free up stuff */
	buf->nblks = 0;
#ifdef DEBUG
	if (!buf->phys)
		msg("cutfree() tried to free an NULL buf->phys pointer.");
#endif
	free((char *)buf->phys);

	/* see if anybody else needs this tmp file */
	if (buf->fd >= 0)
	{
		for (i = 0; i < 27; i++)
		{
			if (named[i].nblks > 0 && named[i].fd == buf->fd)
			{
				break;
			}
		}
	}

	/* if nobody else needs it, then discard the tmp file */
	if (buf->fd >= 0 && i == 27)
	{
		close(buf->fd);
#if MSDOS || TOS
		strcpy(cutfname, o_directory);
		if ((i = strlen(cutfname)) && !strchr(":/\\", cutfname[i-1]))
			cutfname[i++]=SLASH;
		sprintf(cutfname+i, CUTNAME+3, getpid(), buf->fd);
#else
		sprintf(cutfname, CUTNAME, o_directory, getpid(), buf->fd);
#endif
		unlink(cutfname);
	}
}

/* This function is called when we are about to abort a tmp file.  If any
 * cut buffers still need the file, then a copy of the file should be
 * created for use by the cut buffers.
 *
 * To minimize the number of extra files lying around, only named cut buffers
 * are preserved in a file switch; the annonymous buffers just go away.
 */
void cutswitch(tmpname)
	char	*tmpname; /* name of the tmp file */
{
	char	cutfname[50];	/* used to build a new name for the tmp file */
	int	fd;		/* a new fd for the current tmp file */
	int	i;
#if MSDOS || TOS
	int	j;
#endif

	/* discard all annonymous cut buffers */
	for (i = 0; i < NANNONS; i++)
	{
		cutfree(&annon[i]);
	}

	/* find the first named buffer that uses this tmp file */
	for (i = 0; i < 27; i++)
	{
		if (named[i].nblks > 0 && named[i].fd < 0)
		{
			break;
		}
	}

	/* if none of them use this tmp file, then we're done */
	if (i == 27)
	{
		return;
	}

	/* else we'll need this file and an fd a little longer */
#if MSDOS || TOS
	strcpy(cutfname, o_directory);
	if ((j = strlen(cutfname)) && !strchr(":/\\", cutfname[j-1]))
		cutfname[j++]=SLASH;
	close(tmpfd);
	fd = open(tmpname, O_RDONLY|O_BINARY);
	close(fd);
	sprintf(cutfname+j, CUTNAME+3, getpid(), fd);
	rename(tmpname, cutfname);
	fd = open(cutfname, O_RDONLY|O_BINARY);
	tmpfd = -1; /* we'll try to close this in tmp.c, but who cares? */
#else
	fd = dup(tmpfd);
# if OSK
	sprintf(cutfname, CUTNAME, "", getpid(), fd);
	if (!link(tmpname, &cutfname[1])) /* skip slash */
		unlink(tmpname);
# else	
	sprintf(cutfname, CUTNAME, o_directory, getpid(), fd);
	link(tmpname, cutfname) || unlink(tmpname);
# endif
#endif

	/* have all cut buffers use the new fd instead */
	for (; i < 27; i++)
	{
		if (named[i].nblks > 0 && named[i].fd < 0)
		{
			named[i].fd = fd;
		}
	}
}

/* This function should be called just before termination of vi */
void cutend()
{
	int	i;

	/* free all named cut buffers, since they might be forcing an older
	 * tmp file to be retained.
	 */
	for (i = 0; i < 27; i++)
	{
		cutfree(&named[i]);
	}
}


/* This function is used to select the cut buffer to be used next */
void cutname(name)
	int	name;	/* a single character */
{
	cbname = name;
}




/* This function copies a selected segment of text to a cut buffer */
void cut(from, to)
	MARK	from;		/* start of text to cut */
	MARK	to;		/* end of text to cut */
{
	int		first;	/* logical number of first block in cut */
	int		last;	/* logical number of last block used in cut */
	long		line;	/* a line number */
	int		lnmode;	/* boolean: will this be a line-mode cut? */
	MARK		delthru;/* end of text temporarily inserted for apnd */
	REG struct cutbuf *cb;
	REG long	l;
	REG int		i;
	REG char	*scan;
	char		*blkc;

	/* detect whether this must be a line-mode cut or char-mode cut */
	if (markidx(from) == 0 && markidx(to) == 0)
		lnmode = TRUE;
	else
		lnmode = FALSE;

	/* by default, we don't "delthru" anything */
	delthru = MARK_UNSET;

	/* decide which cut buffer to use */
	if (Iswindowpastebuf(cbname))
	{
		msg("Cutting to the window system not supported");
		cbname = '\0';
		return;
	}
	else if (!cbname)
	{
		/* free up the last annonymous cut buffer */
		cutfree(&annon[NANNONS - 1]);

		/* shift the annonymous cut buffers */
		for (i = NANNONS - 1; i > 0; i--)
		{
			annon[i] = annon[i - 1];
		}

		/* use the first annonymous cut buffer */
		cb = annon;
		cb->nblks = 0;
	}
	else if (cbname >= 'a' && cbname <= 'z')
	{
		cb = &named[cbname - 'a'];
		cutfree(cb);
	}
#ifndef CRUNCH
	else if (cbname >= 'A' && cbname <= 'Z')
	{
		cb = &named[cbname - 'A'];
		if (cb->nblks > 0)
		{
			/* resolve linemode/charmode differences */
			if (!lnmode && cb->lnmode)
			{
				from &= ~(BLKSIZE - 1);
				if (markidx(to) != 0 || to == from)
				{
					to = to + BLKSIZE - markidx(to);
				}
				lnmode = TRUE;
			}

			/* insert the old cut-buffer before the new text */
			mark[28] = to;
			delthru = paste(from, FALSE, TRUE);
			if (delthru == MARK_UNSET)
			{
				return;
			}
			delthru++;
			to = mark[28];
		}
		cutfree(cb);
	}
#endif /* not CRUNCH */
	else if (cbname == '.')
	{
		cb = &named[26];
		cutfree(cb);
	}
	else
	{
		msg("Invalid cut buffer name: \"%c", cbname);
		cbname = '\0';
		return;
	}
	cbname = '\0';
	cb->fd = -1;

	/* detect whether we're doing a line mode cut */
	cb->lnmode = lnmode;

	/* ---------- */

	/* Reporting... */	
	if (markidx(from) == 0 && markidx(to) == 0)
	{
		rptlines = markline(to) - markline(from);
		rptlabel = "yanked";
	}

	/* ---------- */

	/* make sure each block has a physical disk address */
	blksync();

	/* find the first block in the cut */
	line = markline(from);
	for (first = 1; line > lnum[first]; first++)
	{
	}

	/* fetch text of the block containing that line */
	blkc = scan = blkget(first)->c;

	/* find the mark in the block */
	for (l = lnum[first - 1]; ++l < line; )
	{
		while (*scan++ != '\n')
		{
		}
	}
	scan += markidx(from);

	/* remember the offset of the start */
	cb->start = scan - blkc;

	/* ---------- */

	/* find the last block in the cut */
	line = markline(to);
	for (last = first; line > lnum[last]; last++)
	{
	}

	/* fetch text of the block containing that line */
	if (last != first)
	{
		blkc = scan = blkget(last)->c;
	}
	else
	{
		scan = blkc;
	}

	/* find the mark in the block */
	for (l = lnum[last - 1]; ++l < line; )
	{
		while (*scan++ != '\n')
		{
		}
	}
	if (markline(to) <= nlines)
	{
		scan += markidx(to);
	}

	/* remember the offset of the end */
	cb->end = scan - blkc;

	/* ------- */

	/* remember the physical block numbers of all included blocks */
	cb->nblks = last - first;
	if (cb->end > 0)
	{
		cb->nblks++;
	}
#ifdef lint
	cb->phys = (short *)0;
#else
	cb->phys = (short *)malloc((unsigned)(cb->nblks * sizeof(short)));
#endif
	for (i = 0; i < cb->nblks; i++)
	{
		cb->phys[i] = hdr.n[first++];
	}

#ifndef CRUNCH
	/* if we temporarily inserted text for appending, then delete that
	 * text now -- before the user sees it.
	 */
	if (delthru)
	{
		line = rptlines;
		delete(from, delthru);
		rptlines = line;
		rptlabel = "yanked";
	}
#endif /* not CRUNCH */
}


static void readcutblk(cb, blkno)
	struct cutbuf	*cb;
	int		blkno;
{
	int		fd;	/* either tmpfd or cb->fd */

	/* decide which fd to use */
	if (cb->fd >= 0)
	{
		fd = cb->fd;
	}
	else
	{
		fd = tmpfd;
	}

	/* get the block */
	lseek(fd, (long)cb->phys[blkno] * (long)BLKSIZE, 0);
	if (read(fd, tmpblk.c, (unsigned)BLKSIZE) != BLKSIZE)
	{
		msg("Error reading back from tmp file for pasting!");
	}
}


/* This function inserts text from a cut buffer, and returns the MARK where
 * insertion ended.  Return MARK_UNSET on errors.
 */
MARK paste(at, after, retend)
	MARK	at;	/* where to insert the text */
	int	after;	/* boolean: insert after mark? (rather than before) */
	int	retend;	/* boolean: return end of text? (rather than start) */
{
	REG struct cutbuf	*cb;
	REG int			i;

	/* decide which cut buffer to use */
	if (Iswindowpastebuf(cbname)) 
	{
	}
	else if (cbname >= 'A' && cbname <= 'Z')
	{
		cb = &named[cbname - 'A'];
	}
	else if (cbname >= 'a' && cbname <= 'z')
	{
		cb = &named[cbname - 'a'];
	}
	else if (cbname >= '1' && cbname <= '9')
	{
		cb = &annon[cbname - '1'];
	}
	else if (cbname == '.')
	{
		cb = &named[26];
	}
	else if (!cbname)
	{
		cb = annon;
	}
	else
	{
		msg("Invalid cut buffer name: \"%c", cbname);
		cbname = '\0';
		return MARK_UNSET;
	}

	/* make sure it isn't empty */
	if (!Iswindowpastebuf(cbname) && cb->nblks == 0)
	{
		if (cbname)
			msg("Cut buffer \"%c is empty", cbname);
		else
			msg("Cut buffer is empty");
		cbname = '\0';
		return MARK_UNSET;
	}

	/* adjust the insertion MARK for "after" and line-mode cuts */
	if (!Iswindowpastebuf(cbname) && cb->lnmode)
	{
		at &= ~(BLKSIZE - 1);
		if (after)
		{
			at += BLKSIZE;
		}
	}
	else if (after)
	{
		/* careful! if markidx(at) == 0 we might be pasting into an
		 * empty line -- so we can't blindly increment "at".
		 */
		if (markidx(at) == 0)
		{
			pfetch(markline(at));
			if (plen != 0)
			{
				at++;
			}
		}
		else
		{
			at++;
		}
	}


	/* put a copy of the "at" mark in the mark[] array, so it stays in
	 * sync with changes made via add().
	 */
	mark[27] = at;

	if (Iswindowpastebuf(cbname))
	{
	    if (Windowpaste(cbname,at) < 0)
	    {
		cbname = '\0';
		return MARK_UNSET;
	    }
	}
	else if (cb->nblks == 1) /* simple one-block paste? */
	{
		/* get the block */
		readcutblk(cb, 0);

		/* isolate the text we need within it */
		if (cb->end)
		{
			tmpblk.c[cb->end] = '\0';
		}

		/* insert it */
		ChangeText
		{
			add(at, &tmpblk.c[cb->start]);
		}
	}
	else
	{
		/* multi-block paste */

		ChangeText
		{
			i = cb->nblks - 1;

			/* add text from the last block first */
			if (cb->end > 0)
			{
				readcutblk(cb, i);
				tmpblk.c[cb->end] = '\0';
				add(at, tmpblk.c);
				i--;
			}

			/* add intervening blocks */
			while (i > 0)
			{
				readcutblk(cb, i);
				add(at, tmpblk.c);
				i--;
			}

			/* add text from the first cut block */
			readcutblk(cb, 0);
			add(at, &tmpblk.c[cb->start]);
		}
	}
	cbname = '\0';

	/* Reporting... */
	rptlines = markline(mark[27]) - markline(at);
	rptlabel = "pasted";

	/* return the mark at the beginning/end of inserted text */
	if (retend)
	{
		return mark[27] - 1L;
	}
	return at;
}




#ifndef NO_AT

/* This function copies characters from a cut buffer into a string.
 * It returns the number of characters in the cut buffer.  If the cut
 * buffer is too large to fit in the string (i.e. if cb2str() returns
 * a number >= size) then the characters will not have been copied.
 * It returns 0 if the cut buffer is empty, and -1 for invalid cut buffers.
 */
int cb2str(name, buf, size)
	int	name;	/* the name of a cut-buffer to get: a-z only! */
	char	*buf;	/* where to put the string */
	unsigned size;	/* size of buf */
{
	REG struct cutbuf	*cb;
	REG char		*src;
	REG char		*dest;

	/* decide which cut buffer to use */
	if (name >= 'a' && name <= 'z')
	{
		cb = &named[name - 'a'];
	}
	else
	{
		return -1;
	}

	/* if the buffer is empty, return 0 */
	if (cb->nblks == 0)
	{
		return 0;
	}

	/* !!! if not a single-block cut, then fail */
	if (cb->nblks != 1)
	{
		return size;
	}

	/* if too big, return the size now, without doing anything */
	if (cb->end - cb->start >= size)
	{
		return cb->end - cb->start;
	}

	/* get the block */
	readcutblk(cb, 0);

	/* isolate the string within that blk */
	if (cb->start == 0)
	{
		tmpblk.c[cb->end] = '\0';
	}
	else
	{
		for (dest = tmpblk.c, src = dest + cb->start; src < tmpblk.c + cb->end; )
		{
			*dest++ = *src++;
		}
		*dest = '\0';
	}

	/* copy the string into the buffer */
	if (buf != tmpblk.c)
	{
		strcpy(buf, tmpblk.c);
	}

	/* return the length */
	return cb->end - cb->start;
}
#endif
SHAR_EOF
fi # end of overwriting check
if test -f 'Makefile'
then
	echo shar: will not over-write existing file "'Makefile'"
else
cat << \SHAR_EOF > 'Makefile'
# combined Makefile for ELVIS - a clone of `vi`
#
# After editing this Makefile as described below, you should...
#
# Use `make` to compile all programs
# Use `make install` to copy the programs to the BIN directory
# Use `make clean` to remove all object files
# Use `make clobber` to remove everything except source & documentation
# Use `make tags` to build new "tags" and "refs" files
# Use `make uue` to produce uuencoded compressed tar archives of the source
# Use `make sh` to produce shar archives of the source
# Use `make print` to print the Elvis documentation
#
# Several groups of Makefile settings are included below.  Choose *ONE* group
# of settings for your particular system, and leave the others commented out.
# The meanings of these settings are:
#	O	the filename extension for unlinked object files -- usually .o
#	E	the filename extension for executable files -- usually null
#	EXTRA	version-specific object files used in elvis
#	EXTRA2	version-specific object files used in elvis, virec, & refont
#	LIBS	any special libraries, such as "-ltermcap"
#	BIN	directory where executables should be installed
#	CC	the C compiler command, possibly with "memory model" flags
#	CFLAGS	compiler flags used to select compile-time options
#	OF	link flag to control the output file's name -- usually -o<space>
#	RF	flag used to denote "compile but don't link" -- usually -c
#	DATE	a "cc" flag that defines "DATE".  e.g. DATE=-DDATE=\"7/4/76\"
#	EVAL	the word "eval", if DATE requires it
#	PROGS	the list of all programs
#	CHMEM	any extra commands to be run after ELVIS is linked
#	SORT	if the "tags" file must be sorted, then SORT=-DSORT
#	INST	installation method: inst.dos, inst.tos, inst.os9, or inst.unix
#	RM	the name of a program that deletes files
#	PR1	used to print documentation -- typically "refont -c"
#	PR2	used to send text to printer -- typically "| lpr"
#	DUMMY	usually nothing, but OS9 needs "dummy"
#	DOC	name of "doc" directory, with a trailing slash

#---- These settings are recommended for System-V UNIX and SCO XENIX-386 ----
#O=	.o
#E=
#EXTRA=
#EXTRA2=
#LIBS=	-ltermcap
#BIN=	/usr/local/bin
#CFLAGS=	-DM_SYSV -O
#OF=	-o 
#RF=	-c
#DATE=	-DDATE=\'\"`date`\"\'
#EVAL=	eval 
#PROGS=	elvis$E ctags$E ref$E virec$E refont$E
#CHMEM=	
#SORT=	-DSORT
#INST=	inst.unix
#RM=	rm -f
#PR1=	refont -c
#PR2=	| lp
#DUMMY=
#DOC=	doc/

#---- These settings are recommended for SCO XENIX-286 ----
#O=	.o
#E=
#EXTRA=
#EXTRA2=
#LIBS=	-ltermcap
#BIN=	/usr/local/bin
#CC=	cc -M2s -i
#CFLAGS=	-DM_SYSV -Ox -DCS_IBMPC
#OF=	-o 
#RF=	-c
#DATE=	-DDATE=\'\"`date`\"\'
#EVAL=	eval 
#PROGS=	elvis$E ctags$E ref$E virec$E refont$E
#CHMEM=	
#SORT=	-DSORT
#INST=	inst.unix
#RM=	rm -f
#PR1=	refont -c
#PR2=	| lp
#DUMMY=
#DOC=	doc/

#---- These settings are recommended for BSD 4.3 UNIX ----
#O=	.o
#E=
#EXTRA=
#EXTRA2=
#LIBS=	-ltermcap
#BIN=	/usr/local/bin
#CFLAGS=	-Dbsd -O
#OF=	-o 
#RF=	-c
#DATE=	-DDATE=\'\"`date`\"\'
#EVAL=	eval 
#PROGS=	elvis$E ctags$E ref$E virec$E refont$E
#CHMEM=	
#SORT=	-DSORT
#INST=	inst.unix
#RM=	rm -f
#PR1=	refont -c
#PR2=	| lpr
#DUMMY=
#DOC=	doc/

#---- These settings are recommended for sunOS with OPENWINDOWS (X11/NeWS)
CHOWN=echo "Chown turned off, would be --> chown"
#CC=gcc -traditional -g
CC=cc -O
O=	.o
E=
EXTRA= ow$O ow_xv$O
EXTRA2=
LIBS=-lwire -lcps -ltermcap -lxview -lolgx -lX11
BIN=/usr/local/bin
PS=$(BIN)/elvis.ps
#PS=/usr/local/src/share/elvis.ps
CFLAGS=	-DMALLOC_DEBUG=0 -DSUNOS=1 -Dbsd -DRUNFILE=\"$(PS)\" -DOPENWINDOWS=1 \
	-I$(OPENWINHOME)/include -L$(OPENWINHOME)/lib
OF=-o
RF=	-c
DATE=	-DDATE=\'\"`date`\"\'
EVAL=	eval 
PROGS=	elvis_cps.h elvis.ps elvis$E ctags$E ref$E virec$E refont$E
CHMEM=	
SORT=	-DSORT
INST=	inst.unix
RM=	rm -f
PR1=	refont -c
PR2=	| lpr
DUMMY=
DOC=	doc/


#---- These settings are recommended for Coherent ----
#O=.o
#E=
#EXTRA=
#EXTRA2=
#LIBS=	-lterm
#BIN=	/usr/bin
#CC=	cc 
#CFLAGS=	-O -DCOHERENT -DCRUNCH -DNO_CHARATTR -DNO_CURSORSHAPE \
#	-DNO_DIGRAPH -DNO_MKEXRC -VSUVAR
#OF=	-o 
#RF=	-c
#DATE=	-DDATE=\'\"`date`\"\'
#EVAL=	eval
#PROGS=	elvis$E ctags$E ref$E virec$E refont$E
#CHMEM=	fixstack 2000 elvis$E
#SORT=
#INST=	inst.unix
#RM=	rm -f
#PR1=	refont -b
#PR2=	| lpr
#DUMMY=
#DOC=	doc/

#---- These settings are recommended for Minix-ST ----
#O=	.o
#E=
#EXTRA=
#EXTRA2=
#LIBS=
#BIN=	/usr/bin
#CC=	cc
#CFLAGS=
#OF=	-o 
#RF=	-c
#DATE=	-DDATE=\'\"`date`\"\'
#EVAL=	eval 
#PROGS=	elvis$E ctags$E ref$E virec$E refont$E
#CHMEM=	chmem =18000 elvis
#SORT=
#INST=	inst.unix
#RM=	rm -f
#PR1=	lpr
#PR2=
#DUMMY=
#DOC=	doc/

#---- These settings are recommended for Minix-PC ----
#O=	.s
#E=
#EXTRA=	tinytcap$O
#EXTRA2=
#LIBS=
#BIN=	/usr/bin
#CC=	cc -i
#CFLAGS=	-O -DCRUNCH -DNO_MKEXRC -DNO_CURSORSHAPE -DNO_CHARATTR \
#	-DNO_SHOWMODE -DNO_MODELINE -DNO_OPTCOLS -DNO_DIGRAPH -DNO_ABBR \
#	-DNO_AT -DNO_SENTENCE -DNO_ERRLIST
#### (all but -DNO_EXTENSIONS, -DNO_RECYCLE, -DNO_MAGIC, and -DNO_CHARSEARCH)
#OF=	-o 
#RF=	-c
#DATE=	-DDATE=\'\"`date`\"\'
#EVAL=	eval 
#PROGS=	elvis$E ctags$E ref$E virec$E refont$E
#CHMEM=
#SORT=
#INST=	inst.unix
#RM=	rm -f
#PR1=	lpr
#PR2=	
#DUMMY=
#DOC=	doc/

#---- These settings are recommended for MS-DOS + MS-C + NDMAKE ----
#O=	.obj
#E=	.exe
#EXTRA=	pc$O sysdos$O tinytcap$O
#EXTRA2=
#LIBS=
#BIN=	c:\dos
#CC=	cl /AM
#CFLAGS=	-O -DCS_IBMPC -DCS_SPECIAL
#OF=	-o 
#RF=	-c
#DATE=
#EVAL=
#PROGS=	elvis$E ex$E ctags$E ref$E virec$E wildcard$E refont$E
#CHMEM=	
#SORT=
#INST=	inst.dos
#RM=	del
#PR1=	refont -c
#PR2=	>PRN
#DUMMY=
#DOC=	doc\

#---- These settings are recommended for Atari TOS + Mark Williams C ----
#O=.o
#E=.ttp
#EXTRA=	sysdos$O tinytcap$O
#EXTRA2=	atari$O
#LIBS=
#BIN=	c:\
#CC=	cc -VPEEP
#CFLAGS=	-O -DCS_IBMPC -DCS_SPECIAL
#OF=	-o 
#RF=	-c
#DATE=
#EVAL=
#PROGS=	elvis$E ctags$E ref$E virec$E wildcard$E shell$E refont$E
#CHMEM=
#SORT=
#INST=	inst.tos
#RM=	rm -f
#PR1=	refont -e
#PR2=	>PRT:
#DUMMY=
#DOC=	'doc\'

#---- These settings are recommended for OS-9/68K V2.3 ----
#O=	.r
#E=
#EXTRA=	date$O
#EXTRA2=	osk$O 
#LIBS=	-l=/dd/lib/termlib.l
#BIN=	/dd/usr/cmds
#CC=	cc
#ODIR=	/dd/usr/src/elvis
#CFLAGS=	-gq -m=2
#OF=	-f=$(ODIR)/
#RF=	-r
#DATE=
#EVAL=
#PROGS=	elvis$E vi$E view$E input$E ctags$E ref$E virec$E refont$E
#CHMEM=	touch date.r
#SORT=
#INST=	inst.os9
#RM=	del *.stb *.dbg
#PR1=	refont -b
#PR2=	>/p
#DUMMY=	dummy
#DOC=	doc/

###########################################################################
###########################################################################
###                                                                     ###
###     The rest of this Makefile contains no user-servicable parts     ###
###                                                                     ###
###########################################################################
###########################################################################

OBJS=	blk$O cmd1$O cmd2$O curses$O cut$O ex$O input$O main$O misc$O \
	modify$O move1$O move2$O move3$O move4$O move5$O opts$O recycle$O \
	redraw$O regexp$O regsub$O system$O tio$O tmp$O vars$O vcmd$O vi$O

ALIAS=	alias$O

DOCS=	$(DOC)index.doc $(DOC)intro.doc $(DOC)visual.doc $(DOC)ex.doc \
	$(DOC)regexp.doc $(DOC)options.doc $(DOC)cutbufs.doc $(DOC)differ.doc \
	$(DOC)internal.doc $(DOC)cflags.doc $(DOC)termcap.doc \
	$(DOC)environ.doc $(DOC)versions.doc

SRC1=	README KNOWN.BUGS $(DOC)intro.doc $(DOC)visual.doc $(DOC)ex.doc \
	$(DOC)versions.doc $(DOC)cflags.doc $(DOC)differ.doc
SRC2=	$(DOC)cutbufs.doc $(DOC)options.doc $(DOC)environ.doc $(DOC)regexp.doc \
	$(DOC)internal.doc $(DOC)termcap.doc $(DOC)index.doc $(DOC)ctags.man \
	$(DOC)elvis.man $(DOC)ref.man $(DOC)refont.man $(DOC)virec.man
SRC3=	Elvis.lnk Elvis.mak Elvis.prj Makefile.mix alias.c atari.c \
	ctags.c pc.c ref.c shell.c sysdos.c virec.c wildcard.c \
	profile.sh osk.c osk.h date.c
SRC4=	blk.c cmd1.c cmd2.c config.h curses.c
SRC5=	curses.h cut.c ex.c input.c main.c misc.c
SRC6=	modify.c move1.c move2.c move3.c move4.c move5.c opts.c recycle.c \
	redraw.c 
SRC7=	regexp.c regexp.h regsub.c system.c tinytcap.c tio.c tmp.c 
SRC8=	vars.c vcmd.c vi.c vi.h refont.c

###########################################################################

all: $(PROGS)
	@echo done.

t$E: ow_xv.o
	$(CC) $(CFLAGS) $(OF) t$E ow_xv.o -lxview -lolgx -lX11

elvis$E: $(OBJS) $(EXTRA) $(EXTRA2)
	$(CC) $(CFLAGS) $(OF) elvis$E $(OBJS) $(EXTRA) $(EXTRA2) $(LIBS)
	$(CHMEM)

ctags$E: ctags.c
	$(CC) $(CFLAGS) $(SORT) $(OF)ctags$E ctags.c

ref$E: ref.c
	$(CC) $(CFLAGS) $(OF)ref$E ref.c

virec$E: virec.c tnamerec.c
	$(CC) $(CFLAGS) $(OF) virec$E virec.c tnamerec.c $(EXTRA2)

view$E: $(ALIAS)
	$(CC) $(CFLAGS) $(OF)view$E $(ALIAS)

ex$E: $(ALIAS)
	$(CC) $(CFLAGS) $(OF)ex$E $(ALIAS)

vi$E: $(ALIAS)
	$(CC) $(CFLAGS) $(OF)vi$E $(ALIAS)

input$E: $(ALIAS)
	$(CC) $(CFLAGS) $(OF)input$E $(ALIAS)

shell$E: shell.c
	$(CC) $(CFLAGS) $(OF)shell$E shell.c

wildcard$E: wildcard.c
	$(CC) $(CFLAGS) $(OF)wildcard$E wildcard.c

refont$E: refont.c
	$(CC) $(CFLAGS) $(OF)refont$E refont.c $(EXTRA2)

##############################################################################

# The file cmd1.c is compiled with the extra flag -DDATE="today's date".
cmd1$O: cmd1.c vi.h config.h
	$(EVAL) $(CC) $(CFLAGS) $(RF) $(DATE) cmd1.c

# "It all depends..."
$(OBJS): vi.h curses.h config.h

# OS9 must create a custom date.c file, and compile it.
date$O: $(OBJS)
	@echo '/* compilation date of elvis */' >-date.c
	@echo -r 'char date[] = "' >+date.c
	@echo -r 'echo -r ' >-/dd/tmp/date.c
	@date >+/dd/tmp/date.c
	@shell /dd/tmp/date.c >+date.c
	@echo '";' >+date.c
	@del /dd/tmp/date.c
	$(CC) $(CFLAGS) $(RF) date.c

##############################################################################
install: $(INST)
	@echo Installation complete.

inst.unix: $(DUMMY)
	cp $(PROGS) $(BIN)
	(cd $(BIN); chmod 755 $(PROGS))
	(cd $(BIN); $(CHOWN) bin $(PROGS))
	-rm $(BIN)/vi; ln -s $(BIN)/elvis $(BIN)/vi
	-rm $(BIN)/ex; ln -s $(BIN)/elvis $(BIN)/ex
	-rm $(BIN)/view; ln -s $(BIN)/elvis $(BIN)/view
	-rm $(BIN)/input; ln -s $(BIN)/elvis $(BIN)/input

inst.dos: $(DUMMY)
	copy $(PROGS) $(BIN)
	copy $(BIN)/ex$E $(BIN)/vi$E
	copy $(BIN)/ex$E $(BIN)/view$E
	copy $(BIN)/ex$E $(BIN)/input$E

inst.tos: $(DUMMY)
	copy $(PROGS) $(BIN)

inst.os9: $(DUMMY)
	copy $(PROGS) -rw=$(BIN)
	chd $(BIN); attr -epenprnpw $(PROGS)

##############################################################################
clean: $(DUMMY)
	$(RM) *$O $(DOC)*.1 elvis?.uue elvis?.sh core

clobber: clean
	$(RM) tags refs $(PROGS)

##############################################################################
print: refont$E
	$(PR1) $(DOCS) $(PR2)

tags refs: ctags$E
	ctags -r *.c *.h

##############################################################################
uue: elvis1.uue elvis2.uue elvis3.uue elvis4.uue elvis5.uue \
	elvis6.uue elvis7.uue elvis8.uue

elvis1.uue: $(SRC1)
	tar cf elvis1.tar $(SRC1)
	compress -b13 elvis1.tar
	cp README elvis1.uue
	uue elvis1.tar.Z - >>elvis1.uue
	$(RM) elvis1.tar*

elvis2.uue: $(SRC2)
	tar cf elvis2.tar $(SRC2)
	compress -b13 elvis2.tar
	uue elvis2.tar.Z
	$(RM) elvis2.tar*

elvis3.uue: $(SRC3)
	tar cf elvis3.tar $(SRC3)
	compress -b13 elvis3.tar
	uuencode elvis3.tar.Z <elvis3.tar.Z >elvis3.uue
	$(RM) elvis3.tar*

elvis4.uue: $(SRC4)
	tar cf elvis4.tar $(SRC4)
	compress -b13 elvis4.tar
	uuencode elvis4.tar.Z <elvis4.tar.Z >elvis4.uue
	$(RM) elvis4.tar*

elvis5.uue: $(SRC5)
	tar cf elvis5.tar $(SRC5)
	compress -b13 elvis5.tar
	uuencode elvis5.tar.Z <elvis5.tar.Z >elvis5.uue
	$(RM) elvis5.tar*

elvis6.uue: $(SRC6)
	tar cf elvis6.tar $(SRC6)
	compress -b13 elvis6.tar
	uuencode elvis6.tar.Z <elvis6.tar.Z >elvis6.uue
	$(RM) elvis6.tar*

elvis7.uue: $(SRC7)
	tar cf elvis7.tar $(SRC7)
	compress -b13 elvis7.tar
	uuencode elvis7.tar.Z <elvis7.tar.Z >elvis7.uue
	$(RM) elvis7.tar*

elvis8.uue: $(SRC8)
	tar cf elvis8.tar $(SRC8)
	compress -b13 elvis8.tar
	uuencode elvis8.tar.Z <elvis8.tar.Z >elvis8.uue
	$(RM) elvis8.tar*

##############################################################################
sh: elvis1.sh elvis2.sh elvis3.sh elvis4.sh elvis5.sh elvis6.sh \
	elvis7.sh elvis8.sh

elvis1.sh: $(SRC1)
	cat   >elvis1.sh README
	echo >>elvis1.sh ': ------------------------ CUT HERE --------------------'
	echo >>elvis1.sh 'test -d doc || mkdir doc || exit 2'
	shar >>elvis1.sh -h $(SRC1)

elvis2.sh: $(SRC2)
	echo  >elvis2.sh ': ------------------------ CUT HERE --------------------'
	echo >>elvis2.sh 'test -d doc || mkdir doc || exit 2'
	shar >>elvis2.sh -h $(SRC2)

elvis3.sh: $(SRC3)
	shar $(SRC3) >elvis3.sh

elvis4.sh: $(SRC4)
	shar $(SRC4) >elvis4.sh

elvis5.sh: $(SRC5)
	shar $(SRC5) >elvis5.sh

elvis6.sh: $(SRC6)
	shar $(SRC6) >elvis6.sh

elvis7.sh: $(SRC7)
	shar $(SRC7) >elvis7.sh

elvis8.sh: $(SRC8)
	shar $(SRC8) >elvis8.sh

##############################################################################

# Under XENIX only!  This stores all sources on a 3.5" 720k floppy disk.
floppy: $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8)
	tar c5v $(SRC1) $(SRC2) $(SRC3) $(SRC4) $(SRC5) $(SRC6) $(SRC7) $(SRC8)

changes:
	for i in *.[ch] M* ; do \
	if test -f $i -a -w $i ; then \
		echo $i \
		fi;\
	done

dep:
	makedep -f $(CFLAGS) -I/usr/include *.c
	sed '/^#-- DO NOT EDIT FROM THIS LINE DOWN/,$$d' Makefile > tmp
	echo  "#-- DO NOT EDIT FROM THIS LINE DOWN" >> tmp
	cat dependencies >> tmp
	mv tmp Makefile
	rm dependencies

#-- DO NOT EDIT FROM THIS LINE DOWN
wildcard.o: \
	$(FRC) \
	/usr/include/stdio.h \
	/usr/include/ctype.h
virec.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	/usr/include/stdio.h \
	/usr/include/ctype.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	osk.h \
	/usr/include/time.h \
	wildcard.c
vi.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	/usr/include/ctype.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
vcmd.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	/usr/include/string.h
vars.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
tnamerec.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	/usr/include/dirent.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/dirent.h
tmp.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	/usr/include/ctype.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	osk.h \
	/usr/include/time.h
tio.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	/usr/include/setjmp.h \
	/usr/include/machine/setjmp.h \
	/usr/include/sun3/setjmp.h \
	/usr/include/sun3x/setjmp.h \
	/usr/include/sun4/setjmp.h \
	/usr/include/sun4c/setjmp.h \
	/usr/include/signal.h \
	/usr/include/sys/signal.h \
	/usr/include/vm/faultcode.h \
	/usr/include/sys/stdtypes.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	/usr/include/varargs.h
tinytcap.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h
system.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	/usr/include/signal.h \
	/usr/include/sys/signal.h \
	/usr/include/vm/faultcode.h \
	/usr/include/string.h
sysdos.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	/usr/include/string.h
shell.o: \
	$(FRC) \
	/usr/include/stdio.h \
	/usr/include/string.h \
	/usr/include/sys/stdtypes.h
regsub.o: \
	$(FRC) \
	/usr/include/ctype.h \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	regexp.h
regexp.o: \
	$(FRC) \
	/usr/include/setjmp.h \
	/usr/include/machine/setjmp.h \
	/usr/include/sun3/setjmp.h \
	/usr/include/sun3x/setjmp.h \
	/usr/include/sun4/setjmp.h \
	/usr/include/sun4c/setjmp.h \
	/usr/include/ctype.h \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	regexp.h
refont.o: \
	$(FRC) \
	/usr/include/stdio.h \
	config.h \
	/usr/include/malloc.h
ref.o: \
	$(FRC) \
	/usr/include/stdio.h
redraw.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
recycle.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
pc.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
ow_xv.o: \
	$(FRC) \
	wconfig.h \
	config.h \
	/usr/include/malloc.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	$(OPENWINHOME)/include/xview/xview.h \
	$(OPENWINHOME)/include/xview/xview_xvin.h \
	/usr/include/signal.h \
	/usr/include/sys/signal.h \
	/usr/include/vm/faultcode.h \
	/usr/include/pixrect/pixrect.h \
	/usr/include/pixrect/pr_planegroups.h \
	/usr/include/pixrect/pr_util.h \
	/usr/include/pixrect/memvar.h \
	/usr/include/pixrect/pixfont.h \
	/usr/include/pixrect/traprop.h \
	/usr/include/pixrect/pr_line.h \
	/usr/include/stdlib.h \
	$(OPENWINHOME)/include/xview/xv_c_types.h \
	$(OPENWINHOME)/include/xview/generic.h \
	$(OPENWINHOME)/include/xview/pkg_public.h \
	$(OPENWINHOME)/include/xview/pkg.h \
	/usr/include/varargs.h \
	$(OPENWINHOME)/include/xview/attr.h \
	$(OPENWINHOME)/include/xview/base.h \
	/usr/include/strings.h \
	$(OPENWINHOME)/include/xview/notify.h \
	$(OPENWINHOME)/include/xview/xv_error.h \
	$(OPENWINHOME)/include/xview/sun.h \
	$(OPENWINHOME)/include/xview/server.h \
	$(OPENWINHOME)/include/xview/screen.h \
	$(OPENWINHOME)/include/xview/pixwin.h \
	$(OPENWINHOME)/include/xview/rect.h \
	$(OPENWINHOME)/include/xview/rectlist.h \
	$(OPENWINHOME)/include/xview/win_input.h \
	/usr/include/sys/time.h \
	/usr/include/time.h \
	$(OPENWINHOME)/include/X11/Xlib.h \
	$(OPENWINHOME)/include/X11/X.h \
	$(OPENWINHOME)/include/xview/win_event.h \
	$(OPENWINHOME)/include/xview/icon.h \
	$(OPENWINHOME)/include/xview/window.h \
	$(OPENWINHOME)/include/xview/drawable.h \
	$(OPENWINHOME)/include/xview/attrol.h \
	$(OPENWINHOME)/include/xview/svrimage.h \
	$(OPENWINHOME)/include/xview/frame.h \
	$(OPENWINHOME)/include/xview/openmenu.h \
	$(OPENWINHOME)/include/xview/seln.h \
	$(OPENWINHOME)/include/xview/sel_svc.h \
	/usr/include/netinet/in.h \
	/usr/include/sys/socket.h \
	$(OPENWINHOME)/include/X11/Xatom.h \
	/usr/include/rpc/rpc.h \
	/usr/include/rpc/types.h \
	/usr/include/rpc/xdr.h \
	/usr/include/rpc/auth.h \
	/usr/include/rpc/clnt.h \
	/usr/include/rpc/rpc_msg.h \
	/usr/include/rpc/auth_unix.h \
	/usr/include/rpc/auth_des.h \
	/usr/include/rpc/svc.h \
	/usr/include/rpc/svc_auth.h \
	$(OPENWINHOME)/include/xview/sel_attrs.h
ow_tcap.o: \
	$(FRC) \
	/usr/include/varargs.h \
	curses.h \
	wconfig.h \
	config.h \
	/usr/include/malloc.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
ow.o: \
	$(FRC) \
	/usr/include/stdio.h \
	/usr/include/sys/time.h \
	/usr/include/time.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/signal.h \
	/usr/include/sys/signal.h \
	/usr/include/vm/faultcode.h \
	/usr/include/assert.h \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	elvis_cps.h \
	/usr/include/sys/file.h \
	/usr/include/sgtty.h \
	/usr/include/sys/ioctl.h \
	/usr/include/sys/ttychars.h \
	/usr/include/sys/ttydev.h \
	/usr/include/sys/ttold.h \
	/usr/include/sys/ioccom.h \
	/usr/include/sys/ttycom.h \
	/usr/include/sys/filio.h \
	/usr/include/sys/sockio.h
osk.o: \
	$(FRC) \
	/usr/include/stdio.h \
	osk.h \
	/usr/include/time.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/signal.h \
	/usr/include/sys/signal.h \
	/usr/include/vm/faultcode.h
opts.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
move5.o: \
	$(FRC) \
	/usr/include/ctype.h \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
move4.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
move3.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
move2.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	regexp.h
move1.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	/usr/include/ctype.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
modify.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
misc.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
main.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	/usr/include/signal.h \
	/usr/include/sys/signal.h \
	/usr/include/vm/faultcode.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/setjmp.h \
	/usr/include/machine/setjmp.h \
	/usr/include/sun3/setjmp.h \
	/usr/include/sun3x/setjmp.h \
	/usr/include/sun4/setjmp.h \
	/usr/include/sun4c/setjmp.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
input.o: \
	$(FRC) \
	/usr/include/ctype.h \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
ex.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	/usr/include/ctype.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
cut.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
curses.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	/usr/include/termio.h \
	/usr/include/sys/ioccom.h \
	/usr/include/sys/termios.h \
	/usr/include/sys/ttydev.h \
	/usr/include/sys/ttycom.h \
	/usr/include/sgtty.h \
	/usr/include/sys/ioctl.h \
	/usr/include/sys/ttychars.h \
	/usr/include/sys/ttold.h \
	/usr/include/sys/filio.h \
	/usr/include/sys/sockio.h \
	/usr/include/signal.h \
	/usr/include/sys/signal.h \
	/usr/include/vm/faultcode.h
ctags.o: \
	$(FRC) \
	/usr/include/ctype.h \
	/usr/include/stdio.h \
	config.h \
	/usr/include/malloc.h \
	wildcard.c
cmd2.o: \
	$(FRC) \
	/usr/include/ctype.h \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	regexp.h \
	osk.h \
	/usr/include/time.h
cmd1.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	/usr/include/ctype.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h \
	regexp.h
blk.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
atari.o: \
	$(FRC) \
	config.h \
	/usr/include/malloc.h \
	vi.h \
	/usr/include/errno.h \
	/usr/include/sys/errno.h \
	/usr/include/sys/types.h \
	/usr/include/sys/stdtypes.h \
	/usr/include/sys/sysmacros.h \
	/usr/include/sys/fcntl.h \
	/usr/include/sys/fcntlcom.h \
	/usr/include/sys/stat.h \
	/usr/include/fcntl.h \
	curses.h \
	wconfig.h \
	$(OPENWINHOME)/include/NeWS/wire.h \
	$(OPENWINHOME)/include/NeWS/psmacros.h \
	/usr/include/stdio.h \
	$(OPENWINHOME)/include/NeWS/psio.h \
	$(OPENWINHOME)/include/NeWS/wire_types.h
alias.o: \
	$(FRC) \
	/usr/include/stdio.h \
	config.h \
	/usr/include/malloc.h
SHAR_EOF
fi # end of overwriting check
if test -f 'config.h'
then
	echo shar: will not over-write existing file "'config.h'"
else
cat << \SHAR_EOF > 'config.h'
/*
 * vi configuration file
 * We try to automatically configure to various compilers and operating
 * systems. Extend the autoconf section as needed.
 */

/*************************** autoconf section ************************/

/* standard unix V (?) */
#ifdef	M_SYSV
# define UNIXV		1
#endif

/* xelos system, University of Ulm */
#ifdef	xelos
# define UNIXV		1
#endif

/* BSD UNIX? */
#ifdef bsd
# define BSD		1
#endif

/* Microsoft C: sorry, Watcom does the same thing */
#ifdef	M_I86
# ifndef M_SYSV
#  define MSDOS		1
#  define MICROSOFT	1
#  define COMPILED_BY	"Microsoft C 5.10"
# endif
#endif

/* Borlands Turbo C */
#ifdef	__TURBOC__
# define MSDOS		1
# define TURBOC		1
# define COMPILED_BY	"Turbo C 2.00"
#endif

/* Tos Mark-Williams */
#ifdef	M68000
# define TOS 1
# define COMPILED_BY	"Mark Williams C"
#endif

/* OS9/68000 */
#ifdef	OSK
# define COMPILED_BY	"Microware C V2.3 Edition 40"
#endif

/*************************** end of autoconf section ************************/

/* All undefined symbols are defined to zero here, to allow for older    */
/* compilers which dont understand #if defined() or #if UNDEFINED_SYMBOL */

/*************************** operating systems *****************************/
 
#ifndef	BSD
# define BSD	0		/* UNIX - Berkeley 4.x */
#endif

#ifndef	UNIXV
# define UNIXV	0		/* UNIX - AT&T SYSV */
#endif

#ifndef	UNIX7
# define UNIX7	0		/* UNIX - version 7 */
#endif

#ifndef	MSDOS
# define MSDOS	0		/* PC		*/
#endif

#ifndef	TOS
# define TOS	0		/* Atari ST	*/
#endif

#ifndef	AMIGA
# define AMIGA	0		/* Commodore Amiga */
#endif

#ifndef OSK
# define OSK	0		/* OS-9 / 68k */
#endif

#ifndef COHERENT
# define COHERENT 0		/* Coherent */
#endif

				/* Minix has no predefines */
#if !BSD && !UNIXV && !UNIX7 && !MSDOS && !TOS && !AMIGA && !OSK && !COHERENT
# define MINIX	1
#else
# define MINIX	0
#endif

				/* generic combination of Unices */
#if UNIXV || UNIX7 || BSD || MINIX || COHERENT
# define ANY_UNIX 1
#else
# define ANY_UNIX 0
#endif

/*************************** compilers **************************************/
 
#ifndef	MICROSOFT
# define MICROSOFT	0
#endif

#ifndef	TURBOC
# define TURBOC		0
#endif

/******************************* Credit ************************************/

#if OPENWINDOWS
# define CREDIT "Ported to X11/NeWS by Mike Hoegeman"
#endif

#if MSDOS
# define CREDIT "Ported to MS-DOS by Guntram Blohm & Martin Patzel"
#endif

#if TOS
# define CREDIT "Ported to Atari/TOS by Guntram Blohm & Martin Patzel"
#endif

#if OSK
# define CREDIT	"Ported to Microware OS9/68k by Peter Reinig"
#endif

#if COHERENT
# define CREDIT	"Ported to Coherent by Esa Ahola"
#endif

/*************************** functions depending on OS *********************/

/* Only MSDOS, TOS, and OS9 need a special function for reading from the
 * keyboard.  All others just read from file descriptor 0.
 */
#if !MSDOS && !TOS && !OSK && !OPENWINDOWS
# define ttyread(buf, len)	read(0, buf, (unsigned)len)	/* raw read */
#endif
#if !TOS && !OPENWINDOWS
# define ttywrite(buf, len)	write(1, buf, (unsigned)(len))	/* raw write */
#endif

/* The strchr() function is an official standard now, so everybody has it
 * except Unix version 7 (which is old) and BSD Unix (which is academic).
 * Those guys use something called index() to do the same thing.
 */
#if BSD || UNIX7 || OSK
# define strchr	index
#endif
extern char *strchr();

/* BSD uses bcopy() instead of memcpy() */
#if BSD
#define memcpy(dest, src, siz)	bcopy(src, dest, siz)
#endif

/* text versa binary mode for read/write */
#if !TOS
#define	tread(fd,buf,n)		read(fd,buf,(unsigned)(n))
#define twrite(fd,buf,n)	write(fd,buf,(unsigned)(n))
#endif

/**************************** Compiler quirks *********************************/

/* the UNIX version 7 and (some) TOS compilers, don't allow "void" */
#if UNIX7 || TOS
# define void int
#endif

/* as far as I know, all compilers except version 7 support unsigned char */
/* NEWFLASH: the Minix-ST compiler has subtle problems with unsigned char */
#if UNIX7 || MINIX
# define UCHAR(c)	((c) & 0xff)
# define uchar		char
#else
# define UCHAR(c)	((unsigned char)(c))
# define uchar		unsigned char
#endif

/* Some compilers prefer to have malloc declared as returning a (void *) */
#if BSD
#if OPENWINDOWS
#include <malloc.h>
#else
extern void *malloc();
#endif
#else
extern char *malloc();
#endif

/* Most compilers could benefit from using the "register" storage class */
#if 1
# define REG	register
#endif

/******************* Names of files and environment vars **********************/

#if ANY_UNIX
# ifndef TMPDIR
#  if MINIX
#   define TMPDIR	"/usr/tmp"	/* Keep elvis' temp files off RAM disk! */
#  else
#   define TMPDIR	"/tmp"		/* directory where temp files live */
#  endif
# endif
# define MAXTMPNAMELEN 256 /* length for tmp file name buffer */
# define TMPNAME	"%s/El%01x%04x%03x-%03x" /* temp file */
# define CUTNAME	"%s/El_%04x%03x" /* cut buffer's temp file */
# ifndef EXRC
#  define EXRC		".exrc"		/* init file in current directory */
# endif
# define SCRATCHOUT	"%s/soXXXXXX"	/* temp file used as input to filter */
# ifndef EXINIT
#  define EXINIT	"EXINIT"
# endif
# ifndef SHELL
#  define SHELL		"/bin/sh"	/* default shell */
# endif
# if COHERENT
#  ifndef REDIRECT
#   define REDIRECT	">"		/* Coherent CC writes errors to stdout */
#  endif
# endif
#endif

#if MSDOS || TOS
/* do not change TMPNAME, CUTNAME and SCRATCH*: they MUST begin with '%s\\'! */
# ifndef TMPDIR
#  define TMPDIR	"C:\\tmp"	/* directory where temp files live */
# endif
# define TMPNAME	"%s\\elv%x%04x.%03x" /* temp file */
# define CUTNAME	"%s\\elv_%04x.%03x" /* cut buffer's temp file */
# if MSDOS
#  if MICROSOFT
#   define CC_COMMAND	"cl -c"		/* C compiler */
#  else /* TURBO_C */
#   define CC_COMMAND	"tc"		/* C compiler */
#  endif
# define MAXTMPNAMELEN 80 /* length for tmp file name buffer */
# endif
# define SCRATCHIN	"%s\\siXXXXXX"	/* DOS ONLY - output of filter program */
# define SCRATCHOUT	"%s\\soXXXXXX"	/* temp file used as input to filter */
# define SLASH		'\\'
# ifndef SHELL
#  if TOS
#   define SHELL	"shell.ttp"	/* default shell */
#  else
#   define SHELL	"command.com"	/* default shell */
#  endif
# endif
# define NEEDSYNC	TRUE		/* assume ":se sync" by default */
# define REDIRECT	">"		/* shell's redirection of stderr */
# ifndef MAXMAPS
#  define MAXMAPS	40
# endif
# ifndef EXINIT
#  define EXINIT	"EXINIT"
# endif
#endif

#if OSK
# ifndef TMPDIR
#  define TMPDIR	"/dd/tmp"	   /* directory where temp files live */
# endif
# define TMPNAME	"%s/elv%x%04x%03x"  /* temp file */
# define CUTNAME	"%s/elv_%04x%03x"  /* cut buffer's temp file */
# ifndef CC_COMMAND
#  define CC_COMMAND	"cc -r"		   /* name of the compiler */
# endif
# ifndef EXRC
#  define EXRC		".exrc"		   /* init file in current directory */
# endif
# define SCRATCHOUT	"%s/soXXXXXX"	   /* temp file used as input to filter */
# ifndef SHELL
#  define SHELL		"shell"		   /* default shell */
# endif
# define FILEPERMS	(S_IREAD|S_IWRITE) /* file permissions used for creat() */
# define REDIRECT	">>-"		   /* shell's redirection of stderr */
#endif

#ifndef	TAGS
# define TAGS		"tags"		/* tags file */
#endif

#ifndef TMPNAME
# define TMPNAME	"%s/elv%x%04x.%03x"	/* temp file */
#endif

#ifndef CUTNAME
# define CUTNAME	"%s/elv_%04x.%03x"	/* cut buffer's temp file */
#endif

#ifndef	EXRC
# define EXRC		"elvis.rc"
#endif

#ifndef HMEXRC
# if !MSDOS && !TOS
#  define HMEXRC	EXRC
# endif
#endif

#ifndef	KEYWORDPRG
# define KEYWORDPRG	"ref"
#endif

#ifndef	SCRATCHOUT
# define SCRATCHIN	"%s/SIXXXXXX"
# define SCRATCHOUT	"%s/SOXXXXXX"
#endif

#ifndef ERRLIST
# define ERRLIST	"errlist"
#endif

#ifndef	SLASH
# define SLASH		'/'
#endif

#ifndef SHELL
# define SHELL		"shell"
#endif

#ifndef REG
# define REG
#endif

#ifndef NEEDSYNC
# define NEEDSYNC	FALSE
#endif

#ifndef FILEPERMS
# define FILEPERMS	0666
#endif

#ifndef CC_COMMAND
# define CC_COMMAND	"cc -c"
#endif

#ifndef MAKE_COMMAND
# define MAKE_COMMAND	"make"
#endif

#ifndef REDIRECT
# define REDIRECT	"2>"
#endif

#ifndef MAXMAPS
# define MAXMAPS	20		/* number of :map keys */
#endif
#ifndef MAXDIGS
# define MAXDIGS	30		/* number of :digraph combos */
#endif
#ifndef MAXABBR
# define MAXABBR	20		/* number of :abbr entries */
#endif
SHAR_EOF
fi # end of overwriting check
if test -f 'ow.c'
then
	echo shar: will not over-write existing file "'ow.c'"
else
cat << \SHAR_EOF > 'ow.c'
#if OPENWINDOWS
#include <stdio.h>
#include <sys/time.h>
#include <signal.h>
#include <assert.h>

#include "config.h"
#include "vi.h"
#include "curses.h"
#include "elvis_cps.h"

#define PS_ESC '\200'
#define TTY 1 /* conditional for compiling in dumb tty support */

#ifndef RUNFILE
#define RUNFILE "/usr/local/lib/elvis.ps" /* server side PostScript code */
#endif

/* openwindows related elvis stuff */
/* author: mike hoegeman , mh@wlv.imsd.contel.com*/

struct ow_data Ow;

int     ElvisDestroyTag;
extern void destroyProc();

int     ElvisKeyTag;
extern void keyProc();

int     ElvisMiscTag;
extern void miscProc();

int     ElvisResizeTag;
extern void resizeProc();

int     ElvisDamageTag;
extern void damageProc();

int    *NewsTags[] =
{
    &ElvisDestroyTag,
    &ElvisKeyTag,
    &ElvisMiscTag,
    &ElvisResizeTag,
    &ElvisDamageTag,
    (int *) 0
};

void
destroyProc(tag, data)
    int     tag;
    caddr_t *data;
{
    ow_beep();
    wire_ReadTag();
    return;
}

void
damageProc(tag, data)
    int     tag;
    caddr_t *data;
{
    int     i;
    if (tag >= 0)
	i = wire_ReadTag();
    redraw(MARK_UNSET, FALSE);
    redraw(cursor, 1);
    refresh();
    return;
}

void
resizeProc(tag, data)
    int     tag;
    caddr_t *data;
{
    int     i;
    i = wire_ReadTag();
    LINES = Ow.wLINES = wire_ReadInt();
    COLS = Ow.wCOLS = wire_ReadInt();
    return;
}

void
keyProc(tag, data)
    int     tag;
    caddr_t *data;
{
    int     t;
    t = wire_ReadTag();
    Ow.keyFromNews = wire_ReadInt();
    wire_ExitNotifier();
    return;
}

int
ow_tmpstart(fname)
    char   *fname;
{
    int     x;
    x = tmpstart(fname);
    if (!Ow.tty)
    {
	ps_set_title(*fname == '\0' ? "Elvis" : fname);
	ps_flush_PostScript();
    }
    return x;
}

int
ow_beep()
{
#ifdef TTY
    if (Ow.tty)
    {
	beep();
	return 0;
    }
#   endif
    ps_beep();
    return 0;
}

int ow_rendermsg(msgtxt)
	char *msgtxt;
{
#ifdef TTY
	if (Ow.tty) return(rendermsg(msgtxt));
#endif
	ps_rendermsg(msgtxt);
	return 0;
}

int ow_appendmsg(old, new)
	char *old, *new;
{
	/* we could get 'old' from the window but since it's handy
	here on the c side we might as well use it */

#ifdef TTY
	if (Ow.tty) return(appendmsg(old, new));
#endif
	ps_appendmsg(old, new);
	return 0;
}

#define DBG
#ifdef DBG
static int SHOW_OUTPUT = -1;
sh(o, s, l, c)
    int     o;
    char   *s;
    int     l, c;
{
    putchar(o);
    while (l > 0)
    {
	putchar(*s++);
	l--;
    }
    putchar(c);
    return (0);
}

#define Print if (SHOW_OUTPUT) printf
#define SH if (SHOW_OUTPUT) sh
#else
#define Print
#define SH
#endif

int
ttywrite(buf, len)
    register char *buf;
    register int len;
{

#define binc() buf++,len--
#define flushstr() {\
    if (string) {\
	SH('(', string, buf-string, ')');\
	ps_ST(string, buf-string);\
	string = (char *)0;\
    }\
}

#ifdef DBG
    if (SHOW_OUTPUT < 0)
    {
	extern char *getenv();
	SHOW_OUTPUT = (getenv("SHOW_OUTPUT") == (char *) 0) ? 0 : 1;
    }
#endif

    /* this is where we bury all the smarts for display */
    if (!Ow.tty)
    {

#define Return(x) {\
	    if (cursor_disabled)\
	    {\
		ps_enable_cursor();\
		Print("{{true /EC C S }}\n");\
	    }\
	    ps_flush_PostScript();\
	    Print("------------------------------------------\n");\
	    return(x);\
	}

#define ErrReturn(x) {\
	    msg("Garbled output, is this a binary file?");\
	    Print("Garbled output, is this a binary file?");\
	    Return(x);\
	}

	char   *string = (char *) 0;
	int     rval = len;
	int     cursor_disabled = 0;

	wire_SetCurrent(Ow.mainWire);

	/*
	   if we have a fair chunk of stuff in our buffer, then just turn off
	   the cursor completely till we are all done then turn it back on at
	   the end. The turning on is done in 'Return'
	*/

	if (len > 30)
	{
	    cursor_disabled++;
	    Print("{{false /EC C S }}\n");
	    ps_disable_cursor();
	}

	while (len > 0)
	{
	    switch (*buf)
	    {
	    case PS_ESC:
		flushstr();
		{
		    register char *p;
		    binc();
		    p = buf;
		    while (*buf != PS_ESC)
		    {
			if (!*buf)
			    ErrReturn(rval);
			binc();
		    }
		    ps_pswrite(p, buf - p);
		    Print("\n");
		    SH('{', p, buf - p, '}');
		    Print("\n");
		}
		binc();
		break;

	    default:
		switch (*buf)
		{
		case '\r':
		    flushstr();
		    if (*(buf + 1) == '\n')
		    {
			Print("<crnl>\n");
			ps_CrNl();
			binc();
		    }
		    else
		    {
			Print("<cr>");
			ps_Cr();
		    }
		    break;
		case '\n':
		    flushstr();
		    if (*(buf + 1) == '\r')
		    {
			Print("<crnl>\n");
			ps_CrNl();
			binc();
		    }
		    else
		    {
			Print("<nl>\n");
			ps_Nl();
		    }
		    break;

		    /* move up one line */
		case '\0':
		    /* some binary file ?? , punt */
		    ErrReturn(rval);

		default:
		    if (!string)
			string = buf;
		    break;
		}
		binc();
		break;
	    }
	}
	flushstr();
	Return(rval);

#undef Return
#undef ErrReturn
    }
#ifdef TTY
    return (write(1, buf, len));
#else
    return -1;
#endif
}

int
ttyread(buf, len)
    char   *buf;
    int     len;
{
    int     rlen = 0;

#ifdef TTY
    if (Ow.tty) return read(0, buf, len);
#endif

    Ow.keyFromNews = -1;
    wire_EnterNotifier();
    if (Ow.keyFromNews < 0)
	return -1;
    else
    {
	*buf++ = Ow.keyFromNews;
	rlen++;
    }
    return rlen;
}

void
miscProc(tag, data)
    int     tag;
    caddr_t *data;
{
    return;
}

ow_vi()
{
    extern char *getenv();
    if (Ow.tty)
    {
	vi();
	return 0;
    }
    if (getenv("ELVIS_DEBUG") == (char *) 0 && Ow.background)
	background();
    vi();
    return;
}

ow_ex()
{
    ex();
    return 0;
}

int
ow_suspend_curses()
{
#ifdef TTY
    if (Ow.tty)
    {
	suspend_curses();
	return 0;
    }
#endif
#ifndef NO_CURSORSHAPE
    if (has_CQ)
    {
	do_CQ();
    }
#endif
    return 0;
}

int
ow_resume_curses(quietly)
    int     quietly;
{
    /* If we're supposed to quit quietly, then we're done */
    void    (*proc) ();

# ifdef TTY
    if (Ow.tty)
    {
	resume_curses(quietly);
	return 0;
    }
# endif

    if (quietly)
	return;
    proc = signal(SIGINT, SIG_IGN);
    {
	move(LINES - 1, 0);
	do_SO();
	qaddstr("[Press <RETURN> to continue]");
	do_SE();
	refresh();
	ttyread(kbuf, 20);	/* in RAW mode, so <20 is very likely */
	if (kbuf[0] == ':')
	{
	    mode = MODE_COLON;
	    addch('\n');
	    refresh();
	}
	else
	{
	    mode = MODE_VI;
	    redraw(MARK_UNSET, FALSE);
	}
	exwrote = FALSE;
    }
    signal(SIGINT, proc);
    return 0;
}

#define register_tag(tag_name, tag_value, tag_proc, proc_data)\
    wire_RegisterTag(tag_value, tag_proc, proc_data);\
    ps_RegisterTag(tag_name, tag_value);

int
ow_initscr()
{
    extern char *getenv();
    extern void starttcap();
    char *server;

#ifdef TTY
    if (Ow.tty)
    {
	initscr();
	return 0;
    }
#endif

    if (!(server = getenv("NEWSSERVER"))) 
    {
	server = getenv("DISPLAY");
	if (!server || 
	    !strncmp(server, "unix", strlen("unix")) || 
	    !strncmp(server, "unix", strlen("UNIX")))
	    server = "localhost";
    }

    Ow.mainWire = wire_Open(server);
    if (Ow.mainWire == wire_INVALID_WIRE)
    {
	/* wire_Perror("elvis"); */
	Ow.tty = 1;
	initscr();
	return 0;
    }
    else
    {
	static int firstime = 1;
	if (firstime)
	{
	    wire_ReserveTags(100);
	    wire_AllocateNamedTags(NewsTags);
	    register_tag("ElvisDestroyTag", ElvisDestroyTag, destroyProc, NULL);
	    register_tag("ElvisKeyTag", ElvisKeyTag, keyProc, NULL);
	    register_tag("ElvisMiscTag", ElvisMiscTag, miscProc, NULL);
	    register_tag("ElvisResizeTag", ElvisResizeTag, resizeProc, NULL);
	    register_tag("ElvisDamageTag", ElvisDamageTag, damageProc, NULL);

	    wire_SetCurrent(Ow.mainWire);
	    ps_RunFile(RUNFILE);
	    ps_flush_PostScript();

#ifdef USE_XV_SELECTION
	    /* so we can paste from the Xview shelf selection */
	    ow_xv_seln_init();
#endif
	}
	else
	    firstime = !firstime;
	stdscr = kbuf;
	starttcap();
	return 0;
    }
}

int
ow_getsize(sig)
    int     sig;
{
    extern char o_columns[], o_lines[];

#ifdef TTY
    if (Ow.tty)
	return getsize(sig);
#endif

    /* copy the new values into Elvis' options */
    *o_columns = COLS = Ow.wCOLS;
    *o_lines = LINES = Ow.wLINES;
    return 0;
}

/* termcap */

/*ARGSUSED*/
int
ow_tgetent(bp, name)
    char   *bp;	/* buffer for entry */
    char   *name;	/* name of the entry */
{
#ifdef TTY
    if (Ow.tty) return(tgetent(bp,name));
#endif

    *bp = '\0';
    return 1;
}

#define CAP(str) CAP2((str)[0], (str)[1])
#define CAP2(a,b) (((a) << 8) + ((b) & 0xff))

int
ow_tgetnum(id)
    char   *id;
{
#ifdef TTY
    if (Ow.tty) return(tgetnum(id));
#endif

    switch (CAP(id))
    {
	/* # lines of lines on screen or page */
    case CAP2('l', 'i'):
	return 44;
	/* # of columns in a line */
    case CAP2('c', 'o'):
	return 80;
	/* # of garbage chars left by so or se */
    case CAP2('s', 'g'):
	return 0;
	/* # of garbage chars left by us or ue */
    case CAP2('u', 'g'):
	return 0;
    default:
	return -1;
    }
}

int
ow_tgetflag(id)
    char   *id;
{
#ifdef TTY
    if (Ow.tty) return(tgetflag(id));
#endif

    switch (CAP(id))
    {
	/* terminal has **no** automatic margins */
    case CAP2('a', 'm'):
	return 0;
	/* terminal has backspace capability */
    case CAP2('b', 's'):
	return 1;
	/* safe to move while in insert mode */
    case CAP2('m', 'i'):
	return 1;
    default:
	return 0;
    }
}

#define VAL2(v,a)      (a)
#define VAL3(a,b,c) (a)

char   *
ow_tgetstr(id, bp)
    char   *id;
    char  **bp;	/* pointer to pointer to buffer - ignored */
{
#ifdef TTY
    extern char *tgetstr();
    if (Ow.tty) return(tgetstr(id,bp));
#endif

/* send method id to 'C', 'S' is a shorthand for 'send' */
#define RETURN(FIRSTLETTER,SECONDLETTER) {\
    static char tp[] = {\
	PS_ESC,\
	    '/', FIRSTLETTER, SECONDLETTER, ' ',\
	    'C',' ','S',' ',\
	PS_ESC\
    };\
    return tp;\
}

    switch (CAP(id))
    {
	/* clear to end of line */
    case CAP2('c', 'e'):
	RETURN('c', 'e');

	/* clear to end of screen and home cursor */
    case CAP2('c', 'l'):
	RETURN('c', 'l');

	/* scroll text down */
    case CAP2('s', 'r'):
	RETURN('s', 'r');

	/* cursor invisible */
    case CAP2('v', 'i'):
	RETURN('v', 'i');

	/* cursor visible */
    case CAP2('v', 'e'):
	RETURN('v', 'e');

/*-
    case CAP2('a', 'l'):
	RETURN('a', 'l');
    case CAP2('d', 'l'):
       RETURN('d', 'l');
*/
	/* start bold */
    case CAP2('s', 'o'):
	RETURN('s', 'o');

	/* end bold */
    case CAP2('s', 'e'):
	RETURN('s', 'e');

	/* start underline */
    case CAP2('u', 's'):
	RETURN('u', 's');
	/* end underline */
    case CAP2('u', 'e'):
	RETURN('u', 'e');

    /* ------ cursor style change commands --------*/
    /* change to normal cursor */
    case CAP2('c', 'Q'):
	RETURN('c', 'Q');
    /* change to ex command entry cursor */
    case CAP2('c', 'X'):
	RETURN('c', 'X');
    /* change to vi command mode cursor */
    case CAP2('c', 'V'):
	RETURN('c', 'V');
    /* change to vi input mode cursor */
    case CAP2('c', 'I'):
	RETURN('c', 'I');
    /* change to vi replace mode cursor */
    case CAP2('c', 'R'):
	RETURN('c', 'R');

#if 0
    case CAP2('V', 'B'):
	RETURN('V', 'B');
    case CAP2('V', 'b'):
	RETURN('V', 'b');

    case CAP2('d', 'o'):
	RETURN('d', 'o');
    case CAP2('n', 'd'):
	RETURN('n', 'd');

    case CAP2('t', 'i'):
	RETURN('t', 'i');
    case CAP2('t', 'e'):
	return "";

    case CAP2('k', 'u'):
	return "#H";
    case CAP2('k', 'd'):
	return "#P";
    case CAP2('k', 'l'):
	return "#K";
    case CAP2('k', 'r'):
	return "#M";
    case CAP2('H', 'M'):
	return "#G";
    case CAP2('E', 'N'):
	return "#O";
    case CAP2('P', 'U'):
	return "#I";
    case CAP2('P', 'D'):
#endif

	/* move up one line */
    case CAP2('u', 'p'):
	RETURN('u', 'p');

	/* backspace */
    case CAP2('b', 'c'):
	RETURN('b', 'c');

	/* cursor motion */
    case CAP2('c', 'm'):
	{
	    static char *tp = "\200%d %d /cm C S \200";
	    return tp;
	}

    default:
	return (char *) 0;
    }
}

/*ARGSUSED*/
char   *
ow_tgoto(cm, destcol, destrow)
    char   *cm;	/* cursor movement string -- ignored */
    int     destcol;	/* destination column, 0 - 79 */
    int     destrow;	/* destination row, 0 - 24 */
{
    static char buf[30];
#ifdef TTY
    extern char *tgoto();
    if (Ow.tty) return (tgoto(cm, destcol, destrow));
#endif

    sprintf(buf, "\200%d %d /cm C S \200", destcol, destrow);
    return buf;
}

    /* declaring cp a register makes gcc blow up ?? ! ?? */
void
ow_tputs(cp, affcnt, outfn)
    char *cp;
    int     affcnt;	/* number of affected lines -- ignored */
    int     (*outfn) ();	/* the output function */
{
#ifdef TTY
    if (Ow.tty) { tputs(cp,affcnt,outfn); return; };
#endif

    while (*cp != '\0')
    {
	(*outfn)(*cp);
	cp++;
    }
    return;
}


int
ow_scrolldown(l, y, x)
    long    l;
    int     y, x;
{
    extern void drawtext();
    REG char *text;
    char    buf[80];

#ifdef TTY
    if (Ow.tty) return(scrolldown(l, y, x));
#endif

    /*- 
	do ...
	    - a move(y, x)
	    - topline-l do_SR()'s 
	    - a move(topline-l-1, 0);
    */
    sprintf( buf, "\200 %d %d /cm C S %d /SR C S %d %d /cm C S \200", 
	     y, x,
	     (topline-l),
	     (topline-1)-1, 0 );

    qaddstr(buf);

    move((topline - l) - 1, 0);
    while (l < topline)
    {
	topline--;
	text = fetchline(topline);
	drawtext(text, FALSE);
	do_UP();
	do_UP();
    }
    move(LINES - 1, 0);
    clrtoeol();
    return 0;
}

int 
ow_scrollup(l, y, x)
    long l;
    int y,x;
{
	REG char *text;
	char buf[80];
	
#ifdef TTY
	if (Ow.tty) return(scrollup(l, y, x));
#endif

	move(y,x);
	clrtoeol();
	sprintf(buf, "\200 %d /RSR C S \200", l-(botline));
	qaddstr(buf);
	move(y - (l-botline), 0);
	while (l > botline)
	{
		topline++; /* <-- also adjusts botline */
		text = fetchline(botline);
		drawtext(text, FALSE);
	}
	return 0;
}


/*+
    X11/NeWS specific flags:

    -tty 
	
	Force elvis to use the plain termcap interface and not the
	window interface. elvis will revert to the termcap interface
	automatically if it cannot connect to the X11/NeWS server.

    -bkg
	
	Have elvis run in the background, disassociated from the parent
	process. If "elvis" is the name of this program this is the
	default.

    +bkg

	Force elvis to run in the forground process. If the name of the
	program is not elvis ("vi" for example). then this is the default.

-*/


int
ow_customflags(argv, argc_p)
    char *argv[];
    int *argc_p;
{
    int x, e;
#   if MALLOC_DEBUG
     malloc_debug(MALLOC_DEBUG);
#   endif

#   define eq(a,b) (!strcmp(a,b))
#   define skip() x++
#   define shift() \
    {\
	int i;\
	for (e = *argc_p, i=x; i<e; i++)\
	    argv[i] = argv[i+1];\
	(*argc_p)--;\
    }
    ow_data_init(&Ow);
    
#   ifndef NO_AUTO_BACKGROUND
    {
	extern char *strrchr();
	char *p  = strchr(argv[0], '/');
	p = p ? p : argv[0];
	if (eq(argv[0], "elvis"))
	    Ow.background = 1;
    }
#   endif


    for(x=1; x<*argc_p;)
    {
	if (*argv[x] != '-' && *argv[x] != '+')
	    skip();
	else
	{
	    if (eq(argv[x], "-bkg"))
	    {
		Ow.background = 1;
		shift();
	    }
	    else if (eq(argv[x], "+bkg"))
	    {
		Ow.background = 0;
		shift();
	    }
	    else if (eq(argv[x], "-tty"))
	    {
		Ow.tty = 1;
		shift();
	    }
	    else
	    {
		skip();
	    }
	}
    }
    return 0;

#   undef eq
#   undef skip
#   undef shift
}

#endif

#if BSD
#include <sys/file.h>
#include <sgtty.h>
int background()
{
    int     fd, p;
    p = fork();
    switch (p)
    {
    case -1:
	perror("fork");
	exit(1);
    default:
	exit(0);
    case 0:
	break;
    }
    (void) setpgrp(0, getpid());
    if ((fd = open("/dev/tty", O_RDWR)) >= 0)
    {
	ioctl(fd, TIOCNOTTY, 0);
	close(fd);
    }
    return 0;
}
#endif
SHAR_EOF
fi # end of overwriting check
if test -f 'ow_xv.c'
then
	echo shar: will not over-write existing file "'ow_xv.c'"
else
cat << \SHAR_EOF > 'ow_xv.c'
/* xview stuff for X11/NeWS version of elvis */
#include "wconfig.h"
#include "vi.h"

#undef WINDOW /* yuck, curses.h has a WINDOW too */
#include <xview/xview.h>
#include <xview/seln.h>

#ifdef USE_XV_SELECTION

/* xview selection support for elvis */


#define FIRST_BUFFER 0
#define NOT_FIRST_BUFFER 1
static Xv_Server server;
static Seln_rank seln_type = SELN_SHELF;
static char *selnbuf = (char *)0;

static Seln_result
ow_xv_seln_read_proc(response)
Seln_request *response;
{
    char *reply; /* pointer to the data in the response recv'd */
    long len; /* total number of bytes in the seln */
    static long have_bytes;

    if (*response->requester.context == FIRST_BUFFER)
    {
	reply = (response->data) + sizeof(SELN_REQ_BYTESIZE);

	/* extract length of seln */
	len = *(long *)reply;
	reply += sizeof(long);

	/* malloc up buf to throw seln into */
	if (selnbuf)
	    free(selnbuf);
	selnbuf = (char *)malloc(len+1);
	if (!selnbuf)
	{
	    perror("malloc failed");
	    return(SELN_FAILED);
	}
	*selnbuf = '\0';
	have_bytes = 0;

	/* move past attribute */
	reply += sizeof(SELN_REQ_CONTENTS_ASCII);

	*response->requester.context = NOT_FIRST_BUFFER;
    }
    else
	reply = response->data;

    /* copy data to selnbuf from tmp buffer */
    len = strlen(reply);
    bcopy(reply, &selnbuf[have_bytes], len+1);
    have_bytes += len;

    return SELN_SUCCESS;
}

int
ow_xv_seln_init(display_str)
    char *display_str;
{
    server = (Xv_Server)xv_create(NULL, SERVER,  XV_NAME, display_str, NULL);
    return 0;
}

int
ow_get_xv_seln()
{
    Seln_holder holder;
    Seln_result result;
    Seln_request *response;
    char context = FIRST_BUFFER;
    if (Ow.tty)
	result = SELN_FAILED;
    else
    {
	holder = selection_inquire(server, seln_type);
	result = selection_query(
		    server, 
		    &holder, 
		    ow_xv_seln_read_proc,
		    &context,
		    SELN_REQ_BYTESIZE,		NULL,
		    SELN_REQ_CONTENTS_ASCII,	NULL,
    		NULL);
    }
    if (result == SELN_FAILED) 
    {
	msg("could not get xview shelf selection");
	return -1;
    }
    return 0;
}

int
ow_xv_windowpaste(cb_name, at)
    char cb_name;
    MARK at;
{
    switch((int)cb_name)
    {
    case 'x':
	if (ow_get_xv_seln() == 0)
	{
	    ChangeText
	    {
		add(at, selnbuf);
	    }
	    free(selnbuf);
	    selnbuf = (char *)0;
	}
	return 0;
    default:
	return -1;
    }
}

#endif
SHAR_EOF
fi # end of overwriting check
if test -f 'wconfig.h'
then
	echo shar: will not over-write existing file "'wconfig.h'"
else
cat << \SHAR_EOF > 'wconfig.h'
/* wconfig.h , window related configuration header file */

/*
   defining macros in this way allows us to fall back on using the dumb
   terminal functions if no window system is available at runtime

   the convention used is to make the macro the same name as the
   original dumb terminal name with the leading letter 'capped

   -MCH 
*/

#ifndef _elvis_w_macs_
#define _elvis_w_macs_ 1

#include "config.h"
#include <NeWS/wire.h>

#if OPENWINDOWS /* || SomeOtherWindowSys || ... */ /* using a window system */

#if OPENWINDOWS

#define USE_XV_SELECTION 1

/* keep all the flags in a single structure to make it easier to
convert to threads later */

struct ow_data {
    /* flags */
    int background;
    int tty;
    int wLINES;
    int wCOLS;
    
    /* */
    wire_Wire mainWire;
    int keyFromNews;
};
#define ow_data_init(op) {\
    (op)->background 		= 0;\
    (op)->tty 			= 0;\
    (op)->wLINES		= 44;\
    (op)->wCOLS			= 80;\
    (op)->mainWire 		= (wire_Wire) NULL;\
    (op)->keyFromNews		= -1;\
}
extern struct ow_data Ow;

/* termcap stuff */
#define Tgetent ow_tgetent
#define Tputs   ow_tputs
#define Tgetnum ow_tgetnum
#define Tgoto   ow_tgoto
#define Tgetstr ow_tgetstr
#define Tgetflag ow_tgetflag

#define Customflags(av, ac_p)	ow_customflags(av, ac_p)
#define Vi()			ow_vi()
#define Ex()			ow_ex()
#define Initscr()		ow_initscr()
#define Beep()			ow_beep()
#define Rendermsg(msg)		ow_rendermsg(msg);
#define Appendmsg(old,new)	ow_appendmsg(old,new);
#define FlushDisplay()		ow_flushdisplay();
#define Getsize			ow_getsize
#define Resume_curses(quietly)  ow_resume_curses((quietly))
#define Suspend_curses()        ow_suspend_curses()
#define Tmpstart(fname)		ow_tmpstart(fname)
#define Scrolldown(l,y,x)	ow_scrolldown(l,y,x)
#define Scrollup(l,y,x)		ow_scrollup(l,y,x)
#if USE_XV_SELECTION
# define Iswindowpastebuf(cb)	(cb == 'x')
# define Windowpaste(cb,at)	ow_xv_windowpaste(cb,at)
#else
# define Iswindowpastebuf(cb)	(0)
# define Windowpaste(cb,at)	(msg("No window mgr paste available"), -1)
#endif
#endif

#else

/* no window system , just use the dumb terminal functions */

/* termcap stuff */
#define Tgetent tgetent
#define Tputs   tputs
#define Tgetnum tgetnum
#define Tgoto   tgoto
#define Tgetstr tgetstr
#define Tgetflag tgetflag
 
#define Customflags(av, ac_p)	/* no-op */
#define Vi()			vi()
#define Ex()			ex()
#define Initscr()		initscr()
#define Beep()			beep()
#define Rendermsg(msg)		rendermsg(msg);
#define Appendmsg(old,new)	appendmsg(old,new);
#define FlushDisplay()
#define Getsize			getsize
#define Resume_curses(quietly)  resume_curses((quietly))
#define Suspend_curses()        suspend_curses()
#define Tmpstart(fname)		tmpstart(fname)
#define Scrolldown(l,y,x)	scrolldown(l,y,x)
#define Scrollup(l,y,x)		scrollup(l,y,x)
#define Iswindowpastebuf(cb)	(0)
#define Windowpaste(cb,at)	(msg("No window mgr. to paste from"), -1)

#endif

#endif
SHAR_EOF
fi # end of overwriting check
if test -f 'CHANGE_NOTES'
then
	echo shar: will not over-write existing file "'CHANGE_NOTES'"
else
cat << \SHAR_EOF > 'CHANGE_NOTES'
Mike Hoegeman's change log, this is not gospel of every single change i made

Dec  7 00:00 - date of my copy of elvis version 1.4
***BUG***
-rw-------  1 mh          16474 Dec 20 20:39 input.c
-rw-------  1 mh          13527 Dec 20 20:47 vcmd.c
    added indentref arg to input(). this is so autoindent works right
    with the 'O' command. I don't know about anybody else but for me
    this *has* to work like the standard vi since i use it constantly.

***BUG***
-rw-------  1 mh          20109 Dec 20 23:14 redraw.c
    A bug (i put a hack in to work around it.
           see the /* HACK */ comment)

    To exercise the bug do the following.  

	- move cursor to a line not at the top or bottom of the screen
	- make a change (like add a couples of X's at the beginning)
	- hit '-' to move the cursor up one line
	- hit 'dd' (it's more obvious if the line you dd is blank)

    notice that the line the cursor is on is displaying the old deleted line
    
    it looks like smartlno is not getting readjusted properly 

-rw-r--r--  1 mh           7618 Dec 20 10:01 elvis.ps
    Various futzing to get ps file closer to using scalable fonts 
    misc minor tweaks
-rw-r--r--  1 mh           1652 Dec 19 13:38 elvismug.im1
    elvismug.im1 is a sun raster format file that has a
    rather grainy picture of elvis. will use this for icon image when i get
    around to it. it would be nice to get a better picture. this one came
    from the pbm package bitmaps. It might look pretty good in
    color/grayscale.
-rw-r--r--  1 mh           1015 Dec 19 13:03 elvis_cps.cps
    elvis_cps.cps file mod to get filename on icon.
    

***BUG***
-rw-r--r--  1 mh          25955 Dec 20 17:25 Makefile
-rw-r--r--  1 mh           2525 Dec 20 17:23 tnamerec.c
-rw-------  1 mh           5248 Dec 20 17:10 virec.c
-rw-------  1 mh           8195 Jan  1 15:50 config.h
-rw-------  1 mh          12876 Dec 20 13:00 tmp.c
    Modified tmp.c virec.c config.h and added module tnamerec.c to
    allow editing multiple instances of the same file at once. May want
    to just put tnamerec.c into virec.c since that is the only place it
    is used. The temp file name now has the pid of the process added on
    to the end with a '-' in front of it (see TMPNAME in config.h).
    Also changed the tmpfile prefix from elv to El so that a filename
    would still fit in 14 chars (for sysV). see tnamerec.c for how
    virec handles this change.  Added tnamerec to Makefile of course.
    note that this won't work for DOG, etc.. but there are suitable
    ifdefs to make it backwards compatible for those unfortunates.

-rw-------  1 mh          20089 Dec 20 22:23 redraw.c
    replaced constant 5 in nudgecursor() with macro NUDGE_COST
    because a move is always cheaper in PostScript than a string
    display. this will also allow other ports to define their
    NUDGE_COST's. should this be put in (w)config.h ??

-rw-------  1 mh           8026 Dec 21 12:56 main.c
-rw-r--r--  1 mh           2353 Dec 21 15:06 wconfig.h
-rw-------  1 mh          13569 Dec 21 15:05 ow.c
    Added Customflags() macro to main(), this is to allow custom
    version of elvis to process any  version specific flags without
    having to clutter up the standard elvis code with ifdefs's. in
    wconfig.h the macro is defined to a no-op for the standard tty
    version of elvis. for the openwindows version Customflags() is
    defined to be ow_customflags in ow.c.  ow_customflags() is a good
    reference for someone wanting to make their own Customflags()
    function.

-rw-------  1 mh          13569 Dec 21 15:05 ow.c
-rw-------  1 mh          20227 Dec 21 14:57 redraw.c
-rw-r--r--  1 mh           2353 Dec 21 15:06 wconfig.h
    Made final fixes to ow termcap modules to switch to using the
    standard termcap functions if no server is running the Ow.tty
    global determines which display style to use.  
    
    Rearranged various ow related globals into a single structure so
    that conversion to threads will be easier. something similar will
    have to be done for the regular elvis globals to make it
    threadable.

-rw-------  1 mh           8026 Dec 30 21:52 main.c
    Changed a resume_curses() call in trapint() to the Resume_curses()
    macro front end. Somehow I missed this before. Without this fix
    your parent shell window will wack out if type ctrl C in it after
    starting an elvis window that is not backgrounded.

-rw-r--r--  1 mh           7852 Jan  1 14:47 elvis.ps
    Fixed a bug in the /RSR method of ElvisCanvas that left it's
    argument on the stack, this (eventually) would cause a stack
    overflow if you scrolled around in a file long enough

-rw-------  1 mh          15041 Jan  1 18:18 ow.c
-rw-------  1 mh          17635 Jan  1 18:23 tio.c
-rw-r--r--  1 mh           2533 Jan  1 18:21 wconfig.h
    isolated out the display specific parts of displaying a string
    on the msg line into the Rendermsg and Appendmsg macro's (in wconfig.h )
	:: for the standard termcap interface they are rendermsg
	and appendmsg ( in tio.c )
	:: for the OPENWINDOWS version as ow_rendermsg and ow_appendmsg
	now in ow.c

-rw-------  1 mh          16672 Jan  1 23:20 input.c
	Replaced beep()'s with Beep()'s. this would mess up the display
	in subtle ways by trying to render  a ^G on the display when
	using the display version

-rw-r--r--  1 mh           8580 Jan  1 23:06 elvis.ps
-rw-------  1 mh          15544 Jan  1 20:29 ow.c
	Put in the cQ cX cV cI cR capabilities for the OPENWINDOWS
	version of elvis. Now the cursor changes shape when you
	switch from insert mode to command mode to the :ex command
	line

-rw-r--r--  1 mh           8627 Jan  2 20:04 elvis.ps
	Fixed bug that did not show up until mutiple cursor types were
	implemented. The ST did not hide the cursor before it started
	drawing text. this was OK with a simple block cursor because
	the text always blanked over the of the old cursor completely.

***BUG***
-rw-------  1 mh          16880 Jan  4 00:31 input.c
	Added some code the end of the interactive section of the input()
	function to make autoindent work more like the original vi.
	This is necessary  really so that things like piping sections
	of text thru fmt have a hope of working the way you would
	expect.  The fix basically un autoindents the last line if it
	ended up being a line that was all white space.

-rw-------  1 mh          13500 Jan 17 23:59 cut.c
-rw-r--r--  1 mh          26261 Jan 17 21:38 Makefile
-rw-------  1 mh           8244 Jan 17 22:02 config.h
-rw-------  1 mh          15658 Jan 17 21:47 ow.c
-rw-r--r--  1 mh           2140 Jan 17 21:55 ow_xv.c
-rw-r--r--  1 mh           2561 Jan 17 21:47 wconfig.h
	Added code to support pasting from the the xview shelf the
	buffer to paste from is buffer 'x'. cut will happen some day but
	that is more work. see Iswindowpastebuf() and Windowpaste() macros
	in cut.c for what the exact changes are
SHAR_EOF
fi # end of overwriting check
#	End of shell archive
exit 0