^A/#repeat vs extended commands
Fix '#repeat' for tty; both it and ^A can repeat an extended command. Fix both for curses; they can repeat an extended command instead of just repeating the initial '#' to start getting an extended command. X11 (tested), Qt (tested), and probably Windows GUI (not tested) behave the same as before: ^A (or #repeat) after an extended command just repeats the # to run the dialog to get an extended command. I hope this introduces fewer bugs than it fixes but I don't think I'd bet on that....
This commit is contained in:
@@ -581,7 +581,15 @@ int NetHackQtExtCmdRequestor::get()
|
||||
}
|
||||
if (result() == xcmdNone)
|
||||
exec();
|
||||
return result() - 1;
|
||||
|
||||
int ret = result() - 1;
|
||||
if (!::g.in_doagain) {
|
||||
if (ret >= 0)
|
||||
savech_extcmd(::extcmdlist[ret].ef_txt, FALSE);
|
||||
else
|
||||
savech(0);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Enable only buttons that match the current prompt string
|
||||
|
||||
@@ -1556,8 +1556,13 @@ X11_get_ext_cmd(void)
|
||||
/* The callbacks will enable the event loop exit. */
|
||||
(void) x_event(EXIT_ON_EXIT);
|
||||
|
||||
if (extended_cmd_selected < 0)
|
||||
if (extended_cmd_selected < 0) {
|
||||
if (!g.in_doagain)
|
||||
savech(0);
|
||||
return -1;
|
||||
}
|
||||
if (!g.in_doagain)
|
||||
savech_extcmd(command_list[extended_cmd_selected], TRUE);
|
||||
return command_indx[extended_cmd_selected];
|
||||
}
|
||||
|
||||
|
||||
@@ -437,7 +437,7 @@ curses_ext_cmd(void)
|
||||
|
||||
curs_set(1);
|
||||
wrefresh(extwin);
|
||||
letter = getch();
|
||||
letter = pgetchar(); /* pgetchar(cmd.c) implements do-again */
|
||||
curs_set(0);
|
||||
prompt_width = (int) strlen(cur_choice);
|
||||
matches = 0;
|
||||
@@ -494,8 +494,23 @@ curses_ext_cmd(void)
|
||||
curses_destroy_win(extwin);
|
||||
if (extwin2)
|
||||
curses_destroy_win(extwin2);
|
||||
if (ret == -1 && *cur_choice)
|
||||
pline("%s: unknown extended command.", cur_choice);
|
||||
|
||||
if (ret != -1) {
|
||||
if (!g.in_doagain)
|
||||
savech_extcmd(cur_choice, TRUE);
|
||||
} else {
|
||||
char extcmd_char = extcmd_initiator();
|
||||
|
||||
if (*cur_choice)
|
||||
pline("%s%s: unknown extended command.",
|
||||
visctrl(extcmd_char), cur_choice);
|
||||
|
||||
if (!g.in_doagain) {
|
||||
savech(0); /* reset do-again buffer */
|
||||
if (letter != '\033')
|
||||
savech(extcmd_char);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -271,6 +271,8 @@ tty_get_ext_cmd(void)
|
||||
char buf[BUFSZ];
|
||||
int nmatches;
|
||||
int *ecmatches;
|
||||
boolean (*no_hook)(char *base) = (boolean (*)(char *)) 0;
|
||||
char extcmd_char[2];
|
||||
|
||||
if (iflags.extmenu)
|
||||
return extcmd_via_menu();
|
||||
@@ -282,27 +284,24 @@ tty_get_ext_cmd(void)
|
||||
* ? ext_cmd_getlin_hook
|
||||
* : (getlin_hook_proc) 0);
|
||||
*/
|
||||
extcmd_char[0] = extcmd_initiator(), extcmd_char[1] = '\0';
|
||||
buf[0] = '\0';
|
||||
hooked_tty_getlin("#", buf, g.in_doagain ? (getlin_hook_proc) 0
|
||||
: ext_cmd_getlin_hook);
|
||||
hooked_tty_getlin(extcmd_char, buf,
|
||||
!g.in_doagain ? ext_cmd_getlin_hook : no_hook);
|
||||
(void) mungspaces(buf);
|
||||
if (buf[0] == 0 || buf[0] == '\033')
|
||||
return -1;
|
||||
|
||||
nmatches = extcmds_match(buf, ECM_IGNOREAC|ECM_EXACTMATCH, &ecmatches);
|
||||
|
||||
if (!g.in_doagain) {
|
||||
int j;
|
||||
for (j = 0; buf[j]; j++)
|
||||
savech(buf[j]);
|
||||
savech('\n');
|
||||
}
|
||||
|
||||
nmatches = (buf[0] == '\0' || buf[0] == '\033') ? -1
|
||||
: extcmds_match(buf, ECM_IGNOREAC | ECM_EXACTMATCH, &ecmatches);
|
||||
if (nmatches != 1) {
|
||||
pline("%s: unknown extended command.", buf);
|
||||
if (nmatches != -1)
|
||||
pline("%s%.60s: unknown extended command.",
|
||||
visctrl(extcmd_char[0]), buf);
|
||||
savech(0); /* reset do-again buffer */
|
||||
savech(extcmd_char[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
savech_extcmd(buf, TRUE); /* savech() for extcmd_char+buf[...]+'\n' */
|
||||
return ecmatches[0];
|
||||
}
|
||||
|
||||
|
||||
@@ -1750,12 +1750,12 @@ int get_ext_cmd(void)
|
||||
int
|
||||
mswin_get_ext_cmd(void)
|
||||
{
|
||||
char cmd[BUFSZ];
|
||||
int ret;
|
||||
logDebug("mswin_get_ext_cmd()\n");
|
||||
|
||||
if (!iflags.wc_popup_dialog) {
|
||||
char c;
|
||||
char cmd[BUFSZ];
|
||||
int i, len;
|
||||
int createcaret;
|
||||
|
||||
@@ -1784,7 +1784,8 @@ mswin_get_ext_cmd(void)
|
||||
break;
|
||||
|
||||
if (extcmdlist[i].ef_txt == (char *) 0) {
|
||||
pline("%s: unknown extended command.", cmd);
|
||||
pline("%s%s: unknown extended command.",
|
||||
visctrl(extcmd_initiator()), cmd);
|
||||
i = -1;
|
||||
}
|
||||
break;
|
||||
@@ -1825,13 +1826,22 @@ mswin_get_ext_cmd(void)
|
||||
createcaret = 0;
|
||||
SendMessage(mswin_hwnd_from_winid(WIN_MESSAGE), WM_MSNH_COMMAND,
|
||||
(WPARAM) MSNH_MSG_CARET, (LPARAM) &createcaret);
|
||||
return i;
|
||||
ret = i;
|
||||
} else {
|
||||
if (mswin_ext_cmd_window(&ret) == IDCANCEL)
|
||||
return -1;
|
||||
cmd[0] = '\0';
|
||||
if (mswin_ext_cmd_window(&ret) != IDCANCEL)
|
||||
Strcpy(cmd, extcmdlist[ret].ef_txt);
|
||||
else
|
||||
return ret;
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if (!g.in_doagain) {
|
||||
if (ret >= 0)
|
||||
savech_extcmd(cmd, TRUE);
|
||||
else
|
||||
savech(0);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user