[comp.os.minix] Atari ST GCC Update 2 of 10

bammi@dsrgsun.ces.cwru.edu (Jwahar R. Bammi) (11/28/88)

#!/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:
#	longname.c
#	move.c
#	mvprintw.c
#	mvscanw.c
#	mvwin.c
#	newwin.c
#	overlay.c
#	overwrite.c
#	printw.c
#	putchar.c
#	refresh.c
#	scanw.c
#	scroll.c
#	standout.c
#	toucholap.c
#	touchwin.c
#	tstp.c
#	unctrl.c
# This archive created: Thu Oct 27 21:16:05 1988
# By:	Jwahar R. Bammi(Case Western Reserve University)
#  Uucp:	 {decvax,sun,att}!cwjcc!dsrgsun!bammi
# Csnet:	 bammi@dsrgsun.ces.CWRU.edu
#  Arpa:	 bammi@dsrgsun.ces.CWRU.edu
#
export PATH; PATH=/bin:$PATH
echo shar: extracting "'longname.c'" '(657 characters)'
if test -f 'longname.c'
then
	echo shar: over-writing existing file "'longname.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'longname.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)longname.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X# define	reg	register
X
X/*
X *	This routine fills in "def" with the long name of the terminal.
X *
X */
Xchar *
Xlongname(bp, def)
Xreg char	*bp, *def; {
X
X	reg char	*cp;
X
X	while (*bp && *bp != ':' && *bp != '|')
X		bp++;
X	if (*bp == '|') {
X		bp++;
X		cp = def;
X		while (*bp && *bp != ':' && *bp != '|')
X			*cp++ = *bp++;
X		*cp = 0;
X	}
X	return def;
X}
SHAR_EOF
if test 657 -ne "`wc -c 'longname.c'`"
then
	echo shar: error transmitting "'longname.c'" '(should have been 657 characters)'
fi
echo shar: extracting "'move.c'" '(655 characters)'
if test -f 'move.c'
then
	echo shar: over-writing existing file "'move.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'move.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)move.c	5.2 (Berkeley) 10/8/85";
X#endif not lint
X
X# include	"curses.ext"
X
X/*
X *	This routine moves the cursor to the given point
X *
X */
Xwmove(win, y, x)
Xreg WINDOW	*win;
Xreg int		y, x; {
X
X# ifdef DEBUG
X	fprintf(outf, "MOVE to (%d, %d)\n", y, x);
X# endif
X	if (x < 0 || y < 0)
X		return ERR;
X	if (x >= win->_maxx || y >= win->_maxy)
X		return ERR;
X	win->_curx = x;
X	win->_cury = y;
X	return OK;
X}
SHAR_EOF
if test 655 -ne "`wc -c 'move.c'`"
then
	echo shar: error transmitting "'move.c'" '(should have been 655 characters)'
fi
echo shar: extracting "'mvprintw.c'" '(1256 characters)'
if test -f 'mvprintw.c'
then
	echo shar: over-writing existing file "'mvprintw.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'mvprintw.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X/*
X * Implementation using varargs and vsprintf by John Gilmore.
X * My changes are in the public domain.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)mvprintw.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X# include	"curses.ext"
X# include	<varargs.h>
X
X/*
X * implement the mvprintw commands.  Due to the variable number of
X * arguments, they cannot be macros.  Sigh....
X *
X */
Xmvprintw(va_alist)
Xva_dcl {
X	int y, x;
X	va_list args;
X	WINDOW	*win;
X	char *fmt;
X	int ret;
X
X	va_start(args);
X	y = va_arg(args, int);
X	x = va_arg(args, int);
X	if (move(y, x) != OK) {
X		va_end(args);
X		return ERR;
X	}
X
X	fmt = va_arg(args, char *);
X
X	ret = _sprintw(stdscr, fmt, &args);
X	va_end(args);
X	return ret;
X}
X
Xmvwprintw(va_alist)
Xva_dcl {
X	int y, x;
X	va_list args;
X	WINDOW	*win;
X	char *fmt;
X	int ret;
X
X	va_start(args);
X	win = va_arg(args, WINDOW *);
X	y = va_arg(args, int);
X	x = va_arg(args, int);
X	if (wmove(win, y, x) != OK) {
X		va_end(args);
X		return ERR;
X	}
X
X	fmt = va_arg(args, char *);
X
X	ret = _sprintw(win, fmt, &args);
X	va_end(args);
X	return ret;
X}
SHAR_EOF
if test 1256 -ne "`wc -c 'mvprintw.c'`"
then
	echo shar: error transmitting "'mvprintw.c'" '(should have been 1256 characters)'
fi
echo shar: extracting "'mvscanw.c'" '(758 characters)'
if test -f 'mvscanw.c'
then
	echo shar: over-writing existing file "'mvscanw.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'mvscanw.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)mvscanw.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X# include	"curses.ext"
