| 5095 | } |
| 5096 | |
| 5097 | int NetHackQtExtCmdRequestor::get() |
| 5098 | { |
| 5099 | const int none = -10; |
| 5100 | char str[32]; |
| 5101 | int cursor=0; |
| 5102 | resize(1,1); // pack |
| 5103 | centerOnMain(this); |
| 5104 | show(); |
| 5105 | setResult(none); |
| 5106 | while (result()==none) { |
| 5107 | while (result()==none && !keysource.Empty()) { |
| 5108 | char k=keysource.GetAscii(); |
| 5109 | if (k=='\r' || k=='\n' || k==' ' || k=='\033') { |
| 5110 | setResult(-1); |
| 5111 | } else { |
| 5112 | str[cursor++] = k; |
| 5113 | int r=-1; |
| 5114 | for (int i=0; extcmdlist[i].ef_txt; i++) { |
| 5115 | if (qstrnicmp(str, extcmdlist[i].ef_txt, cursor)==0) { |
| 5116 | if ( r == -1 ) |
| 5117 | r = i; |
| 5118 | else |
| 5119 | r = -2; |
| 5120 | } |
| 5121 | } |
| 5122 | if ( r == -1 ) { // no match! |
| 5123 | QApplication::beep(); |
| 5124 | cursor=0; |
| 5125 | } else if ( r != -2 ) { // only one match |
| 5126 | setResult(r); |
| 5127 | } |
| 5128 | } |
| 5129 | } |
| 5130 | if (result()==none) |
| 5131 | qApp->enter_loop(); |
| 5132 | } |
| 5133 | hide(); |
| 5134 | return result(); |
| 5135 | } |
| 5136 | |
| 5137 | |
| 5138 | int NetHackQtBind::qt_get_ext_cmd() |
no test coverage detected