Changeset 5195 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Sep 18, 2005, 2:13:28 AM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r5192 r5195 41 41 this->classID = CL_NULL; 42 42 this->commandList = new tList<ShellCommandBase>; 43 this->aliasList = new tList<ShellCommandAlias>; 43 44 44 45 ShellCommandClass::commandClassList->add(this); … … 88 89 } 89 90 91 bool ShellCommandClass::getCommandListOfAlias(tList<const char>* stringList) 92 { 93 if (stringList == NULL) 94 return false; 95 96 tIterator<ShellCommandAlias>* iterator = ShellCommandClass::aliasList->getIterator(); 97 ShellCommandAlias* elem = iterator->firstElement(); 98 while(elem != NULL) 99 { 100 stringList->add(elem->getName()); 101 elem = iterator->nextElement(); 102 } 103 delete iterator; 104 return true; 105 } 106 107 90 108 /** 91 109 * unregisters all Commands that exist … … 93 111 void ShellCommandClass::unregisterAllCommands() 94 112 { 113 // unregister all commands 95 114 tIterator<ShellCommandClass>* iterator = ShellCommandClass::commandClassList->getIterator(); 96 115 ShellCommandClass* elem = iterator->firstElement(); … … 105 124 delete ShellCommandClass::commandClassList; 106 125 ShellCommandClass::commandClassList = NULL; 126 127 // unregister all aliases (there should be nothing to do here :)) 128 tIterator<ShellCommandAlias>* itAL = ShellCommandClass::aliasList->getIterator(); 129 ShellCommandAlias* elemAL = itAL->firstElement(); 130 while(elemAL != NULL) 131 { 132 delete elemAL; 133 elemAL = itAL->nextElement(); 134 } 135 delete itAL; 136 delete ShellCommandClass::aliasList; 137 ShellCommandClass::aliasList = NULL; 107 138 } 108 139 … … 168 199 169 200 tList<ShellCommandClass>* ShellCommandClass::commandClassList = NULL; 201 tList<ShellCommandAlias>* ShellCommandClass::aliasList = NULL; 170 202 171 203 /** … … 428 460 } 429 461 462 ShellCommandBase* ShellCommandBase::setAlias(const char* alias) 463 { 464 ShellCommandAlias* aliasCMD = new ShellCommandAlias(alias, this); 465 ShellCommandClass::aliasList->add(aliasCMD); 466 } 467 430 468 /** 431 469 * see ShellCommandBase::debug() -
trunk/src/lib/shell/shell_command.h
r5190 r5195 52 52 public: 53 53 static const tList<ShellCommandClass>* getCommandClassList() { return ShellCommandClass::commandClassList; }; 54 static bool ShellCommandClass::getCommandListOfClass(const char* className, tList<const char>* stringList); 54 static bool getCommandListOfClass(const char* className, tList<const char>* stringList); 55 static bool getCommandListOfAlias(tList<const char>* aliasList); 55 56 56 57 static ShellCommandClass* getCommandClass(const char* className); … … 69 70 tList<ShellCommandBase>* commandList; //!< A list of Commands from this Class 70 71 static tList<ShellCommandClass>* commandClassList; //!< A list of Classes 71 static tList<ShellCommandAlias>* alias esList;//!< An Alias to A Command. (only for classes with one Instance)72 static tList<ShellCommandAlias>* aliasList; //!< An Alias to A Command. (only for classes with one Instance) 72 73 }; 73 74 … … 320 321 public: 321 322 ShellCommandAlias(const char* aliasName, ShellCommandBase* command) { this->aliasName = aliasName; this->command = command; }; 323 324 const char* getName() const { return this->aliasName; }; 325 ShellCommandBase* getCommand() const { return this->command; }; 322 326 private: 323 327 const char* aliasName; -
trunk/src/lib/shell/shell_completion.cc
r5194 r5195 108 108 if (inputSplits.getCount() == 0) 109 109 { 110 PRINTF(5)("Listing all Classes\n");111 110 completeType |= SHELLC_CLASS; 111 completeType |= SHELLC_ALIAS; 112 112 113 } 113 114 else if (inputSplits.getCount() == 1 && emptyComplete == false) 114 115 { 115 printf("trying to complete a Class with '%s'\n", inputSplits.getString(0));116 116 completeType |= SHELLC_CLASS; 117 completeType |= SHELLC_ALIAS; 117 118 } 118 119 … … 148 149 if (completeType & SHELLC_FUNCTION) 149 150 this->functionComplete(completeString, classID); 151 if (completeType & SHELLC_ALIAS) 152 this->aliasComplete(completeString); 150 153 151 154 … … 211 214 return true; 212 215 } 216 217 bool ShellCompletion::aliasComplete(const char* aliasBegin) 218 { 219 if (unlikely(aliasBegin == NULL)) 220 return false; 221 tList<const char> aliasList; 222 ShellCommandClass::getCommandListOfAlias(&aliasList); 223 //printf("%s\n", boList->firstElement()->getName()); 224 if (!this->addToCompleteList(&aliasList, aliasBegin)) 225 return false; 226 return true; 227 } 228 213 229 214 230 /** -
trunk/src/lib/shell/shell_completion.h
r5194 r5195 42 42 bool functionComplete(const char* functionBegin, long classID); 43 43 bool functionMatch(const char* functionBegin, long classID, unsigned int* length); 44 bool aliasComplete(const char* aliasBegin); 44 45 45 46 bool generalComplete(const char* begin, const char* displayAs = "%s", const char* addBack = NULL, const char* addFront = NULL); … … 48 49 bool addToCompleteList(const tList<BaseObject>* inputList, const char* completionBegin); 49 50 void emptyCompletionList(); 50 // const tList<const char>* createCompleteList(const tList<ShellCommandBase>* inputList, const char* completionBegin);51 52 51 53 52 private:
Note: See TracChangeset
for help on using the changeset viewer.