number_pad (modified from <Someone>'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 [<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.)
This commit is contained in:
nethack.allison
2003-06-06 03:49:56 +00:00
parent 3a31710a6c
commit a67ed775cb
8 changed files with 58 additions and 16 deletions

View File

@@ -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;

View 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