// Displays a hit-any-key type prompt and waits for a key. void pausePrompt(short nClear, short nCenter) { char* szText = "[Hit any key to continue]"; time_t timeout = time(NULL); if ( nCenter != 1 ) local(szText, LWHITE, 0); else center(szText, LWHITE, 0); while ( inkey(0) == 0 ) { checkCarrier(); checkTimeLeft(); inactiveCheck(timeout); Sleep(0); } if (nClear == 1) clearScreen(); else local(" "); }
/* * Hack -- ask for a keymap "trigger" (see below) * * Note that both "flush()" calls are extremely important. This may * no longer be true, since "util.c" is much simpler now. XXX XXX XXX */ static void do_cmd_macro_aux_keymap(char *buf) { char tmp[1024]; s32b ch; /* Flush */ flush(); ch = inkey(); if ((ch < 0) || (ch > 255)) { Term_addstr( -1, TERM_WHITE, "BAD TRIGGER"); return; } /* Get a key */ buf[0] = (char) ch; buf[1] = '\0'; /* Convert to ascii */ ascii_to_text(tmp, buf); /* Hack -- display the trigger */ Term_addstr( -1, TERM_WHITE, tmp); /* Flush */ flush(); }
/* Prompt the user for a choice: [1] keys[0] is the default choice if quick_messages and PROMPT_FORCE_CHOICE is not set. [2] keys[0] is returned on ESC if PROMPT_ESCAPE_DEFAULT is set. [3] You get back the char in the keys prompt, not the actual character pressed. This makes a difference if PROMPT_CASE_SENSITIVE is not set (and simplifies your coding). Sample Usage: char ch = cmsg_prompt(TERM_VIOLET, "Really commit suicide? [Y,n]", "nY", PROMPT_NEW_LINE | PROMPT_CASE_SENSITIVE); if (ch == 'Y') {...} */ static char cmsg_prompt_imp(byte color, cptr prompt, char keys[], int options) { if (options & PROMPT_NEW_LINE) msg_boundary(); auto_more_state = AUTO_MORE_PROMPT; cmsg_print(color, prompt); for (;;) { char ch = inkey(); int i; if (ch == ESCAPE && (options & PROMPT_ESCAPE_DEFAULT)) return keys[0]; if (ch == '\r' && (options & PROMPT_RETURN_1)) return keys[1]; for (i = 0; ; i++) { char choice = keys[i]; if (!choice) break; if (ch == choice) return choice; if (!(options & PROMPT_CASE_SENSITIVE)) { if (tolower(ch) == tolower(choice)) return choice; } } if (!(options & PROMPT_FORCE_CHOICE) && quick_messages) return keys[0]; } }
/** * ------------------------------------------------------------------------ * Quickstart? screen. * ------------------------------------------------------------------------ */ static enum birth_stage textui_birth_quickstart(void) { const char *prompt = "['Y' to use this character, 'N' to start afresh, 'C' to change name or history]"; enum birth_stage next = BIRTH_QUICKSTART; /* Prompt for it */ prt("New character based on previous one:", 0, 0); prt(prompt, Term->hgt - 1, Term->wid / 2 - strlen(prompt) / 2); do { /* Get a key */ struct keypress ke = inkey(); if (ke.code == 'N' || ke.code == 'n') { cmdq_push(CMD_BIRTH_RESET); next = BIRTH_RACE_CHOICE; } else if (ke.code == KTRL('X')) { quit(NULL); } else if (ke.code == 'C' || ke.code == 'c') { next = BIRTH_NAME_CHOICE; } else if (ke.code == 'Y' || ke.code == 'y') { cmdq_push(CMD_ACCEPT_CHARACTER); next = BIRTH_COMPLETE; } } while (next == BIRTH_QUICKSTART); /* Clear prompt */ clear_from(23); return next; }
/* * Hack -- quick debugging hook */ static void do_cmd_wiz_hack_ben(void) { int py = p_ptr->py; int px = p_ptr->px; int i, y, x; for (i = 0; i < MONSTER_FLOW_DEPTH; ++i) { /* Update map */ for (y = Term->offset_y; y < Term->offset_y + SCREEN_HGT; y++) { for (x = Term->offset_x; x < Term->offset_x + SCREEN_WID; x++) { byte a = TERM_RED; if (!in_bounds_fully(y, x)) continue; /* Display proper cost */ if (cave_cost[y][x] != i) continue; /* Reliability in yellow */ if (cave_when[y][x] == cave_when[py][px]) { a = TERM_YELLOW; } /* Display player/floors/walls */ if ((y == py) && (x == px)) { print_rel('@', a, y, x); } else if (cave_floor_bold(y, x)) { print_rel('*', a, y, x); } else { print_rel('#', a, y, x); } } } /* Prompt */ prt(format("Depth %d: ", i), 0, 0); /* Get key */ if (inkey() == ESCAPE) break; /* Redraw map */ prt_map(); } /* Done */ prt("", 0, 0); /* Redraw map */ prt_map(); }
/** * ------------------------------------------------------------------------ * Final confirmation of character. * ------------------------------------------------------------------------ */ static enum birth_stage get_confirm_command(void) { const char *prompt = "['ESC' to step back, 'S' to start over, or any other key to continue]"; struct keypress ke; enum birth_stage next = BIRTH_RESET; /* Prompt for it */ prt(prompt, Term->hgt - 1, Term->wid / 2 - strlen(prompt) / 2); /* Get a key */ ke = inkey(); /* Start over */ if (ke.code == 'S' || ke.code == 's') { next = BIRTH_RESET; } else if (ke.code == KTRL('X')) { quit(NULL); } else if (ke.code == ESCAPE) { next = BIRTH_BACK; } else { cmdq_push(CMD_ACCEPT_CHARACTER); next = BIRTH_COMPLETE; } /* Clear prompt */ clear_from(23); return next; }
//"STR$(RND(2)+VAL(MID$(STR$(SIN(1)+COS(1)),3,2)) + 2^.5)+\"F**K\""; int main() { init(); *memoryP(CUR_S) = 2; memoryV(); /*/put_char('H'); put_char('E'); put_char('L'); put_char('L'); put_char('O'); rect( 30 , 30 , 10 , 10 , 1 , 1 ); ellipse( 35 , 35 , 15 , 15 , 0 , 1 );*/ while(1) { gets(testcode); char *p =testcode; Data* data = parse_expression(&p); if( data->type == TYPE_ERROR ) printf(" %s ERROR IN %d\n", err_str[data->storage.error.id] , data->storage.error.line_no); if( data->type == TYPE_REAL ) printf(" REAL(%lf)\n",data->storage.Real ); if( data->type == TYPE_INTEGER ) printf(" INTEGER(%d)\n",data->storage.Integer ); if( data->type == TYPE_STRING ) printf(" STRING(%s)\n",data->storage.String ); dispose(data); } while( inkey() != 'q' ); return 0; }
static void _text_file(cptr name, _file_fn fn) { FILE *fff = NULL; char buf[1024]; path_build(buf, sizeof(buf), ANGBAND_DIR_HELP, name); fff = my_fopen(buf, "w"); if (!fff) { path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name); fff = my_fopen(buf, "w"); if (!fff) { prt("Failed!", 0, 0); (void)inkey(); return; } } fn(fff); fprintf(fff, "\n\n[[[[s| Automatically generated for PosChengband %d.%d.%d.\n", VER_MAJOR, VER_MINOR, VER_PATCH); my_fclose(fff); msg_format("Created %s", buf); }
/* * Peruse the spells/prayers in a Book * * Note that *all* spells in the book are listed */ void show_browse(int book) { /* Save the screen */ Term_save(); /* Display the spells */ print_spells(book); /* Clear the top line */ prt("", 0, 0); /* Prompt user */ put_str("[Press any key to continue]", 0, 23); /* Wait for key */ (void)inkey(); /* Restore the screen */ Term_load(); /* The screen is OK now */ section_icky_row = 0; section_icky_col = 0; /* Flush any events */ Flush_queue(); }
/*! * @brief スコアサーバへの転送処理 * @param do_send 実際に転送ア処置を行うか否か * @return 転送が成功したらTRUEを返す */ bool send_world_score(bool do_send) { #ifdef WORLD_SCORE if(send_score && do_send) { if(easy_band) { msg_print(_("初心者モードではワールドスコアに登録できません。", "Since you are in the Easy Mode, you cannot send score to world score server.")); } else if(get_check_strict(_("スコアをスコア・サーバに登録しますか? ", "Do you send score to the world score sever? "), (CHECK_NO_ESCAPE | CHECK_NO_HISTORY))) { errr err; prt("",0,0); prt(_("送信中..", "Sending..."),0,0); Term_fresh(); screen_save(); err = report_score(); screen_load(); if (err) { return FALSE; } prt(_("完了。何かキーを押してください。", "Completed. Hit any key."), 0, 0); (void)inkey(); } else return FALSE; } #endif return TRUE; }
static void spoil_spells_by_realm(void) { int i, row, col, realm_idx; while (1) { Term_clear(); prt("Realm Spoilers", 2, 0); /* Realms */ row = 4; col = 2; c_prt(TERM_RED, "Realms", row++, col - 2); for (realm_idx = REALM_LIFE; realm_idx <= MAX_MAGIC; realm_idx++) { prt(format("(%c) %s", 'a' + realm_idx - 1, realm_names[realm_idx]), row++, col); } i = inkey(); if (i == ESCAPE) break; realm_idx = i - 'a' + 1; if (REALM_LIFE <= realm_idx && realm_idx <= MAX_MAGIC) _spoil_spells_by_realm_aux1(realm_idx); } }
/* * Display the text from a note on the screen. */ void note_info_screen(const object_type *o_ptr) { /* Redirect output to the screen */ text_out_hook = text_out_to_screen; /* Save the screen */ screen_save(); /* Indent output by 14 characters, and wrap at column 60 */ text_out_wrap = 60; text_out_indent = 14; /* Note intro */ Term_gotoxy(text_out_indent, 0); text_out_c(TERM_L_WHITE+TERM_SHADE, "The note here reads:\n\n"); /* Note text */ Term_gotoxy(text_out_indent, 2); text_out_to_screen(TERM_WHITE, k_text + k_info[o_ptr->k_idx].text); /* Note outro */ text_out_c(TERM_L_WHITE+TERM_SHADE, "\n\n(press any key)\n"); /* Reset text_out() vars */ text_out_wrap = 0; text_out_indent = 0; /* Wait for input */ (void)inkey(); /* Load the screen */ screen_load(); return; }
bool send_world_score(bool do_send) { #ifdef WORLD_SCORE if(send_score && do_send) { if(easy_band) { msg_print("Since you are in the Easy Mode, you cannot send score to world score server."); } else if(get_check_strict("Do you send score to the world score sever? ", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY))) { errr err; prt("",0,0); prt("Sending...",0,0); Term_fresh(); screen_save(); err = report_score(); screen_load(); if (err) { return FALSE; } prt("Completed. Hit any key.", 0, 0); (void)inkey(); } else return FALSE; } #endif return TRUE; }
//按行间距设定页长 UINT8 ucSetPrintPageLongByRow(DevHandle hDev, UINT8 ucRowNum) { UINT8 ucInBuf[20]; UINT32 uiInLen; UINT8 ucOutBuf[20]; UINT32 uiOutLen; UINT8 ucRet; memcpy(ucInBuf, "\x1B\x43", 2); uiInLen = 2; ucInBuf[uiInLen] = ucRowNum; uiInLen += 1; ucMakePrinterCmd(ucInBuf, uiInLen, ucOutBuf, &uiOutLen); ucRet = EA_ucWriteDevice(hDev, uiOutLen, 3, ucOutBuf); if (ucRet != EM_SUCCESS) { display(2, "%s(%d):%02x", __FILE__, __LINE__, ucRet); inkey(0); return 1; } return 0; }
/** * This ugly piece of code exists to figure out what keycodes the user has * been generating. */ static void do_cmd_keylog(void) { int i; char buf[50]; char buf2[12]; struct keypress keys[2] = {{EVT_NONE, 0}, {EVT_NONE, 0}}; screen_save(); prt("Previous keypresses (top most recent):", 0, 0); for (i = 0; i < KEYLOG_SIZE; i++) { if (i < log_size) { /* find the keypress from our log */ int j = (log_i + i) % KEYLOG_SIZE; struct keypress k = keylog[j]; /* ugh. it would be nice if there was a verion of keypress_to_text * which took only one keypress. */ keys[0] = k; keypress_to_text(buf2, sizeof(buf2), keys, TRUE); /* format this line of output */ strnfmt(buf, sizeof(buf), " %-12s (code=%u mods=%u)", buf2, k.code, k.mods); } else { /* create a blank line of output */ strnfmt(buf, sizeof(buf), "%40s", ""); } prt(buf, i + 1, 0); } prt("Press any key to continue.", KEYLOG_SIZE + 1, 0); inkey(); screen_load(); }
byte SplinterQuitGame() { // Sizes in character coordinaes unsigned ww = 34, hh = 5; byte b = 0, f = 14; SplinterDrawDialogBox(ww, hh, f, b); // Locations in pixel coordinates unsigned xx = (40 - ww)/2, yy = (27 - hh)/2; unsigned x = xx * 8, y = yy * 8; // Draw the quit message BlitterDrawText(FontDataFontIndex, FontDataFontData, f, b, 40, y - 6, 1, "Are you sure you want to stop?"); BlitterDrawText(FontDataFontIndex, FontDataFontData, f, b, 120, y + 6, 1, "Press Y or N"); // Wait for the user to response byte shouldQuit = FALSE; do { byte c = inkey(); if ((c == 'n') || (c == 'N')) break; if ((c == 'y') || (c == 'Y')) { shouldQuit = TRUE; break; } } while(TRUE); // Restore the screen SplinterEraseDialogBox(ww, hh, b); SplinterRefresh(); return shouldQuit; }
void msg_print(char* str_buff){ register int old_len; char in_char; if(msg_flag){ old_len=strlen(old_msg[last_msg])+1; if (old_len>MSG_LEN) old_len=MSG_LEN; put_buffer("-more-",MSG_LINE, old_len); wait_for_more=1; do{ in_char=inkey(); }while((in_char!=' ')&&(in_char!=ESCAPE)&&(in_char!='\n')&& (in_char!='\r')); wait_for_more=0; } gotoxy(1,MSG_LINE+1); clreol(); if(str_buff){ put_buffer(str_buff,MSG_LINE,0); command_count=0; if(++last_msg>=MAX_SAVE_MSG) last_msg=0; strncpy(old_msg[last_msg],str_buff,VTYPESIZ); old_msg[last_msg][VTYPESIZ-1]='\0'; msg_flag=TRUE; }else msg_flag=FALSE; }
void textui_cmd_suicide(void) { /* Flush input */ flush(); /* Verify Retirement */ if (p_ptr->total_winner) { /* Verify */ if (!get_check("Do you want to retire? ")) return; } /* Verify Suicide */ else { char ch; /* Verify */ if (!get_check("Do you really want to commit suicide? ")) return; /* Special Verification for suicide */ prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0); flush(); ch = inkey(); prt("", 0, 0); if (ch != '@') return; } cmd_insert(CMD_SUICIDE); }
/* * Pause for user response XXX XXX XXX */ void pause_line(int row) { prtf(0, row, ""); put_fstr(23, row, "[Press any key to continue]"); inkey(); prtf(0, row, ""); }
/** * Ask the user to respond with a character. Options is a constant string, * e.g. "yns"; len is the length of the constant string, and fallback should * be the default answer if the user hits escape or an invalid key. * * Example: get_char("Study? ", "yns", 3, 'n') * This prompts "Study? [yns]" and defaults to 'n'. * */ char get_char(const char *prompt, const char *options, size_t len, char fallback) { struct keypress key; char buf[80]; /* Paranoia */ event_signal(EVENT_MESSAGE_FLUSH); /* Hack -- Build a "useful" prompt */ strnfmt(buf, 78, "%.70s[%s] ", prompt, options); /* Prompt for it */ prt(buf, 0, 0); /* Get an acceptable answer */ key = inkey(); /* Lowercase answer if necessary */ if (key.code >= 'A' && key.code <= 'Z') key.code += 32; /* See if key is in our options string */ if (!strchr(options, (char)key.code)) key.code = fallback; /* Erase the prompt */ prt("", 0, 0); /* Success */ return key.code; }
/* * Get the Sex. */ static bool get_sex(void) { char query2; int loopagain = TRUE; // Set the default sex info to female if (p_ptr->psex == SEX_UNDEFINED) { p_ptr->psex = SEX_FEMALE; sp_ptr = &sex_info[SEX_FEMALE]; } while (loopagain == TRUE) { /* Display the player */ display_player(0); // Highlight the relevant feature c_put_str(TERM_YELLOW, sp_ptr->title, 3, 8); /* Prompt */ Term_putstr(QUESTION_COL, INSTRUCT_ROW + 1, -1, TERM_SLATE, "Enter accept sex"); Term_putstr(QUESTION_COL, INSTRUCT_ROW + 2, -1, TERM_SLATE, "Space change sex"); /* Hack - highlight the key names */ Term_putstr(QUESTION_COL, INSTRUCT_ROW + 1, - 1, TERM_L_WHITE, "Enter"); Term_putstr(QUESTION_COL, INSTRUCT_ROW + 2, - 1, TERM_L_WHITE, "Space"); /* Move the cursor */ Term_gotoxy(0, INSTRUCT_ROW + 1); /* Query */ query2 = inkey(); if ((query2 == '\r') || (query2 == '\n')) { /* got a sex*/ loopagain = FALSE; p_ptr->redraw |= (PR_MISC); } else if (query2 == ESCAPE) return (FALSE); else if (((query2 == 'Q') || (query2 == 'q')) && (turn == 0)) quit (NULL); else { if (p_ptr->psex == SEX_FEMALE) p_ptr->psex = SEX_MALE; else p_ptr->psex = SEX_FEMALE; sp_ptr = &sex_info[p_ptr->psex]; } } return (TRUE); }
//设置行间距 UINT8 ucSetPrintRowSpacing(DevHandle hDev, UINT8 ucMode, UINT8 n) { UINT8 ucInBuf[20]; UINT32 uiInLen; UINT8 ucOutBuf[20]; UINT32 uiOutLen; UINT8 ucRet; uiInLen = 0; memset(ucInBuf, 0, sizeof(ucInBuf)); switch(ucMode) { case 0: //1/8英寸 memcpy(ucInBuf, "\x1B\x30", 2); uiInLen = 2; break; case 1: //1/6英寸 memcpy(ucInBuf, "\x1B\x32", 2); uiInLen = 2; break; case 2: //1/180英寸 memcpy(ucInBuf, "\x1B\x33", 2); uiInLen = 2; ucInBuf[uiInLen] = n; uiInLen += 1; break; case 3: //1/60英寸 memcpy(ucInBuf, "\x1B\x41", 2); uiInLen = 2; ucInBuf[uiInLen] = n; uiInLen += 1; break; case 4: //1/360英寸 memcpy(ucInBuf, "\x1B\x2B", 2); uiInLen = 2; ucInBuf[uiInLen] = n; uiInLen += 1; break; default: break; } ucMakePrinterCmd(ucInBuf, uiInLen, ucOutBuf, &uiOutLen); ucRet = EA_ucWriteDevice(hDev, uiOutLen, 3, ucOutBuf); if (ucRet != EM_SUCCESS) { display(2, "%s(%d):%02x", __FILE__, __LINE__, ucRet); inkey(0); return 1; } return 0; }
void vClearNoAnswer(void) { memset((char *)gtBakFile.stMissedCall, 0, sizeof(gtBakFile.stMissedCall)); gtBakFile.ucMissedCallPos = 1; WRITE_nVAR(gtBakFile); TPA_vDisplayInv(3, DISP_CENTER,"删除未接电话成功"); inkey(3); return; }
void vClearDial(void) { memset((char *)gtBakFile.stDialCall, 0x00, sizeof(gtBakFile.stDialCall)); gtBakFile.ucDialCallPos = 1; WRITE_nVAR(gtBakFile); TPA_vDisplayInv(3, DISP_CENTER, "删除已拨电话成功"); inkey(3); return; }
/** * ------------------------------------------------------------------------ * The rolling bit of the roller. * ------------------------------------------------------------------------ */ static enum birth_stage roller_command(bool first_call) { char prompt[80] = ""; size_t promptlen = 0; struct keypress ch; enum birth_stage next = BIRTH_ROLLER; /* Used to keep track of whether we've rolled a character before or not. */ static bool prev_roll = FALSE; /* Display the player - a bit cheaty, but never mind. */ display_player(0); if (first_call) prev_roll = FALSE; /* Prepare a prompt (must squeeze everything in) */ strnfcat(prompt, sizeof (prompt), &promptlen, "['r' to reroll"); if (prev_roll) strnfcat(prompt, sizeof(prompt), &promptlen, ", 'p' for previous roll"); strnfcat(prompt, sizeof (prompt), &promptlen, " or 'Enter' to accept]"); /* Prompt for it */ prt(prompt, Term->hgt - 1, Term->wid / 2 - promptlen / 2); /* Prompt and get a command */ ch = inkey(); /* Analyse the command */ if (ch.code == ESCAPE) { /* Back out */ next = BIRTH_BACK; } else if (ch.code == KC_ENTER) { /* 'Enter' accepts the roll */ next = BIRTH_NAME_CHOICE; } else if ((ch.code == ' ') || (ch.code == 'r')) { /* Reroll this character */ cmdq_push(CMD_ROLL_STATS); prev_roll = TRUE; } else if (prev_roll && (ch.code == 'p')) { /* Previous character */ cmdq_push(CMD_PREV_STATS); } else if (ch.code == KTRL('X')) { /* Quit */ quit(NULL); } else if (ch.code == '?') { /* Help XXX */ do_cmd_help(); } else { /* Nothing handled directly here */ bell("Illegal roller command!"); } return next; }
/** * Close up the current game (player may or may not be dead) * * Note that the savefile is not saved until the tombstone is * actually displayed and the player has a chance to examine * the inventory and such. This allows cheating if the game * is equipped with a "quit without save" method. XXX XXX XXX */ void close_game(void) { /* Tell the UI we're done with the game state */ event_signal(EVENT_LEAVE_GAME); /* Handle stuff */ handle_stuff(player->upkeep); /* Flush the messages */ event_signal(EVENT_MESSAGE_FLUSH); /* Flush the input */ event_signal(EVENT_INPUT_FLUSH); /* No suspending now */ signals_ignore_tstp(); /* Hack -- Increase "icky" depth */ screen_save_depth++; /* Save monster memory to user directory */ if (!lore_save("lore.txt")) { msg("lore save failed!"); event_signal(EVENT_MESSAGE_FLUSH); } /* Handle death or life */ if (player->is_dead) { death_knowledge(); death_screen(); /* Save dead player */ if (!savefile_save(savefile)) { msg("death save failed!"); event_signal(EVENT_MESSAGE_FLUSH); } } else { /* Save the game */ save_game(); if (Term->mapped_flag) { struct keypress ch; prt("Press Return (or Escape).", 0, 40); ch = inkey(); if (ch.code != ESCAPE) predict_score(); } } /* Hack -- Decrease "icky" depth */ screen_save_depth--; /* Allow suspending now */ signals_handle_tstp(); }
/** * Get some input at the cursor location. * * The buffer is assumed to have been initialized to a default string. * Note that this string is often "empty" (see below). * * The default buffer is displayed in yellow until cleared, which happens * on the first keypress, unless that keypress is Return. * * Normal chars clear the default and append the char. * Backspace clears the default or deletes the final char. * Return accepts the current buffer contents and returns true. * Escape clears the buffer and the window and returns false. * * Note that 'len' refers to the size of the buffer. The maximum length * of the input is 'len-1'. * * 'keypress_h' is a pointer to a function to handle keypresses, altering * the input buffer, cursor position and suchlike as required. See * 'askfor_aux_keypress' (the default handler if you supply NULL for * 'keypress_h') for an example. */ bool askfor_aux(char *buf, size_t len, bool (*keypress_h)(char *, size_t, size_t *, size_t *, struct keypress, bool)) { int y, x; size_t k = 0; /* Cursor position */ size_t nul = 0; /* Position of the null byte in the string */ struct keypress ch = KEYPRESS_NULL; bool done = false; bool firsttime = true; if (keypress_h == NULL) keypress_h = askfor_aux_keypress; /* Locate the cursor */ Term_locate(&x, &y); /* Paranoia */ if ((x < 0) || (x >= 80)) x = 0; /* Restrict the length */ if (x + len > 80) len = 80 - x; /* Truncate the default entry */ buf[len-1] = '\0'; /* Get the position of the null byte */ nul = strlen(buf); /* Display the default answer */ Term_erase(x, y, (int)len); Term_putstr(x, y, -1, COLOUR_YELLOW, buf); /* Process input */ while (!done) { /* Place cursor */ Term_gotoxy(x + k, y); /* Get a key */ ch = inkey(); /* Let the keypress handler deal with the keypress */ done = keypress_h(buf, len, &k, &nul, ch, firsttime); /* Update the entry */ Term_erase(x, y, (int)len); Term_putstr(x, y, -1, COLOUR_WHITE, buf); /* Not the first time round anymore */ firsttime = false; } /* Done */ return (ch.code != ESCAPE); }
bool do_control_inven(void) { if (!p_ptr->control) return FALSE; screen_save(); prt("Carried items", 0, 0); // DGDGDGDG show_monster_inven(p_ptr->control, monst_list); inkey(); screen_load(); return TRUE; }
static int message(int x1,int y1,char* txt1) { char txt[STRSIZ]; int mess, marg, i=0, x2, y2; void * dump; int xold, yold; char * c; strcpy(txt,txt1); c=txt; xold = where_x(); yold = where_y(); x2 = x1 + maxline(&y2,txt) /*+4*/; y2 = y1 + y2 + 1; get_text(x1,y1,x2,y2,&dump); chepbox(x1,y1,x2,y2); be_be(); c=strtok(txt,"\n"); while(c) { ++(i); marg = (x2 - x1 - strlen(c)) / 2; if (y1+i == y2) { goto_xy(x1+1+marg ,y1 + i); print("%s",c); }else { char buff[STRSIZ]; memset(buff,' ',x2-x1 -1); memcpy(buff+marg,c,strlen(c)); buff[x2-x1-1]=0; goto_xy(x1+1,y1+i); print(buff); } c=strtok(NULL,"\n"); } ret_: if (blind) mess='Y' ; else do{mess = inkey();} while (mess == KB_SIZE); /* mouse filter */ if (mess == KB_MOUSE) { if ( (mouse_info.but1 !=2) || (mouse_info.row < y1) || (mouse_info.row > y2) || (mouse_info.col < x1) || (mouse_info.col > x2) ) goto ret_; if (mouse_info.row == y2 ) { if (mouse_info.col < (x1+x2)/2 /* -1*/ ) mess='Y'; if (mouse_info.col > (x1+x2)/2 /*+1 */) mess='N'; } } /* end of filter */ put_text(&dump); goto_xy(xold,yold); return mess; } /* message */
int get_com(char *prompt,char *command){ int res; if(prompt) prt(prompt,0,0); *command=inkey(); if(*command==ESCAPE) res=FALSE; else res=TRUE; erase_line(MSG_LINE,0); return(res); }