MCPcopy Create free account
hub / github.com/amule-project/amule / command_completion

Function command_completion

src/ExternalConnector.cpp:221–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219
220
221char *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 */

Callers

nothing calls this directly

Calls 7

GetSubCommandsForMethod · 0.80
GetCommandMethod · 0.80
StartsWithMethod · 0.80
wxStringClass · 0.70
unicode2charFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected