- Timestamp:
- Aug 28, 2010, 12:02:03 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.cc
r7231 r7233 177 177 this->retrievePossibleArguments(); 178 178 179 if ( this->possibleArguments_.empty())179 if (CommandEvaluation::getSize(this->possibleArguments_) == 0) 180 180 { 181 181 return this->string_; … … 184 184 { 185 185 std::string output = this->string_.substr(0, this->string_.find_last_of(' ') + 1); 186 187 186 output += CommandEvaluation::getCommonBegin(this->possibleArguments_); 188 187 return output; … … 234 233 MultiType param[MAX_FUNCTOR_ARGUMENTS]; 235 234 235 size_t max = this->hintArgumentsOffset_ + this->hintCommand_->getExecutor()->getParamCount(); 236 236 237 for (size_t i = 0; i < argumentID; ++i) 237 param[i] = this->getToken(this->getNumberOfArguments() - i - 1); 238 239 this->possibleArguments_ = (*ac)(param[0], param[1], param[2], param[3], param[4]); 240 241 CommandEvaluation::strip(this->possibleArguments_, param[0]); 238 param[i] = this->getToken(std::min(this->getNumberOfArguments(), max) - i - 1); 239 240 if (this->getNumberOfArguments() > max) 241 { 242 if (ac->useMultipleWords()) 243 { 244 std::string surplusArguments = this->tokens_.subSet(max - 1).join(); 245 if (this->string_[this->string_.size() - 1] == ' ') 246 surplusArguments += ' '; 247 248 this->possibleArguments_ = (*ac)(surplusArguments, param[1], param[2], param[3], param[4]); 249 CommandEvaluation::strip(this->possibleArguments_, this->getToken(this->getNumberOfArguments() - 1)); 250 } 251 } 252 else 253 { 254 this->possibleArguments_ = (*ac)(param[0], param[1], param[2], param[3], param[4]); 255 CommandEvaluation::strip(this->possibleArguments_, param[0]); 256 } 242 257 } 243 258 } … … 250 265 { 251 266 const std::string& entry = it->getComparable(); 267 268 if (entry == "") 269 { 270 ++it; 271 continue; 272 } 252 273 253 274 if (entry.size() < fragmentLC.size()) … … 275 296 } 276 297 298 /* static */ size_t CommandEvaluation::getSize(const ArgumentCompletionList& list) 299 { 300 size_t count = 0; 301 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it) 302 if (it->getComparable() != "") 303 ++count; 304 return count; 305 } 306 277 307 /* static */ std::string CommandEvaluation::dump(const ArgumentCompletionList& list) 278 308 { … … 280 310 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it) 281 311 { 282 if (it != list.begin()) 312 output += it->getDisplay(); 313 314 if (it->getComparable() != "") 283 315 output += ' '; 284 285 output += it->getDisplay();286 316 } 287 317 return output; … … 316 346 /* static */ std::string CommandEvaluation::getCommonBegin(const ArgumentCompletionList& list) 317 347 { 318 if ( list.size() == 0)348 if (CommandEvaluation::getSize(list) == 0) 319 349 { 320 350 return ""; 321 351 } 322 else if (list.size() == 1) 323 { 324 if (list.begin()->hasDisplay()) 325 return (list.begin()->getString()); 326 else 327 return (list.begin()->getString() + ' '); 352 else if (CommandEvaluation::getSize(list) == 1) 353 { 354 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it) 355 { 356 if (it->getComparable() != "") 357 { 358 if (it->hasDisplay()) 359 return (it->getString()); 360 else 361 return (it->getString() + ' '); 362 } 363 } 364 365 return ""; 328 366 } 329 367 else … … 338 376 const std::string& argumentComparable = it->getComparable(); 339 377 const std::string& argument = it->getString(); 378 379 if (argumentComparable == "") 380 continue; 381 340 382 if (argument.size() > i) 341 383 { 342 if ( it == list.begin())384 if (tempComparable == 0) 343 385 { 344 386 tempComparable = argumentComparable[i];
Note: See TracChangeset
for help on using the changeset viewer.