From: nethack.allison Date: Fri, 6 Jun 2003 03:49:56 +0000 (+0000) Subject: number_pad (modified from 's patch) X-Git-Tag: MOVE2GIT~1938 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a67ed775cb3e84371edc754d3c882682dcdbd8ea;p=nethack number_pad (modified from 's patch) 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 [] 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.) --- diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index a6d0e085e..6328a88c0 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -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_.''). diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index b19d5e88b..56398f3a4 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -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 diff --git a/include/flag.h b/include/flag.h index 5d49b27db..1392cd7bd 100644 --- a/include/flag.h +++ b/include/flag.h @@ -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 */ diff --git a/src/cmd.c b/src/cmd.c index 8897856cc..9309ab474 100644 --- 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; diff --git a/src/options.c b/src/options.c index 0c6d94f47..869322c17 100644 --- a/src/options.c +++ b/src/options.c @@ -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 diff --git a/sys/msdos/msdos.c b/sys/msdos/msdos.c index c43af3bad..29e19fbf9 100644 --- a/sys/msdos/msdos.c +++ b/sys/msdos/msdos.c @@ -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 }; diff --git a/sys/winnt/nhdefkey.c b/sys/winnt/nhdefkey.c index 74a2bdd2c..ad7156b03 100644 --- a/sys/winnt/nhdefkey.c +++ b/sys/winnt/nhdefkey.c @@ -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 */ }; diff --git a/win/win32/mhmain.c b/win/win32/mhmain.c index ccb9811aa..65658dcaf 100644 --- a/win/win32/mhmain.c +++ b/win/win32/mhmain.c @@ -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 */ };