Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7415 in orxonox.OLD for trunk/src/lib/shell/shell_completion.cc


Ignore:
Timestamp:
Apr 28, 2006, 1:30:13 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: Super-good completion :), and extremely tired bensch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/shell/shell_completion.cc

    r7414 r7415  
    5656    long completeType = NullCompletion;              //< the Type we'd like to complete.
    5757    std::string completeString = "";                 //< the string to complete.
    58     unsigned int parameterBegin = 0;                 //< The SubString-entry, the Parameters begin.
     58    unsigned int completeParam = 0;                  //< The Parameter to finish.
    5959    const ShellCommand* command = NULL;              //< The Command.
    6060
     
    102102    if (completeType == NullCompletion)
    103103    {
    104 
     104      unsigned int parameterBegin = parameterBegin;
    105105      if ((command = ShellCommand::getCommandFromInput(inputSplits, parameterBegin)) != NULL)
    106106        completeType |= ParamCompletion;
     107      if (emptyComplete)
     108        completeParam = inputSplits.size() - parameterBegin;
     109      else
     110        completeParam = inputSplits.size() - parameterBegin - 1;
    107111    }
    108112
     
    116120      this->aliasComplete(completeString);
    117121    if (completeType & ParamCompletion)
    118       this->paramComplete(completeString, command);
     122      this->paramComplete(completeString, command, completeParam);
    119123
    120124    this->generalComplete(input, completeString);
     
    177181   * @returns true on succes, false if something went wrong
    178182   */
    179   bool ShellCompletion::paramComplete(const std::string& paramBegin, const ShellCommand* command)
    180   {
     183  bool ShellCompletion::paramComplete(const std::string& paramBegin, const ShellCommand* command, unsigned int paramNumber)
     184  {
     185    if (paramNumber >= command->getParamCount())
     186    {
     187      PRINT(0)("Last Parameter reached\n");
     188      return false;
     189    }
    181190    std::vector<std::string> completed;
    182     command->getCompletorPlugin(0)->addToCompleteList(completed, paramBegin);
    183       for (unsigned int i = 0; i < completed.size(); i++)
    184         this->completionList.push_back(CompletionElement(completed[i], ParamCompletion));
     191    command->getCompletorPlugin(paramNumber)->addToCompleteList(completed, paramBegin);
     192    for (unsigned int i = 0; i < completed.size(); i++)
     193      this->completionList.push_back(CompletionElement(completed[i], ParamCompletion));
     194    return true;
    185195  }
    186196
Note: See TracChangeset for help on using the changeset viewer.