X
X/*
X * implement the mvscanw commands.  Due to the variable number of
X * arguments, they cannot be macros.  Another sigh....
X *
X */
X
Xmvscanw(y, x, fmt, args)
Xreg int		y, x;
Xchar		*fmt;
Xint		args; {
X
X	return move(y, x) == OK ? _sscans(stdscr, fmt, &args) : ERR;
X}
X
Xmvwscanw(win, y, x, fmt, args)
Xreg WINDOW	*win;
Xreg int		y, x;
Xchar		*fmt;
Xint		args; {
X
X	return wmove(win, y, x) == OK ? _sscans(win, fmt, &args) : ERR;
X}
SHAR_EOF
if test 758 -ne "`wc -c 'mvscanw.c'`"
then
	echo shar: error transmitting "'mvscanw.c'" '(should have been 758 characters)'
fi
echo shar: extracting "'mvwin.c'" '(1054 characters)'
if test -f 'mvwin.c'
then
	echo shar: over-writing existing file "'mvwin.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'mvwin.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)mvwin.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X# include	"curses.ext"
X
X/*
X * relocate the starting position of a window
X *
X */
X
Xmvwin(win, by, bx)
Xreg WINDOW	*win;
Xreg int		by, bx; {
X
X	register WINDOW	*orig;
X	register int	dy, dx;
X
X	if (by + win->_maxy > LINES || bx + win->_maxx > COLS)
X		return ERR;
X	dy = by - win->_begy;
X	dx = bx - win->_begx;
X	orig = win->_orig;
X	if (orig == NULL) {
X		orig = win;
X		do {
X			win->_begy += dy;
X			win->_begx += dx;
X			_swflags_(win);
X			win = win->_nextp;
X		} while (win != orig);
X	}
X	else {
X		if (by < orig->_begy || win->_maxy + dy > orig->_maxy)
X			return ERR;
X		if (bx < orig->_begx || win->_maxx + dx > orig->_maxx)
X			return ERR;
X		win->_begy = by;
X		win->_begx = bx;
X		_swflags_(win);
X		_set_subwin_(orig, win);
X	}
X	touchwin(win);
X	return OK;
X}
SHAR_EOF
if test 1054 -ne "`wc -c 'mvwin.c'`"
then
	echo shar: error transmitting "'mvwin.c'" '(should have been 1054 characters)'
fi
echo shar: extracting "'newwin.c'" '(4709 characters)'
if test -f 'newwin.c'
then
	echo shar: over-writing existing file "'newwin.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'newwin.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)newwin.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X/*
