Changeset 7413 in orxonox.OLD for trunk/src/lib/shell/shell_completion.cc
- Timestamp:
- Apr 28, 2006, 12:54:04 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_completion.cc
r7412 r7413 57 57 std::string completeString = ""; //< the string to complete. 58 58 unsigned int parameterBegin = 0; //< The SubString-entry, the Parameters begin. 59 const ShellCommand* command = NULL; //< The Command. 59 60 60 61 … … 82 83 // OBJECT/FUNCTION COMPLETIONS 83 84 else if ((emptyComplete && inputSplits.size() == 1) || 84 85 (!emptyComplete && inputSplits.size() == 2)) 85 86 { 86 87 classID = ClassList::StringToID(inputSplits.getString(0)); … … 99 100 100 101 // Looking for ParameterCompletions. 102 if (completeType == NullCompletion) 103 { 104 if ((command = ShellCommand::getCommandFromInput(input)) != NULL) 105 completeType |= ParamCompletion; 106 } 101 107 102 108 if (completeType & ClassCompletion) … … 108 114 if (completeType & AliasCompletion) 109 115 this->aliasComplete(completeString); 110 111 if (completeType == NullCompletion) 112 { 113 const ShellCommand* sc = ShellCommand::getCommand(inputSplits[2], inputSplits[0]); 114 if (sc != NULL) 115 { 116 std::vector<std::string> completed; 117 sc->getCompletorPlugin(0)->addToCompleteList(completed, inputSplits[inputSplits.size()-1]); 118 for (unsigned int i = 0; i < completed.size(); i++) 119 this->completionList.push_back(CompletionElement(completed[i], ParamCompletion)); 120 } 121 } 116 if (completeType & ParamCompletion) 117 this->paramComplete(completeString, command); 118 122 119 123 120 … … 157 154 std::list<std::string> fktList; 158 155 ShellCommandClass::getCommandListOfClass(className, fktList); 159 //printf("%s\n", boList->firstElement()->getName());160 156 if (!this->addToCompleteList(fktList, commandBegin, FunctionCompletion)) 161 157 return false; … … 172 168 std::list<std::string> aliasList; 173 169 ShellCommandAlias::getCommandListOfAlias(aliasList); 174 //printf("%s\n", boList->firstElement()->getName());175 170 if (!this->addToCompleteList(aliasList, aliasBegin, AliasCompletion)) 176 171 return false; 177 172 return true; 173 } 174 175 /** 176 * @brief completes Parameters. 177 * @param paramBegin: Begin of the Parameters. 178 * @returns true on succes, false if something went wrong 179 */ 180 bool ShellCompletion::paramComplete(const std::string& paramBegin, const ShellCommand* command) 181 { 182 std::vector<std::string> completed; 183 command->getCompletorPlugin(0)->addToCompleteList(completed, paramBegin); 184 for (unsigned int i = 0; i < completed.size(); i++) 185 this->completionList.push_back(CompletionElement(completed[i], ParamCompletion)); 178 186 } 179 187 … … 197 205 CompletionElement addElem = completionList.front(); 198 206 const std::string& addString = addElem.name; 199 unsigned int addLength = 0;207 unsigned int addLength = addString.size(); 200 208 unsigned int inputLenght = begin.size(); 201 209 202 // Determin the longest Match 203 addLength = addString.size(); 204 210 // Determin the longest Match (starting with the first candidate in full length). 205 211 CompletionType changeType = NullCompletion; 206 212 std::vector<CompletionElement>::iterator charIT; 207 213 for (charIT = completionList.begin(); charIT != completionList.end(); charIT++) 208 214 { 215 printf("== %s\n", (*charIT).name.c_str()); 209 216 if ((*charIT).type != changeType) 210 217 { … … 217 224 for (unsigned int i = inputLenght; i < addLength; i++) 218 225 if (addString[i] != (*charIT).name[i]) 219 {220 226 addLength = i; 221 // break;222 }223 227 } 224 228 PRINT(0)("\n");
Note: See TracChangeset
for help on using the changeset viewer.