예제 #1
0
void print_number(int y, int x, int number){
	int num1[][3] = { { 0, 0, 1 }, { 0, 1, 1 }, { 1, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 } };
	int num2[][3] = { { 1, 1, 1 }, { 0, 0, 1 }, { 1, 1, 1 }, { 1, 0, 0 }, { 1, 1, 1 } };
	int num3[][3] = { { 1, 1, 1 }, { 0, 0, 1 }, { 1, 1, 1 }, { 0, 0, 1 }, { 1, 1, 1 } };
	int num4[][3] = { { 1, 0, 1 }, { 1, 0, 1 }, { 1, 1, 1 }, { 0, 0, 1 }, { 0, 0, 1 } };
	int num5[][3] = { { 1, 1, 1 }, { 1, 0, 0 }, { 1, 1, 1 }, { 0, 0, 1 }, { 1, 1, 1 } };
	int num6[][3] = { { 1, 1, 1 }, { 1, 0, 0 }, { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 } };
	int num7[][3] = { { 1, 1, 1 }, { 1, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 } };
	int num8[][3] = { { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 } };
	int num9[][3] = { { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 }, { 0, 0, 1 }, { 1, 1, 1 } };
	int num0[][3] = { { 1, 1, 1 }, { 1, 0, 1 }, { 1, 0, 1 }, { 1, 0, 1 }, { 1, 1, 1 } };

	chtype C = ACS_BLOCK; // OVDE BRZO MENJAMO ISPIS BROJEVA.

	switch (number){
	case 1: show_number(y, x, num1, C);	break;
	case 2: show_number(y, x, num2, C);	break;
	case 3: show_number(y, x, num3, C);	break;
	case 4: show_number(y, x, num4, C);	break;
	case 5: show_number(y, x, num5, C);	break;
	case 6: show_number(y, x, num6, C);	break;
	case 7: show_number(y, x, num7, C);	break;
	case 8: show_number(y, x, num8, C);	break;
	case 9: show_number(y, x, num9, C);	break;
	case 0: show_number(y, x, num0, C);	break;
	}
	refresh();

}
예제 #2
0
int time_control(){
	if (prev != new_time.ti_sec)//show hour minute and second when prev!=ti.te_sec
	{                               //that is after 1 second
		setfillstyle(1,4);
		setcolor(4);
		pieslice(550,260,angle,angle+1,30);
		angle-= INCREASE;
		if(increase==90)
			angle=359;
		if(increase==180)
			angle=269;
		if(increase==270)
			angle=179;
		sec++;
		increase+= INCREASE;
		if(sec==60){
			min++;	sec=0;
		}
		setfillstyle(1,15);
		bar(569,47,589,60);
		if(second<=9){
			if(!second){
				bar(550,47,560,60);
				if(!minute){
					color_text(574,50,"00",4);
					outtextxy(550,50,"0");
					setfillstyle(1,4);
					setcolor(4);
					pieslice(550,260,90,120,30);
					summary_content();
					end_lesson(min,sec,eff,err,speed);
					return 1;

				}
				minute--;
				second=59;
				show_number(second,574,50,4,0,1);
			}
			else{
				outtextxy(574,50,"0");
				show_number(second,582,50,4,0,1);
			}
		}

		else
			show_number(second,574,50,4,0,1);
		show_number(minute,552,50,4,0,1);
		second--;
		prev = new_time.ti_sec;

	}

	return 0;

}
예제 #3
0
void run_info(int pr, int crct, int w, int crtn){
	/* pr= pressed, crct= correct, w= wrong , crtn= correction */

	setfillstyle(1,15);
	bar(582,130,609,200);

	show_number(pr,584,130,4,0,1);
	show_number(crct,584,150,4,0,1);
	show_number(w,584,170,4,0,1);
	show_number(crtn,584,190,4,0,1);

}
예제 #4
0
static void
show_cap_number(MYDATA * data, const char *ti, const char *tc)
{
    const char *name = (opt_t ? tc : ti);
    show_number(data, name, (opt_t
			     ? tgetnum_sp(TC_PARMS)
			     : tigetnum_sp(TI_PARMS)));
}
예제 #5
0
파일: acm288.c 프로젝트: zhouer/ACM
int main()
{
	while(fgets(line_buf, 65536, stdin)) {
		line_buf_index = 0;
		get_token();
		show_number(pre4());
	}

	return 0;
}
예제 #6
0
파일: helpers.cpp 프로젝트: Murony/Cameleo
void show_clique(const set<int> &clique, const vector<vector<int>> &new_neutral_bits_set, vector<vector<int>> &final_set){
	int w = 0;
	char str[20];
	_snprintf_s(str, 20, 20, "w_clique_%d_%d.txt", clique.size(), global_count);
	ofstream fout(str);
	for (auto q = clique.begin(); q != clique.end(); q++){
		w = 0;
		for (auto t = new_neutral_bits_set.begin(); t != new_neutral_bits_set.end(); t++){
			if (w == *q){
				//final_set.push_back(*t);
				show_number(*t, fout);
			}
			w++;
		}
	}
	fout.close();
}
예제 #7
0
파일: dgrep.c 프로젝트: jarmoruuth/tools
/**********************************************************************
 *
 *	print_line
 */