X * allocate space for and set up defaults for a new window
X *
X */
X
X# include	"curses.ext"
X
Xchar	*malloc();
X
X# define	SMALLOC	(short *) malloc
X
Xstatic WINDOW	*makenew();
X
X# undef		nl	/* don't need it here, and it interferes	*/
X
XWINDOW *
Xnewwin(num_lines, num_cols, begy, begx)
Xint	num_lines, num_cols, begy, begx;
X{
X	reg WINDOW	*win;
X	reg char	*sp;
X	reg int		i, by, bx, nl, nc;
X	reg int		j;
X
X	by = begy;
X	bx = begx;
X	nl = num_lines;
X	nc = num_cols;
X
X	if (nl == 0)
X		nl = LINES - by;
X	if (nc == 0)
X		nc = COLS - bx;
X	if ((win = makenew(nl, nc, by, bx)) == NULL)
X		return ERR;
X	if ((win->_firstch = SMALLOC(nl * sizeof win->_firstch[0])) == NULL) {
X		free(win->_y);
X		free(win);
X		return NULL;
X	}
X	if ((win->_lastch = SMALLOC(nl * sizeof win->_lastch[0])) == NULL) {
X		free(win->_y);
X		free(win->_firstch);
X		free(win);
X		return NULL;
X	}
X	win->_nextp = win;
X	for (i = 0; i < nl; i++) {
X		win->_firstch[i] = _NOCHANGE;
X		win->_lastch[i] = _NOCHANGE;
X	}
X	for (i = 0; i < nl; i++)
X		if ((win->_y[i] = malloc(nc * sizeof win->_y[0])) == NULL) {
X			for (j = 0; j < i; j++)
X				free(win->_y[j]);
X			free(win->_firstch);
X			free(win->_lastch);
X			free(win->_y);
X			free(win);
X			return ERR;
X		}
X		else
X			for (sp = win->_y[i]; sp < win->_y[i] + nc; )
X				*sp++ = ' ';
X	win->_ch_off = 0;
X# ifdef DEBUG
X	fprintf(outf, "NEWWIN: win->_ch_off = %d\n", win->_ch_off);
X# endif
X	return win;
X}
X
XWINDOW *
Xsubwin(orig, num_lines, num_cols, begy, begx)
Xreg WINDOW	*orig;
Xint		num_lines, num_cols, begy, begx;
X{
X	reg int		i;
X	reg WINDOW	*win;
X	reg int		by, bx, nl, nc;
X
X	by = begy;
X	bx = begx;
X	nl = num_lines;
X	nc = num_cols;
X
X	/*
X	 * make sure window fits inside the original one
X	 */
X# ifdef	DEBUG
X	fprintf(outf, "SUBWIN(%0.2o, %d, %d, %d, %d)\n", orig, nl, nc, by, bx);
X# endif
X	if (by < orig->_begy || bx < orig->_begx
X	    || by + nl > orig->_maxy + orig->_begy
X	    || bx + nc > orig->_maxx + orig->_begx)
X		return ERR;
X	if (nl == 0)
X		nl = orig->_maxy + orig->_begy - by;
X	if (nc == 0)
X		nc = orig->_maxx + orig->_begx - bx;
X	if ((win = makenew(nl, nc, by, bx)) == NULL)
X		return ERR;
X	win->_nextp = orig->_nextp;
X	orig->_nextp = win;
X	win->_orig = orig;
X	_set_subwin_(orig, win);
X	return win;
X}
X
X/*
X * this code is shared with mvwin()
X */
X_set_subwin_(orig, win)
Xregister WINDOW	*orig, *win;
X{
X	register int	i, j, k;
X
X	j = win->_begy - orig->_begy;
X	k = win->_begx - orig->_begx;
X	win->_ch_off = k;
X# ifdef DEBUG
X	fprintf(outf, "_SET_SUBWIN_: win->_ch_off = %d\n", win->_ch_off);
X# endif
X	win->_firstch = &orig->_firstch[j];
X	win->_lastch = &orig->_lastch[j];
X	for (i = 0; i < win->_maxy; i++, j++)
X		win->_y[i] = &orig->_y[j][k];
X
X}
X
X/*
X *	This routine sets up a window buffer and returns a pointer to it.
X */
Xstatic WINDOW *
Xmakenew(num_lines, num_cols, begy, begx)
Xint	num_lines, num_cols, begy, begx; {
X
X	reg int		i;
X	reg WINDOW	*win;
X	reg int		by, bx, nl, nc;
X
X	by = begy;
X	bx = begx;
X	nl = num_lines;
X	nc = num_cols;
X
X# ifdef	DEBUG
X	fprintf(outf, "MAKENEW(%d, %d, %d, %d)\n", nl, nc, by, bx);
X# endif
X	if ((win = (WINDOW *) malloc(sizeof *win)) == NULL)
X		return NULL;
X# ifdef DEBUG
X	fprintf(outf, "MAKENEW: nl = %d\n", nl);
X# endif
X	if ((win->_y = (char **) malloc(nl * sizeof win->_y[0])) == NULL) {
X		free(win);
X		return NULL;
X	}
X# ifdef DEBUG
X	fprintf(outf, "MAKENEW: nc = %d\n", nc);
X# endif
X	win->_cury = win->_curx = 0;
X	win->_clear = FALSE;
X	win->_maxy = nl;
X	win->_maxx = nc;
X	win->_begy = by;
X	win->_begx = bx;
X	win->_flags = 0;
X	win->_scroll = win->_leave = FALSE;
X	_swflags_(win);
X# ifdef DEBUG
X	fprintf(outf, "MAKENEW: win->_clear = %d\n", win->_clear);
X	fprintf(outf, "MAKENEW: win->_leave = %d\n", win->_leave);
X	fprintf(outf, "MAKENEW: win->_scroll = %d\n", win->_scroll);
X	fprintf(outf, "MAKENEW: win->_flags = %0.2o\n", win->_flags);
X	fprintf(outf, "MAKENEW: win->_maxy = %d\n", win->_maxy);
X	fprintf(outf, "MAKENEW: win->_maxx = %d\n", win->_maxx);
X	fprintf(outf, "MAKENEW: win->_begy = %d\n", win->_begy);
X	fprintf(outf, "MAKENEW: win->_begx = %d\n", win->_begx);
X# endif
X	return win;
X}
X
X_swflags_(win)
Xregister WINDOW	*win;
X{
X	win->_flags &= ~(_ENDLINE|_FULLLINE|_FULLWIN|_SCROLLWIN);
X	if (win->_begx + win->_maxx == COLS) {
X		win->_flags |= _ENDLINE;
X		if (win->_begx == 0) {
X			if (AL && DL)
X				win->_flags |= _FULLLINE;
X			if (win->_maxy == LINES && win->_begy == 0)
X				win->_flags |= _FULLWIN;
X		}
X		if (win->_begy + win->_maxy == LINES)
X			win->_flags |= _SCROLLWIN;
X	}
X}
SHAR_EOF
if test 4709 -ne "`wc -c 'newwin.c'`"
then
	echo shar: error transmitting "'newwin.c'" '(should have been 4709 characters)'
fi
echo shar: extracting "'overlay.c'" '(1625 characters)'
if test -f 'overlay.c'
then
	echo shar: over-writing existing file "'overlay.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'overlay.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)overlay.c	5.2 (Berkeley) 2/12/86";
