Пример #1
0
/*charge username is being*/
bool creatUserName(int sockfd,char *name){
    //printf("Please enter a name to login:"******"Please enter a name to login:"******"%64s%*[^\n]",name);
    //printf("name : %s\n",name);
    wrefresh(local_win_down);
    wrefresh(local_win_left);
    wrefresh(local_win_up);
    if(!strcmp(name,"\0"))
        return false;
    packetInit(&sendline,SERVICE_LOGIN,STATUS_REQUEST,name,NULL,NULL);
    //printf("send %s\n",sendline.send_name);
    send(sockfd,&sendline,sizeof(sendline),0);
    //printf("send success!!\n");
    //memset(&recvline,0,sizeof((struct packet*)recvline));
    //printf("memset success!!!!!|n");
    recv(sockfd,&recvline,sizeof(recvline),0);
    //printf("recv %s\n",recvline.data);
    if(strcmp(recvline.data,"name_being")==0)
        return false;
    else if(strcmp(recvline.data,"name_not_being")==0)
        return true;
    return false;
}
Пример #2
0
/* authenticate : takes the username and password of the useer and stores it in the infostruct */
void authenticate(infostruct *user){
	WINDOW *auth;
	char *u = "Username : "******"Password : "******"%s",u);
	mvwprintw(auth,3,5,"%s",p);

	mvwscanw(auth,2,(5 + strlen(u)),"%s",user->username);
	noecho();
	mvwscanw(auth,3,(5 + strlen(p)),"%s",user->password);
	wmove(auth,3,5 +strlen(p));

	wrefresh(auth);
	delwin(auth);
	return;
}
Пример #3
0
/*Function of chatting with all people*/
void chat_with_all(struct send_thread_data *send_data){
    struct packet sendline;
    //printf("The mssage will send to all people:\n");
    //show_user_list(send_data);
    char msg[MAXDATA];
    memset(&msg,0,sizeof(msg));
    while(1){
        //printf("%s: ",send_data->send_name);
	    memset(&msg,0,sizeof(msg));
		wclear(local_win_down);
	    wborder(local_win_down,'|',' ','-',' ','+', ' ','+',' ');
	    mvwprintw(local_win_down,1,1,"The message will send to all people:");
        mvwprintw(local_win_down,2,1,"%s:",send_data->send_name);
        //wrefresh(local_win_down);
        wrefresh(local_win_down);
        if(getchar()=='')
			return;
		wrefresh(local_win_down);
		mvwscanw(local_win_down,2,strlen(send_data->send_name)+2,"%[^\n]",msg);
        //if(!strcmp(msg,""))
        //   return;
		//char temp;
		//int len;
		//while(true){
		//	len=strlen(msg);
		//	temp=getchar();
		//	if(temp!='\n'&&temp!=EOF)
		//		msg[temp]=temp;
		//}
        wrefresh(local_win_down);
		if(!strcmp(msg,""))
			continue;
        if(linetag==(2*row/3-1)){
            linetag=1;
            wclear(local_win_up);
            wborder(local_win_up,'|','|','-','-','+','+','+','+');
        }
        mvwprintw(local_win_up,linetag,1,"%s:%s",send_data->send_name,msg);
        //fgets(msg,MAXNAME,stdin);
        //msg[strlen(msg)-1]='\0';
        wrefresh(local_win_up);
        packetInit(&sendline,SERVICE_MESSAGE,STATUS_REQUEST,send_data->send_name," ",msg);
        send(send_data->sockfd,&sendline,sizeof(sendline),0);
		//if(Get_Key()==12)
		//	break;
		//if(getchar()=='')
		//	return;
	}
}
Пример #4
0
//
// Affiche une fenêtre de demande d'entier.
// Ex: demande du nombre de joueurs participant.
//
int displayNumberPromptMenu(char title[], char fieldTitle[], int min, int max, int yPos, int xPos) {
    int n = 0;
    
    do {
        //variables pour l'affichage du menu
        WINDOW *win = getMenuWindowNoLogo(1, title, yPos, xPos);
        mvwprintw(win, 4, 2, "%s", fieldTitle);
        
        wrefresh(win);
        refresh();
        
        //on affiche un champ pour demander un nombre
        mvwscanw(win, 4, (int) strlen(fieldTitle) + 3, "%d", &n);
        
        wclear(win);
        wrefresh(win);
        delwin(win);
    } while(n < min || n > max);
    
    return n;
}
Пример #5
0
/* patio brasil, 504 sul, locus
 * vi x emacs
 *
 * */
