示例#1
0
文件: FED.C 项目: MegaGod/TW
void edit( int ch ) {
	struct viewporttype tmp;
	char key, *buff;

	take_char( ( char ) ch );
	backup_char( );
	getviewsettings( &tmp );
	setviewport( 400, 30, getmaxx( ), getmaxy( ), 1 );
	buff = ( char* ) malloc( imagesize( 0 + align, 0, X*( 2 + WIDTH_X ) + align, Y*( 2 + WIDTH_Y ) ) );
	getimage( 0 + align, 0, X*( 2 + WIDTH_X ) + align, Y*( 2 + WIDTH_Y ), buff );
	draw_char( );
	start_clock( EDIT_FONT );

	while ( ( key = get_pos( &pos_x, &pos_y, X - 1, Y - 1, 1, 1 ) ) != 3 ) {
		switch ( tolower( key ) ) {
		case 1:
			xor_dot( pos_x, pos_y );
			continue;

		case '8':
			pan_up( );
			draw_char( );
			break;

		case '2':
			pan_down( );
			draw_char( );
			break;

		case '4':
			pan_left( );
			draw_char( );
			break;

		case '6':
			pan_right( );
			draw_char( );
			break;

		case 'r':
			insert_row( pos_y );
			draw_char( );
			break;

		case 'c':
			insert_col( pos_x );
			draw_char( );
			break;

		case 'e':
			del_row( pos_y );
			draw_char( );
			break;

		case 'd':
			del_col( pos_x );
			draw_char( );
			break;

		case 'i':
			invert( );
			draw_char( );
			break;

		case 'm':
			mirror( );
			draw_char( );
			break;

		case '.':
			++draw_mode;
			switch ( draw_mode ) {
			case 0:
				break;
			case 1:
				put_dot( pos_x, pos_y );
				edit_font[pos_x][pos_y] = ~0;
				break;
			case 2:
				square( pos_x, pos_y );
				edit_font[pos_x][pos_y] = 0;
				break;
			case 3:
				draw_mode = 0;
			}
			continue;

		case 'u':
			undo( );
			draw_char( );
			goto exit;

		case '?':
			help( );
			break;

		default:
			if ( draw_mode == 1 ) {
				put_dot( pos_x, pos_y );
				edit_font[pos_x][pos_y] = ~0;
			}
			if ( draw_mode == 2 ) {
				square( pos_x, pos_y );
				edit_font[pos_x][pos_y] = 0;
			}

		}
	}
	update_char( ( char ) ch );
exit:
	putimage( 0 + align, 0, buff, COPY_PUT );
	free( buff );
	stop_clock( );
	dispblank( 50, 16, strlen( "Move mode" ), 0 );
	setviewport( tmp.left, tmp.top, tmp.right, tmp.bottom, tmp.clip );
	print_table( which_page( ch ) );
}
示例#2
0
文件: menu.c 项目: cls/bohm
void info()
{
    int select='x';
    while((select!='y')&&(select!='n')){
	printf("Display time and number of interactions?\n");
	printf("Please answer 'y' or 'n' (type 'h' for help).\n\n>");
	select = take_char();
	printf("\n");
	switch(select){
	    case 'y':
		seetime=true;
		break;
	    case 'n':
		seetime=false;
		break;
	    case 'h':
		printf("HELP . . .\n\n");
		printf("Answering 'y', the interpreter will display,\n");
		printf("after each reduction, the following informations:\n");
		printf("- Time taken by reduction, divided into:\n");
		printf("-     User   time (given in seconds).\n");
		printf("-     System time (given in seconds).\n");
		printf("- Total number of interactions.\n");
		printf("  (but the garbage ones)\n");
		printf("- Total number of family redex reductions.\n");
		printf("- Total number of proper interactions.\n");
		printf("  (those involving not-structural nodes\n");
		break;
	    default:
		printf("Illegal answer (type 'h' for help) . . .\n");
		break;
	}
    printf("\n");
    }
    select = 'x';
    while((select!='y')&&(select!='n')){
	printf("Display memory occupation informations ?\n");
	printf("Please answer 'y' or 'n' (type 'h' for help).\n\n>");
	select = take_char();
	printf("\n");
	switch(select){
	    case 'y':
		seenode=true;
		break;
	    case 'n':
		seenode=false;
		break;
	    case 'h':
		printf("HELP . . .\n\n");
		printf("Answering 'y', the program will display\n");
		printf("the following informations:\n");
		printf("- Initial number of nodes\n");
		printf("  (at the beginning of every reduction).\n");
		printf("- Maximum number of nodes\n");
		printf("  (existing at the same time during the\n");
		printf("  whole program execution).\n");
		printf("- Final number of nodes\n");
		printf("  (at the end of every reduction).\n");
		break;
	    default:
		printf("Illegal answer (type 'h' for help) . . .\n");
	}
    printf("\n");
    }
    select = 'x';
    while((select!='y')&&(select!='n')){
	printf("Display garbage collection informations ?\n");
	printf("Please answer 'y' or 'n' (type 'h' for help).\n\n>");
	select = take_char();
	printf("\n");
	switch(select){
	    case 'y':
		seegarb=true;
		break;
	    case 'n':
		seegarb=false;
		break;
	    case 'h':
		printf("HELP . . .\n\n");
		printf("Answering 'y' the program will display\n");
		printf("the following informations:\n");
		printf("- Number of erasing operations required\n");
		printf("  for eliminating the previous term and\n");
		printf("  the corresponding time.\n");
		printf("- Number of erasing operations performed\n");
		printf("  during the actual reduction, the\n");
		printf("  corresponding time, and the number\n");
		printf("  of garbage collection activations\n");
		printf("- Number of erasing operations done\n");
		printf("  in collecting disconnected parts of the\n");
		printf("  term.\n");
		break;
	    default:
		printf("Illegal answer (type 'h' for help) . . .\n");
	}
    printf("\n");
    }
    system("clear");
    printf("***********************************************************\n");
    printf("* O.K. Your choice has been recorded . . .                *\n");
    printf("***********************************************************\n\n");

}