static void print_line(char* beg, REG1 char* end, ulong lineno)
{
	REG3 int	c;

	dassert(*end == EOL2);
	
	if (end > beg && end[-1] == EOL1)
		end--;
	c = *end;
	*end = '\0';
	if (show_fname == BEFORE_LINE)
		printf(path);
	else if (show_fname == BLOCK && !fname_shown) {
		printf("*** File %s:\n", path);
		fname_shown = TRUE;
	}
	if (number)
		show_number(lineno);
	if (show_fname == BEFORE_LINE || number)
		printf(":");
	printf("%s\n", beg);
	*end = c;
}
예제 #8
0
void advanced_level(int file_no,int MINUTE, int angleINCREASE){

	FILE *file;
	file= fopen(file_name[file_no],"r");

	char choice[2],comp;
	// line & i will keep track wid total lines and chars respectively
	int i=0,chars=0, file_pointer,line,z,char_x,char_y,dummy_choice;
	int j1,ch1,x1,y1,time_up;

	prev= -1;
	time_interval=0, min=0, sec=0, eff=0, err=0, speed=0;
	pressed=0, correct= 0, wrong= 0, cpm=0, correction=0;
	minute=MINUTE, INCREASE= angleINCREASE,second=0;
	tutorial_window();
	hideMouse();

	file_pointer=0; choice[1]='\0';

	setcolor(4);
	settextstyle(0,0,1);
	outtextxy(542,50,"0");
	outtextxy(562,50,":");
	outtextxy(574,50,"00");
	show_number(minute,550,50,4,0,1);
	user_response(250,130,1,3);
	time(&start_time);

	settextstyle(2,0,5);
	color_text(535,76,"ESC to",3);
	color_text(536,76,"ESC to",3);
	color_text(524,92,"quit/pause",3);
	color_text(525,92,"quit/pause",3);

	dummy_choice= 'A'; //just to initialize the drawing of a key
	increase=0, angle=89;

	file_open4_screen(file,173,72,36,1,6,30,0);

	while(!feof(file)){

		i=0;char_x=173;char_y=90; line=0; chars=0;
		rewind(file);
		fseek(file,file_pointer,0);

		while(line<6){
			if(feof(file)){
				summary_content();
				end_lesson(min,sec,eff,err,speed);
				return;
				//break;
			}
			gettime (&new_time);
			time_up= time_control();
			if(time_up)
				return ;

			if(i>=0){
				color_text(char_x+8*i,(char_y+36*line)+1,"_",4);
				color_text(char_x+8*i,(char_y+36*line)-23,"^",4);
			}

			if(kbhit()){

				check_kb_up_down(dummy_choice,0);
				choice[0]= getch(); // user input
				dummy_choice= choice[0];
				pressed++;
				check_kb_up_down(choice[0],1);

				if(chars>29){
					color_text((char_x+i*8),(char_y+36*line)+1,"_",15);
					color_text((char_x+i*8),(char_y+36*line)-23,"^",15);
					i=0; line++; chars=0;
				}

				if(choice[0]==27 )  // ESC
				{
					pressed--;
					make_sound(2000,100);
					if(i>0)
						summary_content();

					z = continue_close(min,sec,eff,err,speed);
					if(z)
						return;
					else
						continue;
				}

				if(choice[0]==0){ // error checking for function keys
					int ch1=getch();
					if(ch1==80||ch1==72||ch1==75||ch1==77)   //error checking  to avoide right,left,up
						continue;
				}

				else if(choice[0]==9)
					continue;    //error checking for tab

				else if(choice[0]==8){  //BACKSPACE
					correction++;

					if(i>0 || line>0){
						if(i>0){
							file_pointer--;
							fseek(file,-1,SEEK_CUR);
							setfillstyle(1,15);
							bar(char_x+i*8,char_y+36*line,char_x+(i*8)-8,char_y+7+36*line);
							color_text((char_x+i*8)-8,(char_y+36*line)+1,"_",4);
							color_text(char_x+i*8,(char_y+36*line)+1,"_",15);
							color_text((char_x+i*8)-8,(char_y+36*line)-23,"^",4);
							color_text(char_x+i*8,(char_y+36*line)-23,"^",15);
							i--; chars--;
						}

						if(i>29){
							line++; i=0;chars=0;
						}

					}
					make_sound(1000,100);

				}

				else{
					file_pointer++; correct++;
					fscanf(file,"%c",&comp);
					setcolor(4);
					if(comp=='\n'){
						i=0; chars=1; line++; continue;

					}
					if(comp!=choice[0] && choice[0]==' ')
					{
						char choice1 = '-';	//when space is pressed instead of any key, print dash
						print_lesson(char_x+i*8,char_y+36*line,choice1,9);
						make_sound(500,100);
						wrong++; correct--;
					}

					else if(comp != choice[0]){
						wrong++; correct--;
						setcolor(9);
						make_sound(500,100);
						outtextxy(char_x+i*8,char_y+36*line,choice);
					}
					else
						outtextxy(char_x+i*8,char_y+36*line,choice);

					color_text((char_x+i*8)+8,(char_y+36*line)-23,"^",4);
					color_text(char_x+i*8,(char_y+36*line)-23,"^",15);
					color_text((char_x+i*8)+8,(char_y+36*line)+1,"_",4);
					color_text(char_x+i*8,(char_y+36*line)+1,"_",15);
					i++; chars++;
				}
			}

		}
		if(feof(file))
			break;
		setfillstyle(1,15);
		bar(165,56,417,300);
		undr_line(165,81,12,250,18,7);
		file_open4_screen(file,173,72,36,1,6,30,file_pointer);
	}
	fclose(file);
	closegraph();
}
예제 #9
0
void lesson_practice(int lesson_no,int num,int MINUTE,int angleINCREASE)
{
/* INCREASE= will control time, MINUTE= given time limit of typing */

	int j1,ch1,x1,y1,time_up;
	int char_x, char_y,i,choice,dummy_choice,line,z;
	int rndm,store; /* 'store' is used to store chars serially in
				store array */
	prev= -1;
	time_interval=0, min=0, sec=0, eff=0, err=0, speed=0;
	pressed=0, correct= 0, wrong= 0, cpm=0, correction=0;
	minute=MINUTE, INCREASE= angleINCREASE, second=0;

	char_x = 173;
	char_y = 72;

	tutorial_window();
	run_info_window();
	hideMouse();

	if(!num)
		LETTER= 4;

	else if(!lesson_no)
		LETTER=20;

	line = 1;
	for(i=1,store=0; line<MAX ;i++,store++)
	{
		rndm = random(LETTER); // randomly seeks chars
		if(!num){
			store_chars[store]= lesson[lesson_no-1][rndm];
			print_lesson(char_x, char_y, lesson[lesson_no-1][rndm],1);
		}

		else if(!lesson_no){
			store_chars[store]= numeric[num-1][rndm];
			print_lesson(char_x, char_y, numeric[num-1][rndm],1);
		}
		char_x +=8; //for next character

		if(i%4==0)       // GIVING SPACE AFTER EVERY 4 CHARS
		{
			char_x +=8;
			store++;
			store_chars[store]=' ';
		}

		if(char_x >405)    // NEXT LINE
		{
			char_x = 173;
			char_y+= 36;
			line++;
		}
	}
	setcolor(4);
	outtextxy(542,50,"0");
	outtextxy(562,50,":");
	outtextxy(574,50,"00");
	show_number(minute,550,50,4,0,1);
	run_info(pressed,correct,wrong,correction);
	user_response(250,130,1,3);
	time(&start_time);

	settextstyle(2,0,5);
	color_text(535,76,"ESC to",3);
	color_text(536,76,"ESC to",3);
	color_text(524,92,"quit/pause",3);
	color_text(525,92,"quit/pause",3);
	char_x= 173; 	char_y= 90;  line =1;  i=0;

	dummy_choice= 'A'; //just to initialize the drawing of a key
	increase=0, angle=89;
	while(1)
	{
	      gettime (&new_time);
	      time_up= time_control();
	      if(time_up)
			return;


	      if(line<7){
			color_text(char_x,char_y+1,"_",4);
			color_text(char_x,char_y-23,"^",4);
	      }

	      if(kbhit())
	      {
			check_kb_up_down(dummy_choice,0);

			choice= getch();  // ASSIGN USER INPUT TO 'CHOICE'
			dummy_choice= choice;
			pressed++;

			check_kb_up_down(choice,1);

			if(line>6)
			{
				summary_content();
				end_lesson(min,sec,eff,err,speed);
				return;
			}
			if(choice==27 )  // ESC
			{
				pressed--;
				make_sound(2000,100);
				if(i>0)
					summary_content();

				z = continue_close(min,sec,eff,err,speed);
				if(z)
					return;
				else
					continue;
			}
			else if(choice==0) // error checking for function keys
			{
				ch1=getch();
				if(ch1==80||ch1==72||ch1==75||ch1==77)   //error checking  to avoide right,left,up
					continue;
			}

			else if(choice==9)
				continue;    //error checking for tab

			else if(choice==8)  	// BACKSPACE
			{
				if(i>0)
				{
					correction++;
					if(char_x<=173){
						setfillstyle(1,15);
						bar(char_x+233,char_y-36,char_x+243,char_y-29);
						color_text(char_x,char_y+1,"_",15);
						color_text(char_x,char_y-23,"^",15);
						char_y-=36;
						char_x+=240;

						color_text(char_x-8,char_y+1,"_",4);
						color_text(char_x-8,char_y-23,"^",4);

					}

					else{
						setfillstyle(1,15);
						bar(char_x-8, char_y, char_x,char_y+7);
						color_text(char_x,char_y+1,"_",15);
						color_text(char_x-8,char_y+1,"_",4);
						color_text(char_x,char_y-23,"^",15);
						color_text(char_x-8,char_y-23,"^",4);
					}
					--i;
					char_x-=8;
					sound(1000);
					delay(100);
					nosound();
				}
			}

			else{

				if(choice==store_chars[i]){  			//letter is ok!
					print_lesson(char_x,char_y,choice,4);
					correct++;
				}

				else if(store_chars[i] !=choice && choice==' ')
				{
					char choice1 = '-';	//when space is pressed instead of any key, print dash
					print_lesson(char_x,char_y,choice1,9);
					make_sound(500,100);
					wrong++;
				}
				else
				{
					print_lesson(char_x, char_y,choice,9);
					make_sound(500,100);
					wrong++;
				}

				color_text(char_x+8,char_y-23,"^",4);
				color_text(char_x,char_y-23,"^",15);
				color_text(char_x+8,char_y+1,"_",4);
				color_text(char_x,char_y+1,"_",15);
				char_x +=8;
				if(char_x > 405)
				{
					color_text(char_x,char_y+1,"_",15);
					color_text(char_x,char_y-23,"^",15);
					char_x = 173;
					char_y +=36;
					line++;
				}
				i++;

			}  // end of else or default typing

			run_info(pressed,correct,wrong,correction);
	      } // end of the initial 'if'
	}  // end of while
}
예제 #10
0
/* shows the summary of typing */
void show_summary(int min, int sec,int acc, int err, int speed)
{
	/* min= required minute, sec= required seconds, acc= percentage of accuracy,
	   err= percentage of pressing b.space, speed= typing speed */

		char ch[5];
		int j1,m,n,i,x=180,y;
		char result[][50]= {"Time Elapsed:-    min    sec","Accuracy  :    %","Backspace :    %","Speed[cpm]:"};

	    //	draw_brief_window(200,90,380,250,1,6,0); // agerta
		draw_brief_window(170,90,410,250,1,6,0);

		settextstyle(0,0,1);
		color_text(182,94,"Result",15);
		settextstyle(2,0,5);//2,0,5    3
		setcolor(6);

		for(i=0,y=120;i<4;i++,y+=18){
			outtextxy(x,y,result[i]);
			outtextxy(x+1,y,result[i]);
		}

	      //	outtextxy(215,210,"Adjacent speed:");  */

		show_number(min,300,120,4,2,5); // min
		show_number(min,301,120,4,2,5);
		show_number(sec,355,120,4,2,5); //sec
		show_number(sec,356,120,4,2,5);
		show_number(acc,268,138,4,2,5); // accuracy
		show_number(acc,269,138,4,2,5); // accuracy
		show_number(err,268,156,4,2,5); // error
		show_number(err,269,156,4,2,5); // error
		show_number(speed,268,174,4,2,5); // speed
		show_number(speed,269,174,4,2,5); // speed

		if(!minute && !second){
			setfillstyle(1,0);
			bar(175,120,405,135);
			color_text(250,115,"TIME IS UP",6);
			color_text(251,115,"TIME IS UP",6);
		}

		setcolor(4);

		if(min ||sec)
		{
			if(acc || err || speed){
				if(acc<=35)
					outtextxy(315,138,"Beginner");

				else if(acc>35 && acc<= 60)
					outtextxy(315,138,"Intermediate");

				else if(acc>60 && acc<= 95 )
					outtextxy(315,138,"Advanced");

				else
					outtextxy(315,138,"Expert");

				if(err <=5)
					outtextxy(315,156,"Expert");

				else if(err>5 && err<=10)
					outtextxy(315,156,"Advanced");

				else if(err>10 && err<=20)
					outtextxy(315,156,"Intermediate");

				else
					outtextxy(315,156,"Beginner");

				if(speed<=100)
					outtextxy(315,174,"Beginner");

				else if( speed>100 && speed<=160)
					outtextxy(315,174,"Intermediate");

				else if( speed>160 && speed<=220)
					outtextxy(315,174,"Advanced");

				else
					outtextxy(315,174,"Expert");

			}

		}
}
예제 #11
0
static void
do_stuff(MYDATA * data)
{
    char *s;
    SCREEN *sp = data->sp;
    int my_code = 1234;
    const char *my_text = "\033[?m";

    set_curterm_sp(sp, data->term);

    /* putp always goes to standard output */
    putp_sp(sp, "Hello ");
    putp_sp(sp, data->name);
    putp_sp(sp, "!\n");

    fprintf(data->fp, "Term: %s\n", termname_sp(sp));
    fprintf(data->fp, "Long: %s\n", longname_sp(sp));
    show_cap_flag(data, "am", "am");
    show_cap_number(data, "lines", "li");
    show_cap_string(data, "clear", "cl");
    show_cap_string(data, "tbc", "ct");
    show_flag(data, "has_ic", has_ic_sp(sp));
    show_flag(data, "has_il", has_il_sp(sp));
    show_number(data, "baudrate", baudrate_sp(sp));
    show_char(data, "erase ch", erasechar_sp(sp));
    show_char(data, "kill ch", killchar_sp(sp));
    show_string(data, "unctrl", unctrl_sp(sp, 033));
    fflush(data->fp);

    define_key_sp(sp, my_text, my_code);
    has_key_sp(sp, 0);
    key_defined_sp(sp, my_text);
    if ((s = keybound_sp(sp, my_code, 0)) != 0)
	free(s);
    keyname_sp(sp, '?');
    keyok_sp(sp, my_code, FALSE);
    keyok_sp(sp, my_code, TRUE);

    savetty_sp(sp);

    def_shell_mode_sp(sp);

    /*
     * These functions are low-level settings for ncurses.
     */
    set_tabsize_sp(sp, 5);	/* waddch */
    typeahead_sp(sp, FALSE);	/* waddch */
    use_env_sp(sp, FALSE);	/* newterm */
    use_tioctl_sp(sp, FALSE);	/* newterm */
    intrflush_sp(sp, 0, 0);	/* wgetch */
    flushinp_sp(sp);		/* waddch */
    halfdelay_sp(sp, 5);	/* wgetch */

    /*
     * These manipulate the terminal modes, mainly for wgetch.
     */
    cbreak_sp(sp);
    raw_sp(sp);
    def_prog_mode_sp(sp);

    delay_output_sp(sp, 200);

    napms_sp(sp, 10);

    nocbreak_sp(sp);
    noqiflush_sp(sp);
    noraw_sp(sp);
    qiflush_sp(sp);

    resetty_sp(sp);

    tputs_sp(sp, "{reset-mode}\n", 0, data->outc);

    reset_prog_mode_sp(sp);

    curs_set_sp(sp, 0);
    tputs_sp(sp, "{prog-mode}\n", 0, data->outc);

    reset_shell_mode_sp(sp);

    tputs_sp(sp, "{shell-mode}\n", 0, data->outc);
}
예제 #12
0
파일: dgrep.c 프로젝트: jarmoruuth/tools
/**********************************************************************
 *
 *	dgrep
 *
 * Greps previously opened handle h.
 */
