#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <process.h>

int far handler();

	far fortran cctrap( trap )
	  int *trap;
	{
	  if( *trap == 1 ) signal( SIGINT, handler );
	  else signal( SIGINT, SIG_DFL );
	}


	int far handler()
	  {
	  static char esc=27;
	  char ch;

	  fflush( stdin );
	  printf( "%1c(B%1c[5m%1c[23;1HExit? (Y/N)", esc, esc, esc );
	  scanf( "%1c", &ch );
	  if( ch == 'y' || ch == 'Y' )
	    { printf( "%1c[m%1c[2J%1c[7m[Fpaint aborted by user]%1c[m\n",esc,esc,esc,esc );
	      exit (0); }
	  else 
	  { printf( "%1c[m%1c[23;1HType ^R to repaint screen", esc, esc );
	    signal( SIGINT, handler ); }
	}
