- Timestamp:
- Apr 26, 2006, 2:23:53 AM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_completion.cc
r7371 r7372 58 58 const std::list<BaseObject*>* objectList; //< the list of Objects stored in classID 59 59 bool emptyComplete = false; //< if the completion input is empty string. e.g "" 60 long completeType = SHELLC_NONE;//< the Type we'd like to complete.60 long completeType = NullCompletion; //< the Type we'd like to complete. 61 61 std::string completeString; //< the string to complete. 62 62 … … 81 81 if (inputSplits.size() == 0) 82 82 { 83 completeType |= SHELLC_CLASS;84 completeType |= SHELLC_ALIAS;83 completeType |= ClassCompletion; 84 completeType |= AliasCompletion; 85 85 } 86 86 else if (inputSplits.size() == 1 && emptyComplete == false) 87 87 { 88 completeType |= SHELLC_CLASS;89 completeType |= SHELLC_ALIAS;88 completeType |= ClassCompletion; 89 completeType |= AliasCompletion; 90 90 } 91 91 … … 97 97 objectList = ClassList::getList((ClassID)classID); 98 98 if (classID != CL_NULL) 99 completeType |= SHELLC_OBJECT;99 completeType |= ObjectCompletion; 100 100 //if (objectList != NULL && objectList->getSize() == 1) 101 completeType |= SHELLC_FUNCTION;101 completeType |= FunctionCompletion; 102 102 } 103 103 else if ((inputSplits.size() == 2 && emptyComplete == true) || … … 108 108 return false; 109 109 else 110 completeType |= SHELLC_FUNCTION;111 } 112 113 if (completeType & SHELLC_CLASS)110 completeType |= FunctionCompletion; 111 } 112 113 if (completeType & ClassCompletion) 114 114 this->objectComplete(completeString, CL_SHELL_COMMAND_CLASS); 115 if (completeType & SHELLC_OBJECT)115 if (completeType & ObjectCompletion) 116 116 this->objectComplete(completeString, classID); 117 if (completeType & SHELLC_FUNCTION)117 if (completeType & FunctionCompletion) 118 118 this->functionComplete(completeString, inputSplits.getString(0)); 119 if (completeType & SHELLC_ALIAS)119 if (completeType & AliasCompletion) 120 120 this->aliasComplete(completeString); 121 121 … … 135 135 if (clList != NULL) 136 136 { 137 if (!this->addToCompleteList(*clList, classBegin, SHELLC_CLASS))137 if (!this->addToCompleteList(*clList, classBegin, ClassCompletion)) 138 138 return false; 139 139 } … … 154 154 if (boList != NULL) 155 155 { 156 SHELLC_TYPE type = SHELLC_OBJECT;156 CompletionType type = ObjectCompletion; 157 157 if (classID == CL_SHELL_COMMAND_CLASS) 158 type = SHELLC_CLASS;158 type = ClassCompletion; 159 159 if (!this->addToCompleteList(*boList, objectBegin, type)) 160 160 return false; … … 175 175 ShellCommandClass::getCommandListOfClass(className, &fktList); 176 176 //printf("%s\n", boList->firstElement()->getName()); 177 if (!this->addToCompleteList(fktList, functionBegin, SHELLC_FUNCTION))177 if (!this->addToCompleteList(fktList, functionBegin, FunctionCompletion)) 178 178 return false; 179 179 return true; … … 190 190 ShellCommandClass::getCommandListOfAlias(&aliasList); 191 191 //printf("%s\n", boList->firstElement()->getName()); 192 if (!this->addToCompleteList(aliasList, aliasBegin, SHELLC_ALIAS))192 if (!this->addToCompleteList(aliasList, aliasBegin, AliasCompletion)) 193 193 return false; 194 194 return true; … … 212 212 return false; 213 213 214 ShellC_Element addElem = completionList.front();214 CompletionElement addElem = completionList.front(); 215 215 const std::string& addString = addElem.name; 216 216 unsigned int addLength = 0; … … 220 220 addLength = addString.size(); 221 221 222 SHELLC_TYPE changeType = SHELLC_NONE;223 list< ShellC_Element>::iterator charIT;222 CompletionType changeType = NullCompletion; 223 list<CompletionElement>::iterator charIT; 224 224 for (charIT = completionList.begin(); charIT != completionList.end(); charIT++) 225 225 { 226 226 if ((*charIT).type != changeType) 227 227 { 228 if (changeType != SHELLC_NONE)228 if (changeType != NullCompletion) 229 229 PRINT(0)("\n"); 230 PRINT(0)("%s: ", ShellCompletion::typeToString((*charIT).type) );230 PRINT(0)("%s: ", ShellCompletion::typeToString((*charIT).type).c_str()); 231 231 changeType = (*charIT).type; 232 232 } … … 265 265 * !! The strings MUST NOT be deleted !! 266 266 */ 267 bool ShellCompletion::addToCompleteList(const std::list<std::string>& inputList, const std::string& completionBegin, SHELLC_TYPEtype)267 bool ShellCompletion::addToCompleteList(const std::list<std::string>& inputList, const std::string& completionBegin, CompletionType type) 268 268 { 269 269 unsigned int searchLength = completionBegin.size(); … … 276 276 { 277 277 printf ("%s\n", (*string).c_str()); 278 ShellC_Element newElem;278 CompletionElement newElem; 279 279 newElem.name = (*string); 280 280 newElem.type = type; … … 291 291 * !! The strings MUST NOT be deleted !! 292 292 */ 293 bool ShellCompletion::addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, SHELLC_TYPEtype)293 bool ShellCompletion::addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, CompletionType type) 294 294 { 295 295 unsigned int searchLength = completionBegin.size(); … … 302 302 !nocaseCmp((*bo)->getName(), completionBegin, searchLength)) 303 303 { 304 ShellC_Element newElem;304 CompletionElement newElem; 305 305 newElem.name = (*bo)->getName(); 306 306 newElem.type = type; … … 322 322 } 323 323 324 const char* ShellCompletion::typeToString(SHELLC_TYPEtype)324 const std::string& ShellCompletion::typeToString(CompletionType type) 325 325 { 326 326 switch (type) 327 327 { 328 328 default:// SHELLC_NONE 329 return "error"; 330 case SHELLC_CLASS: 331 return "class"; 332 case SHELLC_OBJECT: 333 return "object"; 334 case SHELLC_FUNCTION: 335 return "function"; 336 case SHELLC_ALIAS: 337 return "alias"; 338 } 339 } 329 return typeNames[0]; 330 case ClassCompletion: 331 return typeNames[1]; 332 case ObjectCompletion: 333 return typeNames[2]; 334 case FunctionCompletion: 335 return typeNames[3]; 336 case AliasCompletion: 337 return typeNames[4]; 338 } 339 } 340 341 342 const std::string ShellCompletion::typeNames[] = 343 { 344 "error", 345 "class", 346 "object", 347 "function", 348 "alias" 349 }; -
trunk/src/lib/shell/shell_completion.h
r7371 r7372 26 26 //! an enumerator for different types the Shell can complete. 27 27 typedef enum { 28 SHELLC_NONE= 0,29 SHELLC_CLASS= 1,30 SHELLC_OBJECT= 2,31 SHELLC_FUNCTION= 4,32 SHELLC_ALIAS= 8,33 } SHELLC_TYPE;28 NullCompletion = 0, 29 ClassCompletion = 1, 30 ObjectCompletion = 2, 31 FunctionCompletion = 4, 32 AliasCompletion = 8, 33 } CompletionType; 34 34 35 35 //! A struct for ShellElements (these are used as containers to identify an Input for what it is) 36 struct ShellC_Element{36 struct CompletionElement{ 37 37 std::string name; //!< the Name of the Element to be completed. 38 SHELLC_TYPEtype; //!< the type of the Element38 CompletionType type; //!< the type of the Element 39 39 }; 40 40 … … 57 57 58 58 59 bool addToCompleteList(const std::list<std::string>& inputList, const std::string& completionBegin, S HELLC_TYPEtype);60 bool addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, S HELLC_TYPEtype);59 bool addToCompleteList(const std::list<std::string>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type); 60 bool addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type); 61 61 void clearCompletionList(); 62 62 63 static const char* ShellCompletion::typeToString(SHELLC_TYPEtype);63 static const std::string& ShellCompletion::typeToString(ShellCompletion::CompletionType type); 64 64 65 65 private: 66 std::list<ShellC_Element> completionList; //!< A list of completions, that are io. 66 std::list<CompletionElement> completionList; //!< A list of completions, that are io. 67 68 69 static const std::string typeNames[]; //!< A list of Completion-Type-Names. 67 70 }; 68 71
Note: See TracChangeset
for help on using the changeset viewer.