Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2008, 8:30:33 PM (16 years ago)
Author:
landauf
Message:

I start to like it

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/CommandExecutor.cc

    r1427 r1430  
    355355                else
    356356                {
    357                     unsigned int argumentNumber = CommandExecutor::argumentsGiven() - 1;
     357                    unsigned int argumentNumber = CommandExecutor::argumentsGiven() - 2;
    358358                    if (CommandExecutor::getEvaluation().functionclass_)
    359359                        argumentNumber -= 1;
    360360
     361std::cout << "arglist: " << CommandExecutor::getLastArgument() << ", " << CommandExecutor::getEvaluation().function_->getName() << ", " << argumentNumber << std::endl;
    361362                    CommandExecutor::createListOfPossibleArguments(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, argumentNumber);
    362363                    CommandExecutor::getEvaluation().state_ = CS_Params;
     
    488489    void CommandExecutor::createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param)
    489490    {
     491        CommandExecutor::createArgumentCompletionList(command, param);
     492
    490493        CommandExecutor::getEvaluation().listOfPossibleArguments_.clear();
    491494        std::string lowercase = getLowercase(fragment);
    492         for (std::list<std::pair<std::string, std::string> >::const_iterator it = command->getArgumentCompletionListBegin(param); it != command->getArgumentCompletionListEnd(param); ++it)
     495        for (std::list<std::pair<std::string, std::string> >::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
    493496            if ((*it).first.find(lowercase) == 0 || fragment == "")
    494497                CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second));
     
    527530    std::string CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)
    528531    {
     532        CommandExecutor::createArgumentCompletionList(command, param);
     533
    529534        std::string lowercase = getLowercase(name);
    530         for (std::list<std::pair<std::string, std::string> >::const_iterator it = command->getArgumentCompletionListBegin(param); it != command->getArgumentCompletionListEnd(param); ++it)
     535        for (std::list<std::pair<std::string, std::string> >::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
    531536            if ((*it).first == lowercase)
    532537                return (*it).second;
     
    535540    }
    536541
     542    void CommandExecutor::createArgumentCompletionList(ConsoleCommand* command, unsigned int param)
     543    {
     544        std::string params[5];
     545
     546        unsigned int index = 0;
     547        unsigned int lowestIndex = 1 + (CommandExecutor::getEvaluation().functionclass_ != 0);
     548
     549        for (unsigned int i = CommandExecutor::argumentsGiven() - 2; i >= lowestIndex; --i)
     550        {
     551            params[index] = CommandExecutor::getArgument(i);
     552            ++index;
     553            if (index >= 5)
     554                break;
     555        }
     556
     557        command->createArgumentCompletionList(param, params[0], params[1], params[2], params[3], params[4]);
     558    }
     559
    537560    std::string CommandExecutor::getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list)
    538561    {
Note: See TracChangeset for help on using the changeset viewer.