Qt fix for typing "#version"
The #version command is a leading substring of the #versionshort command and for Qt, it couldn't be executed by typing, only via mouse click or one of the Qt-specific menus. #version<return> or #version<space> now works for that. The #versionshort command ought to be renamed to something else.
This commit is contained in:
+5
-1
@@ -1,4 +1,4 @@
|
|||||||
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.370 $ $NHDT-Date: 1606919254 2020/12/02 14:27:34 $
|
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.371 $ $NHDT-Date: 1606954304 2020/12/03 00:11:44 $
|
||||||
|
|
||||||
General Fixes and Modified Features
|
General Fixes and Modified Features
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
@@ -507,6 +507,10 @@ Qt: don't get stuck in a loop after choosing "play" while the character name
|
|||||||
field is empty in the character selection widget
|
field is empty in the character selection widget
|
||||||
Qt: when a new message is issued, pan the message window to its left edge if
|
Qt: when a new message is issued, pan the message window to its left edge if
|
||||||
player panned it horizontally then didn't manually scroll it back
|
player panned it horizontally then didn't manually scroll it back
|
||||||
|
Qt: there was no way to enter extended command "#version" by typing; command
|
||||||
|
name matching was waiting to disambiguate it from "#versionshort"
|
||||||
|
and the only way to that was to type #version<return> but <return>
|
||||||
|
explicitly triggered rejection, cancelling '#' processing
|
||||||
Qt: {maybe just Qt+OSX:} when viewing a text window ('V' to look at 'history'
|
Qt: {maybe just Qt+OSX:} when viewing a text window ('V' to look at 'history'
|
||||||
for instance), clicking on [Search], entering a search target in the
|
for instance), clicking on [Search], entering a search target in the
|
||||||
resulting popup and clicking on [Okay] or typing <return>, the text
|
resulting popup and clicking on [Okay] or typing <return>, the text
|
||||||
|
|||||||
+24
-10
@@ -167,26 +167,40 @@ void NetHackQtExtCmdRequestor::keyPressEvent(QKeyEvent *event)
|
|||||||
if (promptstr != "#")
|
if (promptstr != "#")
|
||||||
prompt->setText(promptstr.left(promptstr.size() - 1));
|
prompt->setText(promptstr.left(promptstr.size() - 1));
|
||||||
enableButtons();
|
enableButtons();
|
||||||
/*} else if (uc == '\r' || uc == '\n'; || uc == ' ') {*/
|
} else if ((uc < ' ' && !(uc == '\n' || uc == '\r'))
|
||||||
} else if (uc < ' ' || uc > std::max('z', 'Z')) {
|
|| uc > std::max('z', 'Z')) {
|
||||||
reject(); // done()
|
reject(); // done()
|
||||||
} else {
|
} else {
|
||||||
promptstr += QChar(uc); // event()->text()
|
// <return> is necessary if one command is a leading substring
|
||||||
|
// of another and superfluous otherwise
|
||||||
|
boolean checkexact = (uc == '\n' || uc == '\r' || uc == ' ');
|
||||||
|
if (!checkexact)
|
||||||
|
promptstr += QChar(uc); // event()->text()
|
||||||
QString typedstr = promptstr.mid(1); // skip the '#'
|
QString typedstr = promptstr.mid(1); // skip the '#'
|
||||||
unsigned matches = 0;
|
unsigned matches = 0;
|
||||||
unsigned match = 0;
|
unsigned matchindx = 0;
|
||||||
for (unsigned i=0; extcmdlist[i].ef_txt; i++) {
|
for (unsigned i=0; extcmdlist[i].ef_txt; i++) {
|
||||||
if (!interesting_command(i))
|
if (!interesting_command(i))
|
||||||
continue;
|
continue;
|
||||||
if (QString(extcmdlist[i].ef_txt).startsWith(typedstr)) {
|
QString cmdtxt = QString(extcmdlist[i].ef_txt);
|
||||||
++matches;
|
if (cmdtxt.startsWith(typedstr)) {
|
||||||
if (matches >= 2)
|
if (checkexact) {
|
||||||
break;
|
if (cmdtxt == typedstr) {
|
||||||
match = i;
|
matchindx = i;
|
||||||
|
matches = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (++matches >= 2)
|
||||||
|
break;
|
||||||
|
matchindx = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (matches == 1)
|
if (matches == 1)
|
||||||
done(match+1);
|
done(matchindx + 1);
|
||||||
|
else if (checkexact)
|
||||||
|
reject();
|
||||||
else if (matches >= 2)
|
else if (matches >= 2)
|
||||||
prompt->setText(promptstr);
|
prompt->setText(promptstr);
|
||||||
enableButtons();
|
enableButtons();
|
||||||
|
|||||||
Reference in New Issue
Block a user