Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 27, 2010, 8:41:22 PM (14 years ago)
Author:
landauf
Message:

hide commands and command groups from auto-completion if they are inactive/denied/hidden

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/consolecommands3/src/libraries/core/command/ArgumentCompletionFunctions.cc

    r7228 r7232  
    5757        }
    5858
     59        bool groupIsVisible(const std::map<std::string, _ConsoleCommand*>& group)
     60        {
     61            for (std::map<std::string, _ConsoleCommand*>::const_iterator it_command = group.begin(); it_command != group.end(); ++it_command)
     62                if (it_command->second->isActive() && it_command->second->hasAccess() && !it_command->second->isHidden())
     63                    return true;
     64
     65            return false;
     66        }
     67
    5968        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(groupsandcommands)()
    6069        {
     
    6372            const std::map<std::string, std::map<std::string, _ConsoleCommand*> >& commands = _ConsoleCommand::getCommands();
    6473            for (std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group)
    65                 // todo: check if active / not hidden / not denied
    66                 groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first)));
     74                if (groupIsVisible(it_group->second))
     75                    groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first)));
    6776
    6877            std::map<std::string, std::map<std::string, _ConsoleCommand*> >::const_iterator it_group = commands.find("");
     
    7281
    7382                for (std::map<std::string, _ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
    74                     // todo: check if active / not hidden / not denied
    75                     groupList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
     83                    if (it_command->second->isActive() && it_command->second->hasAccess() && !it_command->second->isHidden())
     84                        groupList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
    7685            }
    7786
     
    93102            {
    94103                for (std::map<std::string, _ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
    95                     // todo: check if active / not hidden / not denied
    96                     commandList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
     104                    if (it_command->second->isActive() && it_command->second->hasAccess() && !it_command->second->isHidden())
     105                        commandList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
    97106            }
    98107
Note: See TracChangeset for help on using the changeset viewer.