]> granicus.if.org Git - nethack/commitdiff
number_pad (modified from <Someone>'s patch)
authornethack.allison <nethack.allison>
Fri, 6 Jun 2003 03:49:56 +0000 (03:49 +0000)
committernethack.allison <nethack.allison>
Fri, 6 Jun 2003 03:49:56 +0000 (03:49 +0000)
The number_pad option can now optionally hold a value
{0,1, 2 } for {off, on, DOS-mode} but plain number_pad and
!number_pad in config files still work as before.

When number_pad:2 is set, iflags.num_pad_mode is set to 1
which triggers the following behaviour:
> '5', M('5') and M('0') are mapped in rhack()
>in cmd.c, only when they are entered as a command. When used as a
>number, like in the 'n' command, no mapping takes place. '0' is
>already mapped to 'i' by the core. The
>only difference [<Someone>] left in (deliberately) is when you press Ctrl-0;
>this used to map to C('i'), which is an invalid command; now
>keep it '0' (which is interpreted as 'i' by the core.)

doc/Guidebook.mn
doc/Guidebook.tex
include/flag.h
src/cmd.c
src/options.c
sys/msdos/msdos.c
sys/winnt/nhdefkey.c
win/win32/mhmain.c

index a6d0e085e8f66a217569e2d66b6e9d6daa32a56f..6328a88c0211ff2886f141d9a47a06cbf0342720 100644 (file)
@@ -5,7 +5,7 @@
 .ds vr "NetHack 3.4
 .ds f0 "\*(vr
 .ds f1
-.ds f2 "May 11, 2003
+.ds f2 "June 5, 2003
 .mt
 A Guide to the Mazes of Menace
 (Guidebook for NetHack)
@@ -1943,7 +1943,9 @@ in setting this with the `O' command.
 .lp "null    "
 Send padding nulls to the terminal (default off).
 .lp number_pad
-Use the number keys to move instead of [yuhjklbn] (default off).
+Use the number keys to move instead of [yuhjklbn] (default 0 or off).
+(number_pad:2 invokes the old DOS behaviour where `5' means `g', meta-`5'
+means `G',  and meta-`0' means `I'.)
 .lp objects
 Set the characters used to display object classes
 (default ``])[="(%!?+/$*`0_.'').
index b19d5e88b616be43b95c40c5be4c6e2c8f0f4c85..56398f3a411bb978d42a0b0497d107c181da498d 100644 (file)
@@ -27,7 +27,7 @@
 \begin{document}
 %
 % input file: guidebook.mn
-% $Revision: 1.64 $ $Date: 2003/04/05 02:14:51 $
+% $Revision: 1.65 $ $Date: 2003/05/12 03:05:00 $
 %
 %.ds h0 "
 %.ds h1 %.ds h2 \%
@@ -40,7 +40,7 @@
 %.au
 \author{Eric S. Raymond\\
 (Extensively edited and expanded for 3.4)}
-\date{May 11, 2003}
+\date{June 5, 2003}
 
 \maketitle
 