void engine_get_hscore_name(char* name, int size)
{
    window_s* w   = &(engine.screen.input);
    WINDOW*   sub = derwin(w->win, 1, 11, 1, 18);
    werase(sub);
    wattrset(sub, engine_get_color(COLOR_BLACK, COLOR_BLUE, false));
    mvwhline(sub, 0, 0, ' ', 11);

    char buffer[256];
    memset(buffer, '\0', 256);

    wattrset(w->win, engine_get_color(COLOR_WHITE, COLOR_BLACK, false));
    nodelay(stdscr, FALSE);
    echo();

    mvwscanw(sub, 0, 0, "%[^\n]s", buffer);
    if (strlen(buffer) != 0)
        strncpy(name, buffer, size);

    noecho();
    nodelay(stdscr, TRUE);
}
Пример #6
0
void inputTest(WINDOW *win)
{
    int w, h, bx, by, sw, sh, i, c, num = 0;
    int line_to_use = 3;
    char buffer[80];
    WINDOW *subWin;
    static const char spinner[4] = "/-\\|";
    int spinner_count = 0;

    wclear(win);

    getmaxyx(win, h, w);
    getbegyx(win, by, bx);

    sw = w / 3;
    sh = h / 3;

    if ((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2))
        == NULL)
        return;

#ifdef A_COLOR
    if (has_colors())
    {
        init_pair(2, COLOR_WHITE, COLOR_RED);
        wbkgd(subWin, COLOR_PAIR(2) | A_BOLD);
    }
    else
#endif
        wbkgd(subWin, A_BOLD);

    box(subWin, ACS_VLINE, ACS_HLINE);
    wrefresh(win);

    nocbreak();

    wclear (win);
    mvwaddstr(win, 1, 1,
        "Press keys (or mouse buttons) to show their names");
    mvwaddstr(win, 2, 1, "Press spacebar to finish");
    wrefresh(win);

    keypad(win, TRUE);
    raw();
    noecho();

    wtimeout(win, 200);

#ifdef PDCURSES
    mouse_set(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION);
    PDC_save_key_modifiers(TRUE);
