Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 28, 2010, 12:02:03 AM (14 years ago)
Author:
landauf
Message:
  • console commands "setMMSoundPath" and "printObjects" are now hidden.
  • added "unhide" command to show hidden commands
  • extended auto-completion capability by allowing multi-word ArgumentCompleter and more
  • added new auto-completion function that allows other commands as argument for a command (for example "delay [time] [command]")
File:
1 edited

Legend:

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

    r7231 r7233  
    177177            this->retrievePossibleArguments();
    178178
    179         if (this->possibleArguments_.empty())
     179        if (CommandEvaluation::getSize(this->possibleArguments_) == 0)
    180180        {
    181181            return this->string_;
     
    184184        {
    185185            std::string output = this->string_.substr(0, this->string_.find_last_of(' ') + 1);
    186 
    187186            output += CommandEvaluation::getCommonBegin(this->possibleArguments_);
    188187            return output;
     
    234233            MultiType param[MAX_FUNCTOR_ARGUMENTS];
    235234
     235            size_t max = this->hintArgumentsOffset_ + this->hintCommand_->getExecutor()->getParamCount();
     236
    236237            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            }
    242257        }
    243258    }
     
    250265        {
    251266            const std::string& entry = it->getComparable();
     267
     268            if (entry == "")
     269            {
     270                ++it;
     271                continue;
     272            }
    252273
    253274            if (entry.size() < fragmentLC.size())
     
    275296    }
    276297
     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
    277307    /* static */ std::string CommandEvaluation::dump(const ArgumentCompletionList& list)
    278308    {
     
    280310        for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
    281311        {
    282             if (it != list.begin())
     312            output += it->getDisplay();
     313
     314            if (it->getComparable() != "")
    283315                output += ' ';
    284 
    285             output += it->getDisplay();
    286316        }
    287317        return output;
     
    316346    /* static */ std::string CommandEvaluation::getCommonBegin(const ArgumentCompletionList& list)
    317347    {
    318         if (list.size() == 0)
     348        if (CommandEvaluation::getSize(list) == 0)
    319349        {
    320350            return "";
    321351        }
    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 "";
    328366        }
    329367        else
     
    338376                    const std::string& argumentComparable = it->getComparable();
    339377                    const std::string& argument = it->getString();
     378
     379                    if (argumentComparable == "")
     380                        continue;
     381
    340382                    if (argument.size() > i)
    341383                    {
    342                         if (it == list.begin())
     384                        if (tempComparable == 0)
    343385                        {
    344386                            tempComparable = argumentComparable[i];
Note: See TracChangeset for help on using the changeset viewer.