@@ -2387,7 +2387,9 @@ in setting this with the `{\tt O}' command.
 Send padding nulls to the terminal (default off).
 %.lp
 \item[\ib{number\_pad}]
-Use the number keys to move instead of {\tt [yuhjklbn]} (default off).
+Use the number keys to move instead of {\tt [yuhjklbn]} (default 0 or off).
+(number\_pad:2 invokes the old DOS behaviour where `{\tt 5}' means `{\tt g}', 
+meta-`{\tt 5}' means `{\tt G}',  and meta-`{\tt 0}' means `{\tt I}'.)
 %.lp
 \item[\ib{objects}]
 Set the characters used to display object classes (default
index 5d49b27db4d40fadad672ec50e56f08fe785775f..1392cd7bdd1b7a3df4f7886b29e187ac1eb31c97 100644 (file)
@@ -172,6 +172,7 @@ struct instance_flags {
        boolean  menu_tab_sep;  /* Use tabs to separate option menu fields */
        boolean  menu_requested; /* Flag for overloaded use of 'm' prefix
                                  * on some non-move commands */
+       uchar num_pad_mode;
        int      purge_monsters;        /* # of dead monsters still on fmon list */
        int *opt_booldup;       /* for duplication of boolean opts in config file */
        int *opt_compdup;       /* for duplication of compound opts in config file */
index 8897856cc611d16f6ee98ad7ddfeb61e4b7ea595..9309ab474b8cc2787c855297f2e344a36388ecae 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1792,7 +1792,18 @@ register char *cmd;
                flags.move = FALSE;
                return;         /* probably we just had an interrupt */
        }
-
+       if (iflags.num_pad && iflags.num_pad_mode == 1) {
+               /* This handles very old inconsistent DOS/Windows behaviour
+                * in a new way: earlier, the keyboard handler mapped these,
+                * which caused counts to be strange when entered from the
+                * number pad. Now do not map them until here. 
+                */
+               switch (*cmd) {
+                   case '5':       *cmd = 'g'; break;
+                   case M('5'):    *cmd = 'G'; break;
+                   case M('0'):    *cmd = 'I'; break;
+               }
+        }
        /* handle most movement commands */
        do_walk = do_rush = prefix_seen = FALSE;
        flags.travel = 0;
index 0c6d94f478596d43f467d0860caa2a198ccf3736..869322c17a525b9b7c86428440148449b224efcd 100644 (file)
@@ -137,7 +137,6 @@ static struct Bool_Opt
        {"news", (boolean *)0, FALSE, SET_IN_FILE},
 #endif
        {"null", &flags.null, TRUE, SET_IN_GAME},
-       {"number_pad", &iflags.num_pad, FALSE, SET_IN_GAME},
 #ifdef MAC
        {"page_wait", &flags.page_wait, TRUE, SET_IN_GAME},
 #else
@@ -268,6 +267,7 @@ static struct Comp_Opt
 # endif
        { "name",     "your character's name (e.g., name:Merlin-W)",
                                                PL_NSIZ, DISP_IN_GAME },
+       { "number_pad", "use the number pad", 1, SET_IN_GAME},
        { "objects",  "the symbols to use for objects",
                                                MAXOCLASSES, SET_IN_FILE },
        { "packorder", "the inventory order of the items in your pack",
@@ -1067,6 +1067,35 @@ boolean tinitial, tfrom_file;
                return;
        }
 
+       fullname = "number_pad";
+       if (match_optname(opts, fullname, 10, TRUE)) {
+               boolean compat = (strlen(opts) <= 10);
+               number_pad(iflags.num_pad ? 1 : 0);
+               op = string_for_opt(opts, (compat || !initial));
+               if (!op) {
+                   if (compat || negated || initial) {
+                       /* for backwards compatibility, "number_pad" without a
+                          value is a synonym for number_pad:1 */
+                       iflags.num_pad = !negated;
+                       if (iflags.num_pad) iflags.num_pad_mode = 0;
+                   }
+                   return;
+               }
+               if (negated) {
+                   bad_negation("number_pad", TRUE);
+                   return;
+               }
+               if (*op == '1' || *op == '2') {
+                       iflags.num_pad = 1;
+                       if (*op == '2') iflags.num_pad_mode = 1;
+                       else iflags.num_pad_mode = 0;
+               } else if (*op == '0') {
+                       iflags.num_pad = 0;
+                       iflags.num_pad_mode = 0;
+               } else badoption(opts);
+               return;
+       }
+
        fullname = "runmode";
        if (match_optname(opts, fullname, 4, TRUE)) {
                if (negated) {
@@ -2131,9 +2160,6 @@ goodfruit:
                            else lan_mail_finish();
                        }
 #endif
-                       else if ((boolopt[i].addr) == &iflags.num_pad)
-                           number_pad(iflags.num_pad ? 1 : 0);
-
                        else if ((boolopt[i].addr) == &flags.lit_corridor) {
                            /*
                             * All corridor squares seen via night vision or
index c43af3badebe84340e5aad605bba85b0185fb1c8..29e19fbf90110de3902111ea67b1e00aee9d2724 100644 (file)
@@ -178,13 +178,13 @@ static const struct pad {
                        {'9', M('9'), '9'},             /* 9 */
                        {'m', C('p'), C('p')},          /* - */
                        {'4', M('4'), '4'},             /* 4 */
-                       {'g', 'G', 'g'},                /* 5 */
+                       {'5', M('5'), '5'},             /* 5 */
                        {'6', M('6'), '6'},             /* 6 */
                        {'p', 'P', C('p')},             /* + */
                        {'1', M('1'), '1'},             /* 1 */
                        {'2', M('2'), '2'},             /* 2 */
                        {'3', M('3'), '3'},             /* 3 */
-                       {'i', 'I', C('i')},             /* Ins */
+                       {'0', M('0'), '0'},             /* Ins */
                        {'.', ':', ':'}                 /* Del */
 #endif
 };
index 74a2bdd2c8bbef20d64fd5329704b69a48acd3cd..ad7156b03d42bdc499549b8c7be09e83ddf13f51 100644 (file)
@@ -81,13 +81,13 @@ static const struct pad {
                        {'9', M('9'), '9'},             /* 9 */
                        {'m', C('p'), C('p')},          /* - */
                        {'4', M('4'), '4'},             /* 4 */
-                       {'g', 'G', 'g'},                /* 5 */
+                       {'5', M('5'), '5'},             /* 5 */
                        {'6', M('6'), '6'},             /* 6 */
                        {'+', 'P', C('p')},             /* + */
                        {'1', M('1'), '1'},             /* 1 */
                        {'2', M('2'), '2'},             /* 2 */
                        {'3', M('3'), '3'},             /* 3 */
-                       {'i', 'I', C('i')},             /* Ins */
+                       {'0', M('0'), '0'},             /* Ins */
                        {'.', ':', ':'}                 /* Del */
 };
 
index ccb9811aa6b7582197ce8a567def35755a48aaa4..65658dcaf6fe2db41c4ed28695eb30f5a3aadf15 100644 (file)
@@ -138,13 +138,13 @@ numpad[KEY_LAST][3] = {
        {'9', M('9'), '9'}, /* 9 */
        {'m', C('p'), C('p')}, /* - */
        {'4', M('4'), '4'}, /* 4 */
-       {'g', 'G', 'g'}, /* 5 */
+       {'5', M('5'), '5'}, /* 5 */
        {'6', M('6'), '6'}, /* 6 */
        {'+', 'P', C('p')}, /* + */
        {'1', M('1'), '1'}, /* 1 */
        {'2', M('2'), '2'}, /* 2 */
        {'3', M('3'), '3'}, /* 3 */
-       {'i', 'I', C('i')}, /* Ins */
+       {'0', M('0'), '0'}, /* Ins */
        {'.', ':', ':'} /* Del */
 };