//  PDC_return_key_modifiers(TRUE);
#endif
    curs_set(0);        /* turn cursor off */

    while (1)
    {
        while (1)
        {
            c = wgetch(win);

            if (c == ERR)
            {
                spinner_count++;
                if (spinner_count == 4)
                    spinner_count = 0;
                mvwaddch(win, line_to_use, 3, spinner[spinner_count]);
                wrefresh(win);
            }
            else
                break;
        }
#ifdef PDCURSES
//      wmove(win, line_to_use + 1, 18);
//      wclrtoeol(win);
#endif
        mvwaddstr(win, line_to_use, 5, "Key Pressed: ");
        wclrtoeol(win);

        wprintw( win, "(%x) ", c);
        if( has_key( c))
            wprintw(win, "%s", keyname(c));
        else if (isprint(c) || c > 0xff)
            waddch( win, c);
        else
            wprintw(win, "%s", unctrl(c));
#ifdef PDCURSES
        if (c == KEY_MOUSE)
        {
            int button = 0, status = 0;
            request_mouse_pos();

            if (BUTTON_CHANGED(1))
                button = 1;
            else if (BUTTON_CHANGED(2))
                button = 2;
            else if (BUTTON_CHANGED(3))
                button = 3;
            else if (BUTTON_CHANGED(4))   /* added 21 Jan 2011: BJG */
                button = 4;
            else if (BUTTON_CHANGED(5))
                button = 5;
            if( button)
                status = (button > 3 ? Mouse_status.xbutton[(button) - 4] :
                                       Mouse_status.button[(button) - 1]);

            wmove(win, line_to_use, 5);
            wclrtoeol(win);
            wprintw(win, "Button %d: ", button);

            if (MOUSE_MOVED)
                waddstr(win, "moved: ");
            else if (MOUSE_WHEEL_UP)
                waddstr(win, "wheel up: ");
            else if (MOUSE_WHEEL_DOWN)
                waddstr(win, "wheel dn: ");
            else if (MOUSE_WHEEL_LEFT)
                waddstr(win, "wheel lt: ");
            else if (MOUSE_WHEEL_RIGHT)
                waddstr(win, "wheel rt: ");
            else if ((status & BUTTON_ACTION_MASK) == BUTTON_PRESSED)
                waddstr(win, "pressed: ");
            else if ((status & BUTTON_ACTION_MASK) == BUTTON_CLICKED)
                waddstr(win, "clicked: ");
            else if ((status & BUTTON_ACTION_MASK) == BUTTON_DOUBLE_CLICKED)
                waddstr(win, "double: ");
            else if ((status & BUTTON_ACTION_MASK) == BUTTON_TRIPLE_CLICKED)
                waddstr(win, "triple: ");
            else
                waddstr(win, "released: ");

            wprintw(win, "Posn: Y: %d X: %d", MOUSE_Y_POS, MOUSE_X_POS);
            if (button && (status & BUTTON_MODIFIER_MASK))
            {
                if (status & BUTTON_SHIFT)
                    waddstr(win, " SHIFT");

                if (status & BUTTON_CONTROL)
                    waddstr(win, " CONTROL");

                if (status & BUTTON_ALT)
                    waddstr(win, " ALT");
            }

        }
        else if (PDC_get_key_modifiers())
        {
            waddstr(win, " Modifier(s):");
            if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_SHIFT)
                waddstr(win, " SHIFT");

            if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_CONTROL)
                waddstr(win, " CONTROL");

            if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_ALT)
                waddstr(win, " ALT");

            if (PDC_get_key_modifiers() & PDC_KEY_MODIFIER_NUMLOCK)
                waddstr(win, " NUMLOCK");
        }
#endif
        wrefresh(win);

        if (c == ' ')
            break;
        line_to_use++;
        if( line_to_use == 10)
           line_to_use = 3;
    }

    wtimeout(win, -1);  /* turn off timeout() */
    curs_set(1);        /* turn cursor back on */

#ifdef PDCURSES
    mouse_set(0L);
    PDC_save_key_modifiers(FALSE);
