-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.279 $ $NHDT-Date: 1597010101 2020/08/09 21:55:01 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.280 $ $NHDT-Date: 1597069374 2020/08/10 14:22:54 $
General Fixes and Modified Features
-----------------------------------
Qt: add Attributes, Overview, and Annotate to the "Info" pull down menu
Qt: rename menu entries game->Save to game->Save-and-exit and game->Quit
to game->Quit-without-saving
+Qt: menu commands are now working; commands invoked via M-c were having that
+ keystroke changed to '?', bringing up nethack's help menu; now those
+ send #abc with just enough letters to disambiguate from other commands
+ ("Compilation" is one remaining problem; it yields "#version" which
+ brings up '#' menu subset with choices of "version" and "versionshort")
Qt+QSX: fix control key
Qt+OSX: rename menu entry "nethack->Preferences..." for invoking nethack's
'O' command to "Game->Run-time options" and entry "Game->Qt settings"
-/* NetHack 3.7 extern.h $NHDT-Date: 1596498536 2020/08/03 23:48:56 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.854 $ */
+/* NetHack 3.7 extern.h $NHDT-Date: 1597069374 2020/08/10 14:22:54 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.855 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */
E int NDECL(rnd_extcmd_idx);
E int NDECL(domonability);
E char FDECL(cmd_from_func, (int NDECL((*))));
+E const char *FDECL(cmdname_from_func, (int NDECL((*)), char *, BOOLEAN_P));
E boolean FDECL(redraw_cmd, (CHAR_P));
E const char *FDECL(levltyp_to_name, (int));
#ifdef USE_TRAMPOLI
-/* NetHack 3.7 cmd.c $NHDT-Date: 1596498153 2020/08/03 23:42:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.421 $ */
+/* NetHack 3.7 cmd.c $NHDT-Date: 1597069374 2020/08/10 14:22:54 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.422 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
return '\0';
}
+/* return extended command name (without leading '#') for command (*fn)() */
+const char *
+cmdname_from_func(fn, outbuf, fullname)
+int NDECL((*fn));
+char outbuf[];
+boolean fullname; /* False: just enough to disambiguate */
+{
+ const struct ext_func_tab *extcmd, *cmdptr = 0;
+ const char *res = 0;
+
+ for (extcmd = extcmdlist; extcmd->ef_txt; ++extcmd)
+ if (extcmd->ef_funct == fn) {
+ cmdptr = extcmd;
+ res = cmdptr->ef_txt;
+ break;
+ }
+
+ if (!res) {
+ /* make sure output buffer doesn't contain junk or stale data;
+ return Null below */
+ outbuf[0] = '\0';
+ } else if (fullname) {
+ /* easy; the entire command name */
+ res = strcpy(outbuf, res);
+ } else {
+ const struct ext_func_tab *matchcmd = extcmdlist;
+ int len = 0;
+
+ /* find the shortest leading substring which is unambiguous */
+ do {
+ if (++len >= (int) strlen(res))
+ break;
+ for (extcmd = matchcmd; extcmd->ef_txt; ++extcmd) {
+ if (extcmd == cmdptr)
+ continue;
+ if ((extcmd->flags & CMD_NOT_AVAILABLE) != 0
+ || ((extcmd->flags & WIZMODECMD) != 0 && !wizard))
+ continue;
+ if (!strncmp(res, extcmd->ef_txt, len)) {
+ matchcmd = extcmd;
+ break;
+ }
+ }
+ } while (extcmd->ef_txt);
+ copynchars(outbuf, res, len);
+ debugpline2("shortened %s: \"%s\"", res, outbuf);
+ res = outbuf;
+ }
+ return res;
+}
+
/*
* wizard mode sanity_check code
*/
if (item[i].name) {
char actchar[32];
char menuitem[BUFSZ];
- actchar[0] = '\0';
+ actchar[0] = actchar[1] = '\0';
if (item[i].funct) {
actchar[0] = cmd_from_func(item[i].funct);
- actchar[1] = '\0';
+ /* M-c won't work */
+ if ((actchar[0] & 0x7f) != actchar[0])
+ actchar[0] = '\0';
}
if (actchar[0] && !qt_compact_mode)
- Sprintf(menuitem, "%s\t%s", item[i].name,
+ Sprintf(menuitem, "%.50s\t%.9s", item[i].name,
visctrl(actchar[0]));
else
Sprintf(menuitem, "%s", item[i].name);
+
+ if (item[i].funct && !actchar[0]) {
+ actchar[0] = '#';
+ (void) cmdname_from_func(item[i].funct,
+ &actchar[1], FALSE);
+ }
if (actchar[0]) {
QString name = menuitem;
QAction *action = item[i].menu->addAction(name);
void NetHackQtMainWindow::doMenuItem(QAction *action)
{
+ /* this converts meta characters to '?'; menu processing has been
+ changed to send multi-character "#abc" instead (already needed
+ for commands that didn't have either a regular keystroke or a
+ meta shortcut); it must send just enough to disambiguate from
+ other extended command names, otherwise the remainder would be
+ left in the queue for subsequent handling as additional commands */
doKeys(action->data().toString());
}
void NetHackQtMainWindow::doKeys(const QString& k)
{
+ /* [this should probably be using toLocal8Bit();
+ toAscii() is not offered as an alternative...] */
keysink.Put(k.toLatin1().constData());
qApp->exit();
}