fix rest_on_space

When rest_on_space is On, assign same function as for #wait to the
<space> key.  When Off, set that key to Null instead.  Binding some
other command to <space> when rest_on_space is Off doesn't work but
I would classify that as something to be discouraged anyway.
This commit is contained in:
PatR
2022-01-21 15:51:05 -08:00
parent 75fed4b92b
commit 6a72e48a40
4 changed files with 26 additions and 4 deletions

View File

@@ -2574,9 +2574,10 @@ commands_init(void)
(void) bind_key(M('2'), "twoweapon");
(void) bind_key(M('n'), "name");
(void) bind_key(M('N'), "name");
/* wait_on_space */
#if 0
/* don't do this until the rest_on_space option is set or cleared */
(void) bind_key(' ', "wait");
#endif
}
static boolean
@@ -3573,6 +3574,22 @@ reset_commands(boolean initial)
(void) bind_key_fn(M(g.Cmd.dirchars[i]), move_funcs[i][MV_RUSH]);
}
}
update_rest_on_space();
}
void
update_rest_on_space(void)
{
/* cloned from extcmdlist['.'], then slightly modified to be distinct;
donull is all that's needed for it to operate; command name and
description get shown by help menu's "Info on what a given key does"
(which runs the '&' command) and "Full list of keyboard commands" */
static const struct ext_func_tab restonspace = {
' ', "wait", "rest one move via 'rest_on_space' option",
donull, (IFBURIED | CMD_M_PREFIX), "waiting"
};
g.Cmd.commands[' '] = flags.rest_on_space ? &restonspace : 0;
}
/* commands which accept 'm' prefix to request menu operation */