Change repeat into extended command

This commit is contained in:
Pasi Kallinen
2022-01-17 17:13:59 +02:00
parent a0f222fe66
commit 2e144e814d
8 changed files with 31 additions and 43 deletions
+4 -4
View File
@@ -697,7 +697,7 @@ Remove one or more worn items, such as armor.
Use \(oqT\(cq (take off) to take off only one piece of armor Use \(oqT\(cq (take off) to take off only one piece of armor
or \(oqR\(cq (remove) to take off only one accessory. or \(oqR\(cq (remove) to take off only one accessory.
.lp \(haA .lp \(haA
Redo the previous command. Repeat the previous command.
.lp c .lp c
Close a door. Close a door.
.lp C .lp C
@@ -1444,6 +1444,9 @@ is on.
.lp "#remove " .lp "#remove "
Remove an accessory (ring, amulet, etc). Remove an accessory (ring, amulet, etc).
Default key is \(oqR\(cq. Default key is \(oqR\(cq.
.lp "#repeat "
Repeat the previous command.
Default key is \(oq\(haA\(cq.
.lp "#reqmenu " .lp "#reqmenu "
Prefix key to modify the behaviour or request menu from some commands. Prefix key to modify the behaviour or request menu from some commands.
Prevents autopickup when used with movement commands. Prevents autopickup when used with movement commands.
@@ -4892,9 +4895,6 @@ Default is \(oqz\(cq.
.lp getpos.valid.prev .lp getpos.valid.prev
When asked for a location, the key to go to previous closest valid location. When asked for a location, the key to go to previous closest valid location.
Default is \(oqZ\(cq. Default is \(oqZ\(cq.
.lp repeat
Key to repeat previous command.
Default is \(oq\(haA\(cq.
.hn 2 .hn 2
Configuring Message Types Configuring Message Types
.pg .pg
+5 -4
View File
@@ -797,7 +797,7 @@ Use `{\tt T}' (take off) to take off only one piece of armor
or `{\tt R}' (remove) to take off only one accessory. or `{\tt R}' (remove) to take off only one accessory.
%.lp %.lp
\item[\tb{\^{}A}] \item[\tb{\^{}A}]
Redo the previous command. Repeat the previous command.
%.lp %.lp
\item[\tb{c}] \item[\tb{c}]
Close a door. Close a door.
@@ -1552,6 +1552,10 @@ and also `{\tt \^{}L}' if {\it number\verb+_+pad\/} is on.
\item[\tb{\#remove}] \item[\tb{\#remove}]
Remove an accessory (ring, amulet, etc). Default key is `{\tt R}'. Remove an accessory (ring, amulet, etc). Default key is `{\tt R}'.
%.lp %.lp
\item[{\bb{\#repeat}}]
Repeat the previous command.
Default key is~`{\tt \^{}A}'.
%.lp
\item[\tb{\#reqmenu}] \item[\tb{\#reqmenu}]
Prefix key to modify the behaviour or request menu from some commands. Prefix key to modify the behaviour or request menu from some commands.
Prevents autopickup when used with movement commands. Prevents autopickup when used with movement commands.
@@ -5398,9 +5402,6 @@ Default is~`{\tt z}'.
\item[{\bb{getpos.valid.prev}}] \item[{\bb{getpos.valid.prev}}]
When asked for a location, the key to go to previous closest valid location. When asked for a location, the key to go to previous closest valid location.
Default is~`{\tt Z}'. Default is~`{\tt Z}'.
%.lp
\item[{\bb{repeat}}]
Key to repeat previous command. Default is~`{\tt \^{}A}'.
\elist \elist
-2
View File
@@ -1294,8 +1294,6 @@ include an indication of monsters' health during farlook feedback (including
/M and autodescribe); also include it in death reason when killed by /M and autodescribe); also include it in death reason when killed by
a monster: "killed by {an uninjured newt,a heavily injured mumak}" a monster: "killed by {an uninjured newt,a heavily injured mumak}"
[later: suppress the indication of monsters' health] [later: suppress the indication of monsters' health]
make DOAGAIN (^A) become unconditional; commenting it out in config.h makes
it be bound to NUL, a no-op, but allows BIND=k:repeat to set it to k
add support for a single monster species to have distinct male, female, add support for a single monster species to have distinct male, female,
and gender-neutral naming terms and gender-neutral naming terms
add support for a single monster species to have distinct male and female add support for a single monster species to have distinct male and female
-7
View File
@@ -483,13 +483,6 @@ typedef unsigned char uchar;
#endif #endif
#endif #endif
/* The "repeat" key used in cmd.c as NHKF_DOAGAIN; if commented out or the
* value is changed from C('A') to 0, it won't be bound to any keystroke
* unless you use the run-time configuration file's BIND directive for it.
* [Note: C() macro isn't defined yet but it will be before DOAGAIN is used.]
*/
#define DOAGAIN C('A') /* repeat previous command; default is ^A, '\001' */
/* CONFIG_ERROR_SECURE: If user makes NETHACKOPTIONS point to a file ... /* CONFIG_ERROR_SECURE: If user makes NETHACKOPTIONS point to a file ...
* TRUE: Show the first error, nothing else. * TRUE: Show the first error, nothing else.
* FALSE: Show all errors as normal, with line numbers and context. * FALSE: Show all errors as normal, with line numbers and context.
-1
View File
@@ -443,7 +443,6 @@ struct early_opt {
/* special key functions */ /* special key functions */
enum nh_keyfunc { enum nh_keyfunc {
NHKF_ESC = 0, NHKF_ESC = 0,
NHKF_DOAGAIN,
NHKF_GETDIR_SELF, NHKF_GETDIR_SELF,
NHKF_GETDIR_SELF2, NHKF_GETDIR_SELF2,
+1
View File
@@ -227,6 +227,7 @@ extern int do_reqmenu(void);
extern int do_rush(void); extern int do_rush(void);
extern int do_run(void); extern int do_run(void);
extern int do_fight(void); extern int do_fight(void);
extern int do_repeat(void);
extern char randomkey(void); extern char randomkey(void);
extern void random_response(char *, int); extern void random_response(char *, int);
extern int rnd_extcmd_idx(void); extern int rnd_extcmd_idx(void);
+19 -17
View File
@@ -2067,6 +2067,21 @@ do_fight(void)
return ECMD_OK; return ECMD_OK;
} }
/* #repeat */
int
do_repeat(void)
{
if (!g.in_doagain && g.saveq[0]) {
g.in_doagain = TRUE;
g.stail = 0;
rhack((char *) 0); /* read and execute command */
g.in_doagain = FALSE;
iflags.menu_requested = FALSE;
return ECMD_TIME;
}
return ECMD_OK;
}
/* extcmdlist: full command list, ordered by command name; /* extcmdlist: full command list, ordered by command name;
commands with no keystroke or with only a meta keystroke generally commands with no keystroke or with only a meta keystroke generally
need to be flagged as autocomplete and ones with a regular keystroke need to be flagged as autocomplete and ones with a regular keystroke
@@ -2199,6 +2214,8 @@ struct ext_func_tab extcmdlist[] = {
doredraw, IFBURIED | GENERALCMD, NULL }, doredraw, IFBURIED | GENERALCMD, NULL },
{ 'R', "remove", "remove an accessory (ring, amulet, etc)", { 'R', "remove", "remove an accessory (ring, amulet, etc)",
doremring, 0, NULL }, doremring, 0, NULL },
{ C('a'), "repeat", "repeat a previous command",
do_repeat, IFBURIED | GENERALCMD, NULL },
{ 'm', "reqmenu", "prefix: request menu or modify command", { 'm', "reqmenu", "prefix: request menu or modify command",
do_reqmenu, PREFIXCMD, NULL }, do_reqmenu, PREFIXCMD, NULL },
{ C('_'), "retravel", "travel to previously selected travel location", { C('_'), "retravel", "travel to previously selected travel location",
@@ -2427,7 +2444,6 @@ static const struct {
{ NHKF_ESC, "cancel current prompt or pending prefix", FALSE }, { NHKF_ESC, "cancel current prompt or pending prefix", FALSE },
{ NHKF_COUNT, { NHKF_COUNT,
"Prefix: for digits when preceding a command with a count", TRUE }, "Prefix: for digits when preceding a command with a count", TRUE },
{ NHKF_DOAGAIN , "repeat: perform the previous command again", FALSE },
{ 0, (const char *) 0, FALSE } { 0, (const char *) 0, FALSE }
}; };
@@ -3295,17 +3311,12 @@ wiz_migrate_mons(void)
} }
#endif #endif
#ifndef DOAGAIN /* might have gotten undefined in config.h */
#define DOAGAIN '\0' /* undefined => 0, '\0' => no key to activate redo */
#endif
static struct { static struct {
int nhkf; int nhkf;
uchar key; uchar key;
const char *name; const char *name;
} const spkeys_binds[] = { } const spkeys_binds[] = {
{ NHKF_ESC, '\033', (char *) 0 }, /* no binding */ { NHKF_ESC, '\033', (char *) 0 }, /* no binding */
{ NHKF_DOAGAIN, DOAGAIN, "repeat" },
{ NHKF_GETDIR_SELF, '.', "getdir.self" }, { NHKF_GETDIR_SELF, '.', "getdir.self" },
{ NHKF_GETDIR_SELF2, 's', "getdir.self2" }, { NHKF_GETDIR_SELF2, 's', "getdir.self2" },
{ NHKF_GETDIR_HELP, '?', "getdir.help" }, { NHKF_GETDIR_HELP, '?', "getdir.help" },
@@ -3692,16 +3703,7 @@ got_prefix_input:
iflags.menu_requested = FALSE; iflags.menu_requested = FALSE;
return; return;
} }
/* DOAGAIN might be '\0'; if so, don't execute it even if *cmd is too */
if ((*cmd && *cmd == g.Cmd.spkeys[NHKF_DOAGAIN])
&& !g.in_doagain && g.saveq[0]) {
g.in_doagain = TRUE;
g.stail = 0;
rhack((char *) 0); /* read and execute command */
g.in_doagain = FALSE;
iflags.menu_requested = FALSE;
return;
}
/* Special case of *cmd == ' ' handled better below */ /* Special case of *cmd == ' ' handled better below */
if (!*cmd || *cmd == (char) 0377) { if (!*cmd || *cmd == (char) 0377) {
nhbell(); nhbell();
@@ -4631,7 +4633,7 @@ parse(void)
g.last_command_count = 0; g.last_command_count = 0;
} else if (g.in_doagain) { } else if (g.in_doagain) {
g.command_count = g.last_command_count; g.command_count = g.last_command_count;
} else if (foo && foo == g.Cmd.spkeys[NHKF_DOAGAIN]) { } else if (foo && foo == cmd_from_func(do_repeat)) {
// g.command_count will be set again when we // g.command_count will be set again when we
// re-enter with g.in_doagain set true // re-enter with g.in_doagain set true
g.command_count = g.last_command_count; g.command_count = g.last_command_count;
+2 -8
View File
@@ -829,9 +829,7 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
QSignalMapper* sm = new QSignalMapper(this); QSignalMapper* sm = new QSignalMapper(this);
connect(sm, SIGNAL(mapped(const QString&)), connect(sm, SIGNAL(mapped(const QString&)),
this, SLOT(doKeys(const QString&))); this, SLOT(doKeys(const QString&)));
// 'donull' is a placeholder here; AddToolButton() will fix it up; AddToolButton(toolbar, sm, "Again", do_repeat, QPixmap(again_xpm));
// button will be omitted if DOAGAIN is bound to '\0'
AddToolButton(toolbar, sm, "Again", donull, QPixmap(again_xpm));
// this used to be called "Get" which is confusing to experienced players // this used to be called "Get" which is confusing to experienced players
AddToolButton(toolbar, sm, "Pick up", dopickup, QPixmap(pickup_xpm)); AddToolButton(toolbar, sm, "Pick up", dopickup, QPixmap(pickup_xpm));
AddToolButton(toolbar, sm, "Drop", doddrop, QPixmap(drop_xpm)); AddToolButton(toolbar, sm, "Drop", doddrop, QPixmap(drop_xpm));
@@ -927,11 +925,7 @@ void NetHackQtMainWindow::AddToolButton(QToolBar *toolbar, QSignalMapper *sm,
char actchar[2]; char actchar[2];
uchar key; uchar key;
// the ^A command is just a keystroke, not a full blown command function key = (uchar) cmd_from_func(func);
if (!strcmp(name, "Again")) {
key = ::g.Cmd.spkeys[NHKF_DOAGAIN];
} else
key = (uchar) cmd_from_func(func);
// if key is valid, add a button for it; otherwise omit the command // if key is valid, add a button for it; otherwise omit the command
// (won't work as intended if a different command is bound to same key) // (won't work as intended if a different command is bound to same key)