static void dgrep(int h)
{
	REG1 int	bufsize;
	REG2 int	nleftover = 0;
	REG3 int	leading_bytes = 0;
	int		nlines;
	int		nread;

	linecount = 1L;		/* first line number is 1 */
	matchcount = 0L;
	waiting_lines = 0;
	if (verbose && show_fname != NONE) {
		printf("*** File %s:\n", path);
		fname_shown = TRUE;
	} else
		fname_shown = FALSE;
	if (show_fname == BLOCK)	/* reset context match flag */
		first_match = TRUE;
	nread = align(maxbuf);
	while ((bufsize = read(h, buffer+leading_bytes+nleftover, nread)) > 0)
	{
		/* update nread to contain all bytes in the buffer */
		nread += leading_bytes+nleftover;
		bufsize += nleftover;
#if 0 /* Pete removed, because it behaves erroneusly when input is pipe */
		if (bufsize + leading_bytes < nread) { /* not full buffer */
			bufsize += add_last_newline_if(buffer, bufsize + leading_bytes);
            }
#endif
		nleftover = dgrep_buffer(buffer+leading_bytes, bufsize);
	    if (nleftover < 0) {
	    	break;
            } else if (nleftover == bufsize) {
		    nread = align(maxbuf-leading_bytes-nleftover);
                if (nread == 0) {
		        fprintf(stderr, "Warning: No line separator in buffer");
		        if (show_fname != NONE)
			        fprintf(stderr, " in file %s", path);
		        fprintf(stderr, "\n");
	    		nleftover = 0;
                }
	    } else {
	    	bufsize += leading_bytes;
		    if (leading_context && bufsize == nread) {
			    nlines = leading_context;
			    leading_bytes = 
				    get_leading_bytes(
				    buffer,
				    buffer+bufsize-nleftover-1,
				    &nlines);
		    } else {
			    leading_bytes = 0;
                }
			memcpy(buffer, buffer+bufsize-leading_bytes-nleftover,
				leading_bytes+nleftover);
            }
		nread = align(maxbuf-leading_bytes-nleftover);
	}
	if (nleftover > 0) {
		buffer[nleftover++] = EOL2;
		dgrep_buffer(buffer, nleftover);
	}
	if (!silent && count && !names) {
		if (show_fname != NONE)
			printf(path);
		show_number(matchcount);
		printf("\n");
	}
}