#include <stdio.h>
main (argc,argv,envp)

	int	argc;
	char	*argv[],*envp[];
{
	FILE *fp,*fopen();
	int	tty,i=0;
	char	line[300];

	if (argc==1) fp=stdin;
	else if ((fp=fopen(argv[1],"r")) == (FILE *) 0) exit (0);

	if ((tty=open("/dev/tty",0))==0) exit(1);

	printf ("\n\n\n\n\n\n\r");
	while (fgets(line,500,fp))
	{
		if (line[0]==12)
		{
			line[0]=32;
			i=21;
		}
		if (i++ >20)
		{
			printf ("\r  COMANDOS : [ENTER : CONTINUA]    [ESC : ABANDONA]  ");
			fflush(stdout);
			while((i=getin1(tty))!=13 && i!=27 && i!=10 && i!=32);
			printf ("\r                                                             \r");
			if (i==13 || i==10) i=20;
			else if (i==32) i=0;
			else exit(0);
		}
		printf ("%s\r",line);
	}
	printf ("\r  COMANDOS : [ENTER : CONTINUA]    [ESC : ABANDONA]  ");
	fflush(stdout);
	while((i=getin1(tty))!=13 && i!=27 && i!=10 && i!=32);
	printf ("\r                                                             \r");
}
getin1 (tty)

	int	tty;
{
	char n;
	int np=0;

	while ((read(tty,&n,1))<0)
	{
		nap(50L);
		np++;
		if (np>600) return(27);
	}
	return(n);
}