X#endif not lint
X
X# include	"curses.ext"
X# include	<ctype.h>
X
X# define	min(a,b)	(a < b ? a : b)
X# define	max(a,b)	(a > b ? a : b)
X
X/*
X *	This routine writes win1 on win2 non-destructively.
X *
X */
Xoverlay(win1, win2)
Xreg WINDOW	*win1, *win2; {
X
X	reg char	*sp, *end;
X	reg int		x, y, endy, endx, starty, startx;
X	reg int 	y1,y2;
X
X# ifdef DEBUG
X	fprintf(outf, "OVERLAY(%0.2o, %0.2o);\n", win1, win2);
X# endif
X	starty = max(win1->_begy, win2->_begy);
X	startx = max(win1->_begx, win2->_begx);
X	endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx);
X	endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx);
X# ifdef DEBUG
X	fprintf(outf, "OVERLAY:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx);
X# endif
X	if (starty >= endy || startx >= endx)
X		return;
X	x = endx - startx;
X	for (y = starty; y < endy; y++) {
X		bcopy(&win1->_y[y - win1->_begy][startx - win1->_begx],
X		      &win2->_y[y - win2->_begy][startx - win2->_begx], x);
X		touchline(win2, y, startx - win2->_begx, endx - win2->_begx);
X	}
X	y1 = starty - win1->_begy;
X	y2 = starty - win2->_begy;
X	for (y = starty; y < endy; y++, y1++, y2++) {
X		end = &win1->_y[y1][endx - win1->_begx];
X		x = startx - win2->_begx;
X		for (sp = &win1->_y[y1][startx - win1->_begx]; sp < end; sp++) {
X			if (!isspace(*sp))
X				mvwaddch(win2, y2, x, *sp);
X			x++;
X		}
X	}
X}
SHAR_EOF
if test 1625 -ne "`wc -c 'overlay.c'`"
then
	echo shar: error transmitting "'overlay.c'" '(should have been 1625 characters)'
fi
echo shar: extracting "'overwrite.c'" '(1301 characters)'
if test -f 'overwrite.c'
then
	echo shar: over-writing existing file "'overwrite.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'overwrite.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)overwrite.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X# include	"curses.ext"
X# include	<ctype.h>
X
X# define	min(a,b)	(a < b ? a : b)
X# define	max(a,b)	(a > b ? a : b)
X
X/*
X *	This routine writes win1 on win2 destructively.
X *
X */
Xoverwrite(win1, win2)
Xreg WINDOW	*win1, *win2; {
X
X	reg char	*sp, *end;
X	reg int		x, y, endy, endx, starty, startx;
X
X# ifdef DEBUG
X	fprintf(outf, "OVERWRITE(%0.2o, %0.2o);\n", win1, win2);
X# endif
X	starty = max(win1->_begy, win2->_begy);
X	startx = max(win1->_begx, win2->_begx);
X	endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx);
X	endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx);
X	if (starty >= endy || startx >= endx)
X		return;
X# ifdef DEBUG
X	fprintf(outf, "OVERWRITE:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx);
X# endif
X	x = endx - startx;
X	for (y = starty; y < endy; y++) {
X		bcopy(&win1->_y[y - win1->_begy][startx - win1->_begx],
X		      &win2->_y[y - win2->_begy][startx - win2->_begx], x);
X		touchline(win2, y, startx - win2->_begx, endx - win2->_begx);
X	}
X}
SHAR_EOF
if test 1301 -ne "`wc -c 'overwrite.c'`"
then
	echo shar: error transmitting "'overwrite.c'" '(should have been 1301 characters)'
fi
echo shar: extracting "'printw.c'" '(1307 characters)'
if test -f 'printw.c'
then
	echo shar: over-writing existing file "'printw.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'printw.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X/*
X * Implementation using varargs and vsprintf by John Gilmore.
X * My changes are in the public domain.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)printw.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X/*
X * printw and friends
X *
X */
X
X# include	"curses.ext"
X# include	<varargs.h>
X
X/*
X *	This routine implements a printf on the standard screen.
X */
Xint
Xprintw(va_alist)
Xva_dcl {
X	va_list args;
X	char *fmt;
X	int ret;
X
X	va_start(args);
X	fmt = va_arg(args, char *);
X
X	ret = _sprintw(stdscr, fmt, &args);
X	va_end(args);
X	return ret;
X}
X
X/*
X *	This routine implements a printf on the given window.
X */
Xint
Xwprintw(va_alist)
Xva_dcl {
X	va_list args;
X	WINDOW	*win;
X	char *fmt;
X	int ret;
X
X	va_start(args);
X	win = va_arg(args, WINDOW *);
X	fmt = va_arg(args, char *);
X
X	ret = _sprintw(win, fmt, &args);
X	va_end(args);
X	return ret;
X}
X
X/*
X *	This routine actually executes the printf and adds it to the window
X */
Xint
X_sprintw(win, fmt, args)
XWINDOW	*win;
Xchar	*fmt;
Xva_list	*args;
X{
X	char	buf[512];	/* Bogus, but what are we to do? */
X
X	(void) sprintf(buf, fmt, *args);
X	return waddstr(win, buf);
X}
SHAR_EOF
if test 1307 -ne "`wc -c 'printw.c'`"
then
	echo shar: error transmitting "'printw.c'" '(should have been 1307 characters)'
fi
echo shar: extracting "'putchar.c'" '(451 characters)'
if test -f 'putchar.c'
then
	echo shar: over-writing existing file "'putchar.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'putchar.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)putchar.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X# include	"curses.ext"
X
Xchar
X_putchar(c)
Xreg char	c; {
X
X	putchar(c);
X#ifdef DEBUG
X	fprintf(outf, "_PUTCHAR(%s)\n", unctrl(c));
X#endif
X}
SHAR_EOF
if test 451 -ne "`wc -c 'putchar.c'`"
then
	echo shar: error transmitting "'putchar.c'" '(should have been 451 characters)'
fi
echo shar: extracting "'refresh.c'" '(6276 characters)'
if test -f 'refresh.c'
then
	echo shar: over-writing existing file "'refresh.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'refresh.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)refresh.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X/*
