Term_gotoxy(col + pos, 0);
/* Get a special key code */
- skey = inkey_special();
+ skey = inkey_special(TRUE);
/* Analyze the key */
switch (skey)
tb->old_hgt = tb->hgt;
/* Get a command */
- key = inkey_special();
+ key = inkey_special(TRUE);
/* Special keys */
if (key & SKEY_MASK)
Term_gotoxy(x + 10, y + 12);
/* Get special key code */
- skey = inkey_special();
+ skey = inkey_special(TRUE);
/* Get a character code */
if (!(skey & SKEY_MASK)) c = (char)skey;
strcpy(inp, "10");
/* Get a response (or escape) */
- if (!askfor_aux(inp, 2)) strcpy(inp, "10");
+ if (!askfor_aux(inp, 2, FALSE)) strcpy(inp, "10");
/* Quit */
if (inp[0] == 'Q') birth_quit();
/* Get a command */
- skey = inkey_special();
+ skey = inkey_special(TRUE);
/* Exit on Escape */
if (skey == ESCAPE) break;
/* Get a "shower" string, or continue */
- if (!askfor_aux(shower, 80)) continue;
+ if (!askfor(shower, 80)) continue;
/* Okay */
continue;
/* Get a "finder" string, or continue */
- if (!askfor_aux(finder, 80)) continue;
+ if (!askfor(finder, 80)) continue;
/* Show it */
strcpy(shower, finder);
sprintf(tmp, "%s.prf", player_name);
/* Ask for a file */
- if (!askfor_aux(tmp, 80)) continue;
+ if (!askfor(tmp, 80)) continue;
/* Process the given filename */
err = process_pref_file(tmp);
sprintf(tmp, "%s.prf", player_name);
/* Ask for a file */
- if (!askfor_aux(tmp, 80)) continue;
+ if (!askfor(tmp, 80)) continue;
/* Dump the macros */
(void)macro_dump(tmp);
ascii_to_text(tmp, macro__buf);
/* Get an encoded action */
- if (askfor_aux(tmp, 80))
+ if (askfor(tmp, 80))
{
/* Convert to ascii */
text_to_ascii(macro__buf, tmp);
sprintf(tmp, "%s.prf", player_name);
/* Ask for a file */
- if (!askfor_aux(tmp, 80)) continue;
+ if (!askfor(tmp, 80)) continue;
/* Dump the macros */
(void)keymap_dump(tmp);
ascii_to_text(tmp, macro__buf);
/* Get an encoded action */
- if (askfor_aux(tmp, 80))
+ if (askfor(tmp, 80))
{
/* Convert to ascii */
text_to_ascii(macro__buf, tmp);
tmp[80] = '\0';
/* Get an encoded action */
- if (!askfor_aux(buf, 80)) continue;
+ if (!askfor(buf, 80)) continue;
/* Extract an action */
text_to_ascii(macro__buf, buf);
sprintf(tmp, "%s.prf", player_name);
/* Query */
- if (!askfor_aux(tmp, 70)) continue;
+ if (!askfor(tmp, 70)) continue;
/* Process the given filename */
(void)process_pref_file(tmp);
sprintf(tmp, "%s.prf", player_name);
/* Get a filename */
- if (!askfor_aux(tmp, 70)) continue;
+ if (!askfor(tmp, 70)) continue;
/* Build the filename */
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
sprintf(tmp, "%s.prf", player_name);
/* Get a filename */
- if (!askfor_aux(tmp, 70)) continue;
+ if (!askfor(tmp, 70)) continue;
/* Build the filename */
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
sprintf(tmp, "%s.prf", player_name);
/* Get a filename */
- if (!askfor_aux(tmp, 70)) continue;
+ if (!askfor(tmp, 70)) continue;
/* Build the filename */
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
sprintf(tmp, "%s.prf", player_name);
/* Query */
- if (!askfor_aux(tmp, 70)) continue;
+ if (!askfor(tmp, 70)) continue;
/* Process the given filename */
(void)process_pref_file(tmp);
sprintf(tmp, "%s.prf", player_name);
/* Get a filename */
- if (!askfor_aux(tmp, 70)) continue;
+ if (!askfor(tmp, 70)) continue;
/* Build the filename */
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
extern void c_roff(byte attr, cptr str);
extern void roff(cptr str);
extern void clear_from(int row);
-extern bool askfor_aux(char *buf, int len);
+extern bool askfor_aux(char *buf, int len, bool numpad_cursor);
+extern bool askfor(char *buf, int len);
extern bool get_string(cptr prompt, char *buf, int len);
extern bool get_check(cptr prompt);
extern bool get_check_strict(cptr prompt, int mode);
extern char *my_strstr(const char *haystack, const char *needle);
extern char *my_strchr(const char *ptr, char ch);
extern void str_tolower(char *str);
-extern int inkey_special(void);
+extern int inkey_special(bool numpad_cursor);
/* xtra1.c */
}
/* Get a special key code */
- skey = inkey_special();
+ skey = inkey_special(TRUE);
/* Show the help for the help */
if (skey == '?')
prt("Show: ", hgt - 1, 0);
#endif
- (void)askfor_aux(shower_str, 80);
+ (void)askfor(shower_str, 80);
/* Make it lowercase */
str_tolower(shower_str);
#endif
- if (askfor_aux(finder_str, 80))
+ if (askfor(finder_str, 80))
{
/* Find it */
find = finder_str;
strcpy(tmp, "0");
- if (askfor_aux(tmp, 80))
+ if (askfor(tmp, 80))
{
line = atoi(tmp);
}
#endif
- if (askfor_aux(tmp, 80))
+ if (askfor(tmp, 80))
{
if (!show_file(TRUE, tmp, NULL, 0, mode)) skey = 'q';
}
strcpy(out_val, "");
/* Ask for filename (or abort) */
- if (!askfor_aux(out_val, 60)) return;
+ if (!askfor(out_val, 60)) return;
/* Return means "show on screen" */
if (!out_val[0]) break;
/* Ask until done */
while (TRUE)
{
+ bool res;
+
+ /* Display prompt */
+ prt(buf, 0, 0);
+
/* Default */
strcpy(out_val, "");
- /* Ask the user for a response */
- if (!get_string(buf, out_val, 32)) return (FALSE);
+ /*
+ * Ask the user for a response.
+ * Don't allow to use numpad as cursor key.
+ */
+ res = askfor_aux(out_val, 32, FALSE);
+
+ /* Clear prompt */
+ prt("", 0, 0);
+
+ /* Cancelled */
+ if (!res) return FALSE;
/* Skip leading spaces */
for (p = out_val; *p == ' '; p++) /* loop */;
* ESCAPE clears the buffer and the window and returns FALSE.
* RETURN accepts the current buffer contents and returns TRUE.
*/
-bool askfor_aux(char *buf, int len)
+bool askfor_aux(char *buf, int len, bool numpad_cursor)
{
int y, x;
int pos = 0;
Term_gotoxy(x + pos, y);
/* Get a special key code */
- skey = inkey_special();
+ skey = inkey_special(numpad_cursor);
/* Analyze the key */
switch (skey)
/*
+ * Get some string input at the cursor location.
+ *
+ * Allow to use numpad keys as cursor keys.
+ */
+bool askfor(char *buf, int len)
+{
+ return askfor_aux(buf, len, TRUE);
+}
+
+
+/*
* Get a string from the user
*
* The "prompt" should take the form "Prompt: "
prt(prompt, 0, 0);
/* Ask the user for a string */
- res = askfor_aux(buf, len);
+ res = askfor(buf, len);
/* Clear prompt */
prt("", 0, 0);
*/
s16b get_quantity(cptr prompt, int max)
{
+ bool res;
int amt;
-
char tmp[80];
-
char buf[80];
{
/* Build a prompt */
#ifdef JP
- sprintf(tmp, "¤¤¤¯¤Ä¤Ç¤¹¤« (1-%d): ", max);
+ sprintf(tmp, "¤¤¤¯¤Ä¤Ç¤¹¤« (1-%d): ", max);
#else
sprintf(tmp, "Quantity (1-%d): ", max);
#endif
prompt = tmp;
}
+ /* Paranoia XXX XXX XXX */
+ msg_print(NULL);
+
+ /* Display prompt */
+ prt(prompt, 0, 0);
/* Default to one */
amt = 1;
/* Build the default */
sprintf(buf, "%d", amt);
- /* Ask for a quantity */
- if (!get_string(prompt, buf, 6)) return (0);
+ /*
+ * Ask for a quantity
+ * Don't allow to use numpad as cursor key.
+ */
+ res = askfor_aux(buf, 6, FALSE);
+
+ /* Clear prompt */
+ prt("", 0, 0);
+
+ /* Cancelled */
+ if (!res) return 0;
/* Extract a number */
amt = atoi(buf);
* This function is a Mega-Hack and depend on pref-xxx.prf's.
* Currently works on Linux(UNIX), Windows, and Macintosh only.
*/
-int inkey_special(void)
+int inkey_special(bool numpad_cursor)
{
static const struct {
cptr keyname;
if (!modifier_key_list[i].keyname) break;
}
+ /* numpad_as_cursorkey option force numpad keys to input numbers */
+ if (!numpad_as_cursorkey) numpad_cursor = FALSE;
+
/* Get a special key code */
for (i = 0; special_key_list[i].keyname; i++)
{
- if ((!special_key_list[i].numpad || numpad_as_cursorkey) &&
+ if ((!special_key_list[i].numpad || numpad_cursor) &&
streq(str, special_key_list[i].keyname))
{
skey = special_key_list[i].keycode;