- Timestamp:
- Sep 16, 2005, 7:56:39 PM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_completion.cc
r5186 r5187 65 65 const char* completionLine; 66 66 67 long classID; //< the classID retrieved from the Class. 68 char* classBegin; //< the beginn of the slass string 69 char* classEnd; //< the end of the class string 70 char* objectBegin; //< the begin of the object string 71 char* objectEnd; //< the end of the object string 72 char* functionBegin; //< the begin of the function string 73 char* functionEnd; //< the end of the function string 67 long classID; //< the classID retrieved from the Class. 68 tList<BaseObject>* objectList; //< the list of Objects stored in classID 69 char* classBegin; //< the beginn of the slass string 70 char* classEnd; //< the end of the class string 71 char* objectBegin; //< the begin of the object string 72 char* objectEnd; //< the end of the object string 73 char* functionBegin; //< the begin of the function string 74 char* functionEnd; //< the end of the function string 74 75 75 76 PRINTF(4)("AutoComplete on input\n"); 77 this->emptyCompletionList(); 76 78 77 79 if (input != NULL) … … 118 120 this->objectComplete("", classID); 119 121 } 122 // else if (inputSplits.getCount() <= 3 ) 120 123 121 124 /* completionLine = new char[strlen(this->input->getText())+1]; … … 160 163 if (clList != NULL) 161 164 { 162 const tList< const char>* classList = this->createCompleteList(clList, classBegin);165 const tList<ShellC_Element>* classList = this->addToCompleteList(clList, classBegin); 163 166 if (classList != NULL) 164 167 this->generalComplete(classList, classBegin, "CL: %s "); … … 187 190 { 188 191 printf("\n", boList->firstElement()->getName()); 189 const tList< const char>* objectList = this->createCompleteList(boList, objectBegin);192 const tList<ShellC_Element>* objectList = this->addToCompleteList(boList, objectBegin); 190 193 if (objectList != NULL) 191 194 this->generalComplete(objectList, objectBegin, "%s "); … … 215 218 * @return true if ok, false otherwise 216 219 */ 217 bool ShellCompletion::generalComplete(const tList< const char>* stringList, const char* begin, const char* displayAs, const char* addBack, const char* addFront)220 bool ShellCompletion::generalComplete(const tList<ShellC_Element>* stringList, const char* begin, const char* displayAs, const char* addBack, const char* addFront) 218 221 { 219 222 if (stringList == NULL || this->input == NULL ) … … 222 225 return false; 223 226 224 const char* addString = stringList->firstElement(); 227 ShellC_Element* addElem = stringList->firstElement(); 228 const char* addString = addElem->name; 225 229 unsigned int addLength = 0; 226 230 unsigned int inputLenght = strlen(begin); 227 231 232 // Determin the longest Match 228 233 if (addString != NULL) 229 234 addLength = strlen(addString); 230 tIterator< const char>* charIterator = stringList->getIterator();231 const char* charElem = charIterator->firstElement();235 tIterator<ShellC_Element>* charIterator = stringList->getIterator(); 236 ShellC_Element* charElem = charIterator->firstElement(); 232 237 while (charElem != NULL) 233 238 { 234 PRINTF(0)(displayAs, charElem );239 PRINTF(0)(displayAs, charElem->name); 235 240 for (unsigned int i = inputLenght; i < addLength; i++) 236 if (addString[i] != charElem [i])241 if (addString[i] != charElem->name[i]) 237 242 { 238 243 addLength = i; … … 267 272 268 273 /** 269 * searches for classes, which beginn with c lassNameBegin274 * searches for classes, which beginn with completionBegin 270 275 * @param inputList the List to parse through 271 * @param classNameBegin the beginning string 272 * @return a NEW char-array with ClassNames. The LIST should be deleted afterwards, 276 * @param completionBegin the beginning string 273 277 * !! The strings MUST NOT be deleted !! 274 278 */ 275 const tList< const char>* ShellCompletion::createCompleteList(const tList<const char>* inputList, const char* classNameBegin)276 { 277 if (inputList == NULL || c lassNameBegin == NULL)279 const tList<ShellC_Element>* ShellCompletion::addToCompleteList(const tList<const char>* inputList, const char* completionBegin) 280 { 281 if (inputList == NULL || completionBegin == NULL) 278 282 return NULL; 279 unsigned int searchLength = strlen(classNameBegin); 280 if (this->completionList != NULL) 281 delete this->completionList; 282 this->completionList = new tList<const char>; 283 284 // tList<const char>* classList = ClassList::getClassList(); 283 unsigned int searchLength = strlen(completionBegin); 285 284 286 285 tIterator<const char>* iterator = inputList->getIterator(); … … 289 288 { 290 289 if (strlen(enumString) >= searchLength && 291 !strncasecmp(enumString, c lassNameBegin, searchLength))290 !strncasecmp(enumString, completionBegin, searchLength)) 292 291 { 293 292 printf("%s\n", enumString); 294 this->completionList->add(enumString); 293 ShellC_Element* newElem = new ShellC_Element; 294 newElem->name = enumString; 295 this->completionList->add(newElem); 295 296 } 296 297 enumString = iterator->nextElement(); … … 302 303 303 304 /** 304 * searches for classes, which beginn with c lassNameBegin305 * searches for classes, which beginn with completionBegin 305 306 * @param inputList the List to parse through 306 * @param classNameBegin the beginning string 307 * @return a NEW char-array with ClassNames. The LIST should be deleted afterwards, 307 * @param completionBegin the beginning string 308 308 * !! The strings MUST NOT be deleted !! 309 309 */ 310 const tList< const char>* ShellCompletion::createCompleteList(const tList<BaseObject>* inputList, const char* classNameBegin)311 { 312 if (inputList == NULL || c lassNameBegin == NULL)310 const tList<ShellC_Element>* ShellCompletion::addToCompleteList(const tList<BaseObject>* inputList, const char* completionBegin) 311 { 312 if (inputList == NULL || completionBegin == NULL) 313 313 return NULL; 314 unsigned int searchLength = strlen(classNameBegin); 315 if (this->completionList != NULL) 316 delete this->completionList; 317 this->completionList = new tList<const char>; 314 unsigned int searchLength = strlen(completionBegin); 318 315 319 316 tIterator<BaseObject>* iterator = inputList->getIterator(); … … 323 320 if (enumBO->getName() != NULL && 324 321 strlen(enumBO->getName()) >= searchLength && 325 !strncasecmp(enumBO->getName(), classNameBegin, searchLength)) 326 { 327 this->completionList->add(enumBO->getName()); 322 !strncasecmp(enumBO->getName(), completionBegin, searchLength)) 323 { 324 ShellC_Element* newElem = new ShellC_Element; 325 newElem->name = enumBO->getName(); 326 this->completionList->add(newElem); 328 327 } 329 328 enumBO = iterator->nextElement(); … … 333 332 return this->completionList; 334 333 } 334 335 void ShellCompletion::emptyCompletionList() 336 { 337 if (this->completionList != NULL) 338 { 339 tIterator<ShellC_Element>* elemIT = this->completionList->getIterator(); 340 ShellC_Element* elem = elemIT->firstElement(); 341 while (elem != NULL) 342 { 343 delete elem; 344 elem = elemIT->nextElement(); 345 } 346 delete this->completionList; 347 } 348 this->completionList = new tList<ShellC_Element>; 349 } -
trunk/src/lib/shell/shell_completion.h
r5184 r5187 15 15 #endif 16 16 17 typedef enum { 18 SHELLC_CLASS, 19 SHELLC_OBJECT, 20 SHELLC_FUNCTION, 21 SHELLC_ALIAS, 22 } SHELL_CTYPE; 23 24 struct ShellC_Element{ 25 const char* name; //!< 26 SHELL_CTYPE type; 27 }; 28 17 29 //! A class for ... 18 30 class ShellCompletion { … … 30 42 bool functionMatch(const char* functionBegin, long classID, unsigned int* length); 31 43 32 bool generalComplete(const tList< const char>* stringList, const char* begin, const char* displayAs = "%s", const char* addBack = NULL, const char* addFront = NULL);44 bool generalComplete(const tList<ShellC_Element>* stringList, const char* begin, const char* displayAs = "%s", const char* addBack = NULL, const char* addFront = NULL); 33 45 34 const tList<const char>* createCompleteList(const tList<const char>* inputList, const char* classNameBegin); 35 const tList<const char>* createCompleteList(const tList<BaseObject>* inputList, const char* classNameBegin); 36 // const tList<const char>* createCompleteList(const tList<ShellCommandBase>* inputList, const char* classNameBegin); 46 const tList<ShellC_Element>* addToCompleteList(const tList<const char>* inputList, const char* completionBegin); 47 const tList<ShellC_Element>* addToCompleteList(const tList<BaseObject>* inputList, const char* completionBegin); 48 void emptyCompletionList(); 49 // const tList<const char>* createCompleteList(const tList<ShellCommandBase>* inputList, const char* completionBegin); 37 50 38 51 39 52 private: 40 tList< const char>*completionList; //!< A list of completions, that are io.53 tList<ShellC_Element>* completionList; //!< A list of completions, that are io. 41 54 ShellInput* input; 42 55 };
Note: See TracChangeset
for help on using the changeset viewer.