Vile 13/17 - vi feel-alike (multi-window)

Paul Fox pgf at cayman.COM
Sat Jun 8 08:10:09 AEST 1991


#!/bin/sh
# this is vileshar.13 (part 13 of Vile)
# do not concatenate these parts, unpack them in order with /bin/sh
# file shorten/COPYING continued
#
if test ! -r _shar_seq_.tmp; then
	echo 'Please unpack part 1 first!'
	exit 1
fi
(read Scheck
 if test "$Scheck" != 13; then
	echo Please unpack part "$Scheck" next!
	exit 1
 else
	exit 0
 fi
) < _shar_seq_.tmp || exit 1
echo 'x - continuing file shorten/COPYING'
sed 's/^X//' << 'SHAR_EOF' >> 'shorten/COPYING' &&
for the physical act of transferring a copy.
X
X  2. You may modify your copy or copies of GNU Emacs source code or
any portion of it, and copy and distribute such modifications under
the terms of Paragraph 1 above, provided that you also do the following:
X
X    a) cause the modified files to carry prominent notices stating
X    that you changed the files and the date of any change; and
X
X    b) cause the whole of any work that you distribute or publish,
X    that in whole or in part contains or is a derivative of GNU Emacs
X    or any part thereof, to be licensed at no charge to all third
X    parties on terms identical to those contained in this License
X    Agreement (except that you may choose to grant more extensive
X    warranty protection to some or all third parties, at your option).
X
X    c) if the modified program serves as a text editor, cause it when
X    started running in the simplest and usual way, to print an
X    announcement including a valid copyright notice "Copyright (C)
X    1988 Free Software Foundation, Inc." (or with the year that is
X    appropriate), saying that there is no warranty (or else, saying
X    that you provide a warranty) and that users may redistribute the
X    program under these conditions, and telling the user how to view a
X    copy of this License Agreement.
X
X    d) You may charge a distribution fee for the physical act of
X    transferring a copy, and you may at your option offer warranty
X    protection in exchange for a fee.
X
Mere aggregation of another unrelated program with this program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other program under the scope of these terms.
X
X  3. You may copy and distribute GNU Emacs (or a portion or derivative of it,
under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:
X
X    a) accompany it with the complete corresponding machine-readable
X    source code, which must be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    b) accompany it with a written offer, valid for at least three
X    years, to give any third party free (except for a nominal
X    shipping charge) a complete machine-readable copy of the
X    corresponding source code, to be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    c) accompany it with the information you received as to where the
X    corresponding source code may be obtained.  (This alternative is
X    allowed only for noncommercial distribution and only if you
X    received the program in object code or executable form alone.)
X
For an executable file, complete source code means all the source code for
all modules it contains; but, as a special exception, it need not include
source code for modules which are standard libraries that accompany the
operating system on which the executable file runs.
X
X  4. You may not copy, sublicense, distribute or transfer GNU Emacs
except as expressly provided under this License Agreement.  Any attempt
otherwise to copy, sublicense, distribute or transfer GNU Emacs is void and
your rights to use GNU Emacs under this License agreement shall be
automatically terminated.  However, parties who have received computer
software programs from you with this License Agreement will not have
their licenses terminated so long as such parties remain in full compliance.
X
X  5. If you wish to incorporate parts of GNU Emacs into other free programs
whose distribution conditions are different, write to the Free Software
Foundation.  We have not yet worked out a simple rule that can be stated
here, but we will often permit this.  We will be guided by the two goals of
preserving the free status of all derivatives of our free software and of
promoting the sharing and reuse of software.
X
Your comments and suggestions about our licensing policies and our
software are welcome!  Please contact the Free Software Foundation, Inc.,
675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296.
X
X			   NO WARRANTY
X
X  BECAUSE GNU EMACS IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE GNU EMACS "AS IS"
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE GNU EMACS
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
SERVICING, REPAIR OR CORRECTION.
X
X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL FREE SOFTWARE
FOUNDATION, INC., RICHARD M. STALLMAN, AND/OR ANY OTHER PARTY WHO MAY
MODIFY AND REDISTRIBUTE GNU EMACS AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER
SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
FAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY
FREE SOFTWARE FOUNDATION, INC.) THE PROGRAM, EVEN IF YOU HAVE BEEN
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY
OTHER PARTY.
SHAR_EOF
echo 'File shorten/COPYING is complete' &&
chmod 0444 shorten/COPYING ||
echo 'restore of shorten/COPYING failed'
Wc_c="`wc -c < 'shorten/COPYING'`"
test 7910 -eq "$Wc_c" ||
	echo 'shorten/COPYING: original size 7910, current size' "$Wc_c"
# ============= shorten/defines.c ==============
echo 'x - extracting shorten/defines.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'shorten/defines.c' &&
#include <stdio.h>
X
int count;
X
main ()
{
X    char buffer[512];
X
X    while (gets (buffer))
X      {
X	printf ("#define %s zz%4.4dzz\n", buffer, count++);
X      }
X    return (0);
}
SHAR_EOF
chmod 0444 shorten/defines.c ||
echo 'restore of shorten/defines.c failed'
Wc_c="`wc -c < 'shorten/defines.c'`"
test 178 -eq "$Wc_c" ||
	echo 'shorten/defines.c: original size 178, current size' "$Wc_c"
# ============= shorten/dups.c ==============
echo 'x - extracting shorten/dups.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'shorten/dups.c' &&
/*
X *	Quick and dirty program to select adjacent records that are common
X *	in the first <arg> character positions.
X *
X */
X 
#include <stdio.h>
X
#define MAXSIZE 512
X
char ping[MAXSIZE];
char pong[MAXSIZE];
X
int flipflop = 0;
int size = MAXSIZE-1;
X
main (argc, argv)
X     int argc;
X     char *argv[];
{
X    register int index;
X    char *newbuf();
X    
X    if (argc == 2)
X      {
X	size = atoi (argv[1]);
X      }
X    while (newbuf() != NULL)
X      {
X	for (index=0; index < size; index++)
X	  {
X	    if (ping[index] != pong[index])
X	      {
X		break;
X	      }
X	  }
X	if (index == size)
X	  {
X	    printf ("%s\n", ping);
X	    printf ("%s\n", pong);
X	  }
X      }
X    return (0);
}
X
char *
newbuf ()
{
X  char *bufp;
X
X  if (flipflop)
X    {
X      bufp = ping;
X      flipflop = 0;
X    }
X  else
X    {
X      bufp = pong;
X      flipflop = 1;
X    }
X  return (gets (bufp));
}
SHAR_EOF
chmod 0444 shorten/dups.c ||
echo 'restore of shorten/dups.c failed'
Wc_c="`wc -c < 'shorten/dups.c'`"
test 857 -eq "$Wc_c" ||
	echo 'shorten/dups.c: original size 857, current size' "$Wc_c"
# ============= shorten/header.h ==============
echo 'x - extracting shorten/header.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'shorten/header.h' &&
/* Header file to remap longnames to shortnames.  Note that not
X   all cpp's support longnames.  In particular, most pre 5.2 UniSoft
X   ports only support 16 unique characters.  To bootstrap GNU emacs
X   to a 5.0 UniPlus+ system I had to port the 5.2 cpp (with FLEXNAMES)
X   to the development system.  This was about a 1 hour job with sources.
X   Alternatively, m4 can probably be used but this is not as clean and
X   requires some changes to the default make rules (add rule to go from
X   a ".cm4" file to a ".c" file and rule to go from a ".hm4" file to
X   a ".h" file.  There are too many changes for sed to handle in a single
X   pass.    Fred Fish, UniSoft Systems. */
SHAR_EOF
chmod 0444 shorten/header.h ||
echo 'restore of shorten/header.h failed'
Wc_c="`wc -c < 'shorten/header.h'`"
test 674 -eq "$Wc_c" ||
	echo 'shorten/header.h: original size 674, current size' "$Wc_c"
