diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 4794c86ad..d7fad4bb9 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -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 ----------------------------------- @@ -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 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 +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 but + explicitly triggered rejection, cancelling '#' processing 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 resulting popup and clicking on [Okay] or typing , the text diff --git a/win/Qt/qt_xcmd.cpp b/win/Qt/qt_xcmd.cpp index ce81fbb44..ed6f870d3 100644 --- a/win/Qt/qt_xcmd.cpp +++ b/win/Qt/qt_xcmd.cpp @@ -167,26 +167,40 @@ void NetHackQtExtCmdRequestor::keyPressEvent(QKeyEvent *event) if (promptstr != "#") prompt->setText(promptstr.left(promptstr.size() - 1)); enableButtons(); - /*} else if (uc == '\r' || uc == '\n'; || uc == ' ') {*/ - } else if (uc < ' ' || uc > std::max('z', 'Z')) { + } else if ((uc < ' ' && !(uc == '\n' || uc == '\r')) + || uc > std::max('z', 'Z')) { reject(); // done() } else { - promptstr += QChar(uc); // event()->text() + // 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 '#' unsigned matches = 0; - unsigned match = 0; + unsigned matchindx = 0; for (unsigned i=0; extcmdlist[i].ef_txt; i++) { if (!interesting_command(i)) continue; - if (QString(extcmdlist[i].ef_txt).startsWith(typedstr)) { - ++matches; - if (matches >= 2) - break; - match = i; + QString cmdtxt = QString(extcmdlist[i].ef_txt); + if (cmdtxt.startsWith(typedstr)) { + if (checkexact) { + if (cmdtxt == typedstr) { + matchindx = i; + matches = 1; + break; + } + } else { + if (++matches >= 2) + break; + matchindx = i; + } } } if (matches == 1) - done(match+1); + done(matchindx + 1); + else if (checkexact) + reject(); else if (matches >= 2) prompt->setText(promptstr); enableButtons();