X * make the current screen look like "win" over the area coverd by
X * win.
X */
X
X# include	"curses.ext"
X
X# ifdef DEBUG
X# define	STATIC
X# else
X# define	STATIC	static
X# endif
X
XSTATIC short	ly, lx;
X
XSTATIC bool	curwin;
X
XWINDOW	*_win = NULL;
X
Xwrefresh(win)
Xreg WINDOW	*win;
X{
X	reg short	wy;
X	reg int		retval;
X	reg WINDOW	*orig;
X
X	/*
X	 * make sure were in visual state
X	 */
X	if (_endwin) {
X		_puts(VS);
X		_puts(TI);
X		_endwin = FALSE;
X	}
X
X	/*
X	 * initialize loop parameters
X	 */
X
X	ly = curscr->_cury;
X	lx = curscr->_curx;
X	wy = 0;
X	_win = win;
X	curwin = (win == curscr);
X
X	if (win->_clear || curscr->_clear || curwin) {
X		if ((win->_flags & _FULLWIN) || curscr->_clear) {
X			_puts(CL);
X			ly = 0;
X			lx = 0;
X			if (!curwin) {
X				curscr->_clear = FALSE;
X				curscr->_cury = 0;
X				curscr->_curx = 0;
X				werase(curscr);
X			}
X			touchwin(win);
X		}
X		win->_clear = FALSE;
X	}
X	if (!CA) {
X		if (win->_curx != 0)
X			_putchar('\n');
X		if (!curwin)
X			werase(curscr);
X	}
X# ifdef DEBUG
X	fprintf(outf, "REFRESH(%0.2o): curwin = %d\n", win, curwin);
X	fprintf(outf, "REFRESH:\n\tfirstch\tlastch\n");
X# endif
X	for (wy = 0; wy < win->_maxy; wy++) {
X# ifdef DEBUG
X		fprintf(outf, "%d\t%d\t%d\n", wy, win->_firstch[wy],
X			win->_lastch[wy]);
X# endif
X		if (win->_firstch[wy] != _NOCHANGE)
X			if (makech(win, wy) == ERR)
X				return ERR;
X			else {
X				if (win->_firstch[wy] >= win->_ch_off)
X					win->_firstch[wy] = win->_maxx +
X							    win->_ch_off;
X				if (win->_lastch[wy] < win->_maxx +
X						       win->_ch_off)
X					win->_lastch[wy] = win->_ch_off;
X				if (win->_lastch[wy] < win->_firstch[wy])
X					win->_firstch[wy] = _NOCHANGE;
X			}
X# ifdef DEBUG
X		fprintf(outf, "\t%d\t%d\n", win->_firstch[wy],
X			win->_lastch[wy]);
X# endif
X	}
X
X	if (win == curscr)
X		domvcur(ly, lx, win->_cury, win->_curx);
X	else {
X		if (win->_leave) {
X			curscr->_cury = ly;
X			curscr->_curx = lx;
X			ly -= win->_begy;
X			lx -= win->_begx;
X			if (ly >= 0 && ly < win->_maxy && lx >= 0 &&
X			    lx < win->_maxx) {
X				win->_cury = ly;
X				win->_curx = lx;
X			}
X			else
X				win->_cury = win->_curx = 0;
X		}
X		else {
X			domvcur(ly, lx, win->_cury + win->_begy,
X				win->_curx + win->_begx);
X			curscr->_cury = win->_cury + win->_begy;
X			curscr->_curx = win->_curx + win->_begx;
X		}
X	}
X	retval = OK;
Xret:
X	_win = NULL;
X	fflush(stdout);
X	return retval;
X}
X
X/*
X * make a change on the screen
X */
XSTATIC
Xmakech(win, wy)
Xreg WINDOW	*win;
Xshort		wy;
X{
X	reg char	*nsp, *csp, *ce;
X	reg short	wx, lch, y;
X	reg int		nlsp, clsp;	/* last space in lines		*/
X
X	wx = win->_firstch[wy] - win->_ch_off;
X	if (wx >= win->_maxx)
X		return OK;
X	else if (wx < 0)
X		wx = 0;
X	lch = win->_lastch[wy] - win->_ch_off;
X	if (lch < 0)
X		return OK;
X	else if (lch >= win->_maxx)
X		lch = win->_maxx - 1;;
X	y = wy + win->_begy;
X
X	if (curwin)
X		csp = " ";
X	else
X		csp = &curscr->_y[wy + win->_begy][wx + win->_begx];
X
X	nsp = &win->_y[wy][wx];
X	if (CE && !curwin) {
X		for (ce = &win->_y[wy][win->_maxx - 1]; *ce == ' '; ce--)
X			if (ce <= win->_y[wy])
X				break;
X		nlsp = ce - win->_y[wy];
X	}
X
X	if (!curwin)
X		ce = CE;
X	else
X		ce = NULL;
X
X	while (wx <= lch) {
X		if (*nsp != *csp) {
X			domvcur(ly, lx, y, wx + win->_begx);
X# ifdef DEBUG
X			fprintf(outf, "MAKECH: 1: wx = %d, lx = %d\n", wx, lx);
X# endif	
X			ly = y;
X			lx = wx + win->_begx;
X			while (*nsp != *csp && wx <= lch) {
X				if (ce != NULL && wx >= nlsp && *nsp == ' ') {
X					/*
X					 * check for clear to end-of-line
X					 */
X					ce = &curscr->_y[ly][COLS - 1];
X					while (*ce == ' ')
X						if (ce-- <= csp)
X							break;
X					clsp = ce - curscr->_y[ly] - win->_begx;
X# ifdef DEBUG
X					fprintf(outf, "MAKECH: clsp = %d, nlsp = %d\n", clsp, nlsp);
X# endif
X					if (clsp - nlsp >= strlen(CE)
X					    && clsp < win->_maxx) {
X# ifdef DEBUG
X						fprintf(outf, "MAKECH: using CE\n");
X# endif
X						_puts(CE);
X						lx = wx + win->_begx;
X						while (wx++ <= clsp)
X							*csp++ = ' ';
X						return OK;
X					}
X					ce = NULL;
X				}
X				/*
X				 * enter/exit standout mode as appropriate
X				 */
X				if (SO && (*nsp&_STANDOUT) != (curscr->_flags&_STANDOUT)) {
X					if (*nsp & _STANDOUT) {
X						_puts(SO);
X						curscr->_flags |= _STANDOUT;
X					}
X					else {
X						_puts(SE);
X						curscr->_flags &= ~_STANDOUT;
X					}
X				}
X				wx++;
X				if (wx >= win->_maxx && wy == win->_maxy - 1)
X					if (win->_scroll) {
X					    if ((curscr->_flags&_STANDOUT) &&
X					        (win->_flags & _ENDLINE))
X						    if (!MS) {
X							_puts(SE);
X							curscr->_flags &= ~_STANDOUT;
X						    }
X					    if (!curwin)
X						_putchar((*csp = *nsp) & 0177);
X					    else
X						_putchar(*nsp & 0177);
X					    if (win->_flags&_FULLWIN && !curwin)
X						scroll(curscr);
X					    ly = win->_begy+win->_cury;
X					    lx = win->_begx+win->_curx;
X					    return OK;
X					}
X					else if (win->_flags&_SCROLLWIN) {
X					    lx = --wx;
X					    return ERR;
X					}
X				if (!curwin)
X					_putchar((*csp++ = *nsp) & 0177);
X				else
X					_putchar(*nsp & 0177);
X# ifdef FULLDEBUG
X				fprintf(outf,
X					"MAKECH:putchar(%c)\n", *nsp & 0177);
X# endif
X				if (UC && (*nsp & _STANDOUT)) {
X					_putchar('\b');
X					_puts(UC);
X				}
X				nsp++;
X			}
X# ifdef DEBUG
X			fprintf(outf, "MAKECH: 2: wx = %d, lx = %d\n", wx, lx);
X# endif	
X			if (lx == wx + win->_begx)	/* if no change */
X				break;
X			lx = wx + win->_begx;
X			if (lx >= COLS && AM) {
X				lx = 0;
X				ly++;
X				/*
X				 * xn glitch: chomps a newline after auto-wrap.
X				 * we just feed it now and forget about it.
X				 */
X				if (XN) {
X					_putchar('\n');
X					_putchar('\r');
X				}
X			}
X		}
X		else if (wx <= lch)
X			while (*nsp == *csp && wx <= lch) {
X				nsp++;
X				if (!curwin)
X					csp++;
X				++wx;
X			}
X		else
X			break;
X# ifdef DEBUG
X		fprintf(outf, "MAKECH: 3: wx = %d, lx = %d\n", wx, lx);
X# endif	
X	}
X	return OK;
X}
X
X/*
X * perform a mvcur, leaving standout mode if necessary
X */
XSTATIC
Xdomvcur(oy, ox, ny, nx)
Xint	oy, ox, ny, nx; {
X
X	if (curscr->_flags & _STANDOUT && !MS) {
X		_puts(SE);
X		curscr->_flags &= ~_STANDOUT;
X	}
X	mvcur(oy, ox, ny, nx);
X}
SHAR_EOF
if test 6276 -ne "`wc -c 'refresh.c'`"
then
	echo shar: error transmitting "'refresh.c'" '(should have been 6276 characters)'
