Changeset 5100 in orxonox.OLD for trunk/src/util/shell.cc
- Timestamp:
- Aug 22, 2005, 12:42:28 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/shell.cc
r5099 r5100 20 20 #include "text_engine.h" 21 21 #include "list.h" 22 #include "array.h" 22 23 #include "graphics_engine.h" 23 24 #include "event_handler.h" 24 25 26 #include "load_param.h" 25 27 #include "debug.h" 26 28 #include <stdarg.h> … … 439 441 * autocompletes the Shell's inputLine 440 442 * @returns true, if a result was found, false otherwise 443 * 444 * @todo implement it!! 441 445 */ 442 446 bool Shell::autoComplete() 443 447 { 444 PRINTF(3)("AutoCompletion not implemented yet\n"); 448 //PRINTF(3)("AutoCompletion not implemented yet\n"); 449 450 char* completionLine = new char[strlen(inputLine)+1]; 451 strcpy(completionLine, this->inputLine); 452 453 char* commandBegin = strrchr(completionLine, ' '); 454 if (commandBegin == NULL) 455 commandBegin = completionLine; 456 else 457 { 458 if(commandBegin >= completionLine + strlen(completionLine)) 459 commandBegin = completionLine + strlen(completionLine); 460 else 461 commandBegin++; 462 } 463 464 printf("%s\n",commandBegin); 465 Array<char*>* classArray = LoadClassDescription::searchClassWithShort(commandBegin); 466 if (classArray->getCount() == 0) 467 { 468 delete[] completionLine; 469 delete classArray; 470 //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; 445 487 } 446 488
Note: See TracChangeset
for help on using the changeset viewer.