//  PDC_return_key_modifiers(FALSE);
#endif
    wclear(win);
    mvwaddstr(win, 2, 1, "Press some keys for 5 seconds");
    mvwaddstr(win, 1, 1, "Pressing ^C should do nothing");
    wrefresh(win);

    werase(subWin);
    box(subWin, ACS_VLINE, ACS_HLINE);

    for (i = 0; i < 5; i++)
    {
        mvwprintw(subWin, 1, 1, "Time = %d", i);
        wrefresh(subWin);
        napms(1000);
        flushinp();
    }

    delwin(subWin);
    werase(win);
    flash();
    wrefresh(win);
    napms(500);
    flushinp();

    mvwaddstr(win, 2, 1, "Press a key, followed by ENTER");
    wmove(win, 9, 10);
    wrefresh(win);
    echo();

    keypad(win, TRUE);
    raw();
    wgetnstr(win, buffer, 3);
    flushinp();

    wmove(win, 9, 10);
    wdelch(win);
    mvwaddstr(win, 4, 1, "The character should now have been deleted");
    Continue(win);

    refresh();
    wclear(win);
    echo();
    buffer[0] = '\0';
    mvwaddstr(win, 3, 2, "The window should have moved");
    mvwaddstr(win, 4, 2,
              "This text should have appeared without you pressing a key");
    mvwaddstr(win, 6, 2, "Enter a number then a string separated by space");
    mvwin(win, 2, 1);
    wrefresh(win);
    mvwscanw(win, 7, 6, "%d %s", &num, buffer);
    mvwprintw(win, 8, 6, "String: %s Number: %d", buffer, num);
    Continue(win);

    refresh();
    wclear(win);
    echo();
    mvwaddstr(win, 3, 2, "Enter a 5 character string: ");
    wgetnstr(win, buffer, 5);
    mvwprintw(win, 4, 2, "String: %s", buffer);
    Continue(win);
}
Пример #7
0
/*handle send*/
void *send_handle(void *threadarg){
    //char func='0';
    struct send_thread_data *send_data;
    char func[2];
    memset(&func,0,sizeof(func));
    send_data=(struct send_thread_data *)threadarg;
    //system("clear");
    while(1){
        //printf("Hello,%s\n",send_data->send_name);
        //printf("Function:\n");
        //printf("1.chat with one person;\n");
        //printf("2.chat with all the people online;\n");
        //printf("3.show all the people online;\n");
        //printf("4.logout;\n");
		memset(&func,0,sizeof(func));
		wclear(local_win_down);
        wclear(local_win_up);
        wborder(local_win_up,'|','|','-','-','+','+','+','+');
        wborder(local_win_down,'|',' ','-',' ','+',' ','+',' ');
        mvwprintw(local_win_right,1,1,"Hello,%s",send_data->send_name);
        mvwprintw(local_win_right,2,1,"Function");
        mvwprintw(local_win_right,3,1,"1.chat with one");
        mvwprintw(local_win_right,4,1,"2.chat with all");
        mvwprintw(local_win_right,5,1,"3.update namelist");
        mvwprintw(local_win_right,6,1,"4.logout");
        mvwprintw(local_win_right,7,1,"input  to return");
        mvwprintw(local_win_right,8,1,"=control+B");
		wrefresh(local_win_right);
        mvwprintw(local_win_down,1,1,"fuc:");
        mvwscanw(local_win_down,1,6,"%2s%*[^\n]",func);
        wrefresh(local_win_down);
        switch(func[0]){
            case '1': {//printf("chat name: %s\n",send_data->send_name);
                       //wclear(local_win_down); 
                       //mvwprintw(local_win_down,1,1,"chat name:%s\n",send_data->send_name);
                       //wrefresh(local_win_down);
                       chat_with_one(send_data);
                       break;
                      }
            case '2': {chat_with_all(send_data);break;}
            case '3': {show_user_list(send_data);break;}
            case '4': {
                        logout(send_data);
                        wclear(local_win_down);
                        wclear(local_win_left);
                        wclear(local_win_up);
                        wclear(local_win_right);
                        delwin(local_win_down);
                        delwin(local_win_up);
                        delwin(local_win_right);
                        delwin(local_win_left);
                        endwin();
                        exit(0);
                        break;}
            default : {
                    //printf("input error\n");
                wclear(local_win_down);
                wborder(local_win_down,'|',' ','-',' ','+',' ','+',' ');
                mvwprintw(local_win_down,2,1,"input error");   
                wrefresh(local_win_down); 
				getchar();
            }
        }
    }
}
Пример #8
0
/*Function of chatting with someone*/
void chat_with_one(struct send_thread_data *send_data){
    struct packet sendline,recvline;
    show_user_list(send_data);
    char name[MAXNAME];
    memset(&name,0,sizeof(name));
    char msg[MAXDATA];
    //printf("name is %s\n",send_data->send_name);
    //printf("choose one person to chat with:");
    wclear(local_win_down);
    wborder(local_win_down,'|',' ','-',' ','+',' ','+',' ');
    mvwprintw(local_win_down,1,1,"choose one person to chat with:");
    //wrefresh(local_win_down);
    mvwscanw(local_win_down,2,2,"%64s%*[^\n]",name);
    wrefresh(local_win_down);
    //sendline->service=SERVICE_ASKISONLINE;
    //sendline->status=STATUS_REQUEST;
    //sendline->send_name=send_data->send_name;
    //sendline->recv_name=name;
    packetInit(&sendline,SERVICE_ASKISONLINE,STATUS_REQUEST,send_data->send_name,name,NULL);
    send(send_data->sockfd,&sendline,sizeof(sendline),0);
    //printf("recv!!!!!!\n");
    //if(recv(send_data->sockfd,&recvline,sizeof(recvline),0)<0){
    //    perror("The server terminated prematurely");
    //    return;
    //}
    //printf("recv success!!!!\n");
    usleep(100000);
    if(!cantalk){
        //printf("user is not online\n");
        //assert(!cantalk);
        if(linetag==(2*row/3-1)){
            linetag=1;
            wclear(local_win_up);
            wborder(local_win_up,'|','|','-','-','+','+','+','+');
        }
        mvwprintw(local_win_up,linetag,1,"user is not online");
        wrefresh(local_win_up);
		return;
	}
    else if(cantalk){
        memset(&msg,0,sizeof(msg));
        while(1){
            //printf("%s : ",((struct send_thread_data *)send_data)->send_name);
			memset(&msg,0,sizeof(msg));
			wclear(local_win_down);
   		    wborder(local_win_down,'|',' ','-',' ','+',' ','+',' ');
    	    mvwprintw(local_win_down,1,1,"You are chatting with %s",name);
     	    //printf("You are chatting with %s\n",name);
     	    wrefresh(local_win_down);            
			mvwprintw(local_win_down,2,1,"%s:",
                      ((struct send_thread_data*)send_data)->send_name);
            //if(Get_Key()==12) break;
			wrefresh(local_win_down);
            if(getchar()=='')
				return;
			mvwscanw(local_win_down,2,
                     strlen(((struct send_thread_data*)send_data)->send_name)+2,"%[^\n]",msg);
            //if(!strcmp(msg,""))
            //    return;
			//char temp;
			//int len;
			//while(true){
			//	len=strlen(msg);
			//	temp=getchar();
			//	if(temp!='\n'&&temp!=EOF)
			//		msg[temp]=temp;
			//}
            wrefresh(local_win_down);
			if(!strcmp(msg ,""))
				continue;
            if(linetag==2*row/3-1){
                linetag=1;
                wclear(local_win_up);
                wborder(local_win_up,'|','|','-','-','+','+','+','+');
            }
            mvwprintw(local_win_up,linetag,1,"%s:%s",
                     ((struct send_thread_data*)send_data)->send_name,msg);
            linetag++;
            wrefresh(local_win_up);
            //wrefresh(local_win_down);
            //fgets(msg,MAXDATA,stdin);
            //msg[strlen(msg)-1]='\0';
            packetInit(&sendline,SERVICE_MESSAGE,STATUS_REQUEST,send_data->send_name,name,msg);
            send(send_data->sockfd,&sendline,sizeof(sendline),0);
			//if(Get_Key()==12){
				//assert(0);
            //    return;
            //}
			//if(getchar()=='')
			//	return;
        }
    }
}
Пример #9
0
static void
inputTest(WINDOW *win)
{
    int answered;
    int repeat;
    int w, h, bx, by, sw, sh, i, c, num;
    char buffer[80];
    WINDOW *subWin;
    wclear(win);

    getmaxyx(win, h, w);
    getbegyx(win, by, bx);
    sw = w / 3;
    sh = h / 3;
    if ((subWin = subwin(win, sh, sw, by + h - sh - 2, bx + w - sw - 2)) == NULL)
	return;

#ifdef A_COLOR
    if (has_colors()) {
	init_pair(2, COLOR_WHITE, COLOR_RED);
	wbkgd(subWin, (chtype) COLOR_PAIR(2) | A_BOLD);
    } else
	wbkgd(subWin, A_BOLD);
#else
    wbkgd(subWin, A_BOLD);
#endif
    box(subWin, ACS_VLINE, ACS_HLINE);
    wrefresh(win);

    nocbreak();
    MvWAddStr(win, 2, 1, "Press some keys for 5 seconds");
    MvWAddStr(win, 1, 1, "Pressing ^C should do nothing");
    wrefresh(win);

    werase(subWin);
    box(subWin, ACS_VLINE, ACS_HLINE);
    for (i = 0; i < 5; i++) {
	MvWPrintw(subWin, 1, 1, "Time = %d", i);
	wrefresh(subWin);
	napms(1000);
	flushinp();
    }

    delwin(subWin);
    werase(win);
    flash();
    wrefresh(win);
    napms(500);

    MvWAddStr(win, 2, 1, "Press a key, followed by ENTER");
    wmove(win, 9, 10);
    wrefresh(win);
    echo();
    noraw();
    wgetch(win);
    flushinp();

    wmove(win, 9, 10);
    wdelch(win);
    MvWAddStr(win, 4, 1, "The character should now have been deleted");
    Continue(win);

    wclear(win);
    MvWAddStr(win, 1, 1, "Press keys (or mouse buttons) to show their names");
    MvWAddStr(win, 2, 1, "Press spacebar to finish");
    wrefresh(win);

    keypad(win, TRUE);
    raw();
    noecho();

#if HAVE_TYPEAHEAD
    typeahead(-1);
#endif

#ifdef NCURSES_MOUSE_VERSION
    mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0);
