Changeset 5102 in orxonox.OLD for trunk/src/util
- Timestamp:
- Aug 22, 2005, 5:26:29 PM (19 years ago)
- Location:
- trunk/src/util
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/loading/load_param.cc
r5100 r5102 17 17 18 18 #include "list.h" 19 #include "array.h"20 19 #include "base_object.h" 21 20 … … 386 385 * searches for classes, which beginn with classNameBegin 387 386 * @param classNameBegin the beginning string of a Class 388 * @return a NEW char-array with ClassNames. The ARRAYshould be deleted afterwards,387 * @return a NEW char-array with ClassNames. The LIST should be deleted afterwards, 389 388 * !! The strings MUST NOT be deleted !! 390 389 */ 391 Array<char*>* LoadClassDescription::searchClassWithShort(const char* classNameBegin)390 tList<const char>* LoadClassDescription::searchClassWithShort(const char* classNameBegin) 392 391 { 393 392 unsigned int searchLength = strlen(classNameBegin); 394 Array<char*>* retVal = new Array<char*>;393 tList<const char>* retVal = new tList<const char>; 395 394 396 395 tIterator<LoadClassDescription>* iterator = LoadClassDescription::classList->getIterator(); … … 401 400 !strncasecmp(enumClassDesc->className, classNameBegin, searchLength)) 402 401 { 403 retVal->add Entry(enumClassDesc->className);402 retVal->add(enumClassDesc->className); 404 403 } 405 404 enumClassDesc = iterator->nextElement(); … … 407 406 delete iterator; 408 407 409 retVal->finalizeArray();410 408 return retVal; 411 409 } -
trunk/src/util/loading/load_param.h
r5100 r5102 31 31 // Forward Declaration // 32 32 template<class T> class tList; 33 template<class T> class Array;34 33 35 34 //! macro that makes it even more easy to load a Parameter … … 312 311 313 312 static void printAll(const char* fileName = NULL); 314 static Array<char*>* searchClassWithShort(const char* classNameBegin);313 static tList<const char>* searchClassWithShort(const char* classNameBegin); 315 314 // static const LoadParamDescription* getClass(const char* className); 316 315 -
trunk/src/util/shell.cc
r5100 r5102 20 20 #include "text_engine.h" 21 21 #include "list.h" 22 #include "array.h"23 22 #include "graphics_engine.h" 24 23 #include "event_handler.h" … … 382 381 { 383 382 if (this->pressedKey == event.type) 383 { 384 384 this->pressedKey = SDLK_FIRST; 385 this->delayed = 0.0; 385 this->delayed = 0.0; 386 } 386 387 } 387 388 } … … 462 463 } 463 464 464 printf("%s\n",commandBegin); 465 Array<char*>* classArray = LoadClassDescription::searchClassWithShort(commandBegin); 466 if (classArray->getCount() == 0) 467 { 468 delete[] completionLine; 469 delete classArray; 465 this->classComplete(commandBegin); 466 467 delete[] completionLine; 468 } 469 470 /** 471 * autocompletes a className 472 * @param classBegin the Beginning of a String to autoComplete 473 * @return true on success, false otherwise 474 */ 475 bool Shell::classComplete(const char* classBegin) 476 { 477 if (unlikely(classBegin == NULL)) 478 return false; 479 tList<const char>* classList = LoadClassDescription::searchClassWithShort(classBegin); 480 if (classList->getSize() == 0) 481 { 482 delete classList; 470 483 //PRINTF(0)("no completion found for %s\n", commandBegin); 471 return false; 472 } 473 474 for (unsigned int i = 0; i < classArray->getCount(); i++) 475 { 476 PRINTF(0)("%s\n", classArray->getEntry(i)); 477 } 478 if (classArray->getCount() == 1) 479 { 480 this->removeCharacters(strlen(commandBegin)); 481 this->addCharacters(classArray->getEntry(0)); 482 this->addCharacter(' '); 483 } 484 485 delete[] completionLine; 486 delete classArray; 487 } 484 return false; 485 } 486 487 const char* addString = classList->firstElement(); 488 unsigned int addLength = 0; 489 unsigned int inputLenght = strlen(classBegin); 490 491 if (addString != NULL) 492 addLength = strlen(addString); 493 tIterator<const char>* charIterator = classList->getIterator(); 494 const char* charElem = charIterator->nextElement(); 495 while (charElem != NULL) 496 { 497 PRINTF(0)("%s:: ", charElem); 498 { 499 for (unsigned int i = inputLenght; i < addLength; i++) 500 if (addString[i] != charElem[i]) 501 { 502 addLength = i; 503 break; 504 } 505 } 506 507 charElem = charIterator->nextElement(); 508 } 509 delete charIterator; 510 511 if (addLength >= inputLenght) 512 { 513 char* adder = new char[addLength+1]; 514 strncpy(adder, addString, addLength); 515 adder[addLength] = '\0'; 516 this->removeCharacters(inputLenght); 517 this->addCharacters(adder); 518 // this->addCharacters("::"); 519 delete[] adder; 520 } 521 delete classList; 522 } 523 524 bool Shell::objectComplete(const char* objectBegin, ClassID classID) 525 { 526 527 } 528 529 bool Shell::functionComplete(const char* functionBegin) 530 { 531 } 532 533 488 534 489 535 /** -
trunk/src/util/shell.h
r5097 r5102 67 67 private: 68 68 bool autoComplete(); 69 bool classComplete(const char* classBegin); 70 bool objectComplete(const char* objectBegin, ClassID classID); 71 bool functionComplete(const char* functionBegin); 69 72 70 73
Note: See TracChangeset
for help on using the changeset viewer.