fi
echo shar: extracting "'scanw.c'" '(1309 characters)'
if test -f 'scanw.c'
then
	echo shar: over-writing existing file "'scanw.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'scanw.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)scanw.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X/*
X * scanw and friends
X *
X */
X
X# include	"curses.ext"
X
X/*
X *	This routine implements a scanf on the standard screen.
X */
Xscanw(fmt, args)
Xchar	*fmt;
X#ifdef __GNUC__
Xlong	args; {
X#else
Xint	args; {
X#endif
X
X
X	return _sscans(stdscr, fmt, &args);
X}
X/*
X *	This routine implements a scanf on the given window.
X */
Xwscanw(win, fmt, args)
XWINDOW	*win;
Xchar	*fmt;
X#ifdef __GNUC__
Xlong	args; {
X#else
Xint	args; {
X#endif
X
X	return _sscans(win, fmt, &args);
X}
X/*
X *	This routine actually executes the scanf from the window.
X *
X *	This is really a modified version of "sscanf".  As such,
X * it assumes that sscanf interfaces with the other scanf functions
X * in a certain way.  If this is not how your system works, you
X * will have to modify this routine to use the interface that your
X * "sscanf" uses.
X */
X_sscans(win, fmt, args)
XWINDOW	*win;
Xchar	*fmt;
X#ifdef __GNUC__
Xlong	*args;
X#else
Xint	*args;
X#endif
X{
X	char buf[256];
X	if (wgetstr(win, buf) == ERR)
X		return ERR;
X	return _doscanf(1, buf, fmt, args);
X}
SHAR_EOF
if test 1309 -ne "`wc -c 'scanw.c'`"
then
	echo shar: error transmitting "'scanw.c'" '(should have been 1309 characters)'
fi
echo shar: extracting "'scroll.c'" '(774 characters)'
if test -f 'scroll.c'
then
	echo shar: over-writing existing file "'scroll.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'scroll.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)scroll.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X# include	"curses.ext"
X
X/*
X *	This routine scrolls the window up a line.
X *
X */
Xscroll(win)
Xregister  WINDOW	*win;
X{
X	register int	oy, ox;
X
X# ifdef DEBUG
X	fprintf(outf, "SCROLL(%0.2o)\n", win);
X# endif
X
X	if (!win->_scroll)
X		return ERR;
X
X	getyx(win, oy, ox);
X	wmove(win, 0, 0);
X	wdeleteln(win);
X	wmove(win, oy, ox);
X
X	if (win == curscr) {
X		_putchar('\n');
X		if (!NONL)
X			win->_curx = 0;
X# ifdef DEBUG
X		fprintf(outf, "SCROLL: win == curscr\n");
X# endif
X	}
X}
SHAR_EOF
if test 774 -ne "`wc -c 'scroll.c'`"
then
	echo shar: error transmitting "'scroll.c'" '(should have been 774 characters)'
fi
echo shar: extracting "'standout.c'" '(728 characters)'
if test -f 'standout.c'
then
	echo shar: over-writing existing file "'standout.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'standout.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)standout.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X/*
X * routines dealing with entering and exiting standout mode
X *
X */
X
X# include	"curses.ext"
X
X/*
X * enter standout mode
X */
Xchar *
Xwstandout(win)
Xreg WINDOW	*win;
X{
X	if (!SO && !UC)
X		return FALSE;
X
X	win->_flags |= _STANDOUT;
X	return (SO ? SO : UC);
X}
X
X/*
X * exit standout mode
X */
Xchar *
Xwstandend(win)
Xreg WINDOW	*win;
X{
X	if (!SO && !UC)
X		return FALSE;
X
X	win->_flags &= ~_STANDOUT;
X	return (SE ? SE : UC);
X}
SHAR_EOF
if test 728 -ne "`wc -c 'standout.c'`"
then
	echo shar: error transmitting "'standout.c'" '(should have been 728 characters)'
fi
echo shar: extracting "'toucholap.c'" '(1475 characters)'
if test -f 'toucholap.c'
then
	echo shar: over-writing existing file "'toucholap.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'toucholap.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)toucholap.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X# include	"curses.ext"
X
X# define	min(a,b)	(a < b ? a : b)
X# define	max(a,b)	(a > b ? a : b)
X
X/*
X *	Touch, on win2, the part that overlaps with win1.
X *
X */
Xtouchoverlap(win1, win2)
Xreg WINDOW	*win1, *win2; {
X
X	reg int		x, y, endy, endx, starty, startx;
X
X# ifdef DEBUG
X	fprintf(outf, "TOUCHOVERLAP(%0.2o, %0.2o);\n", win1, win2);
X# endif
X	starty = max(win1->_begy, win2->_begy);
X	startx = max(win1->_begx, win2->_begx);
X	endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begx);
X	endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx);
X# ifdef DEBUG
X	fprintf(outf, "TOUCHOVERLAP:from (%d,%d) to (%d,%d)\n", starty, startx, endy, endx);
X	fprintf(outf, "TOUCHOVERLAP:win1 (%d,%d) to (%d,%d)\n", win1->_begy, win1->_begx, win1->_begy + win1->_maxy, win1->_begx + win1->_maxx);
X	fprintf(outf, "TOUCHOVERLAP:win2 (%d,%d) to (%d,%d)\n", win2->_begy, win2->_begx, win2->_begy + win2->_maxy, win2->_begx + win2->_maxx);
X# endif
X	if (starty >= endy || startx >= endx)
X		return;
X	starty -= win2->_begy;
X	startx -= win2->_begx;
X	endy -= win2->_begy;
X	endx -= win2->_begx;
X	endx--;
X	for (y = starty; y < endy; y++)
X		touchline(win2, y, startx, endx);
X}
SHAR_EOF
if test 1475 -ne "`wc -c 'toucholap.c'`"
then
	echo shar: error transmitting "'toucholap.c'" '(should have been 1475 characters)'