# ============= shorten/names.c ==============
echo 'x - extracting shorten/names.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'shorten/names.c' &&
/*
X *	A quick and dirty C program to spit out possible identifiers
X *	from a stream of *.c and *.h files.  Takes a single parameter
X *	which specifies the minimum length of an identifier to be
X *	extracted.
X *
X */
X 
#include <stdio.h>
#include <ctype.h>
X
#define FIRSTCHAR(a) (isalpha(a) || (a)=='_')
#define OTHERCHAR(a) (FIRSTCHAR(a) || isdigit(a))
#define TRUE 1
#define FALSE 0
X
int size = 0;
char buffer[512];
char *bp = buffer;
X
main (argc, argv)
X     int argc;
X     char *argv[];
{
X  register int ch;
X  register int spitout;
X  register int eating_comment;
X
X  if (argc == 2)
X    {
X      size = atoi (argv[1]);
X    }
X  spitout = FALSE;
X  eating_comment = FALSE;
X  while ((ch = getchar()) != EOF)
X    {
X      if (ch == '/')
X	{
X	  if ((ch = getchar()) == EOF)
X	    {
X	      fprintf (stderr, "unexpected EOF!\n");
X	      exit (1);
X	    }
X	  else
X	    {
X	      if (ch == '*')
X		{
X		  eating_comment = TRUE;
X		}
X	      else
X		{
X		  ungetc (ch, stdin);
X		}
X	    }
X	}
X      else if (eating_comment && ch == '*')
X	{
X	  if ((ch = getchar()) == EOF)
X	    {
X	      fprintf (stderr, "unexpected EOF!\n");
X	      exit (1);
X	    }
X	  else
X	    {
X	      if (ch == '/')
X		{
X		  eating_comment = FALSE;
X		}
X	      else
X		{
X		  ungetc (ch, stdin);
X		}
X	    }
X	}
X      else if (!eating_comment)
X	{
X	  if (!spitout && FIRSTCHAR(ch))
X	    {
X	      spitout = TRUE;
X	      *bp++ = ch;
X	    }
X	  else if (spitout && OTHERCHAR(ch))
X	    {
X	      *bp++ = ch;
X	    }
X	  else if (spitout)
X	    {
X	      *bp++ = '\000';
X	      bp = buffer;
X	      if (strlen (bp) >= size)
X		{
X		  printf ("%s\n", bp);
X		}
X	      spitout = FALSE;
X	    }
X	}
X    }
X  return (0);
}
SHAR_EOF
chmod 0444 shorten/names.c ||
echo 'restore of shorten/names.c failed'
Wc_c="`wc -c < 'shorten/names.c'`"
test 1637 -eq "$Wc_c" ||
	echo 'shorten/names.c: original size 1637, current size' "$Wc_c"
# ============= shorten/reserved ==============
echo 'x - extracting shorten/reserved (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'shorten/reserved' &&
int
char
float
double
struct
union
long
short
unsigned
auto
extern
register
typedef
static
goto
return
sizeof
break
continue
if
else
for
do
while
switch
case
default
entry
include
define
defined
undef
undefined
undefine
SHAR_EOF
chmod 0444 shorten/reserved ||
echo 'restore of shorten/reserved failed'
Wc_c="`wc -c < 'shorten/reserved'`"
test 220 -eq "$Wc_c" ||
	echo 'shorten/reserved: original size 220, current size' "$Wc_c"
# ============= shorten/special ==============
echo 'x - extracting shorten/special (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'shorten/special' &&
SHAR_EOF
chmod 0444 shorten/special ||
echo 'restore of shorten/special failed'
Wc_c="`wc -c < 'shorten/special'`"
test 0 -eq "$Wc_c" ||
	echo 'shorten/special: original size 0, current size' "$Wc_c"
