Changeset 7235 for code/branches/consolecommands3/src/libraries
- Timestamp:
- Aug 28, 2010, 1:25:04 AM (14 years ago)
- Location:
- code/branches/consolecommands3/src/libraries/core/command
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc
r7234 r7235 69 69 } 70 70 71 ArgumentCompletionList _groupsandcommands( bool bOnlyShowHidden)71 ArgumentCompletionList _groupsandcommands(const std::string& fragment, bool bOnlyShowHidden) 72 72 { 73 73 ArgumentCompletionList groupList; 74 std::string fragmentLC = getLowercase(fragment); 74 75 75 76 const std::map<std::string, std::map<std::string, _ConsoleCommand*> >& commands = _ConsoleCommand::getCommands(); 76 77 for (std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group) 77 if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "" )78 if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "" && (fragmentLC == "" || getLowercase(it_group->first).find_first_of(fragmentLC) == 0)) 78 79 groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first))); 79 80 … … 81 82 if (it_group != commands.end()) 82 83 { 83 groupList.push_back(ArgumentCompletionListElement("", "", "\n")); 84 if (!groupList.empty()) 85 groupList.push_back(ArgumentCompletionListElement("", "", "\n")); 84 86 85 87 for (std::map<std::string, _ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command) 86 if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden )88 if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(it_command->first).find_first_of(fragmentLC) == 0)) 87 89 groupList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first))); 88 90 } 91 92 if (!groupList.empty() && groupList.back().getDisplay() == "\n") 93 groupList.pop_back(); 89 94 90 95 return groupList; … … 113 118 } 114 119 115 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(groupsandcommands)( )116 { 117 return detail::_groupsandcommands(f alse);120 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(groupsandcommands)(const std::string& fragment) 121 { 122 return detail::_groupsandcommands(fragment, false); 118 123 } 119 124 … … 128 133 const std::string& hint = evaluation.hint(); 129 134 130 if (evaluation.getPossibleArguments().size() > 0 )135 if (evaluation.getPossibleArguments().size() > 0 && evaluation.getPossibleArgumentsSize() > 0) 131 136 { 132 137 return evaluation.getPossibleArguments(); … … 145 150 146 151 if (tokens.size() == 0) 147 return detail::_groupsandcommands( true);152 return detail::_groupsandcommands(fragment, true); 148 153 149 154 if (_ConsoleCommand::getCommandLC(getLowercase(tokens[0]))) … … 156 161 return detail::_subcommands(fragment, tokens[0], true); 157 162 else 158 return detail::_groupsandcommands( true);163 return detail::_groupsandcommands(fragment, true); 159 164 } 160 165 -
code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.h
r7234 r7235 60 60 { 61 61 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(fallback)(); 62 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(groupsandcommands)( );62 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(groupsandcommands)(const std::string& fragment); 63 63 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(subcommands)(const std::string& fragment, const std::string& group); 64 64 ARGUMENT_COMPLETION_FUNCTION_DECLARATION(command)(const std::string& fragment); -
code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.cc
r7233 r7235 197 197 this->retrievePossibleArguments(); 198 198 199 if ( !this->possibleArguments_.empty())199 if (CommandEvaluation::getSize(this->possibleArguments_) > 0 || (!this->possibleArguments_.empty() && this->isValid())) 200 200 return CommandEvaluation::dump(this->possibleArguments_); 201 201 … … 256 256 } 257 257 } 258 } 259 260 /* static */ size_t CommandEvaluation::getSize(const ArgumentCompletionList& list) 261 { 262 size_t count = 0; 263 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it) 264 if (it->getComparable() != "") 265 ++count; 266 return count; 258 267 } 259 268 … … 294 303 } 295 304 } 296 }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 307 /* static */ std::string CommandEvaluation::dump(const ArgumentCompletionList& list)308 {309 std::string output;310 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)311 {312 output += it->getDisplay();313 314 if (it->getComparable() != "")315 output += ' ';316 }317 return output;318 }319 320 /* static */ std::string CommandEvaluation::dump(const _ConsoleCommand* command)321 {322 std::string output = command->getName();323 if (command->getExecutor()->getParamCount() > 0)324 output += ": ";325 326 for (unsigned int i = 0; i < command->getExecutor()->getParamCount(); i++)327 {328 if (i != 0)329 output += ' ';330 331 if (command->getExecutor()->defaultValueSet(i))332 output += '[';333 else334 output += '{';335 336 output += command->getExecutor()->getTypenameParam(i);337 338 if (command->getExecutor()->defaultValueSet(i))339 output += '=' + command->getExecutor()->getDefaultValue(i).getString() + ']';340 else341 output += '}';342 }343 return output;344 305 } 345 306 … … 405 366 } 406 367 } 368 369 /* static */ std::string CommandEvaluation::dump(const ArgumentCompletionList& list) 370 { 371 std::string output; 372 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it) 373 { 374 output += it->getDisplay(); 375 376 if (it->getComparable() != "") 377 output += ' '; 378 } 379 return output; 380 } 381 382 /* static */ std::string CommandEvaluation::dump(const _ConsoleCommand* command) 383 { 384 std::string output = command->getName(); 385 if (command->getExecutor()->getParamCount() > 0) 386 output += ": "; 387 388 for (unsigned int i = 0; i < command->getExecutor()->getParamCount(); i++) 389 { 390 if (i != 0) 391 output += ' '; 392 393 if (command->getExecutor()->defaultValueSet(i)) 394 output += '['; 395 else 396 output += '{'; 397 398 output += command->getExecutor()->getTypenameParam(i); 399 400 if (command->getExecutor()->defaultValueSet(i)) 401 output += '=' + command->getExecutor()->getDefaultValue(i).getString() + ']'; 402 else 403 output += '}'; 404 } 405 return output; 406 } 407 407 } -
code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.h
r7233 r7235 68 68 { return this->possibleArguments_; } 69 69 70 size_t getPossibleArgumentsSize() const 71 { return CommandEvaluation::getSize(this->possibleArguments_); } 72 70 73 private: 71 74 void initialize(const std::string& command);
Note: See TracChangeset
for help on using the changeset viewer.