fi
echo shar: extracting "'touchwin.c'" '(1265 characters)'
if test -f 'touchwin.c'
then
	echo shar: over-writing existing file "'touchwin.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'touchwin.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)touchwin.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X# include	"curses.ext"
X
X/*
X * make it look like the whole window has been changed.
X *
X */
Xtouchwin(win)
Xregister WINDOW	*win;
X{
X	register int	y, maxy;
X
X# ifdef	DEBUG
X	fprintf(outf, "TOUCHWIN(%0.2o)\n", win);
X# endif
X	maxy = win->_maxy;
X	for (y = 0; y < maxy; y++)
X		touchline(win, y, 0, win->_maxx - 1);
X}
X
X/*
X * touch a given line
X */
Xtouchline(win, y, sx, ex)
Xregister WINDOW	*win;
Xregister int	y, sx, ex;
X{
X# ifdef DEBUG
X	fprintf(outf, "TOUCHLINE(%0.2o, %d, %d, %d)\n", win, y, sx, ex);
X	fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", win->_firstch[y], win->_lastch[y]);
X# endif
X	sx += win->_ch_off;
X	ex += win->_ch_off;
X	if (win->_firstch[y] == _NOCHANGE) {
X		win->_firstch[y] = sx;
X		win->_lastch[y] = ex;
X	}
X	else {
X		if (win->_firstch[y] > sx)
X			win->_firstch[y] = sx;
X		if (win->_lastch[y] < ex)
X			win->_lastch[y] = ex;
X	}
X# ifdef	DEBUG
X	fprintf(outf, "TOUCHLINE:first = %d, last = %d\n", win->_firstch[y], win->_lastch[y]);
X# endif
X}
SHAR_EOF
if test 1265 -ne "`wc -c 'touchwin.c'`"
then
	echo shar: error transmitting "'touchwin.c'" '(should have been 1265 characters)'