# ============= spawn.c ==============
echo 'x - extracting spawn.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'spawn.c' &&
/*	Spawn:	various DOS access commands
X		for MicroEMACS
*/
X
#include        <stdio.h>
#include	"estruct.h"
#include        "edef.h"
#if BSD | USG
#include	<sys/types.h>
#include	<sys/stat.h>
#endif
X
#if     AMIGA
#define  NEW   1006L
#endif
X
#if		ST520 & MEGAMAX
#include <osbind.h>
#include <string.h>
#define LOAD_EXEC 0 	/* load and execute the program */
char	*STcmd,		/* the command filename & path  */
X	*STargs,	/* command args (if any)        */
X	*STenv,		/* environment                  */
X	*STwork;	/* work area			*/
#endif
X
#if     VMS
#define EFN     0                               /* Event flag.          */
X
#include        <ssdef.h>                       /* Random headers.      */
#include        <stsdef.h>
#include        <descrip.h>
#include        <iodef.h>
X
extern  int     oldmode[3];                     /* In "termio.c"        */
extern  int     newmode[3];                     /* In "termio.c"        */
extern  short   iochan;                         /* In "termio.c"        */
#endif
X
#if     UNIX
#include        <signal.h>
#include        <string.h>
#endif
X
#if	MSDOS & (MSC | TURBO)
#include	<process.h>
#endif
X
/*
X * Create a subjob with a copy of the command intrepreter in it. When the
X * command interpreter exits, mark the screen as garbage so that you do a full
X * repaint. The message at the start in VMS puts out a newline.
X * Under some (unknown) condition, you don't get one free when DCL starts up.
X */
spawncli(f, n)
{
#if     UNIX
# if     NeWS
X	mlwrite("Not availible under NeWS");
X	return(FALSE);
# else
X        register char *cp;
X        char    *getenv();
X        
X        movecursor(term.t_nrow, 0);             /* Seek to last line.   */
X	ttclean(TRUE);
X        TTputc('\n');
X        if ((cp = getenv("SHELL")) != NULL && *cp != '\0')
X                system(cp);
X        else
X                system("exec /bin/sh");
X        TTflush();
X	ttunclean();
X        sgarbf = TRUE;
X        return(TRUE);
# endif /* News */
#endif /* UNIX */
X
#if	AMIGA
X        long newcli;
X        mlwrite("[Starting new CLI]");
X        sgarbf = TRUE;
X        Execute("NEWCLI \"CON:0/0/640/200/MicroEMACS Subprocess\"", 0L, 0L);
X        return(TRUE);
#endif
X
#if     VMS
X        movecursor(term.t_nrow, 0);             /* In last line.        */
X        mlputs("[Starting DCL]\r\n");
X        TTflush(); 	                     /* Ignore "ttcol".      */
X        sgarbf = TRUE;
X        return (sys(NULL));                     /* NULL => DCL.         */
#endif
#if     CPM
X        mlwrite("Not in CP/M-86");
X	return FALSE;
#endif
#if	ST520
X	mlwrite("Not in TOS");
X	return FALSE;
#endif
#if     MSDOS & (AZTEC | MSC | TURBO)
X        movecursor(term.t_nrow, 0);             /* Seek to last line.   */
X        TTflush();
X	TTkclose();
X	system("command.com");
X	TTkopen();
X        sgarbf = TRUE;
X        return(TRUE);
#endif
#if     MSDOS & LATTICE
X        movecursor(term.t_nrow, 0);             /* Seek to last line.   */
X        TTflush();
X	TTkclose();
X        sys("\\command.com", "");               /* Run CLI.             */
X	TTkopen();
X        sgarbf = TRUE;
X        return(TRUE);
#endif
}
X
#if UNIX && defined(SIGTSTP)
X
bktoshell()		/* suspend MicroEMACS and wait to wake up */
{
#if     NeWS
X	mlwrite("Not availible under NeWS");
X	return(FALSE);
#else
X	int pid;
X
X	vttidy(TRUE);
X	pid = getpid();
X	kill(pid,SIGTSTP);
#endif
}
X
rtfrmshell()
{
#if     NeWS
X	mlwrite("Not available under NeWS");
X	return(FALSE);
#else
X	ttunclean();
X	curwp->w_flag = WFHARD;  /* is this needed, with sgarbf == TRUE? */
X	sgarbf = TRUE;
#if USG
X	signal(SIGCONT,rtfrmshell);	/* suspend & restart */
X	update(TRUE);
#endif
#endif
}
#endif /* SIGTSTP */
X
#if UNIX
pressreturn()
{
X	int s;
X
X        mlputs("[Press return to continue]");
X        TTflush();
X	/* loop for a CR, a space, or a : to do another named command */
X        while ((s = kbd_key()) != '\r' && s != ' ' && s != kcod2key(abortc)) {
X		extern CMDFUNC f_namedcmd;
X                if (kcod2fnc(s) == &f_namedcmd) {
X			tungetc(kcod2key(s));
X			break;
X		}
X	}
}
#endif
X
respawn(f,n) {
X	spawn(f,n,TRUE);
}
X
/*
X * Run a one-liner in a subjob. When the command returns, wait for a single
X * character to be typed, then mark the screen as garbage so a full repaint is
X * done.
X */
/* the #ifdefs have been totally separated, for readability */
spawn(f, n, rerun)
{
X
#if  UNIX
X        register int    s;
X        static char oline[NLINE];	/* command line send to shell */
X        char	line[NLINE];	/* command line send to shell */
X	register char	*cp;
X	char		line2[NLINE];
X	int cb;
X	char prompt[50];
X	char *getenv();
X
X	if (!rerun) {
X		if (cb = anycb())
X			sprintf(prompt,"Warning: %d modified buffer%s: !",
X				cb, cb>1 ? "s":"");
X		else
X			sprintf(prompt,": !");
X
X	        if ((s=mlreply(prompt, oline, NLINE)) != TRUE)
X	                return (s);
X	} else {
X		if (!oline[0])
X			return FALSE;
X		mlwrite(": !%s",oline);
X	}
X	strcpy(line,oline);
X        if ((cp = getenv("SHELL")) == NULL || *cp == '\0')
X                cp = "/bin/sh";
X	sprintf(line2, "%s -c \"%s\"", cp, line);
#if	NeWS
X	system(line2);
#else
X	ttclean(TRUE);
X	system(line2);
X        TTflush();
X	ttunclean();
X        sgarbf = TRUE;
X	pressreturn();
#endif /* NeWS */
X        return (TRUE);
#endif /* UNIX */
X
#if     AMIGA
X        register int    s;
X        static char oline[NLINE];	/* command line send to shell */
X        char	line[NLINE];	/* command line send to shell */
X	register char	*cp;
X	char		line2[NLINE];
X        long newcli;
X
X
X        if ((s=mlreply("cmd: !", oline, NLINE)) != TRUE)
X                return (s);
X	strcpy(line,oline);
X        newcli = Open("CON:0/0/640/200/MicroEMACS Subprocess", NEW);
X        Execute(line, 0L, newcli);
X        Close(newcli);
X        tgetc();     /* Pause.               */
X        sgarbf = TRUE;
X        return(TRUE);
#endif
#if	ST520 & MEGAMAX
X        register int    s;
X        static char oline[NLINE];	/* command line send to shell */
X        char	line[NLINE];	/* command line send to shell */
X	register char	*cp;
X	char		line2[NLINE];
X
X	int i,j,k;
X	char *sptr,*tptr;
X
X        if ((s=mlreply("cmd: !", oline, NLINE)) != TRUE)
X                return(s);
X	strcpy(line,oline);
X	movecursor(term.t_nrow - 1, 0);
X	TTclose();
X	/*
X	 * break the line into the command and its args
X	 * be cute about it, if there is no '.' in the filename, try
X	 * to find .prg, .tos or .ttp in that order
X	 * in any case check to see that the file exists before we run 
X	 * amok
X	 */
X	STenv = NULL;
X	if((tptr = index(&line[0],' ')) == NULL) { /* no args */
X		STcmd = malloc(strlen(line) + 1);
X		strcpy(STcmd,line);
X		STargs = NULL;
X	}
X	else {  /* seperate out the args from the command */
X		/* resist the temptation to do ptr arithmetic */
X		STcmd = malloc(strlen(line) + 1);
X		for(i = 0,sptr = &line[0]; sptr != tptr; sptr++,i++)
X			STcmd[i] = *sptr;
X		STcmd[i] = '\0';
X		for(; *tptr == ' ' || *tptr == '\t'; tptr++);
X		if(*tptr == '\0')
X			STargs = NULL;
X		else {
X			STargs = malloc(strlen(tptr) + 2);
/* first byte of STargs is the length of the string */
X			STargs[0] = strlen(tptr);
X			STargs[1] = NULL; /* fake it for strcat */
X			strcat(STargs,tptr);
X		}
X	}
X	/*
X	 * before we issue the command look for the '.', if it's not there
X	 * try adding .prg, .tos and .ttp to see if they exist, if not
X	 * issue the command as is
X	 */
X	if((tptr = index(STcmd,'.')) == NULL) {
X 		STwork = malloc(strlen(STcmd) + 4);
X 		strcpy(STwork,STcmd);
X 		strcat(STwork,".prg");
X 		tptr = index(STwork,'.');
X 		if(Fsfirst(1,STwork) != 0) { /* try .tos */
X 			strcpy(tptr,".tos");
X 			if(Fsfirst(1,STwork) != 0) { /* try .ttp */
X 				strcpy(tptr,".ttp");
X 				if(Fsfirst(1,STwork) != 0) /* never mind */
X 					*STwork = NULL;
X 				}
X 			}
X 	}
X 	if(*STwork != NULL)
X	        Pexec(LOAD_EXEC,STwork,STargs,STenv); 		
X	else
X	        Pexec(LOAD_EXEC,STcmd,STargs,STenv);
X	TTopen();
X        mlputs("\r\n\n[End]");                  /* Pause.               */
X        TTgetc();			     /* Pause.               */
X        sgarbf = TRUE;
X        return (TRUE);
#endif
#if     VMS
X        register int    s;
X        static char oline[NLINE];	/* command line send to shell */
X        char	line[NLINE];	/* command line send to shell */
X	register char	*cp;
X	char		line2[NLINE];
X
X
X        if ((s=mlreply("cmd: !", oline, NLINE)) != TRUE)
X                return (s);
X	strcpy(line,oline);
X        TTputc('\n');                /* Already have '\r'    */
X        TTflush();
X        s = sys(line);                          /* Run the command.     */
X        mlputs("\r\n\n[End]");                  /* Pause.               */
X        TTflush();
X        tgetc();
X        sgarbf = TRUE;
X        return (s);
#endif
#if     CPM
X        mlwrite("Not in CP/M-86");
X        return (FALSE);
#endif
#if     MSDOS | (ST520 & LATTICE)
X        register int    s;
X        static char oline[NLINE];	/* command line send to shell */
X        char	line[NLINE];	/* command line send to shell */
X	register char	*cp;
X	char		line2[NLINE];
X
X
X        if ((s=mlreply("cmd: !", oline, NLINE)) != TRUE)
X                return(s);
X	strcpy(line,oline);
X	movecursor(term.t_nrow - 1, 0);
X	TTkclose();
X        system(line);
X	TTkopen();
X	/* if we are interactive, pause here */
X	if (clexec == FALSE) {
X	        mlputs("\r\n\n[End]");
X        	tgetc();
X        }
X        sgarbf = TRUE;
X        return (TRUE);
#endif
}
X
#if UNIX
/*
X * Pipe a one line command into a window
X */
pipecmd(f, n)
{
X	register WINDOW *wp;	/* pointer to new window */
X	register BUFFER *bp;	/* pointer to buffer to zot */
X        static char oline[NLINE];	/* command line send to shell */
X        register int    s;
X	static char bname[] = "[Output]";
X	int cb;
X	char prompt[50];
X
X
X	/* if it doesn't start with '!', or if that's all it is */
X	if (oline[0] != '!' || oline[1] == '\0') {
X		oline[0] = '!';
X		oline[1] = '\0';
X	}
X
X	if (cb = anycb())
X		sprintf(prompt,"Warning: %d modified buffer%s. !",
X			cb, cb>1 ? "s":"");
X	else
X		sprintf(prompt,"!");
X		
X	/* get the command to pipe in */
X        if ((s=mlreply(prompt, &oline[1], NLINE)) != TRUE)
X                return(s);
X
X	/* first check if we are already here */
X	bp = bfind(bname, OK_CREAT, 0);
X	if (bp == NULL)
X		return FALSE;
X
X	/* and read the stuff in */
X	if (popupbuff(bp) != TRUE || 
X		swbuffer(bp) != TRUE || 
X		readin(oline, FALSE, bp, TRUE) != TRUE) {
X		return(FALSE);
X	}
X	strcpy(bp->b_bname,bname);
X	strncpy(bp->b_fname, oline, NFILEN-1);
X	bp->b_mode |= MDVIEW;
X	return TRUE;
}
X
#else /* ! UNIX */
X
/*
X * Pipe a one line command into a window
X */
pipecmd(f, n)
{
X        register int    s;	/* return status from CLI */
X	register WINDOW *wp;	/* pointer to new window */
X	register BUFFER *bp;	/* pointer to buffer to zot */
X        static char oline[NLINE];	/* command line send to shell */
X        char	line[NLINE];	/* command line send to shell */
X	static char bname[] = "[output]";
X	WINDOW *ocurwp;		/* save the current window during delete */
X
#if	AMIGA
X	static char filnam[] = "ram:command";
X        long newcli;
#else
X	static char filnam[NSTRING] = "command";
#endif
X
#if	MSDOS
X	char *tmp;
X	char *getenv();
X	FILE *fp;
X	FILE *fopen();
#endif
X
#if	MSDOS
X	if ((tmp = getenv("TMP")) == NULL)
X		strcpy(filnam, "command");
X	else {
X		strcpy(filnam, tmp);
X                strcat(filnam,"\\command");
X        }
#endif
#if     VMS
X	mlwrite("Not availible under VMS");
X	return(FALSE);
#endif
#if     CPM
X        mlwrite("Not availible under CP/M-86");
X        return(FALSE);
#endif
X	/* get the command to pipe in */
X        if ((s=mlreply("cmd: <", oline, NLINE)) != TRUE)
X                return(s);
X
X	strcpy(line,oline);
X
X	/* get rid of the command output buffer if it exists */
X        if ((bp=bfind(bname, NO_CREAT, 0)) != FALSE) {
X		/* try to make sure we are off screen */
X		wp = wheadp;
X		ocurwp = NULL;
X		while (wp != NULL) {
X			if (wp->w_bufp == bp) {
X				if (curwp != wp) {
X					ocurwp = curwp;
X					curwp = wp;
X				}
X				delwind(FALSE, 1);
X				if (ocurwp != NULL)
X					curwp = ocurwp;
X				break;
X			}
X			wp = wp->w_wndp;
X		}
X		if (zotbuf(bp) != TRUE)
X
X			return(FALSE);
X	}
X
#if     AMIGA
X        newcli = Open("CON:0/0/640/200/MicroEMACS Subprocess", NEW);
X	strcat(line, " >");
X	strcat(line, filnam);
X        Execute(line, 0L, newcli);
X	s = TRUE;
X        Close(newcli);
X        sgarbf = TRUE;
#endif
#if     MSDOS
X	strcat(line," >>");
X	strcat(line,filnam);
X	movecursor(term.t_nrow - 1, 0);
X	TTkclose();
X        system(line);
X	TTkopen();
X        sgarbf = TRUE;
X	if ((fp = fopen(filnam, "r")) == NULL) {
X		s = FALSE;
X	} else {
X		fclose(fp);
X		s = TRUE;
X	}
#endif
X
X	if (s != TRUE)
X		return(s);
X
X	/* split the current window to make room for the command output */
X	if (splitwind(FALSE, 1) == FALSE)
X			return(FALSE);
X
X	/* and read the stuff in */
X	if (getfile(filnam, FALSE) == FALSE)
X		return(FALSE);
X
X	/* make this window in VIEW mode, update all mode lines */
X	curwp->w_bufp->b_mode |= MDVIEW;
X	wp = wheadp;
X	while (wp != NULL) {
X		wp->w_flag |= WFMODE;
X		wp = wp->w_wndp;
X	}
X
#if FINDERR
X	strcpy(febuff,bp->b_bname);
X	newfebuff = TRUE;
#endif
X
X	/* and get rid of the temporary file */
X	unlink(filnam);
X	return(TRUE);
}
#endif /* UNIX */
X
/* run a region through an external filter, replace it with its output */
filterregion(f,n)
{
X        static char oline[NLINE];	/* command line send to shell */
X        char	line[NLINE];	/* command line send to shell */
X	FILE *fr, *fw;
X	int s;
X
X	/* get the filter name and its args */
X        if ((s=mlreply("!", oline, NLINE)) != TRUE)
X                return(s);
X	strcpy(line,oline);
X	if ((s = inout_popen(&fr, &fw, line)) != TRUE) {
X		mlwrite("Couldn't open pipe or command");
X		return s;
X	}
X
X	killregion(f,n);
X	if (fork()) {
X		fclose(fw);
X		/* backline(FALSE,1); */
X		curwp->w_dotp = lback(curwp->w_dotp);
X		s = ifile(NULL,TRUE,fr);
X		npclose(fr);
X		firstnonwhite();
X		setmark();
X		return s;
X	} else {
X		KILL *kp;		/* pointer into kill register */
X		kregcirculate(FALSE);
X		/* make sure there is something to put */
X		if (kbs[ukb].kbufh == NULL)
X			return TRUE;		/* not an error, just nothing */
X
X		kp = kbs[ukb].kbufh;
X		while (kp != NULL) {
X			if (kp->d_next == NULL)
X				fwrite(kp->d_chunk, 1, kbs[ukb].kused, fw);
X			else
X				fwrite(kp->d_chunk, 1, KBLOCK, fw);
X			kp = kp->d_next;
X		}
X		fflush(fw);
X		fclose(fw);
X		exit (0);
X	}
}
X
/*
X * filter a buffer through an external DOS program
X * this is obsolete, the filterregion code is better.
X */
filter(f, n)
{
X        register int    s;	/* return status from CLI */
X	register BUFFER *bp;	/* pointer to buffer to zot */
X        static char oline[NLINE];	/* command line send to shell */
X        char	line[NLINE];	/* command line send to shell */
X	char tmpnam[NFILEN];	/* place to store real file name */
X	static char bname1[] = "fltinp";
X
#if	AMIGA
X	static char filnam1[] = "ram:fltinp";
X	static char filnam2[] = "ram:fltout";
X        long newcli;
#else
X	static char filnam1[] = "fltinp";
X	static char filnam2[] = "fltout";
#endif
X
#if     VMS
X	mlwrite("Not availible under VMS");
X	return(FALSE);
#endif
#if     CPM
X        mlwrite("Not availible under CP/M-86");
X        return(FALSE);
#endif
X	/* get the filter name and its args */
X        if ((s=mlreply("cmd: |", oline, NLINE)) != TRUE)
X                return(s);
X	strcpy(line,oline);
X
X	/* setup the proper file names */
X	bp = curbp;
X	strcpy(tmpnam, bp->b_fname);	/* save the original name */
X	strcpy(bp->b_fname, bname1);	/* set it to our new one */
X
X	/* write it out, checking for errors */
X	if (writeout(filnam1,curbp,TRUE) != TRUE) {
X		mlwrite("[Cannot write filter file]");
X		strcpy(bp->b_fname, tmpnam);
X		return(FALSE);
X	}
X
#if     AMIGA
X        newcli = Open("CON:0/0/640/200/MicroEMACS Subprocess", NEW);
X	strcat(line, " <ram:fltinp >ram:fltout");
X        Execute(line,0L,newcli);
X	s = TRUE;
X        Close(newcli);
X        sgarbf = TRUE;
#endif
#if     MSDOS
X	strcat(line," <fltinp >fltout");
X	movecursor(term.t_nrow - 1, 0);
X	TTkclose();
X        system(line);
X	TTkopen();
X        sgarbf = TRUE;
X	s = TRUE;
#endif
#if     UNIX
#if	! NeWS
X        ttclean(TRUE);
#endif
X	strcat(line," <fltinp >fltout");
X        system(line);
#if	! NeWS
X        ttunclean();
X        TTflush();
X        sgarbf = TRUE;
#endif
X       s = TRUE;
#endif
X
X	/* on failure, escape gracefully */
X	if (s != TRUE || (readin(filnam2,FALSE,curbp,TRUE) == FALSE)) {
X		mlwrite("[Execution failed]");
X		strcpy(bp->b_fname, tmpnam);
X		unlink(filnam1);
X		unlink(filnam2);
X		return(s);
X	}
X
X	/* reset file name */
X	strcpy(bp->b_fname, tmpnam);	/* restore name */
X	bp->b_flag |= BFCHG;		/* flag it as changed */
X
X	/* and get rid of the temporary file */
X	unlink(filnam1);
X	unlink(filnam2);
X	return(TRUE);
}
X
#if     VMS
/*
X * Run a command. The "cmd" is a pointer to a command string, or NULL if you
X * want to run a copy of DCL in the subjob (this is how the standard routine
X * LIB$SPAWN works. You have to do wierd stuff with the terminal on the way in
X * and the way out, because DCL does not want the channel to be in raw mode.
X */
sys(cmd)
register char   *cmd;
{
X        struct  dsc$descriptor  cdsc;
X        struct  dsc$descriptor  *cdscp;
X        long    status;
X        long    substatus;
X        long    iosb[2];
X
X        status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
X                          oldmode, sizeof(oldmode), 0, 0, 0, 0);
X        if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
X                return (FALSE);
X        cdscp = NULL;                           /* Assume DCL.          */
X        if (cmd != NULL) {                      /* Build descriptor.    */
X                cdsc.dsc$a_pointer = cmd;
X                cdsc.dsc$w_length  = strlen(cmd);
X                cdsc.dsc$b_dtype   = DSC$K_DTYPE_T;
X                cdsc.dsc$b_class   = DSC$K_CLASS_S;
X                cdscp = &cdsc;
X        }
X        status = LIB$SPAWN(cdscp, 0, 0, 0, 0, 0, &substatus, 0, 0, 0);
X        if (status != SS$_NORMAL)
X                substatus = status;
X        status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
X                          newmode, sizeof(newmode), 0, 0, 0, 0);
X        if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
X                return (FALSE);
X        if ((substatus&STS$M_SUCCESS) == 0)     /* Command failed.      */
X                return (FALSE);
X        return (TRUE);
}
#endif
X
#if	~AZTEC & ~MSC & ~TURBO & MSDOS
X
/*
X * This routine, once again by Bob McNamara, is a C translation of the "system"
X * routine in the MWC-86 run time library. It differs from the "system" routine
X * in that it does not unconditionally append the string ".exe" to the end of
X * the command name. We needed to do this because we want to be able to spawn
X * off "command.com". We really do not understand what it does, but if you don't
X * do it exactly "malloc" starts doing very very strange things.
X */
sys(cmd, tail)
char    *cmd;
char    *tail;
{
#if MWC86
X        register unsigned n;
X        extern   char     *__end;
X
X        n = __end + 15;
X        n >>= 4;
X        n = ((n + dsreg() + 16) & 0xFFF0) + 16;
X        return(execall(cmd, tail, n));
#endif
X
#if LATTICE
X        return(forklp(cmd, tail, (char *)NULL));
#endif
}
#endif
X
#if	MSDOS & LATTICE
/*	System: a modified version of lattice's system() function
X		that detects the proper switchar and uses it
X		written by Dana Hogget				*/
X
system(cmd)
X
char *cmd;	/*  Incoming command line to execute  */
X
{
X	char *getenv();
X	static char *swchar = "/C";	/*  Execution switch  */
X	union REGS inregs;	/*  parameters for dos call  */
X	union REGS outregs;	/*  Return results from dos call  */
X	char *shell;		/*  Name of system command processor  */
X	char *p;		/*  Temporary pointer  */
X	int ferr;		/*  Error condition if any  */
X
X	/*  get name of system shell  */
X	if ((shell = getenv("COMSPEC")) == NULL) {
X		return (-1);		/*  No shell located  */
X	}
X
X	p = cmd;
X	while (isspace(*p)) {		/*  find out if null command */
X		p++;
X	}
X
X	/**  If the command line is not empty, bring up the shell  **/
X	/**  and execute the command.  Otherwise, bring up the     **/
X	/**  shell in interactive mode.   **/
X
X	if (p && *p) {
X		/**  detect current switch character and us it  **/
X		inregs.h.ah = 0x37;	/*  get setting data  */
X		inregs.h.al = 0x00;	/*  get switch character  */
X		intdos(&inregs, &outregs);
X		*swchar = outregs.h.dl;
X		ferr = forkl(shell, "command", swchar, cmd, (char *)NULL);
X	} else {
X		ferr = forkl(shell, "command", (char *)NULL);
X	}
X
X	return (ferr ? ferr : wait());
}
#endif
SHAR_EOF
chmod 0444 spawn.c ||
echo 'restore of spawn.c failed'
Wc_c="`wc -c < 'spawn.c'`"
test 20300 -eq "$Wc_c" ||
	echo 'spawn.c: original size 20300, current size' "$Wc_c"
