Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7412 in orxonox.OLD for trunk/src/lib/shell


Ignore:
Timestamp:
Apr 28, 2006, 12:03:54 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Another CompletionMode is working

Location:
trunk/src/lib/shell
Files:
5 edited

Legend:

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

    r7411 r7412  
    295295  }
    296296
     297  ShellCommand* ShellCommand::completionPlugin(unsigned int parameter, const CompletorPlugin& completorPlugin)
     298  {
     299    if (this == NULL || this->executor == NULL)
     300      return NULL;
     301
     302    if (parameter >= this->executor->getParamCount())
     303    {
     304      PRINTF(1)("Parameter %d not inside of valid ParameterCount %d of Command %s::%s\n",
     305    parameter, this->executor->getParamCount(), this->getName(), this->shellClass->getName());
     306    }
     307    else
     308    {
     309      delete this->completors[parameter];
     310      this->completors[parameter] = completorPlugin.clone();
     311    }
     312    return this;
     313  }
     314
     315
    297316  /**
    298317   * @brief prints out nice information about the Shells Commands
     
    331350
    332351
     352
     353  ///////////
     354  // ALIAS //
     355  ///////////
     356
    333357  /**
    334358   * @param aliasName the name of the Alias
  • trunk/src/lib/shell/shell_command.h

    r7411 r7412  
    6262    friend class ShellCommandClass;
    6363  public:
    64     //! an enumerator for different types the Shell parses.
    65     typedef enum {
    66       NullRecognition         = 0,
    67       ClassRecognition              = 1,
    68       ObjectRecognition             = 2,
    69       FunctionRecognition           = 4,
    70       AliasRecognition              = 8,
    71       ParameterRecognition          = 16,
    72     } RecognitionType;
    73 
    7464    static bool execute (const std::string& executionString);
    7565
     
    7969                                const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
    8070                                const MultiType& value4 = MT_NULL);
     71    ShellCommand* completionPlugin(unsigned int parameter, const CompletorPlugin& completorPlugin);
    8172
    8273    static ShellCommand* registerCommand(const std::string& commandName, const std::string& className, const Executor& executor);
  • trunk/src/lib/shell/shell_completion.cc

    r7409 r7412  
    114114      if (sc != NULL)
    115115      {
    116         std::vector<std::string> test;
    117         sc->getCompletorPlugin(0)->addToCompleteList(test, inputSplits[inputSplits.size()-1]);
     116        std::vector<std::string> completed;
     117        sc->getCompletorPlugin(0)->addToCompleteList(completed, inputSplits[inputSplits.size()-1]);
     118        for (unsigned int i = 0; i < completed.size(); i++)
     119          this->completionList.push_back(CompletionElement(completed[i], ParamCompletion));
    118120      }
    119121    }
     
    256258          !nocaseCmp(*string, completionBegin, searchLength))
    257259      {
    258         CompletionElement newElem;
    259         newElem.name = (*string);
    260         newElem.type = type;
    261         this->completionList.push_back(newElem);
     260        this->completionList.push_back(CompletionElement (*string, type));
    262261      }
    263262    }
     
    282281          !nocaseCmp((*bo)->getName(), completionBegin, searchLength))
    283282      {
    284         CompletionElement newElem;
    285         newElem.name = (*bo)->getName();
    286         newElem.type = type;
    287         this->completionList.push_back(newElem);
     283        this->completionList.push_back(CompletionElement((*bo)->getName(), type));
    288284      }
    289285    }
     
    316312      case AliasCompletion:
    317313        return typeNames[4];
     314      case ParamCompletion:
     315        return typeNames[5];
    318316    }
    319317  }
     
    326324      "object",
    327325      "function",
    328       "alias"
     326      "alias",
     327      "parameter",
    329328    };
    330329
  • trunk/src/lib/shell/shell_completion.h

    r7406 r7412  
    2929        FunctionCompletion     = 4,
    3030        AliasCompletion        = 8,
     31        ParamCompletion        = 16,
    3132    } CompletionType;
    3233
     
    3435      struct CompletionElement
    3536      {
     37        CompletionElement(std::string name, CompletionType type) : name(name), type(type) {}
    3638        std::string     name;     //!< the Name of the Element to be completed.
    3739        CompletionType  type;     //!< the type of the Element
  • trunk/src/lib/shell/shell_completion_plugin.cc

    r7409 r7412  
    4747  void CompletorStringArray::addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) const
    4848  {
     49    printf("TEST\n");
    4950    unsigned int inputLen = completionBegin.size();
    5051    for (unsigned int i = 0; i < this->_size; ++i)
     52    {
     53      printf("%s\n", this->_stringArray[i].c_str());
    5154      if (!nocaseCmp(this->_stringArray[i], completionBegin, inputLen))
    5255        completionList.push_back(this->_stringArray[i]);
     56    }
    5357  }
    5458
Note: See TracChangeset for help on using the changeset viewer.