Changeset 5185 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Sep 15, 2005, 5:16:14 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_completion.cc
r5184 r5185 73 73 char* functionEnd; //< the end of the function string 74 74 75 PRINTF(4)("AutoComplete on input\n"); 76 75 77 if (input != NULL) 76 78 this->input = input; 77 79 if (this->input == NULL) 78 return false; 79 if (this->input->getText() == NULL) 80 { 81 PRINTF(2)("No ShellInput supplied\n"); 82 return false; 83 } 84 if (this->input->getInput() == NULL) 80 85 return this->classComplete(""); 81 86 82 completionLine = this->input->getText() + strspn(this->input->getText(), " \t\n"); 87 88 completionLine = this->input->getInput() + strspn(this->input->getInput(), " \t\n"); 83 89 84 90 SubString inputSplits(completionLine, true); 85 91 92 93 // CLASS COMPLETION 86 94 if (inputSplits.getCount() == 0) 87 95 { 88 // this->classComplete(""); 96 PRINTF(5)("Listing all Classes\n"); 97 this->classComplete(""); 89 98 return false; 90 99 } 91 100 else if (inputSplits.getCount() == 1 && strlen(inputSplits.getString(0)) == strlen(completionLine)) 92 101 { 93 // this->classComplete(inputSplits.getString(0)); 94 95 } 96 97 if (inputSplits.getCount() > 1) 98 { 99 102 printf("trying to complete a Class with %d\n", inputSplits.getString(0)); 103 this->classComplete(inputSplits.getString(0)); 104 } 105 106 // OBJECT COMPLETIONS 107 else if ( inputSplits.getCount() <= 2 && strlen(inputSplits.getString(0)) < strlen(completionLine)) 108 { 109 classID = ClassList::StringToID(inputSplits.getString(0)); 110 if (classID == CL_NULL) 111 return false; 112 if (inputSplits.getCount()==2) 113 this->objectComplete(inputSplits.getString(1), classID); 114 else 115 this->objectComplete("", classID); 100 116 } 101 117 … … 143 159 const tList<const char>* classList = this->createCompleteList(clList, classBegin); 144 160 if (classList != NULL) 145 this->generalComplete(classList, classBegin, " %s::", "::");161 this->generalComplete(classList, classBegin, "CL: %s "); 146 162 else 147 163 return false; … … 170 186 const tList<const char>* objectList = this->createCompleteList(boList, objectBegin); 171 187 if (objectList != NULL) 172 this->generalComplete(objectList, objectBegin, "%s" );188 this->generalComplete(objectList, objectBegin, "%s", " "); 173 189 else 174 190 return false; … … 198 214 bool ShellCompletion::generalComplete(const tList<const char>* stringList, const char* begin, const char* displayAs, const char* addBack, const char* addFront) 199 215 { 216 if (stringList == NULL || this->input == NULL ) 217 return false; 200 218 if (stringList->getSize() == 0) 201 219 return false; … … 214 232 for (unsigned int i = inputLenght; i < addLength; i++) 215 233 if (addString[i] != charElem[i]) 216 {217 addLength = i;218 break;219 }234 { 235 addLength = i; 236 break; 237 } 220 238 charElem = charIterator->nextElement(); 221 239 } … … 233 251 this->input->addCharacters(adder); 234 252 235 if (addBack != NULL && stringList->getSize() == 1) 236 this->input->addCharacters("::"); 253 if (stringList->getSize() == 1) 254 { 255 if ( addBack != NULL ) 256 this->input->addCharacters(addBack); 257 this->input->addCharacter(' '); 258 } 237 259 delete[] adder; 238 260 } … … 263 285 while (enumString != NULL) 264 286 { 265 if (strlen(enumString) >searchLength+1&&287 if (strlen(enumString) >= searchLength && 266 288 !strncasecmp(enumString, classNameBegin, searchLength)) 267 289 { 290 printf("%s\n", enumString); 268 291 this->completionList->add(enumString); 269 292 } … … 296 319 { 297 320 if (enumBO->getName() != NULL && 298 strlen(enumBO->getName()) >searchLength+1&&321 strlen(enumBO->getName()) >= searchLength && 299 322 !strncasecmp(enumBO->getName(), classNameBegin, searchLength)) 300 323 { -
trunk/src/lib/shell/shell_input.h
r5182 r5185 22 22 virtual ~ShellInput(); 23 23 24 /** @returns the inputLine */ 25 const char* getInput() const { return this->inputLine; }; 24 26 25 27 // InputLine
Note: See TracChangeset
for help on using the changeset viewer.