# ============= st520.c ==============
echo 'x - extracting st520.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'st520.c' &&
/*
X
The routines in this file provide support for the Atari 520 or 1040ST
using VT52 emulation.  The I/O services are provided here as well.  It
compiles into nothing if not a 520ST style device.
X
*/
X
#define	termdef	1			/* don't define "term" external */
X
#include        <stdio.h>
#include        "estruct.h"
#include	"edef.h"
X
#if     ATARI & ST520 & MEGAMAX
#include	<osbind.h>
X
#define LINEA_INIT 0xA000
#define V_CEL_WR   -0x28
X
#define V_CEL_MY   -0x2a
#define V_CEL_HT   -0x2e
#define V_FNT_AD   -0x16
#define V_OFF_AD   -0x0a
#define V_DISAB    -346
X
#define NROW    25                      /* Screen size.                 */
#define NCOL    80                      /* Edit if you want to.         */
#define	MARGIN	8			/* size of minimim margin and	*/
#define	SCRSIZ	64			/* scroll size for extended lines */
#define	NPAUSE	25			/* # times thru update to pause */
#define BIAS    0x20                    /* Origin 0 coordinate bias.    */
#define ESC     0x1B                    /* ESC character.               */
#define BEL     0x07                    /* ascii bell character         */
X
extern  int     ttopen();               /* Forward references.          */
extern  int     ttgetc();
extern  int     ttputc();
extern  int     ttflush();
extern  int     ttclose();
extern  int     st520move();
extern  int     st520eeol();
extern  int     st520eeop();
extern  int     st520beep();
extern  int     st520open();
extern	int	st520close();
extern	int	st520rev();
extern  int st520kopen();
extern  int st520kclose();
extern	int st520chgrez();
X
#if	COLOR
extern	int	st520fcol();
extern	int	st520bcol();
X
int		cfcolor = -1;		/* current fg (character) color */
int		cbcolor = -1;		/* current bg color */
int		oldpal[8];		/* pallette when emacs was invoked */
int		newpal[8] = {		/* default emacs pallette */
X	0x000, 0x700, 0x070, 0x770, 0x007, 0x707, 0x077, 0x777};
#endif
X
int STncolors = 0;		/* number of colors  */
int STrez;			/* physical screen resolution */	
X
/*
X * Dispatch table. All the
X * hard fields just point into the
X * terminal I/O code.
X */
TERM    term    = {
X        NROW-1,
X        NCOL,
X	MARGIN,
X	MARGIN,
X	SCRSIZ,
X	NPAUSE,
X        &st520open,
X        &st520close,
X	&st520kopen,
X	&st520kclose,
X        &ttgetc,
X        &ttputc,
X        &ttflush,
X        &st520move,
X        &st520eeol,
X        &st520eeop,
X        &st520beep,
X        &st520rev
#if	MULTREZ
X	, &st520chgrez
#endif
#if	COLOR
X	, &st520fcol,
X	&st520bcol
#endif
};
X	struct KBDvecs {
X		int (*midivec) ();
X		int (*vkbderr) ();
X		int (*vmiderr) ();
X		int (*statvec) ();
X		int (*mousevec) ();
X		int (*clockvec) ();
X		int (*joyvec) ();
X		int (*midisys) ();
X		int (*ikbdsys) ();
X	};
X	struct Param {
X		char topmode;
X		char buttons;
X		char xparam;
X		char yparam;
X		int xmax,ymax;
X		int xinitial,yinitial;
X	};
X	struct KBDvecs *kbdvecs;
X	struct Param *paramp;
X	char kbdcmds[25];
X
st520move(row, col)
{
X        ttputc(ESC);
X        ttputc('Y');
X        ttputc(row+BIAS);
X        ttputc(col+BIAS);
}
X
st520eeol()
{
X        ttputc(ESC);
X        ttputc('K');
}
X
st520eeop()
{
X
#if	COLOR
X		st520fcol(gfcolor);
X		st520bcol(gbcolor);
#endif
X        ttputc(ESC);
X        ttputc('J');
}
X
st520rev(status)	/* set the reverse video state */
X
int status;	/* TRUE = reverse video, FALSE = normal video */
X
{
X
X	if(status) {
X		ttputc(ESC);
X		ttputc('p');
X	}
X	else {
X		ttputc(ESC);
X		ttputc('q');
X	}
}
X
#if	COLOR
st520fcol(color)
int color;	
{
X		if(color == cfcolor || !STncolors)
X			return;
X		else {
X
X			ttputc(ESC);
X			ttputc('b');
X			ttputc(color & 0x0f);
X			cfcolor = color;
X		}
}
X
st520bcol(color)
int color;
{
X		if(color == cbcolor || !STncolors)
X			return;
X		else {
X			ttputc(ESC);
X			ttputc('c');
X			ttputc(color & 0x0f);
X			cbcolor = color;
X		}
X
}
#endif
X
st520beep()
{
#ifdef	BEL
X        ttputc(BEL);
X        ttflush();
#endif
}
X
st520open()
{
X	int i,j,k;
X	long phys, log;	/* screen bases */
X	
/* IMPORTANT: it is ABSOLUTELY necessary that the default resolution be the
X *	largest possible so that display will allocate (malloc) the maximum
X *	size for the VIDEO arrray
X */
X	STrez = Getrez();
X	switch(STrez) {
X		case 0: /* low res 25x40 16 colors */
X			phys = Physbase();
X			log  = Logbase();
X			Setscreen(log, phys, 1);
X			STrez = 1;
X			/* fall thru to med res */
X
X		case 1: /* med res 25x80 4 colors */
X			term.t_nrow = 25 - 1;
X			term.t_ncol  = 80;
X			grez = 1;
#if	COLOR
X			STncolors = 4;
X			for(i=0;i<8;i++) {
X				oldpal[i] = Setcolor(i,newpal[i]);
X			}
#endif
X			break;
X		case 2: /* high res 25x80 no colors */
X			term.t_nrow  = 40 - 1;
X			term.t_ncol  = 80;
X			grez = 2;
X			make_8x10(); /* create a smaller font */
X			set_40();    /* and go to 40 line mode */
#if	COLOR
X			STncolors = 0;
#endif
X			break;
X	}
X
X	revexist = TRUE;
X	eolexist = TRUE;
X	paramp = (struct Param *)malloc(sizeof(struct Param));
X	kbdvecs = (struct KBDvecs *)Kbdvbase();
X	paramp -> topmode = 0;
X	paramp -> buttons = 4;
X	paramp -> xparam = 8;
X	paramp -> yparam = 10;
X	paramp -> xmax = 79;
X	paramp -> ymax = 23;
X	paramp -> xinitial = 0;
X	paramp -> yinitial = 0;
X	Initmous(1,paramp,kbdvecs -> mousevec);
X
X	i = 0;
X	kbdcmds[i++] = 0x0a;	/*set mouse keycode mode */
X	kbdcmds[i++] = 0x08;
X	kbdcmds[i++] = 0x0a;
X	Ikbdws(i-1,&kbdcmds[0]);
X	Cursconf(1,0);
X	Cursconf(3,0);
X	Cconout(27);Cconout('E');
X        ttopen();
}
X
st520close()
X
{
X	int i,j,k;
X
X	i = 0;
X	kbdcmds[i++] = 0x80;	/*reset mouse keycode mode */
X	kbdcmds[i++] = 0x01;
X	Ikbdws(i-1,&kbdcmds[0]);
X	if(grez == 2 && STrez == 2) /* b/w monitor in 40 row mode */
X		restore();
X
#if		COLOR
X	for(i=0;i<STncolors;i++)
X		Setcolor(i,oldpal[i]);
#endif
X	Cconout(27);Cconout('E');
X	paramp -> buttons = 0;
X	Initmous(2,paramp,kbdvecs -> mousevec);
X	i = 0;
X	kbdcmds[i++] = 0x80;	/*reset the keyboard*/
X	kbdcmds[i++] = 0x01;
X	Ikbdws(i-1,&kbdcmds[0]);
X	Cursconf(1,0);
X	ttclose();
}
st520kopen()
{
X
}
st520kclose()
{
X
}
X
st520chgrez(nurez)
int nurez;
{
X	int ierr, i, j ,k;
X	long phys, log;	/* screen bases */
X	char dum[80]; /* for debugging only */
X		
X	if(grez == nurez)
X		return(TRUE);
X		
X	if(STrez == 2) { /* b/w monitor-only allow hi | med rez */
X		switch(nurez) {
X			case 2: /* high res */
X				term.t_nrow  = 40 - 1;
X				term.t_ncol  = 80;
X				make_8x10(); /* create a smaller font */
X				set_40();    /* and go to 40 line mode */
X				grez = 2;
X				sgarbf = TRUE;
X				onlywind(1,1);
X				break;
X			case 1: /* med res */
X				term.t_nrow  = 25 - 1;
X				term.t_ncol  = 80;
X				restore();
X				grez = 1;
X				sgarbf = TRUE;
X				onlywind(1,1);
X				break;
X			default:
X				mlwrite("Invalid resolution");
X				return(FALSE);
X				break;
X		}
X	}
X	else { /* color monitor-only allow low | medium resolution */
X		phys = Physbase();
X		log  = Logbase();
X		switch(nurez) {
X			case 1:
X				term.t_nrow  = 25 - 1;
X				term.t_ncol  = 80;
X				Setscreen(log, phys, 1);
X				STncolors = 4;
X				grez = 1;
X				sgarbf = TRUE;
X				onlywind(1,1);
X				break;
X			case 0:
X				term.t_nrow  = 25 - 1;
X				term.t_ncol  = 40;
X				Setscreen(log, phys, 0);
X				STncolors = 8;
X				grez = 0;
X				sgarbf = TRUE;
X				onlywind(1,1);
X				break;
X			default:
X				mlwrite("%Invalid resolution");
X				return(FALSE);
X				break;
X		}
X	}
}			
X
STcurblink(onoff)
int onoff;
{
X	if(onoff)
X		Cursconf(2,0);
X	else
X		Cursconf(3,0);
}
X
X
char parm_save[28];
long fnt_8x10[640];
X
make_8x10()
{
X	int i,j,k;
X	long savea23[2];
X	
X	for(i=0;i<640;i++)
X		fnt_8x10[i] = 0;
X		
X	asm {
X	movem.l	A2-A3,savea23(A6)
X	
X	dc.w	LINEA_INIT		;A1 -> array of font headers
X
X	lea	parm_save(A4),A2	;A2 -> parameters savearea
X	move.l	V_OFF_AD(A0),(A2)+
X	move.l	V_FNT_AD(A0),(A2)+
X	move.w	V_CEL_HT(A0),(A2)+
X	move.w	V_CEL_MY(A0),(A2)+
X	move.w	V_CEL_WR(A0),(A2)+
X
X
X	move.l	04(A1),A1		; A1 -> 8x8 font header
X	move.l	76(A1),A2		; A2 -> 8x8 font data
X	lea	fnt_8x10+0x100(A4),A3	; A3 -> 2nd line of font buffer
X	move.w	#0x200-1,D0		; D0 <- longword counter for font xfer
X
fnt_loop:
X
X	move.l	(A2)+,(A3)+
X	dbf	D0,fnt_loop
X		
X	movem.l	savea23(A6),A2-A3
X	}
X	
}
X
set_40()
{
X	long	savea23[2];
X	
X	asm {
X	
;
;  use the 8x10 character set: 40 line mode
;
X
X	movem.l	A2-A3,savea23(A6)
X	
X	dc.w	LINEA_INIT
X
X	move.l	04(A1),A1		; A1 -> 8x8 font header
X	move.l	72(A1),V_OFF_AD(A0)	; v_off_ad <- 8x8  offset table addr
X	lea	fnt_8x10(A4),A2
X	move.l	A2,V_FNT_AD(A0)		; v_fnt_ad <- 8x10 font data addr
X
X	move.w	#10,V_CEL_HT(A0)	; v_cel_ht <- 10   8x10 cell height
X	move.w	#39,V_CEL_MY(A0)	; v_cel_my <- 39   maximum cell "Y"
X	move.w	#800,V_CEL_WR(A0)	; v_cel_wr <- 800  offset to cell Y+1
X
X	movem.l savea23,A2-A3
X	}
}
X
set_20()
{
X	long	savea23[2];
X
X	asm {
X		
;
;  use the 8x10 character set: 20 line mode
;
X
X	movem.l	A2-A3,savea23(A6)
X	
X	dc.w	LINEA_INIT		; A0 -> line A variables
X
X	move.l	04(A1),A1		; A1 -> 8x8 font header
X	move.l	72(A1),V_OFF_AD(A0)	; v_off_ad <- 8x8  offset table addr
X	lea	fnt_8x10(A4),A2
X	move.l	A2,V_FNT_AD(A0)		; v_fnt_ad <- 8x10 font data addr
X
X	move.w	#10,V_CEL_HT(A0)	; v_cel_ht <- 10   8x10 cell height
X	move.w	#19,V_CEL_MY(A0)	; v_cel_my <- 19   maximum cell "Y"
X	move.w	#1600,V_CEL_WR(A0)	; v_cel_wr <- 800  offset to cell Y+1
X	
X	movem.l	savea23,A2-A3
X	}
}
X
X
restore()
{
X	long savea23[2];
X	
X	asm {
X	
;  return what was saved in parameter save zone	
X
X	movem.l	A2-A3,savea23(A6)
X
X	dc.w	LINEA_INIT		; a0 -> line A variables
X
X	lea	parm_save(A4),A2	; a2 -> parameter save area
X	move.l	(A2)+,V_OFF_AD(A0)
X	move.l	(A2)+,V_FNT_AD(A0)
X	move.w	(A2)+,V_CEL_HT(A0)
X	move.w	(A2)+,V_CEL_MY(A0)
X	move.w	(A2)+,V_CEL_WR(A0)
X	
X	movem.l	savea23(A6),A2-A3
X	}          
}
GetCurStat(onoff)
int	onoff;
{
X	long savea23[2];
X
X	asm {
X	movem.l	A2-A3,savea23(A6)
X
X	dc.w	LINEA_INIT		; a0 -> line A variables
X	move.w	V_DISAB(A0),onoff(A6)	; 0 = cursor visible
X	moveq	#0,D0
X	move.w	V_DISAB(A0),D0	
X	movem.l	savea23(A6),A2-A3
X	}          
}
#else
#if	ATARI & ST520 & LATTICE
X
/*
X	These routines provide support for the ATARI 1040ST using
the LATTICE compiler using the virtual VT52 Emulator
X
*/
X
#define NROW    40                      /* Screen size.                 */
#define NCOL    80                      /* Edit if you want to.         */
#define	MARGIN	8			/* size of minimim margin and	*/
#define	SCRSIZ	64			/* scroll size for extended lines */
#define	NPAUSE	300			/* # times thru update to pause */
#define BIAS    0x20                    /* Origin 0 coordinate bias.    */
#define ESC     0x1B                    /* ESC character.               */
#define BEL     0x07                    /* ASCII bell character         */
X
/****	ST Internals definitions		*****/
X
/*	BIOS calls */
X
#define	BCONSTAT	1	/* return input device status */
#define	CONIN		2	/* read character from device */
#define	BCONOUT		3	/* write character to device */
X
/*	XBIOS calls */
X
#define	INITMOUS	0	/* initialize the mouse */
#define	GETREZ		4	/* get current resolution */
#define	SETSCREEN	5	/* set screen resolution */
#define	SETPALETTE	6	/* set the color pallette */
#define	SETCOLOR	7	/* set or read a color */
#define	CURSCONF	21	/* set cursor configuration */
#define	IKBDWS		25	/* intelligent keyboard send command */
#define	KBDVBASE	34	/* get keyboard table base */
X
/*	GEMDOS calls */
X
#define	EXEC		0x4b	/* Exec off a process */
X
#define	CON		2	/* CON: Keyboard and screen device */
X
/*	LINE A variables	*/
X
#define LINEA_INIT 0xA000
#define V_CEL_WR   -0x28
#define V_CEL_MY   -0x2a
#define V_CEL_HT   -0x2e
#define V_FNT_AD   -0x16
#define V_OFF_AD   -0x0a
#define V_DISAB    -346
X
/*	Palette color definitions	*/
X
#define	LOWPAL	"000700070770007707077777"
#define	MEDPAL	"000700007777"
#define	HIGHPAL	"000111"
X
/*	ST Global definitions		*/
X
/* keyboard vector table */
struct KVT {
X	long midivec;		/* midi input */
X	long vkbderr;		/* keyboard error */
X	long vmiderr;		/* MIDI error */
X	long statvec;		/* IKBD status */
X	int (*mousevec)();	/* mouse vector */
X	long clockvec;		/* clock vector */
X	long joyvec;		/* joystict vector */
} *ktable;
X
int (*sysmint)();			/* system mouse interupt handler */
X
/* mouse parameter table */
struct Param {
X	char topmode;
X	char buttons;
X	char xparam;
X	char yparam;
X	int xmax,ymax;
X	int xinitial,yinitial;
} mparam;
X
int initrez;			/* initial screen resolution */
int currez;			/* current screen resolution */
char resname[][8] = {		/* screen resolution names */
X	"LOW", "MEDIUM", "HIGH", "DENSE"
};
short spalette[16];			/* original color palette settings */
short palette[16];			/* current palette settings */
X
extern  int     ttopen();               /* Forward references.          */
extern  int     ttgetc();
extern  int     ttputc();
extern  int     ttflush();
extern  int     ttclose();
extern  int     stmove();
extern  int     steeol();
extern  int     steeop();
extern  int     stbeep();
extern  int     stopen();
extern	int	stclose();
extern	int	stgetc();
extern	int	stputc();
extern	int	strev();
extern	int	strez();
extern	int	stkopen();
extern	int	stkclose();
X
#if	COLOR
extern	int	stfcol();
extern	int	stbcol();
#endif
X
/*
X * Dispatch table. All the
X * hard fields just point into the
X * terminal I/O code.
X */
TERM    term    = {
X	NROW-1,
X        NROW-1,
X        NCOL,
X        NCOL,
X	MARGIN,
X	SCRSIZ,
X	NPAUSE,
X        &stopen,
X        &stclose,
X	&stkopen,
X	&stkclose,
X        &stgetc,
X	&stputc,
X        &ttflush,
X        &stmove,
X        &steeol,
X        &steeop,
X        &stbeep,
X        &strev,
X	&strez
#if	COLOR
X	, &stfcol,
X	&stbcol
#endif
};
X
stmove(row, col)
{
X        stputc(ESC);
X        stputc('Y');
X        stputc(row+BIAS);
X        stputc(col+BIAS);
}
X
steeol()
{
X        stputc(ESC);
X        stputc('K');
}
X
steeop()
{
#if	COLOR
X	stfcol(gfcolor);
X	stbcol(gbcolor);
#endif
X        stputc(ESC);
X        stputc('J');
}
X
strev(status)	/* set the reverse video state */
X
int status;	/* TRUE = reverse video, FALSE = normal video */
X
{
X	if (currez > 1) {
X		stputc(ESC);
X		stputc(status ? 'p' : 'q');
X	}
}
X
#if	COLOR
mapcol(clr)	/* medium rez color translation */
X
int clr;	/* emacs color number to translate */
X
{
X	static int mctable[] = {0, 1, 2, 3, 2, 1, 2, 3};
X
X	if (currez != 1)
X		return(clr);
X	else
X		return(mctable[clr]);
}
X
stfcol(color)	/* set the forground color */
X
int color;	/* color to set forground to */
X
{
X	if (currez < 2) {
X		stputc(ESC);
X		stputc('b');
X		stputc(mapcol(color));
X	}
}
X
stbcol(color)	/* set the background color */
X
int color;	/* color to set background to */
X
X
{
X	if (currez < 2) {
X		stputc(ESC);
X		stputc('c');
X		stputc(mapcol(color));
X	}
}
#endif
X
stbeep()
{
X        stputc(BEL);
X        ttflush();
}
X
domouse()	/* mouse interupt handler */
X
{
X	return((*sysmint)());
}
X
stkopen()	/* open the keyboard (and mouse) */
X
{
X	/* grab the keyboard vector table */
X	ktable = (struct KVT *)xbios(KBDVBASE);
X	sysmint = ktable->mousevec;	/* save mouse vector */
X
X	/* initialize the mouse */
X	mparam.topmode = 0;
X	mparam.buttons = 4;
X	mparam.xparam = 8;
X	mparam.yparam = 10;
X	mparam.xmax = 79;
X	mparam.ymax = 23;
X	mparam.xinitial = 0;
X	mparam.yinitial = 0;
X	xbios(INITMOUS, 4, &mparam, &domouse);
}
X
stopen()	/* open the screen */
X
{
X	int i;
X
X        ttopen();
X	eolexist = TRUE;
X
X	/* switch to a steady cursor */
X	xbios(CURSCONF, 3);
X
X	/* save the current color palette */
X	for (i=0; i<16; i++)
X		spalette[i] = xbios(SETCOLOR, i, -1);
X
X	/* and find the current resolution */
X	initrez = currez = xbios(GETREZ);
X	strcpy(sres, resname[currez]);
X
X	/* set up the screen size and palette */
X	switch (currez) {
X		case 0:	term.t_mrow = 25 - 1;
X			term.t_nrow = 25 - 1;
X			term.t_ncol = 40;
X			strcpy(palstr, LOWPAL);
X			break;
X
X		case 1: term.t_mrow = 25 - 1;
X			term.t_nrow = 25 - 1;
X			strcpy(palstr, MEDPAL);
X			break;
X
X		case 2: term.t_mrow = 40 - 1;
X			term.t_nrow = 25 - 1;
X			strcpy(palstr, HIGHPAL);
X	}
X
X	/* and set up the default palette */
X	spal(palstr);
X
X	stputc(ESC);	/* automatic overflow off */
X	stputc('w');
X	stputc(ESC);	/* turn cursor on */
X	stputc('e');
}
X
stkclose()	/* close the keyboard (and mouse) */
X
{
X	static char resetcmd[] = {0x80, 0x01};	/* keyboard reset command */
X
X	/* restore the mouse interupt routines */
X	xbios(INITMOUS, 2, &mparam, (long)sysmint);
X
X	/* and reset the keyboard controller */
X	xbios(IKBDWS, 1, &resetcmd[0]);
}
X
stclose()
X
{
X	stputc(ESC);	/* auto overflow on */
X	stputc('v');
X
X	/* switch to a flashing cursor */
X	xbios(CURSCONF, 2);
X
X	/* restore the original screen resolution */
X	strez(resname[initrez]);
X
X	/* restore the original palette settings */
X	xbios(SETPALETTE, spalette);
X
X	ttclose();
}
X
/* 	spal(pstr):	reset the current palette according to a
X			"palette string" of the form
X
X	000111222333444555666777
X
X	which contains the octal values for the palette registers
*/
X
spal(pstr)
X
char *pstr;	/* palette string */
X
{
X	int pal;	/* current palette position */
X	int clr;	/* current color value */
X	int i;
X
X	for (pal = 0; pal < 16; pal++) {
X		if (*pstr== 0)
X			break;
X
X		/* parse off a color */
X		clr = 0;
X		for (i = 0; i < 3; i++)
X			if (*pstr)
X				clr = clr * 16 + (*pstr++ - '0');
X		palette[pal] = clr;
X	};
X
X	/* and now set it */
X	xbios(SETPALETTE, palette);
}
X
stgetc()	/* get a char from the keyboard */
X
{
X	int rval;		/* return value from BIOS call */
X	static int funkey = 0;	/* held fuction key scan code */
X
X	/* if there is a pending function key, return it */
X	if (funkey) {
X		rval = funkey;
X		funkey = 0;
X	} else {
X		/* waiting... flash the cursor */
X		xbios(CURSCONF, 2);
X
X		/* get the character */
X		rval = bios(CONIN, CON);
X		if ((rval & 255) == 0) {
X			funkey = (rval >> 16) & 255;
X			rval = 0;
X		}
X
X		/* and switch to a steady cursor */
X		xbios(CURSCONF, 3);
X	}
X
X	return(rval & 255);
}
X
stputc(c)	/* output char c to the screen */
X
char c;		/* character to print out */
X
{
X	bios(BCONOUT, CON, c);
}
X
strez(newrez)	/* change screen resolution */
X
char *newrez;	/* requested resolution */
X
{
X	int nrez;	/* requested new resolution */
X
X	/* first, decode the resolution name */
X	for (nrez = 0; nrez < 4; nrez++)
X		if (strcmp(newrez, resname[nrez]) == 0)
X			break;
X	if (nrez == 4) {
X		mlwrite("%%No such resolution");
X		return(FALSE);
X	}
X
X	/* next, make sure this resolution is legal for this monitor */
X	if ((currez < 2 && nrez > 1) || (currez > 1 && nrez < 2)) {
X		mlwrite("%%Resolution illegal for this monitor");
X		return(FALSE);
X	}
X
X	/* eliminate non-changes */
X	if (currez == nrez)
X		return(TRUE);
X
X	/* finally, make the change */
X	switch (nrez) {
X		case 0:	/* low resolution - 16 colors */
X			newwidth(TRUE, 40);
X			strcpy(palstr, LOWPAL);
X			xbios(SETSCREEN, -1, -1, 0);
X			break;
X
X		case 1:	/* medium resolution - 4 colors */
X			newwidth(TRUE, 80);
X			strcpy(palstr, MEDPAL);
X			xbios(SETSCREEN, -1, -1, 1);
X			break;
X
X		case 2:	/* High resolution - 2 colors - 25 lines */
X			newscreensize(25, term.t_ncol);
X			strcpy(palstr, HIGHPAL);
X			/* change char set back to normal */
X			break;
X
X		case 3:	/* Dense resolution - 2 colors - 40 lines */
X			newscreensize(40, term.t_ncol);
X			strcpy(palstr, HIGHPAL);
X			/*change char set size */
X			break;
X	}
X
X	/* and set up the default palette */
X	spal(palstr);
X	currez = nrez;
X	strcpy(sres, resname[currez]);
X
X	stputc(ESC);	/* automatic overflow off */
X	stputc('w');
X	stputc(ESC);	/* turn cursor on */
X	stputc('e');
X
X	return(TRUE);
}
X
system(cmd)	/* call the system to execute a new program */
X
char *cmd;	/* command to execute */
X
{
X	char *pptr;			/* pointer into program name */
X	char pname[NSTRING];		/* name of program to execute */
X	char tail[NSTRING];		/* command tail */
X
X	/* scan off program name.... */
X	pptr = pname;
X	while (*cmd && (*cmd != ' ' && *cmd != '\t'))
X		*pptr++ = *cmd++;
X	*pptr = 0;
X
X	/* create program name length/string */
X	tail[0] = strlen(cmd);
X	strcpy(&tail[1], cmd);
X
X	/* go do it! */
X	return(gemdos(		(int)EXEC,
X				(int)0,
X				(char *)pname,
X				(char *)tail,
X				(char *)NULL));
}
X
#if	TYPEAH
typahead()
X
{
X	int rval;	/* return value from BIOS call */
X
X	/* get the status of the console */
X	rval = bios(BCONSTAT, CON);
X
X	/* end return the results */
X	if (rval == 0)
X		return(FALSE);
X	else
X		return(TRUE);
}
#endif
X
#if	FLABEL
fnclabel(f, n)		/* label a function key */
X
int f,n;	/* default flag, numeric argument [unused] */
X
{
X	/* on machines with no function keys...don't bother */
X	return(TRUE);
}
#endif
#else
sthello()
{
}
#endif
#endif
X
SHAR_EOF
chmod 0444 st520.c ||
echo 'restore of st520.c failed'
Wc_c="`wc -c < 'st520.c'`"
test 19931 -eq "$Wc_c" ||
	echo 'st520.c: original size 19931, current size' "$Wc_c"
