| 219 | |
| 220 | |
| 221 | char *command_completion(const char *text, int state) |
| 222 | { |
| 223 | static const CmdList_t* curCommands; |
| 224 | static CmdPosConst_t nextCommand; |
| 225 | |
| 226 | if (state == 0) { |
| 227 | wxString lineBuffer(rl_line_buffer, wxConvLibc); |
| 228 | wxString prefix(lineBuffer.Left(rl_point).BeforeLast(' ')); |
| 229 | |
| 230 | curCommands = theCommands->GetSubCommandsFor(prefix); |
| 231 | if (curCommands) { |
| 232 | nextCommand = curCommands->begin(); |
| 233 | } else { |
| 234 | return NULL; |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | wxString test(wxString(text, wxConvLibc).Lower()); |
| 239 | while (nextCommand != curCommands->end()) { |
| 240 | wxString curTest = (*nextCommand)->GetCommand(); |
| 241 | ++nextCommand; |
| 242 | if (curTest.Lower().StartsWith(test)) { |
| 243 | return strdup(static_cast<const char *>(unicode2char(curTest))); |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | return NULL; |
| 248 | } |
| 249 | |
| 250 | |
| 251 | #endif /* HAVE_LIBREADLINE */ |
nothing calls this directly
no test coverage detected