#endif
#if defined(PDCURSES)
    mouse_set(ALL_MOUSE_EVENTS);
#endif

    for (;;) {
	wmove(win, 3, 5);
	c = wgetch(win);
	wclrtobot(win);
	if (c >= KEY_MIN)
	    wprintw(win, "Key Pressed: %s", keyname(c));
	else if (isprint(c))
	    wprintw(win, "Key Pressed: %c", c);
	else
	    wprintw(win, "Key Pressed: %s", unctrl(UChar(c)));
#ifdef KEY_MOUSE
	if (c == KEY_MOUSE) {
#if defined(NCURSES_MOUSE_VERSION)
#define ButtonChanged(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, 037))
#define ButtonPressed(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED))
#define ButtonDouble(n)  ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED))
#define ButtonTriple(n)  ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED))
#define ButtonRelease(n) ((event.bstate) & NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED))
	    MEVENT event;
	    int button = 0;

	    getmouse(&event);
	    if (ButtonChanged(1))
		button = 1;
	    else if (ButtonChanged(2))
		button = 2;
	    else if (ButtonChanged(3))
		button = 3;
	    else
		button = 0;
	    wmove(win, 4, 18);
	    wprintw(win, "Button %d: ", button);
	    if (ButtonPressed(button))
		wprintw(win, "pressed: ");
	    else if (ButtonDouble(button))
		wprintw(win, "double: ");
	    else if (ButtonTriple(button))
		wprintw(win, "triple: ");
	    else
		wprintw(win, "released: ");
	    wprintw(win, " Position: Y: %d X: %d", event.y, event.x);
#elif defined(PDCURSES)
	    int button = 0;
	    request_mouse_pos();
	    if (BUTTON_CHANGED(1))
		button = 1;
	    else if (BUTTON_CHANGED(2))
		button = 2;
	    else if (BUTTON_CHANGED(3))
		button = 3;
	    else
		button = 0;
	    wmove(win, 4, 18);
	    wprintw(win, "Button %d: ", button);
	    if (MOUSE_MOVED)
		wprintw(win, "moved: ");
	    else if ((BUTTON_STATUS(button) & BUTTON_ACTION_MASK) == BUTTON_PRESSED)
		wprintw(win, "pressed: ");
	    else if ((BUTTON_STATUS(button) & BUTTON_ACTION_MASK) == BUTTON_DOUBLE_CLICKED)
		wprintw(win, "double: ");
	    else
		wprintw(win, "released: ");
	    wprintw(win, " Position: Y: %d X: %d", MOUSE_Y_POS, MOUSE_X_POS);
#endif /* NCURSES_VERSION vs PDCURSES */
	}
#endif /* KEY_MOUSE */
	wrefresh(win);
	if (c == ' ')
	    break;
    }
#if 0
    nodelay(win, TRUE);
    wgetch(win);
    nodelay(win, FALSE);
#endif
#if defined(PDCURSES)
    mouse_set(0L);
#endif
    refresh();

    repeat = 0;
    do {
	static const char *fmt[] =
	{
	    "%d %10s",
	    "%d %[a-zA-Z]s",
	    "%d %[][a-zA-Z]s",
	    "%d %[^0-9]"
	};
	char *format = strdup(fmt[(unsigned) repeat % SIZEOF(fmt)]);

	wclear(win);
	MvWAddStr(win, 3, 2, "The window should have moved");
	MvWAddStr(win, 4, 2,
		  "This text should have appeared without you pressing a key");
	MvWPrintw(win, 6, 2,
		  "Scanning with format \"%s\"", format);
	mvwin(win, 2 + 2 * (repeat % 4), 1 + 2 * (repeat % 4));
	erase();
	refresh();
	wrefresh(win);
	echo();
	noraw();
	num = 0;
	*buffer = 0;
	answered = mvwscanw(win, 7, 6, format, &num, buffer);
	MvWPrintw(win, 8, 6,
		  "String: %s Number: %d (%d values read)",
		  buffer, num, answered);
	Continue(win);
	++repeat;
	free(format);
    } while (answered > 0);
}
Пример #10
0
int main()
{

    WINDOW *log_win;
    WINDOW *show_win;
    WINDOW *chat_win;
    WINDOW *scan_win;
    WINDOW *help_win;

    int x_loop;
    int y_loop;

    char str[20];

    initscr();
    echo();
    log_win = newwin(3, 65, 0, 27);
    show_win = newwin(20, 25, 4, 0);
    chat_win = newwin(20, 65, 4, 27);
    scan_win = newwin(5,65,24,27);
    help_win = newwin(20,25,4,94);

    box(log_win, ACS_VLINE, ACS_HLINE);
    box(scan_win, ACS_VLINE, ACS_HLINE);
    box(show_win, ACS_VLINE, ACS_HLINE);
    box(chat_win, ACS_VLINE, ACS_HLINE);
    box(help_win, ACS_VLINE, ACS_HLINE);

    mvwprintw(log_win, 1, 18, " ********JJ chat room*********");
    mvwprintw(show_win, 1, 1, "local people:");
    mvwprintw(show_win, 3, 1, "line people:");
    mvwprintw(scan_win, 1, 1, " ");
    mvwprintw(chat_win, 1, 1, " ");
    mvwprintw(help_win, 1, 1, "help window    | cmd");
    mvwprintw(help_win, 2, 1, "_______________|_______");   
    mvwprintw(help_win, 3, 1, "show line peple|show");
    mvwprintw(help_win, 4, 1, "chat people    |chat");
    mvwprintw(help_win, 5, 1, "broadcast      |broad");
    mvwprintw(help_win, 6, 1, "face look      |hi");
    mvwprintw(help_win, 7, 1, "change password|cpwd ");
    mvwprintw(help_win, 8, 1, "change name    |rname");
    mvwprintw(help_win, 9, 1, "logoff         |logoff");
    mvwprintw(help_win, 10, 1, "quit           |exit ");
    wrefresh(log_win);
    wrefresh(show_win);
    wrefresh(chat_win);
    wrefresh(help_win);
    wrefresh(scan_win);
 //   refresh();

    mvwscanw(scan_win,1,2,"%s",str);
    mvwprintw(show_win, 0, 1, "%s", str);
    wrefresh(show_win);
   
    mvwprintw(scan_win, 1, 1, "                 ");
 //   refresh();

    echo();
    mvwscanw(scan_win,2,2,"%s",str);
    mvwprintw(chat_win, 0, 1, "%s", str);
  //  refresh();
 //   wrefresh(new_window_ptr);
 //   wrefresh(new_window_ptr2);
    wrefresh(chat_win);

    sleep(10);
    endwin();
    exit(1);

    return 0;
}
Пример #11
0
void
init_player_ui(jeu_s jeu, aff_s aff)
{
    char nomj1[TAILLE_NOM];
    char nomj2[TAILLE_NOM];
    char rolej1;
    char ai;
    int roleint;

    curs_set(1);
    echo();

    do {
    wattron(aff->etat, A_BOLD | A_REVERSE);
    mvwprintw(aff->etat, 1, 2, "Entrez le rôle du joueur 1");
    mvwprintw(aff->etat, 2, 2, "0 pour chèvre, 1 pour tigre :");
    wattroff(aff->etat, A_BOLD | A_REVERSE);
    wattron(aff->etat, A_BOLD);
    mvwscanw(aff->etat, 3, 2, "%c", &rolej1);
    wrefresh(aff->etat);
    wattroff(aff->etat, A_BOLD);

    wmove(aff->etat, 1, 2);
    wclrtoeol(aff->etat);
    wmove(aff->etat, 2, 2);
    wclrtoeol(aff->etat);
    wmove(aff->etat, 3, 2);
    wclrtoeol(aff->etat);
    wrefresh(aff->etat);
    } while ((rolej1 != '0') && (rolej1) != '1');

    if (rolej1 == '0')
        roleint = 0;
    else
        roleint = 1;


    do {
    wattron(aff->etat, A_BOLD | A_REVERSE);
    mvwprintw(aff->etat, 1, 2, "Jouer contre l'AI ?");
    mvwprintw(aff->etat, 2, 2, "0 pour NON, 1 pour OUI:");
    wattroff(aff->etat, A_BOLD | A_REVERSE);
    wattron(aff->etat, A_BOLD);
    mvwscanw(aff->etat, 3, 2, "%c", &ai);
    wrefresh(aff->etat);
    wattroff(aff->etat, A_BOLD);

    wmove(aff->etat, 1, 2);
    wclrtoeol(aff->etat);
    wmove(aff->etat, 2, 2);
    wclrtoeol(aff->etat);
    wmove(aff->etat, 3, 2);
    wclrtoeol(aff->etat);
    wrefresh(aff->etat);
    } while ((ai != '0') && (ai) != '1');

    if (ai == '0')
        init_player(jeu, roleint);
    else
        init_player_ai(jeu, roleint, !roleint);

    curs_set(0);
    noecho();
}
Пример #12
0
void debugloop() {
    int key;
  a:
    if (!(debugds & 2))
        nextopcode();
    if (!(debugds & 1))
        nextspcopcode();

  b:
    // redrawing the display is always a good idea
    refresh();
    wrefresh(debugwin);

   key = getch();
   if (key >= 0 && key < 256)
       key = toupper(key);

   switch (key) {
   case KEY_F(1): // run
       execut = 1;
       return;

   case KEY_F(2): // debugsavestate
       statesaver();
       goto b;

   case KEY_F(4): // debugloadstate
       debugloadstate();
       goto a;

   case 27:       // exit
       return;

   case '\n':     // step
       goto e;


   /* Ported this but couldn't bring myself to commit it.
      pagefault said to remove it.
   case '-':      // skip opcode
   */

   case 'C':      // clear
       numinst = 0;
       goto a;

   case 'M':      // modify
   {
       WINDOW *w;
       unsigned addr, value, n;

       w = openwindow(7, 33, 11, 24, "    Enter Address : ");
       mvwaddstr(w, 3, 1,            "    Previous Value: ");
       mvwaddstr(w, 5, 1,            "    Enter Value   : ");

       wrefresh(w);

       echo();
       n = mvwscanw(w, 1, 21, "%x", &addr);
       noecho();

       if (n == 1) {
       mvwprintw(w, 3, 21, "%02x", memtabler8_wrapper(addr >> 16, addr));
       wrefresh(w);

       echo();
       n = mvwscanw(w, 5, 21, "%x", &value);
       noecho();

       if (n == 1) {
          memtablew8_wrapper(addr >> 16, addr, value);
       }}

       closewindow(w);
       goto b;
   }