# ============= tags ==============
echo 'x - extracting tags (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'tags' &&
ABORT	estruct.h	/^#define ABORT	2			\/* Death, ESC, abort, etc.	*\/$/
ABS	estruct.h	/^#define ABS	0x10	\/* command causes absolute (i.e. non-relative) motion *\/$/
AEDIT	estruct.h	/^#define	AEDIT	1	\/* advanced editing options: e.g. en\/detabbing	*\/$/
ALTDOTO	undo.c	/^#define ALTDOTO(bp) (bp->b_uddotos[1^(bp->b_udstki/
ALTDOTP	undo.c	/^#define ALTDOTP(bp) (bp->b_uddotps[1^(bp->b_udstki/
ALTSTK	undo.c	/^#define ALTSTK(bp) (&(bp->b_udstks[1^(bp->b_udstki/
AMG_MAXBUF	termio.c	/^#define AMG_MAXBUF      1024L$/
AMIGA	estruct.h	/^#define AMIGA	0			\/* AmigaDOS			*\/$/
ANSI	estruct.h	/^#define ANSI	0			\/* ANSI escape sequences	*\/$/
ANY	estruct.h	/^#define	ANY		2$/
APROP	estruct.h	/^#define	APROP	1	\/* Add code for Apropos command	(needs REBIND)	*\/$/
AT386	estruct.h	/^#define AT386	0			\/* AT style 386 unix console	*\/$/
ATARI	estruct.h	/^#define	ATARI	0			\/* Atari 520\/1040ST screen	*\/$/
AZTEC	estruct.h	/^#define	AZTEC	0	\/* Aztec C 3.20e *\/$/
BACK	csrch.c	/^#define BACK 0$/
BANG	estruct.h	/^#define BANG	(4<<16)		\/* allow a ! after the command name *\/$/
BEL	tcap.c	/^#define BEL     0x07$/
BFCHG	estruct.h	/^#define BFCHG	0x02			\/* Changed since last write	*\/$/
SHAR_EOF
true || echo 'restore of tags failed'
echo 'End of Vile part 13'
echo 'File tags is continued in part 14'
echo 14 > _shar_seq_.tmp
exit 0
-- 
		paul fox, pgf at cayman.com, (617)494-1999
		Cayman Systems, 26 Landsdowne St., Cambridge, MA 02139



More information about the Alt.sources mailing list