OSDN Git Service

askfor_aux()で数値入力をする時は、テンキーは常に数字を入力するように修正。
authormogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sun, 2 Nov 2003 08:06:06 +0000 (08:06 +0000)
committermogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sun, 2 Nov 2003 08:06:06 +0000 (08:06 +0000)
src/autopick.c
src/birth.c
src/cmd4.c
src/externs.h
src/files.c
src/store.c
src/util.c

index 8293296..b75ffee 100644 (file)
@@ -3314,7 +3314,7 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp)
                Term_gotoxy(col + pos, 0);
 
                /* Get a special key code */
-               skey = inkey_special();
+               skey = inkey_special(TRUE);
 
                /* Analyze the key */
                switch (skey)
@@ -5999,7 +5999,7 @@ void do_cmd_edit_autopick(void)
                tb->old_hgt = tb->hgt;
 
                /* Get a command */
-               key = inkey_special();
+               key = inkey_special(TRUE);
 
                /* Special keys */
                if (key & SKEY_MASK)
index 95c6407..d169520 100644 (file)
@@ -5406,7 +5406,7 @@ static void edit_history(void)
                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;
@@ -5947,7 +5947,7 @@ static bool player_birth_aux(void)
                        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();
index 06a200e..f9a35b5 100644 (file)
@@ -1382,7 +1382,7 @@ void do_cmd_messages(int num_now)
 
 
                /* Get a command */
-               skey = inkey_special();
+               skey = inkey_special(TRUE);
 
                /* Exit on Escape */
                if (skey == ESCAPE) break;
@@ -1402,7 +1402,7 @@ void do_cmd_messages(int num_now)
 
 
                        /* Get a "shower" string, or continue */
-                       if (!askfor_aux(shower, 80)) continue;
+                       if (!askfor(shower, 80)) continue;
 
                        /* Okay */
                        continue;
@@ -1422,7 +1422,7 @@ void do_cmd_messages(int num_now)
 
 
                        /* Get a "finder" string, or continue */
-                       if (!askfor_aux(finder, 80)) continue;
+                       if (!askfor(finder, 80)) continue;
 
                        /* Show it */
                        strcpy(shower, finder);
@@ -3146,7 +3146,7 @@ void do_cmd_macros(void)
                        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);
@@ -3202,7 +3202,7 @@ void do_cmd_macros(void)
                        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);
@@ -3314,7 +3314,7 @@ void do_cmd_macros(void)
                        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);
@@ -3389,7 +3389,7 @@ void do_cmd_macros(void)
                        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);
@@ -3501,7 +3501,7 @@ void do_cmd_macros(void)
                        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);
@@ -3577,7 +3577,7 @@ void do_cmd_macros(void)
                        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);
@@ -3737,7 +3737,7 @@ void do_cmd_visuals(void)
                        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);
@@ -3770,7 +3770,7 @@ void do_cmd_visuals(void)
                        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);
@@ -3838,7 +3838,7 @@ void do_cmd_visuals(void)
                        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);
@@ -3913,7 +3913,7 @@ void do_cmd_visuals(void)
                        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);
@@ -4380,7 +4380,7 @@ void do_cmd_colors(void)
                        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);
@@ -4419,7 +4419,7 @@ void do_cmd_colors(void)
                        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);
index 7981850..1f0f2e8 100644 (file)
@@ -1259,7 +1259,8 @@ extern void prt(cptr str, int row, int col);
 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);
@@ -1286,7 +1287,7 @@ extern size_t my_strcat(char *buf, const char *src, size_t bufsize);
 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 */
index d57dc43..1b1cc33 100644 (file)
@@ -5543,7 +5543,7 @@ prt("[
                }
 
                /* Get a special key code */
-               skey = inkey_special();
+               skey = inkey_special(TRUE);
 
                /* Show the help for the help */
                if (skey == '?')
@@ -5568,7 +5568,7 @@ prt("[
                        prt("Show: ", hgt - 1, 0);
 #endif
 
-                       (void)askfor_aux(shower_str, 80);
+                       (void)askfor(shower_str, 80);
 
                        /* Make it lowercase */
                        str_tolower(shower_str);
@@ -5588,7 +5588,7 @@ prt("[
 #endif
 
 
-                       if (askfor_aux(finder_str, 80))
+                       if (askfor(finder_str, 80))
                        {
                                /* Find it */
                                find = finder_str;
@@ -5615,7 +5615,7 @@ prt("
 
                        strcpy(tmp, "0");
 
-                       if (askfor_aux(tmp, 80))
+                       if (askfor(tmp, 80))
                        {
                                line = atoi(tmp);
                        }
@@ -5646,7 +5646,7 @@ strcpy(tmp, "jhelp.hlp");
 #endif
 
 
-                       if (askfor_aux(tmp, 80))
+                       if (askfor(tmp, 80))
                        {
                                if (!show_file(TRUE, tmp, NULL, 0, mode)) skey = 'q';
                        }
@@ -6693,7 +6693,7 @@ put_str("
                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;
index 3ad5a24..21e0c5b 100644 (file)
@@ -2590,11 +2590,25 @@ static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
        /* 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 */;
index 2cb8f71..0d25aa8 100644 (file)
@@ -3180,7 +3180,7 @@ void clear_from(int row)
  * 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;
@@ -3221,7 +3221,7 @@ bool askfor_aux(char *buf, int len)
                Term_gotoxy(x + pos, y);
 
                /* Get a special key code */
-               skey = inkey_special();
+               skey = inkey_special(numpad_cursor);
 
                /* Analyze the key */
                switch (skey)
@@ -3423,6 +3423,17 @@ bool askfor_aux(char *buf, int len)
 
 
 /*
+ * 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: "
@@ -3443,7 +3454,7 @@ bool get_string(cptr prompt, char *buf, int len)
        prt(prompt, 0, 0);
 
        /* Ask the user for a string */
-       res = askfor_aux(buf, len);
+       res = askfor(buf, len);
 
        /* Clear prompt */
        prt("", 0, 0);
@@ -3616,10 +3627,9 @@ bool get_com(cptr prompt, char *command, bool z_escape)
  */
 s16b get_quantity(cptr prompt, int max)
 {
+       bool res;
        int amt;
-
        char tmp[80];
-
        char buf[80];
 
 
@@ -3661,7 +3671,7 @@ s16b get_quantity(cptr prompt, int max)
        {
                /* Build a prompt */
 #ifdef JP
-                       sprintf(tmp, "¤¤¤¯¤Ä¤Ç¤¹¤« (1-%d): ", max);
+               sprintf(tmp, "¤¤¤¯¤Ä¤Ç¤¹¤« (1-%d): ", max);
 #else
                sprintf(tmp, "Quantity (1-%d): ", max);
 #endif
@@ -3671,6 +3681,11 @@ s16b get_quantity(cptr prompt, int max)
                prompt = tmp;
        }
 
+       /* Paranoia XXX XXX XXX */
+       msg_print(NULL);
+
+       /* Display prompt */
+       prt(prompt, 0, 0);
 
        /* Default to one */
        amt = 1;
@@ -3678,8 +3693,17 @@ s16b get_quantity(cptr prompt, int max)
        /* 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);
@@ -5316,7 +5340,7 @@ void str_tolower(char *str)
  * 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;
@@ -5415,10 +5439,13 @@ int inkey_special(void)
                        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;