fi
echo shar: extracting "'tstp.c'" '(915 characters)'
if test -f 'tstp.c'
then
	echo shar: over-writing existing file "'tstp.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'tstp.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)tstp.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X# include	<signal.h>
X
X# include	"curses.ext"
X
X/*
X * handle stop and start signals
X *
X * @(#)tstp.c	5.1 (Berkeley) 6/7/85
X */
Xtstp() {
X
X# ifdef SIGTSTP
X
X	SGTTY	tty;
X	int	omask;
X# ifdef DEBUG
X	if (outf)
X		fflush(outf);
X# endif
X	tty = _tty;
X	mvcur(0, COLS - 1, LINES - 1, 0);
X	endwin();
X	fflush(stdout);
X	/* reset signal handler so kill below stops us */
X	signal(SIGTSTP, SIG_DFL);
X#define	mask(s)	(1 << ((s)-1))
X	omask = sigsetmask(sigblock(0) &~ mask(SIGTSTP));
X	kill(0, SIGTSTP);
X	sigblock(mask(SIGTSTP));
X	signal(SIGTSTP, tstp);
X	_tty = tty;
X	stty(_tty_ch, &_tty);
X	wrefresh(curscr);
X# endif	SIGTSTP
X}
SHAR_EOF
if test 915 -ne "`wc -c 'tstp.c'`"
then
	echo shar: error transmitting "'tstp.c'" '(should have been 915 characters)'
fi
echo shar: extracting "'unctrl.c'" '(1134 characters)'
if test -f 'unctrl.c'
then
	echo shar: over-writing existing file "'unctrl.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'unctrl.c'
X/*
X * Copyright 1980 Kenneth C. R. C. Arnold and The Regents of the
X * University of California.  Permission is granted to freely
X * distribute curses and its documentation provided that this
X * notice is left intact.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)unctrl.c	5.1 (Berkeley) 6/7/85";
X#endif not lint
X
X/*
X * define unctrl codes for each character
X *
X */
X
X/* LINTLIBRARY */
Xchar	*_unctrl[]	= {	/* unctrl codes for ttys		*/
X	"^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", "^H", "^I", "^J", "^K",
X	"^L", "^M", "^N", "^O", "^P", "^Q", "^R", "^S", "^T", "^U", "^V", "^W",
X	"^X", "^Y", "^Z", "^[", "^\\", "^]", "^~", "^_",
X	" ", "!", "\"", "#", "$",  "%", "&", "'", "(", ")", "*", "+", ",", "-",
X	".", "/", "0",  "1", "2",  "3", "4", "5", "6", "7", "8", "9", ":", ";",
X	"<", "=", ">",  "?", "@",  "A", "B", "C", "D", "E", "F", "G", "H", "I",
X	"J", "K", "L",  "M", "N",  "O", "P", "Q", "R", "S", "T", "U", "V", "W",
X	"X", "Y", "Z",  "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e",
X	"f", "g", "h",  "i", "j",  "k", "l", "m", "n", "o", "p", "q", "r", "s",
X	"t", "u", "v",  "w", "x",  "y", "z", "{", "|", "}", "~", "^?"
X};
SHAR_EOF
if test 1134 -ne "`wc -c 'unctrl.c'`"
then
	echo shar: error transmitting "'unctrl.c'" '(should have been 1134 characters)'
fi
#	End of shell archive
exit 0
usenet: {decvax,sun}!cwjcc!dsrgsun!bammi	jwahar r. bammi
csnet:       bammi@dsrgsun.ces.CWRU.edu
arpa:        bammi@dsrgsun.ces.CWRU.edu
compuServe:  71515,155