Changeset 7221 in orxonox.OLD for trunk/src/lib/shell/shell_completion.cc
- Timestamp:
- Mar 15, 2006, 3:10:45 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_completion.cc
r5885 r7221 76 76 77 77 // Check if we are in a input. eg. the supplied string "class " and now we complete either function or object 78 if (this->input->getInput() != NULL && 79 strrchr(this->input->getInput(), ' ') >= this->input->getInput() + strlen(this->input->getInput())-1) 78 if (this->input->getInput()[this->input->getInput().size()-1] == ' ') 80 79 { 81 80 emptyComplete = true; … … 83 82 84 83 // CREATE INPUTS 85 if (this->input->getInput() == NULL) 86 completionLine = ""; 87 else 88 completionLine = this->input->getInput() + strspn(this->input->getInput(), " \t\n"); 89 SubString inputSplits(completionLine, " \t\n,"); 84 SubString inputSplits(this->input->getInput(), " \t\n,"); 90 85 91 86 // What String will be completed … … 93 88 completeString = ""; 94 89 else 95 completeString = inputSplits.getString(inputSplits.getCount()-1) ;90 completeString = inputSplits.getString(inputSplits.getCount()-1).c_str(); 96 91 97 92 // CLASS COMPLETION … … 111 106 (inputSplits.getCount() == 2 && emptyComplete == false)) 112 107 { 113 classID = ClassList::StringToID(inputSplits.getString(0) );108 classID = ClassList::StringToID(inputSplits.getString(0).c_str()); //FIXME 114 109 objectList = ClassList::getList((ClassID)classID); 115 110 if (classID != CL_NULL) … … 121 116 (inputSplits.getCount() == 3 && emptyComplete == false)) 122 117 { 123 classID = ClassList::StringToID(inputSplits.getString(0) );118 classID = ClassList::StringToID(inputSplits.getString(0) .c_str()); // FIXME 124 119 if (classID == CL_NULL) 125 120 return false; … … 133 128 this->objectComplete(completeString, classID); 134 129 if (completeType & SHELLC_FUNCTION) 135 this->functionComplete(completeString, inputSplits.getString(0) );130 this->functionComplete(completeString, inputSplits.getString(0).c_str()); // FIXME 136 131 if (completeType & SHELLC_ALIAS) 137 132 this->aliasComplete(completeString); … … 151 146 if (unlikely(classBegin == NULL)) 152 147 return false; 153 const std::list< const char*>* clList = ClassList::getClassNames();148 const std::list<std::string>* clList = ClassList::getClassNames(); 154 149 if (clList != NULL) 155 150 { … … 195 190 if (unlikely(functionBegin == NULL)) 196 191 return false; 197 std::list< const char*> fktList;192 std::list<std::string> fktList; 198 193 ShellCommandClass::getCommandListOfClass(className, &fktList); 199 194 //printf("%s\n", boList->firstElement()->getName()); … … 212 207 if (unlikely(aliasBegin == NULL)) 213 208 return false; 214 std::list< const char*> aliasList;209 std::list<std::string> aliasList; 215 210 ShellCommandClass::getCommandListOfAlias(&aliasList); 216 211 //printf("%s\n", boList->firstElement()->getName()); … … 295 290 * !! The strings MUST NOT be deleted !! 296 291 */ 297 bool ShellCompletion::addToCompleteList(const std::list< const char*>* inputList, const char* completionBegin, SHELLC_TYPE type)292 bool ShellCompletion::addToCompleteList(const std::list<std::string>* inputList, const char* completionBegin, SHELLC_TYPE type) 298 293 { 299 294 if (inputList == NULL || completionBegin == NULL) … … 301 296 unsigned int searchLength = strlen(completionBegin); 302 297 303 list< const char*>::const_iterator string;298 list<std::string>::const_iterator string; 304 299 for (string = inputList->begin(); string != inputList->end(); string++) 305 300 { 306 if ( strlen(*string) >= searchLength &&307 !strncasecmp(*string, completionBegin, searchLength))301 if ((*string).size() >= searchLength && 302 !strncasecmp((*string).c_str(), completionBegin, searchLength)) 308 303 { 309 304 ShellC_Element newElem; 310 newElem.name = *string;305 newElem.name = (*string).c_str(); 311 306 newElem.type = type; 312 307 this->completionList.push_back(newElem);
Note: See TracChangeset
for help on using the changeset viewer.