📄 input.c
字号:
if(current_card%10>=2 && current_card%10<=8) if(search_card(my_sit,current_card-1)>=0 && search_card(my_sit,current_card+1)>=0 ) { eat_pool[m]=current_card-1; m++; } if(current_card%10<=7) if(search_card(my_sit,current_card+1)>=0 && search_card(my_sit,current_card+2)>=0) { eat_pool[m]=current_card; m++; } eat_pool[m]=0; if(m>1) { input_mode=EAT_MODE; /* Display different eating choices */ wmvaddstr(stdscr,15,58,"┌───────┐"); wmvaddstr(stdscr,16,58,"│ │"); wmvaddstr(stdscr,17,58,"└───────┘"); for(i=0;i<m;i++) { if(eat_pool[i]) { sprintf(msg_buf,"%d%d%d",eat_pool[i]%10,eat_pool[i]%10+1, eat_pool[i]%10+2); wmvaddstr(stdscr,org_eat_y,org_eat_x+i*4,msg_buf); } } current_eat=0; eat_x=org_eat_x; eat_y=org_eat_y; return_cursor(); } else { i=current_card-eat_pool[m-1]+7; write_check(i); input_mode=PLAY_MODE; return_cursor(); } } else { write_check(current_check); input_mode=PLAY_MODE; return_cursor(); } break; default: break; } } /* --------- CHOOSE_EAT ------------ */ else if(input_mode==EAT_MODE) { for(i=0;i<m;i++) { if(key=='0'+eat_pool[i]%10) { current_eat=i; goto quick_eat; } } switch(key) { case TAB: input_mode=TALK_MODE; current_mode=EAT_MODE; return_cursor(); break; case ',': case KEY_LEFT: if(current_eat<=0) break; current_eat--; eat_x-=4; return_cursor(); break; case '.': case KEY_RIGHT: if(current_eat>=m-1) break; current_eat++; eat_x+=4; return_cursor(); break; case CTRL_L: redraw_screen(); break; case KEY_ENTER: case ENTER: case SPACE: quick_eat:; input_mode=PLAY_MODE; i=current_card-eat_pool[current_eat]+7; write_check(i); show_cardmsg(0,0); break; } } /* --------- TALK_MODE ------------ */ else if(input_mode==TALK_MODE) switch(key) { case 0: break; case TAB: if(screen_mode==PLAYING_SCREEN_MODE) { input_mode=current_mode; return_cursor(); } break; case KEY_LEFT: if(talk_x==0) break; talk_x--; return_cursor(); break; case KEY_RIGHT: if(talk_x==talk_buf_count) break; talk_x++; return_cursor(); break; case CTRL_P: case KEY_UP: if(h_point==(h_head+1)%HISTORY_SIZE || h_point==h_head) break; else h_point=(h_point-1+HISTORY_SIZE)%HISTORY_SIZE; werase(inputwin); mvwaddstr(inputwin,0,0,history[h_point]); wrefresh(inputwin); strcpy(talk_buf,history[h_point]); talk_buf[talk_right-talk_left-1]=0; talk_buf_count=strlen(talk_buf); talk_x=talk_buf_count; break; case CTRL_N: case KEY_DOWN: if(h_point==h_tail) break; else h_point=(h_point+1)%HISTORY_SIZE; werase(inputwin); mvwaddstr(inputwin,0,0,history[h_point]); wrefresh(inputwin); strcpy(talk_buf,history[h_point]); talk_buf[talk_right-talk_left-1]=0; talk_buf_count=strlen(talk_buf); talk_x=talk_buf_count; break; case CTRL_A: talk_x=0; wmove(inputwin,talk_y,talk_x); wrefresh(inputwin); break; case CTRL_E: talk_x=strlen(talk_buf); wmove(inputwin,talk_y,talk_x); wrefresh(inputwin); break; case CTRL_D: talk_x++; case CTRL_H: case BACKSPACE: if(talk_x==0) break; talk_x--; for(i=talk_x;i<talk_buf_count;i++) talk_buf[i]=talk_buf[i+1]; talk_buf[talk_buf_count--]='\0'; strcpy(history[h_tail],talk_buf); mvprintstr(inputwin,talk_y,talk_x,talk_buf+talk_x); printch(inputwin,' '); return_cursor(); break; case KEY_ENTER: case ENTER: switch(input_mode) { case TALK_MODE: if(talk_buf_count==0) break; strcpy(history[h_tail],talk_buf); command_parser(talk_buf); h_tail=(h_tail+1)%HISTORY_SIZE; history[h_tail][0]=0; if(h_tail==h_head) h_head=(h_head+1)%HISTORY_SIZE; h_point=h_tail; clear_input_line(); talk_x=0; return_cursor(); if(input_mode==PLAY_MODE) { return_cursor(); } break; case PLAY_MODE: break; default: err("Unknow input mode"); break; } break; case CTRL_U: clear_input_line(); break; case CTRL_J: break; case CTRL_K: break; case CTRL_L: redraw_screen(); break; case CTRL_G: break; default: if(talk_x==talk_right-talk_left) break; /* Cursor is in the right most side of characters */ if(talk_buf_count==talk_x) { talk_buf[talk_buf_count]=key; talk_buf_count++; talk_buf[talk_buf_count]='\0'; mvprintch(inputwin,talk_y,talk_x,key); talk_x++; wrefresh(inputwin); } else { if(talk_buf_count<talk_right-talk_left) talk_buf[++talk_buf_count]='\0'; else talk_buf[talk_buf_count-1]='\0'; for(i=talk_buf_count;i>talk_x;i--) talk_buf[i]=talk_buf[i-1]; talk_buf[talk_x]=key; mvprintstr(inputwin,talk_y,talk_x,talk_buf+talk_x); talk_x++; return_cursor(); } strcpy(history[h_tail],talk_buf); break; }/* }*/ }}my_getch(){ int i; static int l=0;AGAIN: i=getch(); if((i==10&&l==ENTER)||(i==ENTER&&l==10)) { l=0; goto AGAIN; } if(i==10||i==ENTER) { l=i; return ENTER; } l=0; if(i==-1) leave(); return i;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -