| 181 | |
| 182 | #ifdef HAVE_EDITLINE |
| 183 | char *ConsoleCommand::ConsoleCompleteHelper(const char *word, int state) |
| 184 | { |
| 185 | static std::vector<String> matches; |
| 186 | |
| 187 | if (state == 0) { |
| 188 | if (!l_Url) |
| 189 | matches = ConsoleHandler::GetAutocompletionSuggestions(word, *l_ScriptFrame); |
| 190 | else { |
| 191 | Array::Ptr suggestions; |
| 192 | |
| 193 | /* Remote debug console. */ |
| 194 | try { |
| 195 | suggestions = AutoCompleteScript(l_Session, word, l_ScriptFrame->Sandboxed); |
| 196 | } catch (...) { |
| 197 | return nullptr; //Errors are just ignored here. |
| 198 | } |
| 199 | |
| 200 | matches.clear(); |
| 201 | |
| 202 | ObjectLock olock(suggestions); |
| 203 | std::copy(suggestions->Begin(), suggestions->End(), std::back_inserter(matches)); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | if (state >= static_cast<int>(matches.size())) |
| 208 | return nullptr; |
| 209 | |
| 210 | return strdup(matches[state].CStr()); |
| 211 | } |
| 212 | #endif /* HAVE_EDITLINE */ |
| 213 | |
| 214 | /** |